ams-master-23/Core/Inc/shunt_monitoring.h

33 lines
716 B
C
Raw Normal View History

2023-03-12 21:06:23 +01:00
#ifndef INC_SHUNT_MONITORING_H
#define INC_SHUNT_MONITORING_H
#include <stdint.h>
2024-04-23 17:37:17 +02:00
#include "stm32h7xx_hal.h"
2023-03-12 21:06:23 +01:00
2023-05-31 00:46:49 +02:00
#define SHUNT_TIMEOUT 300 // ms
#define SHUNT_THRESH_OVERCURRENT 300000 // mA
#define SHUNT_THRESH_OVERTEMP 1000 // 1/10 °C
2023-03-12 21:06:23 +01:00
typedef struct {
int32_t current; // mA
int32_t voltage_bat; // mV
int32_t voltage_veh; // mV
int32_t voltage3; // mV
2023-03-12 21:06:23 +01:00
int32_t busbartemp;
int32_t power;
int32_t energy;
float current_counter; // mAs
2023-03-12 21:06:23 +01:00
uint32_t last_message;
uint32_t last_current_message;
2023-03-12 21:06:23 +01:00
} ShuntData;
extern ShuntData shunt_data;
void shunt_init();
void shunt_check();
2023-03-15 18:07:38 +01:00
void shunt_handle_can_msg(uint16_t id, const uint8_t *data);
2023-03-12 21:06:23 +01:00
#endif // INC_SHUNT_MONITORING_H