|
foxBMS-UnitTests
1.0.0
The foxBMS Unit Tests API Documentation
|
Go to the documentation of this file.
57 #include "HL_system.h"
68 #define N775_MAX_SUPPORTED_CELLS (12u)
73 #define N775_SAVELASTSTATES() \
74 n775_state.lastState = n775_state.state; \
75 n775_state.lastSubState = n775_state.subState
80 #pragma SET_DATA_SECTION(".sharedRAM")
83 #pragma SET_DATA_SECTION()
115 .errRequestCounter = 0,
120 .txTransmitOngoing =
false,
121 .rxTransmitOngoing =
false,
123 .remainingMessages = 0u,
129 static void N775_WakeUp(uint16_t daisyChainAddress, uint16_t deviceAddress, uint16_t registerAddress);
130 static void N775_Write(uint16_t daisyChainAddress, uint16_t deviceAddress, uint16_t registerAddress, uint16_t data);
132 uint16_t daisyChainAddress,
133 uint16_t deviceAddress,
134 uint16_t registerAddress,
135 uint16_t totalNumberOfRequestedRegister);
164 uint16_t local_remainder = remainder;
166 local_remainder ^= item;
168 for (i = 0; i < 16; i++) {
172 if ((local_remainder & 0x8000u) > 0u) {
173 local_remainder = (local_remainder << 1u) ^ ((0x9eb2u << 1u) + 0x1u);
175 local_remainder = (local_remainder << 1u);
179 return (local_remainder);
192 uint16_t remainder = 0;
215 for (uint8_t stringNumber = 0u; stringNumber <
BS_NR_OF_STRINGS; stringNumber++) {
355 bool n775_goToTrigger =
true;
362 n775_goToTrigger =
false;
369 n775_goToTrigger =
false;
378 n775_goToTrigger =
false;
387 n775_goToTrigger =
false;
394 if (n775_goToTrigger ==
true) {
446 MC33775_SYS_COM_CFG_OFFSET,
448 (MC33775_SYS_COM_CFG_BUSFW_ENABLED_ENUM_VAL << MC33775_SYS_COM_CFG_BUSFW_POS));
458 MC33775_SYS_COM_CFG_OFFSET,
460 (MC33775_SYS_COM_CFG_BUSFW_ENABLED_ENUM_VAL << MC33775_SYS_COM_CFG_BUSFW_POS));
563 buffer[0] = message->
head;
567 buffer[i + 2u] = message->
data[i];
569 buffer[i + 3u] = message->
crc;
584 static void N775_WakeUp(uint16_t daisyChainAddress, uint16_t deviceAddress, uint16_t registerAddress) {
585 uint16_t messageCounter = 0u;
643 static void N775_Write(uint16_t daisyChainAddress, uint16_t deviceAddress, uint16_t registerAddress, uint16_t data) {
644 uint16_t messageCounter = 0u;
706 uint16_t daisyChainAddress,
707 uint16_t deviceAddress,
708 uint16_t registerAddress,
709 uint16_t totalNumberOfRequestedRegister) {
710 uint16_t messageCounter = 0u;
711 uint16_t dataLen = 0u;
712 uint16_t readParameters = 0u;
739 readParameters = (0u << 11u) +
742 ((totalNumberOfRequestedRegister - 1u) << 0);
uint16_t nrModuleMinimumTemperature[BS_NR_OF_STRINGS]
Implementation of the tasks used by the system, headers.
#define N775_TIME_AFTER_ENUMERATION_MS
N775_STATE_REQUEST_e N775_TransferStateRequest()
transfers the current state request to the state machine.
#define BS_NR_OF_BAT_CELLS
static DATA_BLOCK_BALANCING_CONTROL_s n775_balancingControl
N775_STATE_REQUEST_e stateReq
@ N775_STATEMACH_INITIALIZED
void TEST_N775_SetFirstMeasurementCycleFinished(N775_STATE_s *n775_state)
static void N775_Initialize_Database(void)
in the database, initializes the fields related to the N775 driver.
static void N775_StateTransition(N775_STATEMACH_e state, uint8_t substate, uint16_t timer_ms)
function for setting N775_Trigger state transitions
uint16_t nrSensorMinimumTemperature[BS_NR_OF_STRINGS]
#define BS_NR_OF_TEMP_SENSORS
int16_t maximumTemperature_ddegC[BS_NR_OF_STRINGS]
uint16_t nrModuleMaximumTemperature[BS_NR_OF_STRINGS]
static void N775_Read(uint16_t daisyChainAddress, uint16_t deviceAddress, uint16_t registerAddress, uint16_t totalNumberOfRequestedRegister)
sends a read command to the daisy-chain.
@ DATA_BLOCK_ID_CELL_TEMPERATURE_BASE
DATA_BLOCK_HEADER_s header
uint16_t nrModuleMinimumCellVoltage[BS_NR_OF_STRINGS]
uint16_t nrSensorMaximumTemperature[BS_NR_OF_STRINGS]
uint16_t n775_RXbuffer[N775_MAX_N_BYTES_FOR_DATA_RECEPTION]
uint16_t nrCellMinimumCellVoltage[BS_NR_OF_STRINGS]
@ N775_STATE_INIT_REQUEST
bool MIC_IsRxTransmitOngoing(void)
gets the SPI transmit status.
N775_RETURN_TYPE_e N775_SetStateRequest(N775_STATE_REQUEST_e statereq)
sets the current state request of the state variable n775_state.
#define DATA_WRITE_DATA(...)
Headers for the driver for the general DMA module of monitoring ICs.
static DATA_BLOCK_CELL_TEMPERATURE_s n775_cellTemperature
uint8_t n775_enumerateAddress
STD_RETURN_TYPE_e firstMeasurementMade
uint8_t N775_CheckReEntrance(void)
re-entrance check of N775 state machine trigger function
bool MIC_IsTxTransmitOngoing(void)
gets the SPI transmit status.
#define N775_TIME_DAISYCHAIN_WAKEUP_MS
uint16_t remainingMessages
DATA_BLOCK_HEADER_s header
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
@ N775_STATEMACH_UNINITIALIZED
void OS_ExitTaskCritical(void)
Exit Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.
DATA_BLOCK_HEADER_s header
@ DATA_BLOCK_ID_CELL_VOLTAGE_BASE
static void N775_SetFirstMeasurementCycleFinished(N775_STATE_s *n775_state)
sets the measurement initialization status.
@ N775_ENTRY_UNINITIALIZED
static N775_RETURN_TYPE_e N775_CheckStateRequest(N775_STATE_REQUEST_e statereq)
checks the state requests that are made.
static DATA_BLOCK_MIN_MAX_s n775_minMax
void OS_EnterTaskCritical(void)
Enter Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.
N775_STATEMACH_e N775_GetState(void)
gets the current state.
uint32_t errRequestCounter
int16_t cellVoltage_mV[BS_NR_OF_STRINGS][BS_NR_OF_BAT_CELLS]
uint16_t nrModuleMaximumCellVoltage[BS_NR_OF_STRINGS]
@ DATA_BLOCK_ID_BALANCING_CONTROL
uint8_t balancingState[BS_NR_OF_STRINGS][BS_NR_OF_BAT_CELLS]
int16_t maximumCellVoltage_mV[BS_NR_OF_STRINGS]
N775_MESSAGE_s n775_receivedData
bool N775_IsFirstMeasurementCycleFinished(void)
gets the measurement initialization status.
#define N775_SAVELASTSTATES()
static void N775_CopyStructToTxBuffer(N775_MESSAGE_s *message, uint16_t *buffer)
sends a write command to the daisy-chain.
static void N775_WakeUp(uint16_t daisyChainAddress, uint16_t deviceAddress, uint16_t registerAddress)
sends a wake-up command to the daisy-chain.
@ N775_STATEMACH_BALANCECONTROL
@ N775_STATEMACH_STARTMEAS
int16_t minimumTemperature_ddegC[BS_NR_OF_STRINGS]
@ N775_STATEMACH_ENUMERATE
@ N775_STATEMACH_READVOLTAGE
STD_RETURN_TYPE_e checkSpiFlag
uint16_t n775_TXbuffer[N775_TX_MESSAGE_LENGTH]
uint16_t n775_CrcAddItem(uint16_t remainder, uint16_t item)
Called to calculate the CRC of a message. NXP function.
uint16_t n775_CalcCrc(const N775_MESSAGE_s *msg)
Calculate the CRC of a message. NXP function.
#define N775_MAX_N_BYTES_FOR_DATA_RECEPTION
N775_STATE_REQUEST_e N775_GetStateRequest(void)
gets the current state request.
Headers for the driver for the MC33775A monitoring chip.
uint16_t nrCellMaximumCellVoltage[BS_NR_OF_STRINGS]
int16_t minimumCellVoltage_mV[BS_NR_OF_STRINGS]
static DATA_BLOCK_CELL_VOLTAGE_s n775_cellVoltage
#define N775_SendData(txbuf, rxbuf, length)
#define FAS_TRAP
Define that evaluates to essential boolean false thus tripping an assert.
#define N775_TX_MESSAGE_LENGTH
N775_MESSAGE_s n775_sentData
static void N775_Write(uint16_t daisyChainAddress, uint16_t deviceAddress, uint16_t registerAddress, uint16_t data)
sends a write command to the daisy-chain.
DATA_BLOCK_HEADER_s header
#define N775_STATEMACH_SHORTTIME
@ N775_STATEMACH_INITIALIZATION
uint8_t TEST_N775_CheckReEntrance(void)
@ N775_ALREADY_INITIALIZED
int16_t cellTemperature_ddegC[BS_NR_OF_STRINGS][BS_NR_OF_TEMP_SENSORS]
void N775_Trigger(void)
trigger function for the N775 driver state machine.