Skip to content

Commit

Permalink
[messages] added field for i2c bus number to I2C_ERRORS message
Browse files Browse the repository at this point in the history
  • Loading branch information
flixr committed Jun 15, 2012
1 parent a34ed01 commit e6bd226
Show file tree
Hide file tree
Showing 10 changed files with 158 additions and 70 deletions.
1 change: 1 addition & 0 deletions conf/messages.xml
Expand Up @@ -1963,6 +1963,7 @@
<field name="smbus_alert_cnt" type="uint16"/>
<field name="unexpected_event_cnt" type="uint16"/>
<field name="last_unexpected_event" type="uint32"/>
<field name="bus_number" type="uint8"/>
</message>

<message name="RDYB_TRAJECTORY" id="254">
Expand Down
4 changes: 3 additions & 1 deletion sw/airborne/boards/lisa_l/test_baro.c
Expand Up @@ -87,6 +87,7 @@ static inline void main_periodic_task( void ) {
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;
const uint8_t _bus2 = 2;
DOWNLINK_SEND_I2C_ERRORS(DefaultChannel, DefaultDevice,
&i2c2_ack_fail_cnt,
&i2c2_miss_start_stop_cnt,
Expand All @@ -96,7 +97,8 @@ static inline void main_periodic_task( void ) {
&i2c2_timeout_tlow_cnt,
&i2c2_smbus_alert_cnt,
&i2c2_unexpected_event_cnt,
&i2c2_last_unexpected_event);
&i2c2_last_unexpected_event,
&_bus2);
});
}

Expand Down
4 changes: 3 additions & 1 deletion sw/airborne/boards/lisa_m/test_baro.c
Expand Up @@ -88,6 +88,7 @@ static inline void main_periodic_task( void ) {
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;
const uint8_t _bus2 = 2;
DOWNLINK_SEND_I2C_ERRORS(DefaultChannel, DefaultDevice,
&i2c2_ack_fail_cnt,
&i2c2_miss_start_stop_cnt,
Expand All @@ -97,7 +98,8 @@ static inline void main_periodic_task( void ) {
&i2c2_timeout_tlow_cnt,
&i2c2_smbus_alert_cnt,
&i2c2_unexpected_event_cnt,
&i2c2_last_unexpected_event);
&i2c2_last_unexpected_event,
&_bus2);
});
}

Expand Down
12 changes: 9 additions & 3 deletions sw/airborne/firmwares/rotorcraft/telemetry.h
Expand Up @@ -751,6 +751,7 @@
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; \
const uint8_t _bus0 = 0; \
DOWNLINK_SEND_I2C_ERRORS(_trans, _dev, \
&i2c0_ack_fail_cnt, \
&i2c0_miss_start_stop_cnt, \
Expand All @@ -760,7 +761,8 @@
&i2c0_timeout_tlow_cnt, \
&i2c0_smbus_alert_cnt, \
&i2c0_unexpected_event_cnt, \
&i2c0_last_unexpected_event); \
&i2c0_last_unexpected_event, \
&_bus0); \
}
#else
#define PERIODIC_SEND_I2C0_ERRORS(_trans, _dev) {}
Expand All @@ -777,6 +779,7 @@
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; \
const uint8_t _bus1 = 1; \
DOWNLINK_SEND_I2C_ERRORS(_trans, _dev, \
&i2c1_ack_fail_cnt, \
&i2c1_miss_start_stop_cnt, \
Expand All @@ -786,7 +789,8 @@
&i2c1_timeout_tlow_cnt, \
&i2c1_smbus_alert_cnt, \
&i2c1_unexpected_event_cnt, \
&i2c1_last_unexpected_event); \
&i2c1_last_unexpected_event, \
&_bus1); \
}
#else
#define PERIODIC_SEND_I2C1_ERRORS(_trans, _dev) {}
Expand All @@ -803,6 +807,7 @@
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; \
const uint8_t _bus2 = 2; \
DOWNLINK_SEND_I2C_ERRORS(_trans, _dev, \
&i2c2_ack_fail_cnt, \
&i2c2_miss_start_stop_cnt, \
Expand All @@ -812,7 +817,8 @@
&i2c2_timeout_tlow_cnt, \
&i2c2_smbus_alert_cnt, \
&i2c2_unexpected_event_cnt, \
&i2c2_last_unexpected_event); \
&i2c2_last_unexpected_event, \
&_bus2); \
}
#else
#define PERIODIC_SEND_I2C2_ERRORS(_trans, _dev) {}
Expand Down
29 changes: 20 additions & 9 deletions sw/airborne/lisa/test/lisa_test_hmc5843.c
Expand Up @@ -90,16 +90,27 @@ static inline void main_periodic_task( void ) {
});
RunOnceEvery(256,
{
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;
const uint8_t _bus2 = 2;
DOWNLINK_SEND_I2C_ERRORS(DefaultChannel, DefaultDevice,
&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);
&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,
&_bus2);
});
if (mag_state == 2) send_config();

Expand Down
31 changes: 21 additions & 10 deletions sw/airborne/lisa/test/lisa_test_itg3200.c
Expand Up @@ -86,16 +86,27 @@ static inline void main_periodic_task( void ) {
LED_PERIODIC();
});
RunOnceEvery(256, {
DOWNLINK_SEND_I2C_ERRORS(DefaultChannel, DefaultDevice,
&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);
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;
const uint8_t _bus2 = 2;
DOWNLINK_SEND_I2C_ERRORS(DefaultChannel, DefaultDevice,
&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,
&_bus2);
});

switch (gyro_state) {
Expand Down
58 changes: 40 additions & 18 deletions sw/airborne/lisa/test/test_board.c
Expand Up @@ -155,16 +155,27 @@ static void test_baro_start(void) {all_led_green();}
static void test_baro_periodic(void) {
RunOnceEvery(2, {baro_periodic();});
RunOnceEvery(100,{
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;
const uint8_t _bus2 = 2;
DOWNLINK_SEND_I2C_ERRORS(DefaultChannel, DefaultDevice,
&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);
&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,
&_bus2);
});
}
static void test_baro_event(void) {BaroEvent(test_baro_on_baro_abs, test_baro_on_baro_diff);}
Expand All @@ -189,16 +200,27 @@ static void test_bldc_periodic(void) {
i2c1_transmit(0x58, 1, NULL);

RunOnceEvery(100,{
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;
const uint8_t _bus1 = 1;
DOWNLINK_SEND_I2C_ERRORS(DefaultChannel, DefaultDevice,
&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);
&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,
&_bus1);
});
}

Expand Down
29 changes: 20 additions & 9 deletions sw/airborne/lisa/test/test_mc_asctec_v1_simple.c
Expand Up @@ -64,16 +64,27 @@ static inline void main_periodic_task( void ) {
RunOnceEvery(256, {DOWNLINK_SEND_ALIVE(DefaultChannel, DefaultDevice, 16, MD5SUM);});
RunOnceEvery(256,
{
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;
const uint8_t _bus1 = 1;
DOWNLINK_SEND_I2C_ERRORS(DefaultChannel, DefaultDevice,
&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);
&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,
&_bus1);
});


Expand Down
31 changes: 21 additions & 10 deletions sw/airborne/test/subsystems/test_ahrs.c
Expand Up @@ -161,16 +161,27 @@ static inline void main_report(void) {
},
{
#ifdef USE_I2C2
DOWNLINK_SEND_I2C_ERRORS(DefaultChannel, DefaultDevice,
&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);
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;
const uint8_t _bus2 = 2;
DOWNLINK_SEND_I2C_ERRORS(DefaultChannel, DefaultDevice,
&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,
&_bus2);
#endif
},
{
Expand Down
29 changes: 20 additions & 9 deletions sw/airborne/test/subsystems/test_imu.c
Expand Up @@ -82,16 +82,27 @@ static inline void main_periodic_task( void ) {
});
#ifdef USE_I2C2
RunOnceEvery(111, {
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;
const uint8_t _bus2 = 2;
DOWNLINK_SEND_I2C_ERRORS(DefaultChannel, DefaultDevice,
&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);
&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,
&_bus2);
});
#endif
if (sys_time.nb_sec > 1) imu_periodic();
Expand Down

0 comments on commit e6bd226

Please sign in to comment.