PER Firmware
Loading...
Searching...
No Matches
adbms.h File Reference

Primary logic and interface for ADBMS battery management system driver. More...

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "adbms6380.h"
#include "adbms_config.h"
#include "phal_G4/spi/spi.h"
Include dependency graph for adbms.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  adbms_bms_t
 Top-level ADBMS driver state, device handle, and pack-level statistics. More...
 

Enumerations

enum  adbms_state_t : uint8_t { ADBMS_STATE_CONNECTING = 0 , ADBMS_STATE_READ_LOOP = 1 , ADBMS_STATE_RECOVERING = 2 , ADBMS_STATE_FATAL = 3 }
 ADBMS driver connection/operation state. More...
 

Functions

void ADBMS_init (adbms_bms_t *bms, SPI_InitConfig_t *spi_ccw, SPI_InitConfig_t *spi_cw)
 Initialize the ADBMS driver instance and underlying ADBMS6380 device chain.
 
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.
 
static float ADBMS_get_cell_voltage (const adbms_bms_t *bms, size_t module_idx, size_t cell_idx)
 Get the latest voltage reading (volts) for a specific module and cell.
 
static float ADBMS_get_cell_temp (const adbms_bms_t *bms, size_t module_idx, size_t cell_therm_idx)
 Get the latest cell thermistor temperature (Celsius) for a specific module and cell thermistor.
 
static float ADBMS_get_board_temp (const adbms_bms_t *bms, size_t module_idx, size_t board_therm_idx)
 Get the latest onboard PCB temperature (Celsius) for a specific module and board thermistor.
 
static bool ADBMS_is_cell_discharging (const adbms_bms_t *bms, size_t module_idx, size_t cell_idx)
 Check whether a specific cell is currently discharging (balancing)
 
static float ADBMS_get_min_voltage (const adbms_bms_t *bms)
 Get the minimum cell voltage across all modules in volts.
 
static float ADBMS_get_max_voltage (const adbms_bms_t *bms)
 Get the maximum cell voltage across all modules in volts.
 
static float ADBMS_get_avg_voltage (const adbms_bms_t *bms)
 Get the average cell voltage across all modules in volts.
 
static float ADBMS_get_sum_voltage (const adbms_bms_t *bms)
 Get the sum of all cell voltages across all modules in volts.
 
static float ADBMS_get_min_cell_temp (const adbms_bms_t *bms)
 Get the minimum cell thermistor temperature across all modules in Celsius.
 
static float ADBMS_get_max_cell_temp (const adbms_bms_t *bms)
 Get the maximum cell thermistor temperature across all modules in Celsius.
 
static float ADBMS_get_avg_cell_temp (const adbms_bms_t *bms)
 Get the average cell thermistor temperature across all modules in Celsius.
 
static float ADBMS_get_min_board_temp (const adbms_bms_t *bms)
 Get the minimum onboard PCB temperature across all chips in Celsius.
 
static float ADBMS_get_max_board_temp (const adbms_bms_t *bms)
 Get the maximum onboard PCB temperature across all chips in Celsius.
 
static float ADBMS_get_avg_board_temp (const adbms_bms_t *bms)
 Get the average onboard PCB temperature across all chips in Celsius.
 
static bool ADBMS_get_cell_voltage_pec_err (const adbms_bms_t *bms, size_t cmd_idx)
 Check whether a cell voltage read command failed PEC.
 
static bool ADBMS_get_gpio_voltage_pec_err (const adbms_bms_t *bms, size_t cmd_idx)
 Check whether a GPIO voltage read command failed PEC.
 
static bool ADBMS_is_break_detected (const adbms_bms_t *bms)
 Check whether an isoSPI harness break is currently detected.
 
static uint8_t ADBMS_get_break_index (const adbms_bms_t *bms)
 Get the broken isoSPI link index (0..ADBMS_CHIP_COUNT or ADBMS6380_NO_BREAK_INDEX when no break)
 
static adbms_state_t ADBMS_get_state (const adbms_bms_t *bms)
 Get the current ADBMS driver state.
 
static bool ADBMS_is_balancing_enabled (const adbms_bms_t *bms)
 Check whether cell discharge balancing is currently enabled.
 
static void ADBMS_set_balancing_enabled (adbms_bms_t *bms, bool enabled)
 Enable or disable cell discharge balancing.
 

Detailed Description

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)

Enumeration Type Documentation

◆ adbms_state_t

enum adbms_state_t : uint8_t

ADBMS driver connection/operation state.

Enumerator
ADBMS_STATE_CONNECTING 
ADBMS_STATE_READ_LOOP 
ADBMS_STATE_RECOVERING 
ADBMS_STATE_FATAL 

Function Documentation

◆ ADBMS_get_avg_board_temp()

static float ADBMS_get_avg_board_temp ( const adbms_bms_t * bms)
inlinestatic

Get the average onboard PCB temperature across all chips in Celsius.

Here is the caller graph for this function:

◆ ADBMS_get_avg_cell_temp()

static float ADBMS_get_avg_cell_temp ( const adbms_bms_t * bms)
inlinestatic

Get the average cell thermistor temperature across all modules in Celsius.

Here is the caller graph for this function:

◆ ADBMS_get_avg_voltage()

static float ADBMS_get_avg_voltage ( const adbms_bms_t * bms)
inlinestatic

Get the average cell voltage across all modules in volts.

Here is the caller graph for this function:

◆ ADBMS_get_board_temp()

static float ADBMS_get_board_temp ( const adbms_bms_t * bms,
size_t module_idx,
size_t board_therm_idx )
inlinestatic

Get the latest onboard PCB temperature (Celsius) for a specific module and board thermistor.

Here is the caller graph for this function:

◆ ADBMS_get_break_index()

static uint8_t ADBMS_get_break_index ( const adbms_bms_t * bms)
inlinestatic

Get the broken isoSPI link index (0..ADBMS_CHIP_COUNT or ADBMS6380_NO_BREAK_INDEX when no break)

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ADBMS_get_cell_temp()

static float ADBMS_get_cell_temp ( const adbms_bms_t * bms,
size_t module_idx,
size_t cell_therm_idx )
inlinestatic

Get the latest cell thermistor temperature (Celsius) for a specific module and cell thermistor.

Here is the caller graph for this function:

◆ ADBMS_get_cell_voltage()

static float ADBMS_get_cell_voltage ( const adbms_bms_t * bms,
size_t module_idx,
size_t cell_idx )
inlinestatic

Get the latest voltage reading (volts) for a specific module and cell.

Here is the caller graph for this function:

◆ ADBMS_get_cell_voltage_pec_err()

static bool ADBMS_get_cell_voltage_pec_err ( const adbms_bms_t * bms,
size_t cmd_idx )
inlinestatic

Check whether a cell voltage read command failed PEC.

Here is the caller graph for this function:

◆ ADBMS_get_gpio_voltage_pec_err()

static bool ADBMS_get_gpio_voltage_pec_err ( const adbms_bms_t * bms,
size_t cmd_idx )
inlinestatic

Check whether a GPIO voltage read command failed PEC.

Here is the caller graph for this function:

◆ ADBMS_get_max_board_temp()

static float ADBMS_get_max_board_temp ( const adbms_bms_t * bms)
inlinestatic

Get the maximum onboard PCB temperature across all chips in Celsius.

Here is the caller graph for this function:

◆ ADBMS_get_max_cell_temp()

static float ADBMS_get_max_cell_temp ( const adbms_bms_t * bms)
inlinestatic

Get the maximum cell thermistor temperature across all modules in Celsius.

Here is the caller graph for this function:

◆ ADBMS_get_max_voltage()

static float ADBMS_get_max_voltage ( const adbms_bms_t * bms)
inlinestatic

Get the maximum cell voltage across all modules in volts.

Here is the caller graph for this function:

◆ ADBMS_get_min_board_temp()

static float ADBMS_get_min_board_temp ( const adbms_bms_t * bms)
inlinestatic

Get the minimum onboard PCB temperature across all chips in Celsius.

Here is the caller graph for this function:

◆ ADBMS_get_min_cell_temp()

static float ADBMS_get_min_cell_temp ( const adbms_bms_t * bms)
inlinestatic

Get the minimum cell thermistor temperature across all modules in Celsius.

Here is the caller graph for this function:

◆ ADBMS_get_min_voltage()

static float ADBMS_get_min_voltage ( const adbms_bms_t * bms)
inlinestatic

Get the minimum cell voltage across all modules in volts.

Here is the caller graph for this function:

◆ ADBMS_get_state()

static adbms_state_t ADBMS_get_state ( const adbms_bms_t * bms)
inlinestatic

Get the current ADBMS driver state.

Here is the caller graph for this function:

◆ ADBMS_get_sum_voltage()

static float ADBMS_get_sum_voltage ( const adbms_bms_t * bms)
inlinestatic

Get the sum of all cell voltages across all modules in volts.

Here is the caller graph for this function:

◆ ADBMS_init()

void ADBMS_init ( adbms_bms_t * bms,
SPI_InitConfig_t * spi_ccw,
SPI_InitConfig_t * spi_cw )

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
bmsNon-null pointer to driver state to initialize.
spi_ccwNon-null CCW SPI configuration.
spi_cwNon-null CW SPI configuration.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ADBMS_is_balancing_enabled()

static bool ADBMS_is_balancing_enabled ( const adbms_bms_t * bms)
inlinestatic

Check whether cell discharge balancing is currently enabled.

Here is the caller graph for this function:

◆ ADBMS_is_break_detected()

static bool ADBMS_is_break_detected ( const adbms_bms_t * bms)
inlinestatic

Check whether an isoSPI harness break is currently detected.

Here is the caller graph for this function:

◆ ADBMS_is_cell_discharging()

static bool ADBMS_is_cell_discharging ( const adbms_bms_t * bms,
size_t module_idx,
size_t cell_idx )
inlinestatic

Check whether a specific cell is currently discharging (balancing)

Here is the caller graph for this function:

◆ 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
bmsNon-null pointer to driver state.
min_voltage_for_balanceMinimum pack voltage required to allow balancing.
min_delta_for_balanceVoltage delta above minimum to start discharging.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ADBMS_set_balancing_enabled()

static void ADBMS_set_balancing_enabled ( adbms_bms_t * bms,
bool enabled )
inlinestatic

Enable or disable cell discharge balancing.

Here is the caller graph for this function: