foxBMS - Unit Tests
1.4.1
The foxBMS Unit Tests API Documentation
|
Driver for the MC33775A monitoring chip. More...
#include "nxp_mc33775a.h"
#include "nxp_mc33775a-ll.h"
#include "HL_gio.h"
#include "HL_system.h"
#include "MC33775A.h"
#include "afe_dma.h"
#include "database.h"
#include "diag.h"
#include "io.h"
#include "mcu.h"
#include "os.h"
#include "spi.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... | |
uint16_t | n775_CrcAddItem (uint16_t remainder, uint16_t item) |
Called to calculate the CRC of a message. More... | |
uint16_t | n775_CalcCrc (const N775_MESSAGE_s *msg) |
Calculate the CRC of a message. More... | |
static void | N775_InitializeDatabase (N775_STATE_s *n775_state) |
in the database, initializes the fields related to the N775 driver. More... | |
void | N775_ResetStringSequence (N775_STATE_s *n775_state) |
reset index in string sequence. More... | |
void | N775_IncrementStringSequence (N775_STATE_s *n775_state) |
updates index in string sequence. More... | |
void | N775_ResetMuxIndex (N775_STATE_s *n775_state) |
resets index in mux sequence. More... | |
void | N775_IncrementMuxIndex (N775_STATE_s *n775_state) |
updates index in mux sequence. More... | |
void | N775_ErrorHandling (N775_STATE_s *n775_state, N775_COMMUNICATION_STATUS_e returnedValue, uint8_t module) |
handles error when doing measurements. More... | |
void | N775_Init (N775_STATE_s *n775_state) |
initializes the N775 driver. More... | |
STD_RETURN_TYPE_e | N775_Enumerate (N775_STATE_s *n775_state) |
enumerates the N775 slaves. More... | |
void | N775_I2cInit (N775_STATE_s *n775_state) |
init I2C for the N775 slaves. More... | |
void | N775_StartMeasurement (N775_STATE_s *n775_state) |
starts the measurement. More... | |
void | N775_CaptureMeasurement (N775_STATE_s *n775_state) |
captures the measurement. More... | |
STD_RETURN_TYPE_e | N775_SetMuxChannel (N775_STATE_s *n775_state) |
sets mux channel. More... | |
void | N775_BalanceSetup (N775_STATE_s *n775_state) |
setups balancing. More... | |
void | N775_BalanceControl (N775_STATE_s *n775_state) |
manages balancing. More... | |
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... | |
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 monitoring chip.
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.
void N775_BalanceControl | ( | N775_STATE_s * | n775_state | ) |
manages balancing.
Reads balancing order from database and balances the corresponding cells.
n775_state | state of the N775A driver |
Definition at line 838 of file nxp_mc33775a.c.
void N775_BalanceSetup | ( | N775_STATE_s * | n775_state | ) |
setups balancing.
Sets all balancing timer to max to allow for software balancing control.
n775_state | state of the N775A driver |
Definition at line 799 of file nxp_mc33775a.c.
uint16_t n775_CalcCrc | ( | const N775_MESSAGE_s * | msg | ) |
Calculate the CRC of a message.
msg |
Definition at line 179 of file nxp_mc33775a.c.
void N775_CaptureMeasurement | ( | N775_STATE_s * | n775_state | ) |
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 541 of file nxp_mc33775a.c.
uint16_t n775_CrcAddItem | ( | uint16_t | remainder, |
uint16_t | item | ||
) |
Called to calculate the CRC of a message.
remainder | |
item |
Definition at line 152 of file nxp_mc33775a.c.
STD_RETURN_TYPE_e N775_Enumerate | ( | N775_STATE_s * | n775_state | ) |
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 416 of file nxp_mc33775a.c.
void N775_ErrorHandling | ( | N775_STATE_s * | n775_state, |
N775_COMMUNICATION_STATUS_e | returnedValue, | ||
uint8_t | module | ||
) |
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 365 of file nxp_mc33775a.c.
void N775_I2cInit | ( | N775_STATE_s * | n775_state | ) |
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 493 of file nxp_mc33775a.c.
void N775_IncrementMuxIndex | ( | N775_STATE_s * | n775_state | ) |
updates index in mux sequence.
n775_state | state of the N775A driver |
Definition at line 345 of file nxp_mc33775a.c.
void N775_IncrementStringSequence | ( | N775_STATE_s * | n775_state | ) |
updates index in string sequence.
n775_state | state of the N775A driver |
Definition at line 322 of file nxp_mc33775a.c.
void N775_Init | ( | N775_STATE_s * | n775_state | ) |
initializes the N775 driver.
This function enumerates the slaves and starts the measurement.
n775_state | state of the N775A driver |
Definition at line 394 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 202 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 869 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 251 of file nxp_mc33775a.c.
void N775_ResetMuxIndex | ( | N775_STATE_s * | n775_state | ) |
resets index in mux sequence.
n775_state | state of the N775A driver |
Definition at line 334 of file nxp_mc33775a.c.
void N775_ResetStringSequence | ( | N775_STATE_s * | n775_state | ) |
reset index in string sequence.
n775_state | state of the N775A driver |
Definition at line 310 of file nxp_mc33775a.c.
|
static |
sets the measurement initialization status.
n775_state | state of the N775A driver |
Definition at line 885 of file nxp_mc33775a.c.
STD_RETURN_TYPE_e N775_SetMuxChannel | ( | N775_STATE_s * | n775_state | ) |
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 692 of file nxp_mc33775a.c.
void N775_StartMeasurement | ( | N775_STATE_s * | n775_state | ) |
starts the measurement.
The MC33775A measures continuously. This function starts the measurement.
n775_state | state of the N775A driver |
Definition at line 513 of file nxp_mc33775a.c.
void N775_waitTime | ( | uint32_t | milliseconds | ) |
waits for a definite amount of time in ms.
This function uses FreeRTOS. It blocks the tasks for the given amount of miliseconds.
milliseconds | time to wait in ms |
Definition at line 904 of file nxp_mc33775a.c.
void TEST_N775_SetFirstMeasurementCycleFinished | ( | N775_STATE_s * | n775_state | ) |
|
static |
local copies of database tables
Definition at line 85 of file nxp_mc33775a.c.
|
static |
local copies of database tables
Definition at line 84 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 82 of file nxp_mc33775a.c.
|
static |
local copies of database tables
Definition at line 81 of file nxp_mc33775a.c.
|
static |
Definition at line 92 of file nxp_mc33775a.c.
|
static |
local copies of database tables
Definition at line 83 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.
N775_STATE_s n775_stateBase |
Variable containing the state machine state for the MC33775A driver.
Definition at line 96 of file nxp_mc33775a.c.
|
static |
Definition at line 91 of file nxp_mc33775a.c.