Primary logic and interface for ADBMS battery management system driver.
More...
#include "adbms.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "adbms6380.h"
#include "phal_G4/spi/spi.h"
#include "rtos/rtos.h"
Primary logic and interface for ADBMS battery management system driver.
- Author
- Millan Kumar (kumar.nosp@m.798@.nosp@m.purdu.nosp@m.e.ed.nosp@m.u)
◆ ADBMS_init()
Initialize the ADBMS driver instance and underlying ADBMS6380 device chain.
Sets the driver state to CONNECTING, clears discharge and error flags, deasserts CS on both SPI ports, and configures the internal SPI TX/RX buffers.
- Parameters
-
| bms | Non-null pointer to driver state to initialize. |
| spi_ccw | Non-null CCW SPI configuration. |
| spi_cw | Non-null CW SPI configuration. |
◆ ADBMS_periodic()
| void ADBMS_periodic |
( |
adbms_bms_t * | bms, |
|
|
float | min_voltage_for_balance, |
|
|
float | min_delta_for_balance ) |
Periodic service routine for connection, measurements, and balancing.
- Parameters
-
| bms | Non-null pointer to driver state. |
| min_voltage_for_balance | Minimum pack voltage required to allow balancing. |
| min_delta_for_balance | Voltage delta above minimum to start discharging. |
◆ calculate_balance_cells()
| static void calculate_balance_cells |
( |
adbms_bms_t * | bms, |
|
|
float | min_voltage, |
|
|
float | min_delta ) |
|
static |
◆ clear_discharging()
◆ is_valid_temp()
| static bool is_valid_temp |
( |
float | temp | ) |
|
|
static |
◆ is_valid_voltage()
| static bool is_valid_voltage |
( |
float | voltage | ) |
|
|
static |
◆ read_cells()
◆ read_therms()
◆ ADBMS_ADAX_CFG
Initial value:= {
.ch = 0b00000U,
.ow = false,
.pup = false,
}
◆ ADBMS_ADCV_CFG
Initial value:= {
.ow = 0b00U,
.rd = false,
.cont = true,
.dcp = false,
.rstf = true,
}
◆ ADBMS_CELL_MAX_VALID_V
| float ADBMS_CELL_MAX_VALID_V = 5.0f |
|
staticconstexpr |
◆ ADBMS_CELL_MIN_VALID_V
| float ADBMS_CELL_MIN_VALID_V = 1.0f |
|
staticconstexpr |
◆ ADBMS_CHIP_SLEEP_CYCLE_MS
| uint32_t ADBMS_CHIP_SLEEP_CYCLE_MS = 2'500U |
|
staticconstexpr |
◆ ADBMS_RECOVERY_MAX_ATTEMPTS
| uint8_t ADBMS_RECOVERY_MAX_ATTEMPTS = 4U |
|
staticconstexpr |
◆ ADBMS_REGA_CFG
Initial value:= {
.cth = 0b110U,
.refon = true,
}
◆ ADBMS_REGB_CFG
Initial value:= {
.overvoltage_threshold_v = 4.2f,
.undervoltage_threshold_v = 3.0f,
}
◆ ADBMS_TEMP_MAX_VALID_C
| float ADBMS_TEMP_MAX_VALID_C = 100.0f |
|
staticconstexpr |
◆ ADBMS_TEMP_MIN_VALID_C
| float ADBMS_TEMP_MIN_VALID_C = -20.0f |
|
staticconstexpr |