diff --git a/flight/OpenPilot/Modules/System/systemmod.c b/flight/OpenPilot/Modules/System/systemmod.c index ab1f9ae6e..c1f57f318 100644 --- a/flight/OpenPilot/Modules/System/systemmod.c +++ b/flight/OpenPilot/Modules/System/systemmod.c @@ -211,7 +211,7 @@ static void updateI2Cstats() I2CStatsGet(&i2cStats); struct pios_i2c_fault_history history; - PIOS_I2C_GetDiagnoistics(&history, &i2cStats.event_errors); + PIOS_I2C_GetDiagnostics(&history, &i2cStats.event_errors); for(uint8_t i = 0; (i < I2C_LOG_DEPTH) && (i < I2CSTATS_EVENT_LOG_NUMELEM); i++) { i2cStats.event_log[i] = history.event[i]; diff --git a/flight/PiOS/STM32F10x/pios_i2c.c b/flight/PiOS/STM32F10x/pios_i2c.c index fc918e873..b9fdef74c 100644 --- a/flight/PiOS/STM32F10x/pios_i2c.c +++ b/flight/PiOS/STM32F10x/pios_i2c.c @@ -789,13 +789,19 @@ void i2c_adapter_log_fault(enum pios_i2c_error_type type) * \param[out] counts three uint16 that receive the bad event, fsm, and error irq * counts */ -void PIOS_I2C_GetDiagnoistics(struct pios_i2c_fault_history * data, uint16_t * counts) +void PIOS_I2C_GetDiagnostics(struct pios_i2c_fault_history * data, uint16_t * counts) { #if defined(PIOS_I2C_DIAGNOSTICS) memcpy(data, &i2c_adapter_fault_history, sizeof(i2c_adapter_fault_history)); counts[0] = i2c_bad_event_counter; counts[1] = i2c_fsm_fault_count; counts[2] = i2c_error_interrupt_counter; +#else + struct pios_i2c_fault_history i2c_adapter_fault_history; + i2c_adapter_fault_history.type = PIOS_I2C_ERROR_EVENT; + + memcpy(data, &i2c_adapter_fault_history, sizeof(i2c_adapter_fault_history)); + counts[0] = counts[1] = counts[2] = 0; #endif } @@ -841,7 +847,7 @@ int32_t PIOS_I2C_Init(void) NVIC_Init(&(i2c_adapter->cfg->event.init)); NVIC_Init(&(i2c_adapter->cfg->error.init)); } - + /* No error */ return 0; } diff --git a/flight/PiOS/inc/pios_i2c.h b/flight/PiOS/inc/pios_i2c.h index 6c7a868d2..800bdfd5b 100644 --- a/flight/PiOS/inc/pios_i2c.h +++ b/flight/PiOS/inc/pios_i2c.h @@ -31,7 +31,7 @@ #ifndef PIOS_I2C_H #define PIOS_I2C_H -//#define PIOS_I2C_DIAGNOSTICS +#define PIOS_I2C_DIAGNOSTICS #include @@ -67,7 +67,7 @@ extern int32_t PIOS_I2C_Init(void); extern bool PIOS_I2C_Transfer(uint8_t i2c, const struct pios_i2c_txn txn_list[], uint32_t num_txns); extern void PIOS_I2C_EV_IRQ_Handler(uint8_t i2c); extern void PIOS_I2C_ER_IRQ_Handler(uint8_t i2c); -extern void PIOS_I2C_GetDiagnoistics(struct pios_i2c_fault_history * data, uint16_t * error_counts); +extern void PIOS_I2C_GetDiagnostics(struct pios_i2c_fault_history * data, uint16_t * error_counts); #endif /* PIOS_I2C_H */