![]() |
foxBMS - Unit Tests
1.5.1
The foxBMS Unit Tests API Documentation
|
Driver for the MC33775A analog front-end. More...
#include "nxp_mc33775a.h"
#include "nxp_mc33775a-ll.h"
#include "HL_gio.h"
#include "HL_system.h"
#include "MC33775A.h"
#include "afe.h"
#include "afe_dma.h"
#include "database.h"
#include "diag.h"
#include "fassert.h"
#include "fstd_types.h"
#include "ftask.h"
#include "io.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_SetFirstMeasurementCycleFinished (N775_STATE_s *n775_state) |
sets the measurement initialization status. More... | |
static void | N775_InitializeDatabase (N775_STATE_s *n775_state) |
in the database, initializes the fields related to the N775 driver. More... | |
static void | N775_ResetStringSequence (N775_STATE_s *n775_state) |
reset index in string sequence. More... | |
static void | N775_IncrementStringSequence (N775_STATE_s *n775_state) |
updates index in string sequence. More... | |
static void | N775_ResetMuxIndex (N775_STATE_s *n775_state) |
resets index in mux sequence. More... | |
static void | N775_IncrementMuxIndex (N775_STATE_s *n775_state) |
updates index in mux sequence. More... | |
static void | N775_ErrorHandling (N775_STATE_s *n775_state, N775_COMMUNICATION_STATUS_e returnedValue, uint8_t module) |
handles error when doing measurements. More... | |
static void | N775_Init (N775_STATE_s *n775_state) |
initializes the N775 driver. More... | |
static STD_RETURN_TYPE_e | N775_Enumerate (N775_STATE_s *n775_state) |
enumerates the N775 slaves. More... | |
static void | N775_I2cInit (N775_STATE_s *n775_state) |
init I2C for the N775 slaves. More... | |
static void | N775_StartMeasurement (N775_STATE_s *n775_state) |
starts the measurement. More... | |
static void | N775_CaptureMeasurement (N775_STATE_s *n775_state) |
captures the measurement. More... | |
static STD_RETURN_TYPE_e | N775_TransmitI2c (N775_STATE_s *n775_state) |
tranmit over I2C on NXP slave. More... | |
static STD_RETURN_TYPE_e | N775_SetMuxChannel (N775_STATE_s *n775_state) |
sets mux channel. More... | |
static void | N775_BalanceSetup (N775_STATE_s *n775_state) |
setups balancing. More... | |
static void | N775_BalanceControl (N775_STATE_s *n775_state) |
manages balancing. More... | |
static void | N775_waitTime (uint32_t milliseconds) |
waits for a definite amount of time in ms. More... | |
void | N775_Meas (N775_STATE_s *n775_state) |
trigger function for the N775 driver state machine. 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... | |
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... | |
bool | N775_IsFirstMeasurementCycleFinished (N775_STATE_s *n775_state) |
gets the measurement initialization status. More... | |
void | TEST_N775_SetFirstMeasurementCycleFinished (N775_STATE_s *n775_state) |
Variables | |
static N775_SUPPLY_CURRENT_s | n775_supplyCurrent = {0} |
static N775_ERRORTABLE_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.
n775_state | state of the N775A driver |
Definition at line 1232 of file nxp_mc33775a.c.
|
static |
setups balancing.
Sets all balancing timer to max to allow for software balancing control.
n775_state | state of the N775A driver |
Definition at line 1193 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.
n775_state | state of the N775A driver |
Definition at line 614 of file nxp_mc33775a.c.
|
static |
enumerates the N775 slaves.
This function gives the slaves in the daisy-chain an address.
n775_state | state of the N775A driver |
Parse all slaves in the daisy-chain
Definition at line 488 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.
n775_state | state of the N775A driver |
returnedValue | status of the low-level communication |
module | number of module addressed |
Definition at line 435 of file nxp_mc33775a.c.
|
static |
init I2C for the N775 slaves.
This function makes slaves ready for I2C transactions with on-slave devices.
n775_state | state of the N775A driver |
Definition at line 565 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 337 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 266 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 295 of file nxp_mc33775a.c.
|
static |
updates index in mux sequence.
n775_state | state of the N775A driver |
Definition at line 413 of file nxp_mc33775a.c.
|
static |
updates index in string sequence.
n775_state | state of the N775A driver |
Definition at line 386 of file nxp_mc33775a.c.
|
static |
initializes the N775 driver.
This function enumerates the slaves and starts the measurement.
n775_state | state of the N775A driver |
Definition at line 466 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 should be called in the initialization or re-initialization routine of the N775 driver.
n775_state | state of the N775A driver |
Definition at line 159 of file nxp_mc33775a.c.
bool N775_IsFirstMeasurementCycleFinished | ( | N775_STATE_s * | n775_state | ) |
gets the measurement initialization status.
n775_state | state of the N775A driver |
Definition at line 1255 of file nxp_mc33775a.c.
void N775_Meas | ( | N775_STATE_s * | n775_state | ) |
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.
n775_state | state of the N775A driver |
Definition at line 209 of file nxp_mc33775a.c.
|
static |
resets index in mux sequence.
n775_state | state of the N775A driver |
Definition at line 400 of file nxp_mc33775a.c.
|
static |
reset index in string sequence.
n775_state | state of the N775A driver |
Definition at line 372 of file nxp_mc33775a.c.
|
static |
sets the measurement initialization status.
n775_state | state of the N775A driver |
Definition at line 1272 of file nxp_mc33775a.c.
|
static |
sets mux channel.
This function uses I2C to set the mux channel.
n775_state | state of the N775A 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 1085 of file nxp_mc33775a.c.
|
static |
starts the measurement.
The MC33775A measures continuously. This function starts the measurement.
n775_state | state of the N775A driver |
Definition at line 586 of file nxp_mc33775a.c.
|
static |
tranmit over I2C on NXP slave.
n775_state | state of the N775A driver |
Definition at line 763 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 1293 of file nxp_mc33775a.c.
void TEST_N775_SetFirstMeasurementCycleFinished | ( | N775_STATE_s * | n775_state | ) |
|
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.
|
static |
local copies of database tables
Definition at line 94 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 89 of file nxp_mc33775a.c.
|
static |
Definition at line 100 of file nxp_mc33775a.c.
|
static |
local copies of database tables
Definition at line 91 of file nxp_mc33775a.c.
|
static |
local copies of database tables
Definition at line 97 of file nxp_mc33775a.c.
|
static |
local copies of database tables
Definition at line 96 of file nxp_mc33775a.c.
N775_STATE_s n775_stateBase |
Variable containing the state machine state for the MC33775A driver.
Definition at line 104 of file nxp_mc33775a.c.
|
static |
Definition at line 99 of file nxp_mc33775a.c.