1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

PiOS/I2C: Fixed typo and also the values for I2C Diagnostics when disabled.

Enabled by default though.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2243 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
peabody124 2010-12-18 07:09:28 +00:00 committed by peabody124
parent 3adf0e044e
commit af99c31a61
3 changed files with 11 additions and 5 deletions

View File

@ -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];

View File

@ -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;
}

View File

@ -31,7 +31,7 @@
#ifndef PIOS_I2C_H
#define PIOS_I2C_H
//#define PIOS_I2C_DIAGNOSTICS
#define PIOS_I2C_DIAGNOSTICS
#include <stdbool.h>
@ -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 */