mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
drivers: AeroFC: Add more leds
Also change the initial state of the leds to off.
This commit is contained in:
parent
83a387a553
commit
aa8fa2ae05
@ -63,45 +63,57 @@ __END_DECLS
|
||||
|
||||
__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_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)
|
||||
{
|
||||
if (led == 0) {
|
||||
/* Pull down to switch on */
|
||||
stm32_gpiowrite(GPIO_LED1, false);
|
||||
}
|
||||
const uint32_t param = _led_param_get(led);
|
||||
|
||||
if (led == 1) {
|
||||
/* Pull down to switch on */
|
||||
stm32_gpiowrite(GPIO_LED2, false);
|
||||
if (param) {
|
||||
stm32_gpiowrite(param, false);
|
||||
}
|
||||
}
|
||||
|
||||
__EXPORT void led_off(int led)
|
||||
{
|
||||
if (led == 0) {
|
||||
/* Pull up to switch off */
|
||||
stm32_gpiowrite(GPIO_LED1, true);
|
||||
}
|
||||
const uint32_t param = _led_param_get(led);
|
||||
|
||||
if (led == 1) {
|
||||
/* Pull up to switch off */
|
||||
stm32_gpiowrite(GPIO_LED2, true);
|
||||
if (param) {
|
||||
stm32_gpiowrite(param, true);
|
||||
}
|
||||
}
|
||||
|
||||
__EXPORT void led_toggle(int led)
|
||||
{
|
||||
if (led == 0) {
|
||||
stm32_gpiowrite(GPIO_LED1, !stm32_gpioread(GPIO_LED1));
|
||||
}
|
||||
const uint32_t param = _led_param_get(led);
|
||||
|
||||
if (led == 1) {
|
||||
stm32_gpiowrite(GPIO_LED2, !stm32_gpioread(GPIO_LED2));
|
||||
if (param) {
|
||||
stm32_gpiowrite(param, !stm32_gpioread(param));
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,8 +57,10 @@
|
||||
|
||||
/* PX4FMU GPIOs ***********************************************************************************/
|
||||
/* LEDs */
|
||||
#define GPIO_LED1 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN12)
|
||||
#define GPIO_LED2 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN10)
|
||||
#define GPIO_LED0 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN9)
|
||||
#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)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user