Send AMS error messages

This commit is contained in:
2023-04-30 00:57:42 +02:00
parent 48ae56fbdf
commit ce4d7253eb
6 changed files with 34 additions and 1 deletions

View File

@ -5,9 +5,12 @@
#include "stm32f3xx_hal_can.h"
#include "stm32f3xx_hal_def.h"
#include "ts_state_machine.h"
#define CAN_ID_SLAVE_PANIC 0x009
#define CAN_ID_AMS_STATUS 0x00A
#define CAN_ID_AMS_IN 0x00B
#define CAN_ID_AMS_ERROR 0x00C
#define CAN_ID_SLAVE_STATUS 0x014
#define CAN_ID_SLAVE_LOG 0x4F4
#define CAN_ID_SHUNT_BASE 0x520
@ -22,6 +25,7 @@
void can_init(CAN_HandleTypeDef *handle);
HAL_StatusTypeDef can_send_status();
HAL_StatusTypeDef can_send_error(TSErrorKind kind, uint8_t arg);
void ftcan_msg_received_cb(uint16_t id, size_t datalen, const uint8_t *data);

View File

@ -6,6 +6,7 @@
#include "stm32f3xx_hal.h"
#define THRESH_OVERCURRENT 300000 // mA
#define THRESH_OVERTEMP 1000 // 1/10 °C
typedef struct {
int32_t current;

View File

@ -29,6 +29,14 @@ typedef enum {
TS_CHARGING
} TSState;
typedef enum {
TS_ERRORKIND_NONE = 0x00,
TS_ERRORKIND_SLAVE_TIMEOUT = 0x01,
TS_ERRORKIND_SLAVE_PANIC = 0x02,
TS_ERRORKIND_SHUNT_TIMEOUT = 0x03,
TS_ERRORKIND_SHUNT_OVERCURRENT = 0x04,
TS_ERRORKIND_SHUNT_OVERTEMP = 0x05
} TSErrorKind;
#define TS_ERROR_SOURCE_SHUNT (1 << 0)
#define TS_ERROR_SOURCE_SLAVES (1 << 1)