diff --git a/sw/airborne/firmwares/rotorcraft/telemetry.h b/sw/airborne/firmwares/rotorcraft/telemetry.h index 56923fa33f4..abd2b233e52 100644 --- a/sw/airborne/firmwares/rotorcraft/telemetry.h +++ b/sw/airborne/firmwares/rotorcraft/telemetry.h @@ -739,44 +739,89 @@ &ahrs.ltp_to_body_euler.psi); \ } +#ifdef USE_I2C0 +#define PERIODIC_SEND_I2C0_ERRORS(_trans, _dev) { \ + uint16_t i2c0_ack_fail_cnt = i2c0.errors->ack_fail_cnt; \ + uint16_t i2c0_miss_start_stop_cnt = i2c0.errors->miss_start_stop_cnt; \ + uint16_t i2c0_arb_lost_cnt = i2c0.errors->arb_lost_cnt; \ + uint16_t i2c0_over_under_cnt = i2c0.errors->over_under_cnt; \ + uint16_t i2c0_pec_recep_cnt = i2c0.errors->pec_recep_cnt; \ + uint16_t i2c0_timeout_tlow_cnt = i2c0.errors->timeout_tlow_cnt; \ + uint16_t i2c0_smbus_alert_cnt = i2c0.errors->smbus_alert_cnt; \ + uint16_t i2c0_unexpected_event_cnt = i2c0.errors->unexpected_event_cnt; \ + uint32_t i2c0_last_unexpected_event = i2c0.errors->last_unexpected_event; \ + DOWNLINK_SEND_I2C_ERRORS(_trans, _dev, \ + &i2c0_ack_fail_cnt, \ + &i2c0_miss_start_stop_cnt, \ + &i2c0_arb_lost_cnt, \ + &i2c0_over_under_cnt, \ + &i2c0_pec_recep_cnt, \ + &i2c0_timeout_tlow_cnt, \ + &i2c0_smbus_alert_cnt, \ + &i2c0_unexpected_event_cnt, \ + &i2c0_last_unexpected_event); \ + } +#else +#define PERIODIC_SEND_I2C0_ERRORS(_trans, _dev) {} +#endif + #ifdef USE_I2C1 -#define PERIODIC_SEND_I2C1_ERRORS(_trans, _dev) { \ - DOWNLINK_SEND_I2C_ERRORS(_trans, _dev, \ - &i2c1.errors->ack_fail_cnt, \ - &i2c1.errors->miss_start_stop_cnt, \ - &i2c1.errors->arb_lost_cnt, \ - &i2c1.errors->over_under_cnt, \ - &i2c1.errors->pec_recep_cnt, \ - &i2c1.errors->timeout_tlow_cnt, \ - &i2c1.errors->smbus_alert_cnt, \ - &i2c1.errors->unexpected_event_cnt, \ - &i2c1.errors->last_unexpected_event); \ +#define PERIODIC_SEND_I2C1_ERRORS(_trans, _dev) { \ + uint16_t i2c1_ack_fail_cnt = i2c1.errors->ack_fail_cnt; \ + uint16_t i2c1_miss_start_stop_cnt = i2c1.errors->miss_start_stop_cnt; \ + uint16_t i2c1_arb_lost_cnt = i2c1.errors->arb_lost_cnt; \ + uint16_t i2c1_over_under_cnt = i2c1.errors->over_under_cnt; \ + uint16_t i2c1_pec_recep_cnt = i2c1.errors->pec_recep_cnt; \ + uint16_t i2c1_timeout_tlow_cnt = i2c1.errors->timeout_tlow_cnt; \ + uint16_t i2c1_smbus_alert_cnt = i2c1.errors->smbus_alert_cnt; \ + uint16_t i2c1_unexpected_event_cnt = i2c1.errors->unexpected_event_cnt; \ + uint32_t i2c1_last_unexpected_event = i2c1.errors->last_unexpected_event; \ + DOWNLINK_SEND_I2C_ERRORS(_trans, _dev, \ + &i2c1_ack_fail_cnt, \ + &i2c1_miss_start_stop_cnt, \ + &i2c1_arb_lost_cnt, \ + &i2c1_over_under_cnt, \ + &i2c1_pec_recep_cnt, \ + &i2c1_timeout_tlow_cnt, \ + &i2c1_smbus_alert_cnt, \ + &i2c1_unexpected_event_cnt, \ + &i2c1_last_unexpected_event); \ } #else #define PERIODIC_SEND_I2C1_ERRORS(_trans, _dev) {} #endif #ifdef USE_I2C2 -#define PERIODIC_SEND_I2C2_ERRORS(_trans, _dev) { \ - DOWNLINK_SEND_I2C_ERRORS(_trans, _dev, \ - &i2c2.errors->ack_fail_cnt, \ - &i2c2.errors->miss_start_stop_cnt, \ - &i2c2.errors->arb_lost_cnt, \ - &i2c2.errors->over_under_cnt, \ - &i2c2.errors->pec_recep_cnt, \ - &i2c2.errors->timeout_tlow_cnt, \ - &i2c2.errors->smbus_alert_cnt, \ - &i2c2.errors->unexpected_event_cnt, \ - &i2c2.errors->last_unexpected_event); \ +#define PERIODIC_SEND_I2C2_ERRORS(_trans, _dev) { \ + uint16_t i2c2_ack_fail_cnt = i2c2.errors->ack_fail_cnt; \ + uint16_t i2c2_miss_start_stop_cnt = i2c2.errors->miss_start_stop_cnt; \ + uint16_t i2c2_arb_lost_cnt = i2c2.errors->arb_lost_cnt; \ + uint16_t i2c2_over_under_cnt = i2c2.errors->over_under_cnt; \ + uint16_t i2c2_pec_recep_cnt = i2c2.errors->pec_recep_cnt; \ + uint16_t i2c2_timeout_tlow_cnt = i2c2.errors->timeout_tlow_cnt; \ + uint16_t i2c2_smbus_alert_cnt = i2c2.errors->smbus_alert_cnt; \ + uint16_t i2c2_unexpected_event_cnt = i2c2.errors->unexpected_event_cnt; \ + uint32_t i2c2_last_unexpected_event = i2c2.errors->last_unexpected_event; \ + DOWNLINK_SEND_I2C_ERRORS(_trans, _dev, \ + &i2c2_ack_fail_cnt, \ + &i2c2_miss_start_stop_cnt, \ + &i2c2_arb_lost_cnt, \ + &i2c2_over_under_cnt, \ + &i2c2_pec_recep_cnt, \ + &i2c2_timeout_tlow_cnt, \ + &i2c2_smbus_alert_cnt, \ + &i2c2_unexpected_event_cnt, \ + &i2c2_last_unexpected_event); \ } #else #define PERIODIC_SEND_I2C2_ERRORS(_trans, _dev) {} #endif -#define PERIODIC_SEND_I2C_ERRORS(_trans, _dev) { \ - PERIODIC_SEND_I2C1_ERRORS(_trans, _dev); \ - PERIODIC_SEND_I2C2_ERRORS(_trans, _dev); \ - } +#define PERIODIC_SEND_I2C_ERRORS(_trans, _dev) { \ + PERIODIC_SEND_I2C0_ERRORS(_trans, _dev); \ + PERIODIC_SEND_I2C1_ERRORS(_trans, _dev); \ + PERIODIC_SEND_I2C2_ERRORS(_trans, _dev); \ +} // FIXME: still used?? or replace by EXTRA_ADC #define PERIODIC_SEND_BOOZ2_SONAR(_trans, _dev) {}