refactor: move more options to config file

This commit is contained in:
Kilian Bracher 2025-03-27 19:01:45 +01:00
parent ae54db62e0
commit 4dda2084a3
4 changed files with 8 additions and 11 deletions

View File

@ -4,13 +4,17 @@
#include "main.h"
#define N_BMS 1
#define N_CELLS 16
#define ADBMS_MAX_CHIP_TEMP 110 // max temperature of ADBMS6830B (not battery) in C
#define ADBMS_SPI_TIMEOUT 50 // Timeout in ms
[[maybe_unused]] static inline void mcuAdbmsCSLow() {
[[maybe_unused, gnu::always_inline]]
static inline void mcuAdbmsCSLow() {
HAL_GPIO_WritePin(AMS_CS_GPIO_Port, AMS_CS_Pin, GPIO_PIN_RESET);
}
[[maybe_unused]] static inline void mcuAdbmsCSHigh() {
[[maybe_unused, gnu::always_inline]]
static inline void mcuAdbmsCSHigh() {
HAL_GPIO_WritePin(AMS_CS_GPIO_Port, AMS_CS_Pin, GPIO_PIN_SET);
}

View File

@ -30,6 +30,4 @@ extern Cell_Module modules[N_BMS];
extern uint32_t balancedCells;
extern bool BalancingActive;
extern uint8_t numberofCells;
#endif /* INC_AMS_HIGHLEVEL_H_ */

View File

@ -12,8 +12,6 @@
#include "swo_log.h"
#include <stddef.h>
extern uint8_t numberofCells;
static const char* const HAL_Statuses[] = {"HAL_OK", "HAL_ERROR", "HAL_BUSY", "HAL_TIMEOUT"};
#define CHECK_RETURN(x) \
@ -275,8 +273,7 @@ HAL_StatusTypeDef amsCheckUnderOverVoltage(Cell_Module (*module)[N_BMS]) {
(*module)[i].overVoltage = 0;
(*module)[i].underVoltage = 0;
for (size_t j = 0; j < numberofCells;
j++) { // ov/uv flags are 1-bit flags for each cell C0UV, C0OV, C1UV, C1OV, ...
for (size_t j = 0; j < N_CELLS; j++) { // ov/uv flags are 1-bit flags for each cell C0UV, C0OV, C1UV, C1OV, ...
(*module)[i].underVoltage |= (ov_uv_data >> (j * 2)) & 0x01;
(*module)[i].overVoltage |= (ov_uv_data >> (j * 2 + 1)) & 0x01;
}

View File

@ -18,8 +18,6 @@ Cell_Module modules[N_BMS] = {};
uint32_t balancedCells = 0;
bool balancingActive = false;
uint8_t numberofCells = 16;
uint8_t packetChecksumFails = 0;
#define MAX_PACKET_CHECKSUM_FAILS 5
@ -37,7 +35,7 @@ static constexpr ADBMS_DetailedStatus NO_ERROR = {ADBMS_NO_ERROR};
ADBMS_DetailedStatus AMS_Init(SPI_HandleTypeDef* hspi) {
debug_log(LOG_LEVEL_INFO, "ADBMS6830B HAL - configured for %d controllers and %d cells per controller...", N_BMS,
numberofCells);
N_CELLS);
if (initAMS(hspi) != HAL_OK) {
debug_log(LOG_LEVEL_ERROR, "ADBMS6830B HAL - initialization failed");
return (ADBMS_DetailedStatus){ADBMS_INTERNAL_BMS_FAULT, -1};