Create set-home.md
[u360gts.git] / src / main / drivers / light_led_stm32f10x.c
blob383818e3f512c87af6b0eea6b12f282835fc701a
1 /*
2 * This file is part of Cleanflight.
4 * Cleanflight is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
18 #include <stdbool.h>
19 #include <stdint.h>
20 #include <stdlib.h>
22 #include "platform.h"
24 #include "common/utils.h"
26 #include "system.h"
27 #include "gpio.h"
29 #include "light_led.h"
32 void ledInit(void)
34 #if defined(LED0) || defined(LED1) || defined(LED2)
35 uint32_t i;
37 struct {
38 GPIO_TypeDef *gpio;
39 gpio_config_t cfg;
40 } gpio_setup[] = {
41 #ifdef LED0
43 .gpio = LED0_GPIO,
44 .cfg = { LED0_PIN, Mode_Out_PP, Speed_2MHz }
46 #endif
47 #ifdef LED1
49 .gpio = LED1_GPIO,
50 .cfg = { LED1_PIN, Mode_Out_PP, Speed_2MHz }
52 #endif
53 #ifdef LED2
55 .gpio = LED2_GPIO,
56 .cfg = { LED2_PIN, Mode_Out_PP, Speed_2MHz }
58 #endif
61 uint8_t gpio_count = ARRAYLEN(gpio_setup);
63 #ifdef LED0
64 RCC_APB2PeriphClockCmd(LED0_PERIPHERAL, ENABLE);
65 #endif
66 #ifdef LED1
67 RCC_APB2PeriphClockCmd(LED1_PERIPHERAL, ENABLE);
68 #endif
69 #ifdef LED2
70 RCC_APB2PeriphClockCmd(LED2_PERIPHERAL, ENABLE);
71 #endif
73 LED0_OFF;
74 LED1_OFF;
75 LED2_OFF;
77 for (i = 0; i < gpio_count; i++) {
78 gpioInit(gpio_setup[i].gpio, &gpio_setup[i].cfg);
81 #endif