foxBMS
1.6.0
The foxBMS Battery Management System API Documentation
|
Driver for the MC33775A analog front-end. More...
#include "nxp_mc33775a.h"
#include "nxp_mc33775a-ll.h"
#include "MC33775A.h"
#include "afe.h"
#include "afe_dma.h"
#include "database.h"
#include "fassert.h"
#include "fstd_types.h"
#include "ftask.h"
#include "mcu.h"
#include "os.h"
#include "spi.h"
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
Go to the source code of this file.
Functions | |
static void | N775_BalanceControl (N775_STATE_s *pState) |
manages balancing. More... | |
static void | N775_BalanceSetup (N775_STATE_s *pState) |
setups balancing. More... | |
static void | N775_CaptureMeasurement (N775_STATE_s *pState) |
captures the measurement. More... | |
static STD_RETURN_TYPE_e | N775_Enumerate (N775_STATE_s *pState) |
enumerates the N775 slaves. More... | |
static void | N775_ErrorHandling (N775_STATE_s *pState, N775_COMMUNICATION_STATUS_e returnedValue, uint8_t module) |
handles error when doing measurements. More... | |
static void | N775_IncrementMuxIndex (N775_STATE_s *pState) |
updates index in mux sequence. More... | |
static void | N775_IncrementStringSequence (N775_STATE_s *pState) |
increments index in string sequence. More... | |
static void | N775_Initialize (N775_STATE_s *pState) |
initializes the N775 driver. More... | |
static void | N775_InitializeDatabase (N775_STATE_s *pState) |
in the database, initializes the fields related to the N775 driver. More... | |
static void | N775_InitializeI2c (N775_STATE_s *pState) |
init I2C for the N775 slaves. More... | |
static void | N775_ResetStringSequence (N775_STATE_s *pState) |
reset index in string sequence. More... | |
static void | N775_ResetMuxIndex (N775_STATE_s *pState) |
resets index in mux sequence. More... | |
static void | N775_SetFirstMeasurementCycleFinished (N775_STATE_s *pState) |
sets the measurement initialization status. More... | |
static STD_RETURN_TYPE_e | N775_SetMuxChannel (N775_STATE_s *pState) |
sets mux channel. More... | |
static void | N775_StartMeasurement (N775_STATE_s *pState) |
starts the measurement. More... | |
static STD_RETURN_TYPE_e | N775_TransmitI2c (N775_STATE_s *pState) |
transmit over I2C on NXP slave. More... | |
static void | N775_Wait (uint32_t milliseconds) |
waits for a definite amount of time in ms. More... | |
STD_RETURN_TYPE_e | N775_I2cRead (uint8_t module, uint8_t deviceAddress, uint8_t *pData, uint8_t dataLength) |
trigger a read on the I2C bus of the slave. More... | |
STD_RETURN_TYPE_e | N775_I2cWrite (uint8_t module, uint8_t deviceAddress, uint8_t *pData, uint8_t dataLength) |
trigger a write on the I2C bus of the slave. More... | |
STD_RETURN_TYPE_e | N775_I2cWriteRead (uint8_t module, uint8_t deviceAddress, uint8_t *pDataWrite, uint8_t writeDataLength, uint8_t *pDataRead, uint8_t readDataLength) |
trigger a read on the I2C bus of the slave, first write address of register to read. More... | |
bool | N775_IsFirstMeasurementCycleFinished (N775_STATE_s *pState) |
gets the measurement initialization status. More... | |
void | N775_Measure (N775_STATE_s *pState) |
trigger function for the N775 driver state machine. More... | |
Variables | |
static N775_SUPPLY_CURRENT_s | n775_supplyCurrent = {0} |
static N775_ERROR_TABLE_s | n775_errorTable = {0} |
N775_STATE_s | n775_stateBase |
static DATA_BLOCK_CELL_VOLTAGE_s | n775_cellVoltage = {.header.uniqueId = DATA_BLOCK_ID_CELL_VOLTAGE_BASE} |
static DATA_BLOCK_CELL_TEMPERATURE_s | n775_cellTemperature = {.header.uniqueId = DATA_BLOCK_ID_CELL_TEMPERATURE_BASE} |
static DATA_BLOCK_MIN_MAX_s | n775_minMax = {.header.uniqueId = DATA_BLOCK_ID_MIN_MAX} |
static DATA_BLOCK_BALANCING_CONTROL_s | n775_balancingControl = {.header.uniqueId = DATA_BLOCK_ID_BALANCING_CONTROL} |
static DATA_BLOCK_ALL_GPIO_VOLTAGES_s | n775_allGpioVoltage = {.header.uniqueId = DATA_BLOCK_ID_ALL_GPIO_VOLTAGES_BASE} |
static DATA_BLOCK_BALANCING_FEEDBACK_s | n775_balancingFeedback |
static DATA_BLOCK_SLAVE_CONTROL_s | n775_slaveControl = {.header.uniqueId = DATA_BLOCK_ID_SLAVE_CONTROL} |
static DATA_BLOCK_OPEN_WIRE_s | n775_openWire = {.header.uniqueId = DATA_BLOCK_ID_OPEN_WIRE_BASE} |
Driver for the MC33775A analog front-end.
SPDX-License-Identifier: BSD-3-Clause
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
We kindly request you to use one or more of the following phrases to refer to foxBMS in your hardware, software, documentation or advertising materials:
Definition in file nxp_mc33775a.c.
|
static |
manages balancing.
Reads balancing order from database and balances the corresponding cells.
pState | state of the NXP MC33775A driver |
Definition at line 251 of file nxp_mc33775a.c.
|
static |
setups balancing.
Sets all balancing timer to max to allow for software balancing control.
pState | state of the NXP MC33775A driver |
Definition at line 274 of file nxp_mc33775a.c.
|
static |
captures the measurement.
The MC33775A measures continuously. This function takes a snapshot on all slaves in the daisy-chain.
pState | state of the NXP MC33775A driver |
Definition at line 302 of file nxp_mc33775a.c.
|
static |
enumerates the N775 slaves.
This function gives the slaves in the daisy-chain an address.
pState | state of the NXP MC33775A driver |
Parse all slaves in the daisy-chain
Definition at line 440 of file nxp_mc33775a.c.
|
static |
handles error when doing measurements.
This function is used in the measurement function. It sets the errors flags in the error table according to the value returned by the communication function.
pState | state of the NXP MC33775A driver |
returnedValue | status of the low-level communication |
module | number of module addressed |
Definition at line 509 of file nxp_mc33775a.c.
STD_RETURN_TYPE_e N775_I2cRead | ( | uint8_t | module, |
uint8_t | deviceAddress, | ||
uint8_t * | pData, | ||
uint8_t | dataLength | ||
) |
trigger a read on the I2C bus of the slave.
module | module number to address in the daisy-chain |
deviceAddress | address of the I2C device addressed |
pData | data read on I2C bus |
dataLength | number of bytes to read |
Definition at line 1096 of file nxp_mc33775a.c.
STD_RETURN_TYPE_e N775_I2cWrite | ( | uint8_t | module, |
uint8_t | deviceAddress, | ||
uint8_t * | pData, | ||
uint8_t | dataLength | ||
) |
trigger a write on the I2C bus of the slave.
module | module number to address in the daisy-chain |
deviceAddress | address of the I2C device addressed |
pData | data to write on I2C bus |
dataLength | number of bytes to write |
Definition at line 1125 of file nxp_mc33775a.c.
STD_RETURN_TYPE_e N775_I2cWriteRead | ( | uint8_t | module, |
uint8_t | deviceAddress, | ||
uint8_t * | pDataWrite, | ||
uint8_t | writeDataLength, | ||
uint8_t * | pDataRead, | ||
uint8_t | readDataLength | ||
) |
trigger a read on the I2C bus of the slave, first write address of register to read.
module | module number to address in the daisy-chain |
deviceAddress | address of the I2C device addressed |
pDataWrite | data written on I2C bus |
writeDataLength | number of bytes to write |
pDataRead | data read on I2C bus |
readDataLength | number of bytes to read |
Definition at line 1154 of file nxp_mc33775a.c.
|
static |
updates index in mux sequence.
pState | state of the NXP MC33775A driver |
Definition at line 532 of file nxp_mc33775a.c.
|
static |
increments index in string sequence.
pState | state of the NXP MC33775A driver |
Definition at line 543 of file nxp_mc33775a.c.
|
static |
initializes the N775 driver.
This function enumerates the slaves and starts the measurement.
pState | state of the NXP MC33775A driver |
Definition at line 551 of file nxp_mc33775a.c.
|
static |
in the database, initializes the fields related to the N775 driver.
This function loops through all the N775-related data fields in the database and sets them to 0. It shall be called in the initialization or re-initialization routine of the N775 driver.
pState | state of the NXP MC33775A driver |
Definition at line 565 of file nxp_mc33775a.c.
|
static |
init I2C for the N775 slaves.
This function makes slaves ready for I2C transactions with on-slave devices.
pState | state of the NXP MC33775A driver |
Definition at line 620 of file nxp_mc33775a.c.
bool N775_IsFirstMeasurementCycleFinished | ( | N775_STATE_s * | pState | ) |
gets the measurement initialization status.
pState | state of the N775A driver |
Definition at line 1196 of file nxp_mc33775a.c.
void N775_Measure | ( | N775_STATE_s * | pState | ) |
trigger function for the N775 driver state machine.
This function contains the sequence of events in the N775 state machine. It must be called time-triggered, every 1ms.
pState | state of the N775A driver |
Definition at line 1207 of file nxp_mc33775a.c.
|
static |
resets index in mux sequence.
pState | state of the NXP MC33775A driver |
Definition at line 640 of file nxp_mc33775a.c.
|
static |
reset index in string sequence.
pState | state of the NXP MC33775A driver |
Definition at line 632 of file nxp_mc33775a.c.
|
static |
sets the measurement initialization status.
pState | state of the NXP MC33775A driver |
Definition at line 647 of file nxp_mc33775a.c.
|
static |
sets mux channel.
This function uses I2C to set the mux channel.
pState | state of the NXP MC33775A driver |
Set data to send, contains channel bit (8 channels) 1 means channel active, 0 means channel inactive
Wait util transaction ends, test on last device in daisy-chain So device address = number of modules
Get I2C read data, on last device in daisy-chain Use result to set error state for all slaves to avoid reading all slaves in daisy-chain.
Definition at line 655 of file nxp_mc33775a.c.
|
static |
starts the measurement.
The MC33775A measures continuously. This function starts the measurement.
pState | state of the NXP MC33775A driver |
Definition at line 755 of file nxp_mc33775a.c.
|
static |
transmit over I2C on NXP slave.
pState | state of the NXP MC33775A driver |
Definition at line 774 of file nxp_mc33775a.c.
|
static |
waits for a definite amount of time in ms.
This function uses FreeRTOS. It blocks the tasks for the given amount of milliseconds.
milliseconds | time to wait in ms |
Definition at line 1088 of file nxp_mc33775a.c.
|
static |
local copies of database tables
Definition at line 89 of file nxp_mc33775a.c.
|
static |
local copies of database tables
Definition at line 88 of file nxp_mc33775a.c.
|
static |
local copies of database tables
Definition at line 90 of file nxp_mc33775a.c.
|
static |
local copies of database tables
Definition at line 86 of file nxp_mc33775a.c.
|
static |
local copies of database tables
Definition at line 85 of file nxp_mc33775a.c.
|
static |
Definition at line 96 of file nxp_mc33775a.c.
|
static |
local copies of database tables
Definition at line 87 of file nxp_mc33775a.c.
|
static |
local copies of database tables
Definition at line 93 of file nxp_mc33775a.c.
|
static |
local copies of database tables
Definition at line 92 of file nxp_mc33775a.c.
N775_STATE_s n775_stateBase |
state of the state machine for the MC33775A driver
Definition at line 100 of file nxp_mc33775a.c.
|
static |
Definition at line 95 of file nxp_mc33775a.c.