Compare commits
2 Commits
c5343f9cdd
...
8005b94b24
Author | SHA1 | Date |
---|---|---|
Kilian Bracher | 8005b94b24 | |
Kilian Bracher | ba05bb5ff4 |
|
@ -13,6 +13,12 @@
|
||||||
#define SLAVE_PANIC_UT 1
|
#define SLAVE_PANIC_UT 1
|
||||||
#define SLAVE_PANIC_OV 2
|
#define SLAVE_PANIC_OV 2
|
||||||
#define SLAVE_PANIC_UV 3
|
#define SLAVE_PANIC_UV 3
|
||||||
|
#define SLAVE_PANIC_TOO_FEW_TEMPS 4
|
||||||
|
#define SLAVE_PANIC_OPENWIRE 5
|
||||||
|
#define SLAVE_PANIC_EEPROM_ERROR 6
|
||||||
|
#define SLAVE_PANIC_INTERNAL_BMS_TIMEOUT 7
|
||||||
|
#define SLAVE_PANIC_INTERNAL_BMS_CHECKSUM 8
|
||||||
|
#define SLAVE_PANIC_INTERNAL_BMS_OVERTEMP 9
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
SLAVE_ERR_NONE,
|
SLAVE_ERR_NONE,
|
||||||
|
@ -21,6 +27,12 @@ typedef enum {
|
||||||
SLAVE_ERR_UT,
|
SLAVE_ERR_UT,
|
||||||
SLAVE_ERR_OV,
|
SLAVE_ERR_OV,
|
||||||
SLAVE_ERR_UV,
|
SLAVE_ERR_UV,
|
||||||
|
SLAVE_ERR_TOO_FEW_TEMPS,
|
||||||
|
SLAVE_ERR_OPENWIRE,
|
||||||
|
SLAVE_ERR_EEPROM,
|
||||||
|
SLAVE_ERR_INTERNAL_BMS_TIMEOUT,
|
||||||
|
SLAVE_ERR_INTERNAL_BMS_CHECKSUM,
|
||||||
|
SLAVE_ERR_INTERNAL_BMS_OVERTEMP,
|
||||||
SLAVE_ERR_UNKNOWN,
|
SLAVE_ERR_UNKNOWN,
|
||||||
} SlaveErrorKind;
|
} SlaveErrorKind;
|
||||||
|
|
||||||
|
|
|
@ -100,18 +100,12 @@ void slaves_handle_panic(const uint8_t *data) {
|
||||||
uint8_t idx = get_slave_index(slave_id);
|
uint8_t idx = get_slave_index(slave_id);
|
||||||
uint8_t error_kind = ftcan_unmarshal_unsigned(ptr, 1);
|
uint8_t error_kind = ftcan_unmarshal_unsigned(ptr, 1);
|
||||||
switch (error_kind) {
|
switch (error_kind) {
|
||||||
case SLAVE_PANIC_OT:
|
case SLAVE_PANIC_OT ... SLAVE_PANIC_INTERNAL_BMS_OVERTEMP:
|
||||||
slaves[idx].error.kind = SLAVE_ERR_OT;
|
slaves[idx].error.kind = error_kind + 2; //SlaveErrorKind on master is 2 higher than on slave (errors.h in slave firmware)
|
||||||
break;
|
break;
|
||||||
case SLAVE_PANIC_UT:
|
default:
|
||||||
slaves[idx].error.kind = SLAVE_ERR_UT;
|
slaves[idx].error.kind = SLAVE_ERR_UNKNOWN;
|
||||||
break;
|
break;
|
||||||
case SLAVE_PANIC_OV:
|
|
||||||
slaves[idx].error.kind = SLAVE_ERR_OV;
|
|
||||||
break;
|
|
||||||
case SLAVE_PANIC_UV:
|
|
||||||
slaves[idx].error.kind = SLAVE_ERR_UV;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
slaves[idx].error.data = ftcan_unmarshal_unsigned(&data, 4);
|
slaves[idx].error.data = ftcan_unmarshal_unsigned(&data, 4);
|
||||||
slaves[idx].last_message = HAL_GetTick();
|
slaves[idx].last_message = HAL_GetTick();
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#define STATUS_LED_2_BLUE_PIN GPIO_PIN_15
|
#define STATUS_LED_2_BLUE_PIN GPIO_PIN_15
|
||||||
|
|
||||||
//TODO: change to correct values for the board
|
//TODO: change to correct values for the board
|
||||||
#error "GPIO pins for status LEDs are not set correctly"
|
#warning "GPIO pins for status LEDs are not set correctly"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t red : 1;
|
uint8_t red : 1;
|
||||||
|
@ -82,52 +82,52 @@ static void set_led_color(LedId id, LedColor color) {
|
||||||
|
|
||||||
void status_led_state(TSState state, TSErrorKind error) {
|
void status_led_state(TSState state, TSErrorKind error) {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case TS_INACTIVE:
|
case TS_INACTIVE:
|
||||||
set_led_color(LED_1, (LedColor) {.red = 0, .green = 0, .blue = 0});
|
set_led_color(LED_1, (LedColor) {.red = 0, .green = 0, .blue = 0});
|
||||||
set_led_color(LED_2, (LedColor) {.red = 0, .green = 0, .blue = 0});
|
set_led_color(LED_2, (LedColor) {.red = 0, .green = 0, .blue = 0});
|
||||||
break;
|
break;
|
||||||
case TS_ACTIVE:
|
case TS_ACTIVE:
|
||||||
set_led_color(LED_1, (LedColor) {.red = 0, .green = 0, .blue = 1});
|
set_led_color(LED_1, (LedColor) {.red = 0, .green = 0, .blue = 1});
|
||||||
set_led_color(LED_2, (LedColor) {.red = 0, .green = 0, .blue = 0});
|
set_led_color(LED_2, (LedColor) {.red = 0, .green = 0, .blue = 0});
|
||||||
break;
|
break;
|
||||||
case TS_PRECHARGE:
|
case TS_PRECHARGE:
|
||||||
set_led_color(LED_1, (LedColor) {.red = 0, .green = 0, .blue = 1});
|
set_led_color(LED_1, (LedColor) {.red = 0, .green = 0, .blue = 1});
|
||||||
set_led_color(LED_2, (LedColor) {.red = 0, .green = 1, .blue = 1});
|
set_led_color(LED_2, (LedColor) {.red = 0, .green = 1, .blue = 1});
|
||||||
break;
|
break;
|
||||||
case TS_DISCHARGE:
|
case TS_DISCHARGE:
|
||||||
set_led_color(LED_1, (LedColor) {.red = 0, .green = 0, .blue = 1});
|
set_led_color(LED_1, (LedColor) {.red = 0, .green = 0, .blue = 1});
|
||||||
set_led_color(LED_2, (LedColor) {.red = 1, .green = 0, .blue = 1});
|
set_led_color(LED_2, (LedColor) {.red = 1, .green = 0, .blue = 1});
|
||||||
break;
|
break;
|
||||||
case TS_ERROR:
|
case TS_ERROR:
|
||||||
set_led_color(LED_1, (LedColor) {.red = 1, .green = 0, .blue = 0});
|
set_led_color(LED_1, (LedColor) {.red = 1, .green = 0, .blue = 0});
|
||||||
switch (error) {
|
switch (error) {
|
||||||
case TS_ERRORKIND_NONE:
|
case TS_ERRORKIND_NONE:
|
||||||
set_led_color(LED_2, (LedColor) {.red = 0, .green = 0, .blue = 0});
|
set_led_color(LED_2, (LedColor) {.red = 0, .green = 0, .blue = 0});
|
||||||
break;
|
break;
|
||||||
case TS_ERRORKIND_SLAVE_TIMEOUT:
|
case TS_ERRORKIND_SLAVE_TIMEOUT:
|
||||||
set_led_color(LED_2, (LedColor) {.red = 0, .green = 0, .blue = 1});
|
set_led_color(LED_2, (LedColor) {.red = 0, .green = 0, .blue = 1});
|
||||||
break;
|
break;
|
||||||
case TS_ERRORKIND_SLAVE_PANIC:
|
case TS_ERRORKIND_SLAVE_PANIC:
|
||||||
set_led_color(LED_2, (LedColor) {.red = 1, .green = 0, .blue = 1});
|
set_led_color(LED_2, (LedColor) {.red = 1, .green = 0, .blue = 1});
|
||||||
break;
|
break;
|
||||||
case TS_ERRORKIND_SHUNT_TIMEOUT:
|
case TS_ERRORKIND_SHUNT_TIMEOUT:
|
||||||
set_led_color(LED_2, (LedColor) {.red = 0, .green = 1, .blue = 0});
|
set_led_color(LED_2, (LedColor) {.red = 0, .green = 1, .blue = 0});
|
||||||
break;
|
break;
|
||||||
case TS_ERRORKIND_SHUNT_OVERCURRENT:
|
case TS_ERRORKIND_SHUNT_OVERCURRENT:
|
||||||
set_led_color(LED_2, (LedColor) {.red = 1, .green = 1, .blue = 0});
|
set_led_color(LED_2, (LedColor) {.red = 1, .green = 1, .blue = 0});
|
||||||
break;
|
break;
|
||||||
case TS_ERRORKIND_SHUNT_OVERTEMP:
|
case TS_ERRORKIND_SHUNT_OVERTEMP:
|
||||||
set_led_color(LED_2, (LedColor) {.red = 1, .green = 0, .blue = 0});
|
set_led_color(LED_2, (LedColor) {.red = 1, .green = 0, .blue = 0});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TS_CHARGING_CHECK:
|
case TS_CHARGING_CHECK:
|
||||||
set_led_color(LED_1, (LedColor) {.red = 0, .green = 1, .blue = 0});
|
set_led_color(LED_1, (LedColor) {.red = 0, .green = 1, .blue = 0});
|
||||||
set_led_color(LED_2, (LedColor) {.red = 0, .green = 1, .blue = 1});
|
set_led_color(LED_2, (LedColor) {.red = 0, .green = 1, .blue = 1});
|
||||||
break;
|
break;
|
||||||
case TS_CHARGING:
|
case TS_CHARGING:
|
||||||
set_led_color(LED_1, (LedColor) {.red = 0, .green = 1, .blue = 0});
|
set_led_color(LED_1, (LedColor) {.red = 0, .green = 1, .blue = 0});
|
||||||
set_led_color(LED_2, (LedColor) {.red = 0, .green = 0, .blue = 0});
|
set_led_color(LED_2, (LedColor) {.red = 0, .green = 0, .blue = 0});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue