1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-18 08:54:15 +01:00

LP-444 Do not touch i2c alarm in case it is uninitialised. This will keep the gcs field grey when I2C is not in use.

This commit is contained in:
Vladimir Zidar 2016-12-05 13:47:17 +01:00
parent e603f9f3fe
commit 1207968362

View File

@ -698,24 +698,25 @@ static void updateSystemAlarms()
}
#ifdef PIOS_INCLUDE_I2C
static const SystemAlarmsAlarmOptions i2c_alarm_by_error[] = {
[PIOS_I2C_BAD_EVENT_COUNTER] = SYSTEMALARMS_ALARM_ERROR,
[PIOS_I2C_FSM_FAULT_COUNT] = SYSTEMALARMS_ALARM_ERROR,
[PIOS_I2C_ERROR_INTERRUPT_COUNTER] = SYSTEMALARMS_ALARM_ERROR,
[PIOS_I2C_NACK_COUNTER] = SYSTEMALARMS_ALARM_CRITICAL,
[PIOS_I2C_TIMEOUT_COUNTER] = SYSTEMALARMS_ALARM_ERROR,
};
if (AlarmsGet(SYSTEMALARMS_ALARM_I2C) != SYSTEMALARMS_ALARM_UNINITIALISED) {
static const SystemAlarmsAlarmOptions i2c_alarm_by_error[] = {
[PIOS_I2C_BAD_EVENT_COUNTER] = SYSTEMALARMS_ALARM_ERROR,
[PIOS_I2C_FSM_FAULT_COUNT] = SYSTEMALARMS_ALARM_ERROR,
[PIOS_I2C_ERROR_INTERRUPT_COUNTER] = SYSTEMALARMS_ALARM_ERROR,
[PIOS_I2C_NACK_COUNTER] = SYSTEMALARMS_ALARM_CRITICAL,
[PIOS_I2C_TIMEOUT_COUNTER] = SYSTEMALARMS_ALARM_ERROR,
};
SystemAlarmsAlarmOptions i2c_alarm = SYSTEMALARMS_ALARM_OK;
SystemAlarmsAlarmOptions i2c_alarm = SYSTEMALARMS_ALARM_OK;
for (uint8_t i = 0; i < PIOS_I2C_ERROR_COUNT_NUMELEM; i++) {
if ((i2c_error_activity[i] > 0) && (i2c_alarm < i2c_alarm_by_error[i])) {
i2c_alarm = i2c_alarm_by_error[i];
for (uint8_t i = 0; i < PIOS_I2C_ERROR_COUNT_NUMELEM; i++) {
if ((i2c_error_activity[i] > 0) && (i2c_alarm < i2c_alarm_by_error[i])) {
i2c_alarm = i2c_alarm_by_error[i];
}
}
AlarmsSet(SYSTEMALARMS_ALARM_I2C, i2c_alarm);
}
AlarmsSet(SYSTEMALARMS_ALARM_I2C, i2c_alarm);
#endif /* PIOS_INCLUDE_I2C */
}