Browse Source

AP_Notify: Handle LED pins being undefined, select appropriate drivers

master
Michael du Breuil 7 years ago committed by Andrew Tridgell
parent
commit
72439a053b
  1. 12
      libraries/AP_Notify/AP_BoardLED.cpp
  2. 9
      libraries/AP_Notify/AP_BoardLED2.cpp
  3. 4
      libraries/AP_Notify/AP_Notify.cpp
  4. 10
      libraries/AP_Notify/PixRacerLED.cpp

12
libraries/AP_Notify/AP_BoardLED.cpp

@ -16,9 +16,19 @@ @@ -16,9 +16,19 @@
#include "AP_Notify.h"
#if (defined(HAL_GPIO_A_LED_PIN) && defined(HAL_GPIO_B_LED_PIN) && \
#if (defined(HAL_GPIO_A_LED_PIN) || defined(HAL_GPIO_B_LED_PIN) || \
defined(HAL_GPIO_C_LED_PIN))
#ifndef HAL_GPIO_A_LED_PIN
#define HAL_GPIO_A_LED_PIN -1
#endif
#ifndef HAL_GPIO_B_LED_PIN
#define HAL_GPIO_B_LED_PIN -1
#endif
#ifndef HAL_GPIO_C_LED_PIN
#define HAL_GPIO_C_LED_PIN -1
#endif
extern const AP_HAL::HAL& hal;
bool AP_BoardLED::init(void)

9
libraries/AP_Notify/AP_BoardLED2.cpp

@ -19,7 +19,14 @@ @@ -19,7 +19,14 @@
// show all status on only 2 leds
#if defined(HAL_GPIO_A_LED_PIN) && defined(HAL_GPIO_B_LED_PIN)
#if defined(HAL_GPIO_A_LED_PIN) || defined(HAL_GPIO_B_LED_PIN)
#ifndef HAL_GPIO_A_LED_PIN
#define HAL_GPIO_A_LED_PIN -1
#endif
#ifndef HAL_GPIO_B_LED_PIN
#define HAL_GPIO_B_LED_PIN -1
#endif
extern const AP_HAL::HAL& hal;

4
libraries/AP_Notify/AP_Notify.cpp

@ -168,8 +168,10 @@ void AP_Notify::add_backends(void) @@ -168,8 +168,10 @@ void AP_Notify::add_backends(void)
#elif CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
# ifdef HAL_HAVE_PIXRACER_LED
ADD_BACKEND(new PixRacerLED());
# else
# elif (defined(HAL_GPIO_A_LED_PIN) && defined(HAL_GPIO_B_LED_PIN) && defined(HAL_GPIO_C_LED_PIN))
ADD_BACKEND(new AP_BoardLED());
#else
ADD_BACKEND(new AP_BoardLED2());
# endif
#ifdef HAL_BUZZER_PIN
ADD_BACKEND(new Buzzer());

10
libraries/AP_Notify/PixRacerLED.cpp

@ -18,6 +18,16 @@ @@ -18,6 +18,16 @@
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4 && CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_PX4_V4 \
|| CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
#ifndef HAL_GPIO_A_LED_PIN
#define HAL_GPIO_A_LED_PIN -1
#endif
#ifndef HAL_GPIO_B_LED_PIN
#define HAL_GPIO_B_LED_PIN -1
#endif
#ifndef HAL_GPIO_C_LED_PIN
#define HAL_GPIO_C_LED_PIN -1
#endif
extern const AP_HAL::HAL& hal;
PixRacerLED::PixRacerLED() :

Loading…
Cancel
Save