Low level BMS driver specific to ADBMS6380 chip.
More...
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "adbms_config.h"
#include "phal_G4/spi/spi.h"
#include "strbuf/strbuf.h"
Go to the source code of this file.
|
| void | ADBMS6380_init (adbms6380_t *dev, SPI_InitConfig_t *spi_ccw, SPI_InitConfig_t *spi_cw) |
| | Initialize the ADBMS6380 device driver instance, SPI buffers, and CS lines.
|
| |
| void | ADBMS6380_wake (adbms6380_t *dev) |
| | Wake the daisy-chained set of ADBMS6380 devices.
|
| |
| void | ADBMS6380_write_rega (adbms6380_t *dev, const adbms6380_rega_config_t *cfg) |
| | Encode and write REGA configuration to all chips in the daisy chain.
|
| |
| bool | ADBMS6380_verify_rega (adbms6380_t *dev) |
| | Discover the active CCW/CW split point, read back REGA from all chips, and compare with cached configuration.
|
| |
| void | ADBMS6380_write_regb (adbms6380_t *dev, const adbms6380_regb_config_t *cfg) |
| | Encode and write REGB configuration (OV/UV thresholds + discharge bits) to all chips.
|
| |
| bool | ADBMS6380_verify_regb (adbms6380_t *dev) |
| | Read back REGB from all chips and compare with cached configuration.
|
| |
| bool | ADBMS6380_has_rega_mismatch (const adbms6380_t *dev) |
| | Check whether any chip in the chain has a REGA mismatch error.
|
| |
| bool | ADBMS6380_has_regb_mismatch (const adbms6380_t *dev) |
| | Check whether any chip in the chain has a REGB mismatch error.
|
| |
| void | ADBMS6380_start_adcv (adbms6380_t *dev, const adbms6380_adcv_config_t *cfg) |
| | Issue the ADCV command to start cell voltage conversions across all chips.
|
| |
| void | ADBMS6380_start_adax (adbms6380_t *dev, const adbms6380_adax_config_t *cfg) |
| | Issue the ADAX command to start GPIO/aux voltage conversions across all chips.
|
| |
| void | ADBMS6380_read_cell_voltages (adbms6380_t *dev) |
| | Read all cell voltages from each chip.
|
| |
| void | ADBMS6380_read_gpio_voltages (adbms6380_t *dev) |
| | Read all GPIO/aux voltages from each chip.
|
| |
| void | ADBMS6380_read_temperatures (adbms6380_t *dev, const adbms6380_adax_config_t *cfg) |
| | Read all GPIO voltages, start the next ADAX conversion, and convert to cell and onboard temperatures.
|
| |
Low level BMS driver specific to ADBMS6380 chip.
- Author
- Millan Kumar (kumar.nosp@m.798@.nosp@m.purdu.nosp@m.e.ed.nosp@m.u)
◆ ADBMS6380_has_rega_mismatch()
| bool ADBMS6380_has_rega_mismatch |
( |
const adbms6380_t * | dev | ) |
|
Check whether any chip in the chain has a REGA mismatch error.
- Parameters
-
| dev | Non-null pointer to device state. |
- Returns
- true if any chip has adbms6380_chip_t::err_rega_mismatch set.
◆ ADBMS6380_has_regb_mismatch()
| bool ADBMS6380_has_regb_mismatch |
( |
const adbms6380_t * | dev | ) |
|
Check whether any chip in the chain has a REGB mismatch error.
- Parameters
-
| dev | Non-null pointer to device state. |
- Returns
- true if any chip has adbms6380_chip_t::err_regb_mismatch set.
◆ ADBMS6380_init()
Initialize the ADBMS6380 device driver instance, SPI buffers, and CS lines.
Deasserts both CS lines high, initializes the internal TX strbuf, and clears discharge and error flags across all chips.
- Parameters
-
| dev | Non-null pointer to device state to initialize. |
| spi_ccw | Non-null CCW SPI configuration. |
| spi_cw | Non-null CW SPI configuration. |
◆ ADBMS6380_read_cell_voltages()
Read all cell voltages from each chip.
Converts raw values to volts and populates each chip's cell_voltages array. If any command fails with a PEC error after retries, the successfully read cell voltages are still updated and the corresponding flag in err_cell_voltage_pecs is set.
- Parameters
-
| dev | Non-null pointer to device state. |
◆ ADBMS6380_read_gpio_voltages()
Read all GPIO/aux voltages from each chip.
Converts raw values to volts and populates each chip's gpio_voltages array. If any command fails with a PEC error after retries, the successfully read GPIO voltages are still updated and the corresponding flag in err_gpio_voltage_pecs is set.
- Parameters
-
| dev | Non-null pointer to device state. |
◆ ADBMS6380_read_temperatures()
Read all GPIO voltages, start the next ADAX conversion, and convert to cell and onboard temperatures.
Populates each chip's gpio_voltages, cell_temps, and board_temp fields.
- Parameters
-
| dev | Non-null pointer to device state. |
| cfg | Non-null pointer to ADAX command parameters. |
◆ ADBMS6380_start_adax()
Issue the ADAX command to start GPIO/aux voltage conversions across all chips.
- Parameters
-
| dev | Non-null pointer to device state. |
| cfg | Non-null pointer to ADAX command parameters. |
◆ ADBMS6380_start_adcv()
Issue the ADCV command to start cell voltage conversions across all chips.
- Parameters
-
| dev | Non-null pointer to device state. |
| cfg | Non-null pointer to ADCV command parameters. |
◆ ADBMS6380_verify_rega()
Discover the active CCW/CW split point, read back REGA from all chips, and compare with cached configuration.
Sets per-chip mismatch or PEC flags when the read-back fails or does not match the cached REGA data.
- Parameters
-
| dev | Non-null pointer to device state. |
- Returns
- false on PEC error or when there is a mismatch; true otherwise.
◆ ADBMS6380_verify_regb()
Read back REGB from all chips and compare with cached configuration.
Sets per-chip mismatch or PEC flags when the read-back fails or does not match the cached REGB data.
- Parameters
-
| dev | Non-null pointer to device state. |
- Returns
- false on PEC error or when there is a mismatch; true otherwise.
◆ ADBMS6380_wake()
Wake the daisy-chained set of ADBMS6380 devices.
Toggles CS with blocking delay to bring each chip out of sleep/idle. If the harness break is already known, wakes only the reachable chips in each direction.
- Parameters
-
| dev | Non-null pointer to device state. |
◆ ADBMS6380_write_rega()
Encode and write REGA configuration to all chips in the daisy chain.
- Parameters
-
| dev | Non-null pointer to device state. |
| cfg | Non-null pointer to REGA configuration parameters. |
◆ ADBMS6380_write_regb()
Encode and write REGB configuration (OV/UV thresholds + discharge bits) to all chips.
- Parameters
-
| dev | Non-null pointer to device state. |
| cfg | Non-null pointer to REGB configuration parameters. |
◆ ADBMS6380_ADAX_ALL_CONV_TIME_MS
| uint32_t ADBMS6380_ADAX_ALL_CONV_TIME_MS = 20U |
|
staticconstexpr |
◆ ADBMS6380_CELL_COUNT
| size_t ADBMS6380_CELL_COUNT = 16U |
|
staticconstexpr |
◆ ADBMS6380_COMMAND_PKT_SIZE
◆ ADBMS6380_COMMAND_RAW_SIZE
| size_t ADBMS6380_COMMAND_RAW_SIZE = 2U |
|
staticconstexpr |
◆ ADBMS6380_GPIO_COUNT
| size_t ADBMS6380_GPIO_COUNT = 10U |
|
staticconstexpr |
◆ ADBMS6380_NO_BREAK_INDEX
| uint8_t ADBMS6380_NO_BREAK_INDEX = 0x0FU |
|
staticconstexpr |
◆ ADBMS6380_PEC_SIZE
| size_t ADBMS6380_PEC_SIZE = 2U |
|
staticconstexpr |
◆ ADBMS6380_RDAUX_CMD_COUNT
| size_t ADBMS6380_RDAUX_CMD_COUNT = 4U |
|
staticconstexpr |
◆ ADBMS6380_RDCV_CMD_COUNT
| size_t ADBMS6380_RDCV_CMD_COUNT = 6U |
|
staticconstexpr |
◆ ADBMS6380_SINGLE_DATA_PKT_SIZE
| size_t ADBMS6380_SINGLE_DATA_PKT_SIZE |
|
staticconstexpr |
Initial value:=
static constexpr size_t ADBMS6380_SINGLE_DATA_RAW_SIZE
Definition adbms6380.h:38
static constexpr size_t ADBMS6380_PEC_SIZE
Definition adbms6380.h:32
◆ ADBMS6380_SINGLE_DATA_RAW_SIZE
| size_t ADBMS6380_SINGLE_DATA_RAW_SIZE = 6U |
|
staticconstexpr |
◆ ADBMS6380_SPI_RX_BUFFER_SIZE
| size_t ADBMS6380_SPI_RX_BUFFER_SIZE |
|
staticconstexpr |
Initial value:=
static constexpr size_t ADBMS6380_SINGLE_DATA_PKT_SIZE
Definition adbms6380.h:40
static constexpr size_t ADBMS_CHIP_COUNT
Definition adbms_config.h:20
◆ ADBMS6380_SPI_TX_BUFFER_SIZE
| size_t ADBMS6380_SPI_TX_BUFFER_SIZE |
|
staticconstexpr |
Initial value:=
static constexpr size_t ADBMS6380_COMMAND_PKT_SIZE
Definition adbms6380.h:36