AP_Periph: airspeed add support for CAN/I2C switch and LED

This commit is contained in:
Nathan Costa 2022-02-01 15:39:43 -05:00 committed by Andrew Tridgell
parent 9f7aa715b1
commit a867e04116
1 changed files with 17 additions and 2 deletions

View File

@ -27,6 +27,7 @@
#if CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
#include <AP_HAL_ChibiOS/hwdef/common/stm32_util.h>
#include <AP_HAL_ChibiOS/hwdef/common/watchdog.h>
#include <AP_HAL_ChibiOS/I2CDevice.h>
#endif
extern const AP_HAL::HAL &hal;
@ -180,10 +181,24 @@ void AP_Periph_FW::init()
#endif
#ifdef HAL_PERIPH_ENABLE_AIRSPEED
if (airspeed.enabled()) {
// Note: logging of ARSPD is not enabled currently. To enable, call airspeed.set_log_bit();
if (airspeed.enabled()){
#if CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
const bool pins_enabled = ChibiOS::I2CBus::check_select_pins(0x01);
if (pins_enabled) {
ChibiOS::I2CBus::set_bus_to_floating(0);
#ifdef HAL_GPIO_PIN_LED_CAN_I2C
palWriteLine(HAL_GPIO_PIN_LED_CAN_I2C, 1);
#endif
} else {
// Note: logging of ARSPD is not enabled currently. To enable, call airspeed.set_log_bit(); here
airspeed.init();
}
#else
// Note: logging of ARSPD is not enabled currently. To enable, call airspeed.set_log_bit(); here
airspeed.init();
#endif
}
#endif
#ifdef HAL_PERIPH_ENABLE_RANGEFINDER