mirror of https://github.com/ArduPilot/ardupilot
AP_Notify: Fix GPIO declaration for Linux boards
Currently, the default behaviour on linux boards tries to write LED gpios with fixed values among them. There is no way to declare that there are no LED GPIOs. This commit moves the declaration of the LED Gpios in AP_HAL_Boards.h and makes AP_Notify do nothing if no LED gpio was declared
This commit is contained in:
parent
8c4803af10
commit
0fa362ff5c
|
@ -123,6 +123,11 @@
|
|||
#define HAL_INS_DEFAULT HAL_INS_HIL
|
||||
#define HAL_BARO_DEFAULT HAL_BARO_HIL
|
||||
#define HAL_COMPASS_DEFAULT HAL_COMPASS_HIL
|
||||
#define HAL_GPIO_A_LED_PIN 61
|
||||
#define HAL_GPIO_B_LED_PIN 48
|
||||
#define HAL_GPIO_C_LED_PIN 117
|
||||
#define HAL_GPIO_LED_ON LOW
|
||||
#define HAL_GPIO_LED_OFF HIGH
|
||||
|
||||
#elif CONFIG_HAL_BOARD == HAL_BOARD_FLYMAPLE
|
||||
#define HAL_BOARD_NAME "FLYMAPLE"
|
||||
|
@ -134,6 +139,11 @@
|
|||
#define HAL_COMPASS_DEFAULT HAL_COMPASS_HMC5843
|
||||
#define HAL_SERIAL0_BAUD_DEFAULT 115200
|
||||
#define CONFIG_HAL_BOARD_SUBTYPE HAL_BOARD_SUBTYPE_NONE
|
||||
#define HAL_GPIO_A_LED_PIN 13
|
||||
#define HAL_GPIO_B_LED_PIN 13
|
||||
#define HAL_GPIO_C_LED_PIN 13
|
||||
#define HAL_GPIO_LED_ON LOW
|
||||
#define HAL_GPIO_LED_OFF HIGH
|
||||
|
||||
#elif CONFIG_HAL_BOARD == HAL_BOARD_PX4
|
||||
#define HAL_BOARD_NAME "PX4"
|
||||
|
@ -153,6 +163,11 @@
|
|||
#define CONFIG_HAL_BOARD_SUBTYPE HAL_BOARD_SUBTYPE_PX4_V2
|
||||
#define HAL_STORAGE_SIZE 16384
|
||||
#endif
|
||||
#define HAL_GPIO_A_LED_PIN 27
|
||||
#define HAL_GPIO_B_LED_PIN 26
|
||||
#define HAL_GPIO_C_LED_PIN 25
|
||||
#define HAL_GPIO_LED_ON LOW
|
||||
#define HAL_GPIO_LED_OFF HIGH
|
||||
|
||||
#elif CONFIG_HAL_BOARD == HAL_BOARD_LINUX
|
||||
#define HAL_BOARD_NAME "Linux"
|
||||
|
@ -167,12 +182,18 @@
|
|||
#define HAL_INS_DEFAULT HAL_INS_HIL
|
||||
#define HAL_BARO_DEFAULT HAL_BARO_HIL
|
||||
#define HAL_COMPASS_DEFAULT HAL_COMPASS_HIL
|
||||
|
||||
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXF || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBOARD
|
||||
#define HAL_BOARD_LOG_DIRECTORY "/var/APM/logs"
|
||||
#define HAL_BOARD_TERRAIN_DIRECTORY "/var/APM/terrain"
|
||||
#define HAL_INS_DEFAULT HAL_INS_MPU9250
|
||||
#define HAL_BARO_DEFAULT HAL_BARO_MS5611_SPI
|
||||
#define HAL_COMPASS_DEFAULT HAL_COMPASS_AK8963_MPU9250
|
||||
#define HAL_GPIO_A_LED_PIN 61
|
||||
#define HAL_GPIO_B_LED_PIN 48
|
||||
#define HAL_GPIO_C_LED_PIN 117
|
||||
#define HAL_GPIO_LED_ON LOW
|
||||
#define HAL_GPIO_LED_OFF HIGH
|
||||
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BEBOP
|
||||
#define HAL_BOARD_LOG_DIRECTORY "/data/ftp/internal_000/APM/logs"
|
||||
#define HAL_BOARD_TERRAIN_DIRECTORY "/data/ftp/internal_000/APM/terrain"
|
||||
|
@ -207,6 +228,11 @@
|
|||
#define HAL_BARO_MS5611_I2C_BUS 0
|
||||
#define HAL_BARO_MS5611_I2C_ADDR 0x77
|
||||
#define HAL_COMPASS_DEFAULT HAL_COMPASS_AK8963_MPU9250
|
||||
#define HAL_GPIO_A_LED_PIN 16
|
||||
#define HAL_GPIO_B_LED_PIN 16
|
||||
#define HAL_GPIO_C_LED_PIN 16
|
||||
#define HAL_GPIO_LED_ON LOW
|
||||
#define HAL_GPIO_LED_OFF HIGH
|
||||
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_RASPILOT
|
||||
#define HAL_BOARD_LOG_DIRECTORY "/var/APM/logs"
|
||||
#define HAL_BOARD_TERRAIN_DIRECTORY "/var/APM/terrain"
|
||||
|
@ -219,6 +245,11 @@
|
|||
#define HAL_INS_DEFAULT HAL_INS_MPU9250
|
||||
#define HAL_BARO_DEFAULT HAL_BARO_MS5611_SPI
|
||||
#define HAL_COMPASS_DEFAULT HAL_COMPASS_AK8963_MPU9250
|
||||
#define HAL_GPIO_A_LED_PIN 24
|
||||
#define HAL_GPIO_B_LED_PIN 25
|
||||
#define HAL_GPIO_C_LED_PIN 16
|
||||
#define HAL_GPIO_LED_ON LOW
|
||||
#define HAL_GPIO_LED_OFF HIGH
|
||||
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ZYNQ
|
||||
#define HAL_BOARD_LOG_DIRECTORY "/var/APM/logs"
|
||||
#define HAL_BOARD_TERRAIN_DIRECTORY "/var/APM/terrain"
|
||||
|
@ -232,6 +263,11 @@
|
|||
#define HAL_INS_DEFAULT HAL_INS_MPU9250
|
||||
#define HAL_BARO_DEFAULT HAL_BARO_MS5611_SPI
|
||||
#define HAL_COMPASS_DEFAULT HAL_COMPASS_AK8963_MPU9250
|
||||
#define HAL_GPIO_A_LED_PIN 61
|
||||
#define HAL_GPIO_B_LED_PIN 48
|
||||
#define HAL_GPIO_C_LED_PIN 117
|
||||
#define HAL_GPIO_LED_ON LOW
|
||||
#define HAL_GPIO_LED_OFF HIGH
|
||||
#else
|
||||
#error "no Linux board subtype set"
|
||||
#endif
|
||||
|
@ -275,6 +311,15 @@
|
|||
#define CONFIG_HAL_BOARD_SUBTYPE HAL_BOARD_SUBTYPE_NONE
|
||||
#define HAL_STORAGE_SIZE 8192
|
||||
#endif
|
||||
#define HAL_GPIO_A_LED_PIN 25
|
||||
#define HAL_GPIO_B_LED_PIN 26
|
||||
#define HAL_GPIO_C_LED_PIN 27
|
||||
#define HAL_GPIO_LED_ON HIGH
|
||||
#define HAL_GPIO_LED_OFF LOW
|
||||
#define EXTERNAL_LED_GPS 28 // GPS LED - AN10
|
||||
#define EXTERNAL_LED_ARMED 29 // Armed LED - AN11
|
||||
#define EXTERNAL_LED_MOTOR1 30 // Motor1 LED - AN8
|
||||
#define EXTERNAL_LED_MOTOR2 31 // Motor2 LED - AN12
|
||||
|
||||
#else
|
||||
#error "Unknown CONFIG_HAL_BOARD type"
|
||||
|
|
|
@ -17,6 +17,9 @@
|
|||
|
||||
#include "AP_Notify.h"
|
||||
|
||||
#if (defined(HAL_GPIO_A_LED_PIN) && defined(HAL_GPIO_B_LED_PIN) && \
|
||||
defined(HAL_GPIO_C_LED_PIN))
|
||||
|
||||
extern const AP_HAL::HAL& hal;
|
||||
|
||||
bool AP_BoardLED::init(void)
|
||||
|
@ -169,3 +172,7 @@ void AP_BoardLED::update(void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
bool AP_BoardLED::init(void) {return true;}
|
||||
void AP_BoardLED::update(void) {return;}
|
||||
#endif
|
||||
|
|
|
@ -25,46 +25,6 @@
|
|||
#define HIGH 1
|
||||
#define LOW 0
|
||||
|
||||
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4
|
||||
# define HAL_GPIO_A_LED_PIN 27
|
||||
# define HAL_GPIO_B_LED_PIN 26
|
||||
# define HAL_GPIO_C_LED_PIN 25
|
||||
# define HAL_GPIO_LED_ON LOW
|
||||
# define HAL_GPIO_LED_OFF HIGH
|
||||
#elif CONFIG_HAL_BOARD == HAL_BOARD_FLYMAPLE
|
||||
# define HAL_GPIO_A_LED_PIN 13
|
||||
# define HAL_GPIO_B_LED_PIN 13
|
||||
# define HAL_GPIO_C_LED_PIN 13
|
||||
# define HAL_GPIO_LED_ON LOW
|
||||
# define HAL_GPIO_LED_OFF HIGH
|
||||
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO
|
||||
# define HAL_GPIO_A_LED_PIN 16
|
||||
# define HAL_GPIO_B_LED_PIN 16
|
||||
# define HAL_GPIO_C_LED_PIN 16
|
||||
# define HAL_GPIO_LED_ON LOW
|
||||
# define HAL_GPIO_LED_OFF HIGH
|
||||
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBRAIN2
|
||||
# define HAL_GPIO_A_LED_PIN 24
|
||||
# define HAL_GPIO_B_LED_PIN 25
|
||||
# define HAL_GPIO_C_LED_PIN 16
|
||||
# define HAL_GPIO_LED_ON LOW
|
||||
# define HAL_GPIO_LED_OFF HIGH
|
||||
#elif CONFIG_HAL_BOARD == HAL_BOARD_LINUX || CONFIG_HAL_BOARD == HAL_BOARD_SITL
|
||||
# define HAL_GPIO_A_LED_PIN 61
|
||||
# define HAL_GPIO_B_LED_PIN 48
|
||||
# define HAL_GPIO_C_LED_PIN 117
|
||||
# define HAL_GPIO_LED_ON LOW
|
||||
# define HAL_GPIO_LED_OFF HIGH
|
||||
#elif CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
|
||||
# define HAL_GPIO_A_LED_PIN 25
|
||||
# define HAL_GPIO_B_LED_PIN 26
|
||||
# define HAL_GPIO_C_LED_PIN 27
|
||||
# define HAL_GPIO_LED_ON HIGH
|
||||
# define HAL_GPIO_LED_OFF LOW
|
||||
#else
|
||||
#error "Unknown board type in AP_Notify"
|
||||
#endif
|
||||
|
||||
class AP_BoardLED: public NotifyDevice
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
#include <AP_HAL/AP_HAL.h>
|
||||
#include "AP_Notify.h"
|
||||
|
||||
#if (defined(EXTERNAL_LED_ARMED) && defined(EXTERNAL_LED_GPS) && \
|
||||
defined(EXTERNAL_LED_MOTOR1) && defined(EXTERNAL_LED_MOTOR2))
|
||||
|
||||
extern const AP_HAL::HAL& hal;
|
||||
|
||||
bool ExternalLED::init(void)
|
||||
|
@ -245,3 +248,7 @@ void ExternalLED::motor_led2(bool on_off)
|
|||
hal.gpio->write(EXTERNAL_LED_MOTOR2, _flags.motorled2_on);
|
||||
}
|
||||
}
|
||||
#else
|
||||
bool ExternalLED::init(void) {return true;}
|
||||
void ExternalLED::update(void) {return;}
|
||||
#endif
|
||||
|
|
|
@ -23,18 +23,6 @@
|
|||
#include <AP_Param/AP_Param.h>
|
||||
#include "NotifyDevice.h"
|
||||
|
||||
#if CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
|
||||
#define EXTERNAL_LED_GPS 28 // GPS LED - AN10
|
||||
#define EXTERNAL_LED_ARMED 29 // Armed LED - AN11
|
||||
#define EXTERNAL_LED_MOTOR1 30 // Motor1 LED - AN8
|
||||
#define EXTERNAL_LED_MOTOR2 31 // Motor2 LED - AN12
|
||||
#else
|
||||
#define EXTERNAL_LED_GPS 0 // pin definitions to allow this lib to build for
|
||||
#define EXTERNAL_LED_ARMED 0 // for other boards even though
|
||||
#define EXTERNAL_LED_MOTOR1 0 // they will never be used
|
||||
#define EXTERNAL_LED_MOTOR2 0
|
||||
#endif
|
||||
|
||||
class ExternalLED: public NotifyDevice
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
#include "VRBoard_LED.h"
|
||||
#include <AP_HAL/AP_HAL.h>
|
||||
|
||||
#if (defined(HAL_GPIO_A_LED_PIN) && defined(HAL_GPIO_B_LED_PIN) && \
|
||||
defined(HAL_GPIO_C_LED_PIN))
|
||||
|
||||
#define VRBRAIN_LED_BRIGHT 1 // full brightness
|
||||
#define VRBRAIN_LED_MEDIUM 1 // medium brightness
|
||||
#define VRBRAIN_LED_DIM 1 // dim
|
||||
|
@ -64,3 +67,5 @@ bool VRBoard_LED::hw_set_rgb(uint8_t r, uint8_t g, uint8_t b){
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue