mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-19 22:23:33 +08:00
drivers: AeroFC: Add more leds
Also change the initial state of the leds to off.
This commit is contained in:
committed by
Lorenz Meier
parent
83a387a553
commit
aa8fa2ae05
@@ -63,45 +63,57 @@ __END_DECLS
|
|||||||
|
|
||||||
__EXPORT void led_init(void)
|
__EXPORT void led_init(void)
|
||||||
{
|
{
|
||||||
/* Configure LED1-2 GPIOs for output */
|
/* Configure LED0-3 GPIOs for output */
|
||||||
|
|
||||||
|
stm32_configgpio(GPIO_LED0);
|
||||||
stm32_configgpio(GPIO_LED1);
|
stm32_configgpio(GPIO_LED1);
|
||||||
stm32_configgpio(GPIO_LED2);
|
stm32_configgpio(GPIO_LED2);
|
||||||
|
stm32_configgpio(GPIO_LED3);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint32_t _led_param_get(int led)
|
||||||
|
{
|
||||||
|
switch (led) {
|
||||||
|
case 0:
|
||||||
|
return GPIO_LED0;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
return GPIO_LED1;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
return GPIO_LED2;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
return GPIO_LED3;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
__EXPORT void led_on(int led)
|
__EXPORT void led_on(int led)
|
||||||
{
|
{
|
||||||
if (led == 0) {
|
const uint32_t param = _led_param_get(led);
|
||||||
/* Pull down to switch on */
|
|
||||||
stm32_gpiowrite(GPIO_LED1, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (led == 1) {
|
if (param) {
|
||||||
/* Pull down to switch on */
|
stm32_gpiowrite(param, false);
|
||||||
stm32_gpiowrite(GPIO_LED2, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__EXPORT void led_off(int led)
|
__EXPORT void led_off(int led)
|
||||||
{
|
{
|
||||||
if (led == 0) {
|
const uint32_t param = _led_param_get(led);
|
||||||
/* Pull up to switch off */
|
|
||||||
stm32_gpiowrite(GPIO_LED1, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (led == 1) {
|
if (param) {
|
||||||
/* Pull up to switch off */
|
stm32_gpiowrite(param, true);
|
||||||
stm32_gpiowrite(GPIO_LED2, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__EXPORT void led_toggle(int led)
|
__EXPORT void led_toggle(int led)
|
||||||
{
|
{
|
||||||
if (led == 0) {
|
const uint32_t param = _led_param_get(led);
|
||||||
stm32_gpiowrite(GPIO_LED1, !stm32_gpioread(GPIO_LED1));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (led == 1) {
|
if (param) {
|
||||||
stm32_gpiowrite(GPIO_LED2, !stm32_gpioread(GPIO_LED2));
|
stm32_gpiowrite(param, !stm32_gpioread(param));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,8 +57,10 @@
|
|||||||
|
|
||||||
/* PX4FMU GPIOs ***********************************************************************************/
|
/* PX4FMU GPIOs ***********************************************************************************/
|
||||||
/* LEDs */
|
/* LEDs */
|
||||||
#define GPIO_LED1 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN12)
|
#define GPIO_LED0 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN9)
|
||||||
#define GPIO_LED2 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN10)
|
#define GPIO_LED1 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN10)
|
||||||
|
#define GPIO_LED2 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN11)
|
||||||
|
#define GPIO_LED3 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN12)
|
||||||
|
|
||||||
#define GPIO_VDD_5V_SENSORS_EN (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTD|GPIO_PIN13)
|
#define GPIO_VDD_5V_SENSORS_EN (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTD|GPIO_PIN13)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user