Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
de184afd03
|
@ -12,7 +12,6 @@
|
|||||||
#define CAN_ID_AMS_IN 0x00B
|
#define CAN_ID_AMS_IN 0x00B
|
||||||
#define CAN_ID_AMS_ERROR 0x00C
|
#define CAN_ID_AMS_ERROR 0x00C
|
||||||
#define CAN_ID_SLAVE_STATUS_BASE 0x080
|
#define CAN_ID_SLAVE_STATUS_BASE 0x080
|
||||||
#define CAN_ID_SLAVE_STATUS_FUCKED 0x0A0
|
|
||||||
#define CAN_ID_SLAVE_LOG 0x4F4
|
#define CAN_ID_SLAVE_LOG 0x4F4
|
||||||
#define CAN_ID_SHUNT_BASE 0x520
|
#define CAN_ID_SHUNT_BASE 0x520
|
||||||
#define CAN_ID_SHUNT_CURRENT 0x521
|
#define CAN_ID_SHUNT_CURRENT 0x521
|
||||||
|
|||||||
@ -5,10 +5,9 @@
|
|||||||
|
|
||||||
#include "stm32f3xx_hal.h"
|
#include "stm32f3xx_hal.h"
|
||||||
|
|
||||||
#define SHUNT_TIMEOUT 300 // ms
|
#define SHUNT_TIMEOUT 300 // ms
|
||||||
#define SHUNT_THRESH_OVERCURRENT 300000 // mA
|
#define SHUNT_THRESH_OVERCURRENT 300000 // mA
|
||||||
#define SHUNT_THRESH_OVERCURRENT_REGEN 50000 // mA
|
#define SHUNT_THRESH_OVERTEMP 1000 // 1/10 °C
|
||||||
#define SHUNT_THRESH_OVERTEMP 1000 // 1/10 °C
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t current; // mA
|
int32_t current; // mA
|
||||||
|
|||||||
@ -18,7 +18,6 @@ void can_init(CAN_HandleTypeDef *handle) {
|
|||||||
ftcan_add_filter(CAN_ID_AMS_IN, 0xFFF);
|
ftcan_add_filter(CAN_ID_AMS_IN, 0xFFF);
|
||||||
ftcan_add_filter(CAN_ID_SLAVE_PANIC, 0xFFF);
|
ftcan_add_filter(CAN_ID_SLAVE_PANIC, 0xFFF);
|
||||||
ftcan_add_filter(CAN_ID_SLAVE_STATUS_BASE, 0xFF0);
|
ftcan_add_filter(CAN_ID_SLAVE_STATUS_BASE, 0xFF0);
|
||||||
ftcan_add_filter(CAN_ID_SLAVE_STATUS_FUCKED, 0xFFF);
|
|
||||||
ftcan_add_filter(CAN_ID_SLAVE_LOG, 0xFFF);
|
ftcan_add_filter(CAN_ID_SLAVE_LOG, 0xFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,8 +50,6 @@ void ftcan_msg_received_cb(uint16_t id, size_t datalen, const uint8_t *data) {
|
|||||||
} else if ((id & 0xFF0) == CAN_ID_SLAVE_STATUS_BASE) {
|
} else if ((id & 0xFF0) == CAN_ID_SLAVE_STATUS_BASE) {
|
||||||
slaves_handle_status(data);
|
slaves_handle_status(data);
|
||||||
return;
|
return;
|
||||||
} else if (id == CAN_ID_SLAVE_STATUS_FUCKED) {
|
|
||||||
slaves_handle_status(data);
|
|
||||||
}
|
}
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case CAN_ID_SLAVE_PANIC:
|
case CAN_ID_SLAVE_PANIC:
|
||||||
|
|||||||
@ -28,10 +28,9 @@ void shunt_check() {
|
|||||||
if (HAL_GetTick() - shunt_data.last_message > SHUNT_TIMEOUT) {
|
if (HAL_GetTick() - shunt_data.last_message > SHUNT_TIMEOUT) {
|
||||||
is_error = 1;
|
is_error = 1;
|
||||||
can_send_error(TS_ERRORKIND_SHUNT_TIMEOUT, 0);
|
can_send_error(TS_ERRORKIND_SHUNT_TIMEOUT, 0);
|
||||||
} else if (shunt_data.current >= SHUNT_THRESH_OVERCURRENT ||
|
} else if (shunt_data.current >= SHUNT_THRESH_OVERCURRENT) {
|
||||||
shunt_data.current <= -SHUNT_THRESH_OVERCURRENT_REGEN) {
|
|
||||||
is_error = 1;
|
is_error = 1;
|
||||||
can_send_error(TS_ERRORKIND_SHUNT_OVERCURRENT, 0);
|
can_send_error(TS_ERRORKIND_SHUNT_OVERTEMP, 0);
|
||||||
} else if (shunt_data.busbartemp >= SHUNT_THRESH_OVERTEMP) {
|
} else if (shunt_data.busbartemp >= SHUNT_THRESH_OVERTEMP) {
|
||||||
is_error = 1;
|
is_error = 1;
|
||||||
can_send_error(TS_ERRORKIND_SHUNT_OVERTEMP, 0);
|
can_send_error(TS_ERRORKIND_SHUNT_OVERTEMP, 0);
|
||||||
|
|||||||
@ -32,7 +32,7 @@ void soc_init() {
|
|||||||
|
|
||||||
void soc_update() {
|
void soc_update() {
|
||||||
uint32_t now = HAL_GetTick();
|
uint32_t now = HAL_GetTick();
|
||||||
if (abs(shunt_data.current) >= SOC_ESTIMATION_NO_CURRENT_THRESH) {
|
if (shunt_data.current >= SOC_ESTIMATION_NO_CURRENT_THRESH) {
|
||||||
last_current_time = now;
|
last_current_time = now;
|
||||||
if (!current_was_flowing) {
|
if (!current_was_flowing) {
|
||||||
soc_before_current = current_soc;
|
soc_before_current = current_soc;
|
||||||
@ -52,7 +52,7 @@ void soc_update() {
|
|||||||
// Otherwise, use the current counter to update SoC
|
// Otherwise, use the current counter to update SoC
|
||||||
float as_delta = shunt_data.current_counter - mAs_before_current;
|
float as_delta = shunt_data.current_counter - mAs_before_current;
|
||||||
float soc_delta = as_delta / SOC_ESTIMATION_BATTERY_CAPACITY * 100;
|
float soc_delta = as_delta / SOC_ESTIMATION_BATTERY_CAPACITY * 100;
|
||||||
current_soc = soc_before_current - soc_delta;
|
current_soc = soc_before_current + soc_delta;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,7 @@ cxxDefinitionsFile:
|
|||||||
asDefinitionsFile:
|
asDefinitionsFile:
|
||||||
|
|
||||||
# Compiler flags
|
# Compiler flags
|
||||||
cFlags: []
|
cFlags: [-Wall, -Wextra, -Wno-unused-parameter]
|
||||||
cxxFlags: []
|
cxxFlags: []
|
||||||
assemblyFlags: []
|
assemblyFlags: []
|
||||||
linkerFlags:
|
linkerFlags:
|
||||||
|
|||||||
@ -43,6 +43,7 @@ Core/Src/main.c \
|
|||||||
Core/Src/shunt_monitoring.c \
|
Core/Src/shunt_monitoring.c \
|
||||||
Core/Src/slave_monitoring.c \
|
Core/Src/slave_monitoring.c \
|
||||||
Core/Src/soc_estimation.c \
|
Core/Src/soc_estimation.c \
|
||||||
|
Core/Src/status_led.c \
|
||||||
Core/Src/stm32f3xx_hal_msp.c \
|
Core/Src/stm32f3xx_hal_msp.c \
|
||||||
Core/Src/stm32f3xx_it.c \
|
Core/Src/stm32f3xx_it.c \
|
||||||
Core/Src/system_stm32f3xx.c \
|
Core/Src/system_stm32f3xx.c \
|
||||||
@ -86,7 +87,7 @@ PREFIX = arm-none-eabi-
|
|||||||
POSTFIX = "
|
POSTFIX = "
|
||||||
# The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
|
# The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
|
||||||
# either it can be added to the PATH environment variable.
|
# either it can be added to the PATH environment variable.
|
||||||
GCC_PATH="/home/jasper/.config/Code/User/globalStorage/bmd.stm32-for-vscode/@xpack-dev-tools/arm-none-eabi-gcc/11.3.1-1.1.2/.content/bin
|
GCC_PATH="/home/kbracher/.vscode-server/data/User/globalStorage/bmd.stm32-for-vscode/@xpack-dev-tools/arm-none-eabi-gcc/12.3.1-1.2.1/.content/bin
|
||||||
ifdef GCC_PATH
|
ifdef GCC_PATH
|
||||||
CXX = $(GCC_PATH)/$(PREFIX)g++$(POSTFIX)
|
CXX = $(GCC_PATH)/$(PREFIX)g++$(POSTFIX)
|
||||||
CC = $(GCC_PATH)/$(PREFIX)gcc$(POSTFIX)
|
CC = $(GCC_PATH)/$(PREFIX)gcc$(POSTFIX)
|
||||||
@ -162,7 +163,7 @@ CXXFLAGS += -g -gdwarf -ggdb
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
# Add additional flags
|
# Add additional flags
|
||||||
CFLAGS +=
|
CFLAGS += -Wall -Wextra -Wno-unused-parameter
|
||||||
ASFLAGS +=
|
ASFLAGS +=
|
||||||
CXXFLAGS +=
|
CXXFLAGS +=
|
||||||
|
|
||||||
@ -242,13 +243,13 @@ $(BUILD_DIR):
|
|||||||
# flash
|
# flash
|
||||||
#######################################
|
#######################################
|
||||||
flash: $(BUILD_DIR)/$(TARGET).elf
|
flash: $(BUILD_DIR)/$(TARGET).elf
|
||||||
"/home/jasper/.config/Code/User/globalStorage/bmd.stm32-for-vscode/@xpack-dev-tools/openocd/0.11.0-5.1/.content/bin/openocd" -f ./openocd.cfg -c "program $(BUILD_DIR)/$(TARGET).elf verify reset exit"
|
"/home/kbracher/.vscode-server/data/User/globalStorage/bmd.stm32-for-vscode/@xpack-dev-tools/openocd/0.12.0-2.1/.content/bin/openocd" -f ./openocd.cfg -c "program $(BUILD_DIR)/$(TARGET).elf verify reset exit"
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# erase
|
# erase
|
||||||
#######################################
|
#######################################
|
||||||
erase: $(BUILD_DIR)/$(TARGET).elf
|
erase: $(BUILD_DIR)/$(TARGET).elf
|
||||||
"/home/jasper/.config/Code/User/globalStorage/bmd.stm32-for-vscode/@xpack-dev-tools/openocd/0.11.0-5.1/.content/bin/openocd" -f ./openocd.cfg -c "init; reset halt; stm32f3x mass_erase 0; exit"
|
"/home/kbracher/.vscode-server/data/User/globalStorage/bmd.stm32-for-vscode/@xpack-dev-tools/openocd/0.12.0-2.1/.content/bin/openocd" -f ./openocd.cfg -c "init; reset halt; stm32f3x mass_erase 0; exit"
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# clean up
|
# clean up
|
||||||
|
|||||||
1159
compile_commands.json
Normal file
1159
compile_commands.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user