2 ******************************************************************************
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * @brief LED functions, init, toggle, on & off.
7 * @see The GNU Public License (GPL) Version 3
8 * @defgroup PIOS_LED LED Functions
11 *****************************************************************************/
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 /* Project Includes */
32 #if defined(PIOS_INCLUDE_LED)
34 /* Private Function Prototypes */
38 // static GPIO_TypeDef* LED_GPIO_PORT[PIOS_LED_NUM] = PIOS_LED_PORTS;
39 // static const uint32_t LED_GPIO_PIN[PIOS_LED_NUM] = PIOS_LED_PINS;
40 // static const uint32_t LED_GPIO_CLK[PIOS_LED_NUM] = PIOS_LED_CLKS;
41 static uint8_t LED_GPIO
[PIOS_LED_NUM
];
44 static inline void PIOS_SetLED(uint32_t LED
, uint8_t stat
)
46 printf("PIOS: LED %i status %i\n", LED
, stat
);
51 * Initialises all the LED's
53 void PIOS_LED_Init(void)
55 // GPIO_InitTypeDef GPIO_InitStructure;
56 // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
57 // GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
59 for (int LEDNum
= 0; LEDNum
< PIOS_LED_NUM
; LEDNum
++) {
60 // RCC_APB2PeriphClockCmd(LED_GPIO_CLK[LEDNum], ENABLE);
61 // GPIO_InitStructure.GPIO_Pin = LED_GPIO_PIN[LEDNum];
62 // GPIO_Init(LED_GPIO_PORT[LEDNum], &GPIO_InitStructure);
65 // LED_GPIO_PORT[LEDNum]->BSRR = LED_GPIO_PIN[LEDNum];
73 * \param[in] LED LED Name (LED1, LED2)
75 void PIOS_LED_On(uint32_t LED
)
77 // LED_GPIO_PORT[LED]->BRR = LED_GPIO_PIN[LED];
84 * \param[in] LED LED Name (LED1, LED2)
86 void PIOS_LED_Off(uint32_t LED
)
88 // LED_GPIO_PORT[LED]->BSRR = LED_GPIO_PIN[LED];
95 * \param[in] LED LED Name (LED1, LED2)
97 void PIOS_LED_Toggle(uint32_t LED
)
99 // LED_GPIO_PORT[LED]->ODR ^= LED_GPIO_PIN[LED];
100 PIOS_SetLED(LED
, LED_GPIO
[LED
] ? 0 : 1);
103 #endif /* if defined(PIOS_INCLUDE_LED) */