|
foxBMS-UnitTests
1.0.0
The foxBMS Unit Tests API Documentation
|
Go to the documentation of this file.
60 #include "HL_system.h"
83 .configValues.communicationMode =
fs8xSPI,
84 .configValues.i2cAddressOtp = 0,
87 .fin.pGIOport = &(systemREG1->SYSPC4),
120 uint32_t registerAddress,
121 uint32_t registerValue);
146 uint8_t registerAddress,
147 uint16_t registerValue);
161 uint8_t registerAddress,
162 uint16_t registerValue);
177 uint8_t registerAddress,
179 uint16_t registerValue);
207 if (registerValue != expectedRegisterValue) {
216 uint32_t registerAddress,
217 uint32_t registerValue) {
221 if (isFailSafe ==
true) {
223 switch (registerAddress) {
294 switch (registerAddress) {
380 uint8_t registerAddress,
381 uint16_t registerValue) {
398 uint8_t registerAddress,
399 uint16_t registerValue) {
415 if (rxTemp.
readData == registerValue) {
428 uint8_t registerAddress,
430 uint16_t registerValue) {
449 if ((rxTemp.
readData & registerValue) == 0u) {
463 uint16_t registerMask = 0u;
464 uint16_t expRegisterValue = 0u;
465 uint16_t registerValue = 0u;
862 uint8_t watchdogRefreshLimit = 0;
870 watchdogRefreshLimit = 6u;
875 watchdogRefreshLimit = 4u;
880 watchdogRefreshLimit = 2u;
882 watchdogRefreshLimit = 1u;
886 uint8_t faultCounter = 0u;
893 *requiredWatchdogRefreshes = faultCounter + (watchdogRefreshLimit - watchdogRefreshCounter);
902 uint8_t faultCounter = 0u;
904 if (faultCounter != 0u) {
944 uint16_t frameLengthBytes,
962 if (spiRetval ==
STD_OK) {
970 return spiCommunicationState;
1048 bool test_assertionRSTB =
false;
1052 if (rstReason == POWERON_RESET) {
1084 test_assertionRSTB =
true;
1087 test_assertionRSTB =
true;
1089 }
else if (rstReason == EXT_RESET) {
1099 test_assertionRSTB =
true;
1102 test_assertionRSTB =
false;
1114 uint16_t expRegisterValue =
1133 test_assertionRSTB =
false;
1147 test_assertionRSTB =
false;
1157 if (test_assertionRSTB ==
true) {
#define FS8X_FS_I_WD_RFR_LIMIT_MASK
#define FS8X_M_INT_MASK2_ADDR
fs8x_status_t FS8x_GetFaultErrorCounterValue(SPI_INTERFACE_CONFIG_s *spiInterface, fs8x_drv_data_t *drvData, uint8_t *faultErrorCounterValue)
Reads actual Fault Error Counter value.
#define FS8X_FS_SPI_FS_CRC_ERROR_DETECTED
static STD_RETURN_TYPE_e SBC_ReadBackRegister(FS85xx_STATE_s *pInstance, bool isFailSafe, uint8_t registerAddress)
Reads SBC register value.
#define FS8X_FS_RELEASE_FS0B_ADDR
uint16_t overvoltageUndervoltageRegisterStatus
#define FS8X_FS_VDDIO_UV_UNDERVOLTAGE_REPORTED
#define FS8X_FS_VMON3_OV_OVERVOLTAGE_REPORTED
#define FS8X_FS_FSM_STATE_MASK
#define FS8X_FS_FS_DIG_REF_OV_OVERVOLTAGE_REPORTED
#define FS8X_FS_I_WD_RFR_CNT_MASK
#define FS8X_M_VSUPUVH_EVENT_OCCURRED
#define FS8X_FS_RSTB_EVENT_RESET_OCCURRED
#define FS8X_FS_I_VMON4_OV_FS_IMPACT_NO_EFFECT
static STD_RETURN_TYPE_e SBC_WriteRegisterFsInit(FS85xx_STATE_s *pInstance, uint8_t registerAddress, uint16_t registerValue)
Write to fail-safe register.
#define FS8X_FS_I_VDDIO_UV_FS_IMPACT_NO_EFFECT
#define FS8X_M_VBOSUVH_EVENT_OCCURRED
#define FS8X_FS_WDW_DC_50
#define FS8X_M_MEMORY0_ADDR
#define FS8X_FS_I_WD_RFR_LIMIT_4
FS85X_MAIN_REGISTERS_s mainRegister
#define FS8X_FS_WD_WINDOW_128MS
#define FS8x_BO_GET_REG_VALUE(value, mask, shift)
Macro for getting value from register.
STD_RETURN_TYPE_e FS85X_InitFS(FS85xx_STATE_s *pInstance)
Configures SBC during INIT_FS phase.
#define FS8X_M_FLAG1_ADDR
#define FS8X_FS_VMON2_UV_UNDERVOLTAGE_REPORTED
volatile uint32_t * pGIOport
#define FS8X_FS_SPI_FS_CLK_WRONG_NUMBER_OF_CLOCK_CYCLES
#define FS8X_M_REG_CTRL1_ADDR
@ SBC_RSTB_ASSERTION_TEST
#define FS8X_FS_WD_SEED_ADDR
#define FS8X_FS_FCCU2_ERROR_DETECTED
enum STD_RETURN_TYPE STD_RETURN_TYPE_e
#define FS8X_FS_VCOREMON_OV_OVERVOLTAGE_REPORTED
#define FS8X_FS_VMON4_OV_OVERVOLTAGE_REPORTED
#define FS8X_FS_I_VMON2_ABIST2_VMON2_BIST
#define FS8X_FS_VMON1_OV_OVERVOLTAGE_REPORTED
#define FS8X_FS_ERRMON_ERROR_DETECTED
#define FS8X_FS_I_VMON3_ABIST2_VMON3_BIST
#define FS8X_FS_I_RSTB_DUR_10MS
#define FS8X_FS_SAFE_IOS_ADDR
static STD_RETURN_TYPE_e SBC_ReadBackAllRegisters(FS85xx_STATE_s *pInstance)
uint16_t iOvervoltageUndervolateSafeReaction2
SPI_INTERFACE_CONFIG_s spi_kSbcMcuInterface
#define FS8X_FS_DIAG_SAFETY_ADDR
#define FS8X_FS_VMON3_UV_UNDERVOLTAGE_REPORTED
#define FS8X_FS_FS_OSC_DRIFT_OSCILLATOR_DRIFT
#define FS8X_FS_I_VMON4_UV_FS_IMPACT_NO_EFFECT
#define FS8X_FS_I_VMON2_OV_FS_IMPACT_NO_EFFECT
resetSource_t MINFO_GetResetSource(void)
Get reason for last reset.
enum SBC_INIT_PHASE SBC_INIT_PHASE_e
FS85X_OPERATION_MODE_e mode
#define FS8X_FS_RSTB_DIAG_NO_FAILURE
long FSYS_RaisePrivilege(void)
raise privilege
#define FS8X_FS_I_FLT_ERR_CNT_1
#define FS8X_FS_WD_ANSWER_ADDR
fs8x_drv_data_t configValues
#define FS8X_FS_I_WD_RFR_LIMIT_SHIFT
#define FS8X_M_WK2FLG_EVENT_OCCURRED
#define FS8X_FS_FCCU12_ERROR_DETECTED
#define FS8X_M_FLAG2_ADDR
#define FS8X_FS_I_FLT_ERR_IMPACT_FS0B_RSTB
DIAG_RETURNTYPE_e DIAG_Handler(DIAG_ID_e diag_id, DIAG_EVENT_e event, DIAG_IMPACT_LEVEL_e impact, uint32_t data)
DIAG_Handler provides generic error handling, based on diagnosis group.
#define FS8X_FS_OTP_CORRUPT_NO_ERROR
fs8x_status_t FS8x_WD_Refresh(SPI_INTERFACE_CONFIG_s *spiInterface, fs8x_drv_data_t *drvData)
Performs the watchdog refresh.
#define FS8X_FS_I_VMON1_UV_FS_IMPACT_NO_EFFECT
#define FS8X_FS_RSTB_REQ_RSTB_ASSERTION
FS85X_FS_REGISTER_s fsRegister
#define FS8X_FS_I_WD_CFG_ADDR
#define FS8X_FS_I_WD_RFR_LIMIT_6
#define FS8X_FS_I_SVS_ADDR
Header for the driver for the FRAM module.
#define FS8X_FS_DBG_MODE_MASK
#define FS8X_M_VSUPUVL_EVENT_OCCURRED
#define FS8X_FS_I_VMON4_ABIST2_VMON4_BIST
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
#define FS8X_FS_I_VCOREMON_UV_FS_IMPACT_NO_EFFECT
Structure representing received data frame.
#define FS8X_M_VSUPUV7_EVENT_OCCURRED
@ MINFO_DEBUG_PROBE_NOT_CONNECTED
#define FS8X_FS_I_ERRMON_FS_IMPACT_FS0B
#define FS8X_FS_VMON1_UV_UNDERVOLTAGE_REPORTED
fs8x_status_t
Status return codes.
STD_RETURN_TYPE_e SPI_TransmitReceiveData(SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16 *pTxBuff, uint16 *pRxBuff, uint32 frameLength)
Transmits and receives data on SPI without DMA.
#define FS8X_FS_I_VMON2_UV_FS_IMPACT_NO_EFFECT
#define FS8X_FS_INTB_MASK_ADDR
#define FS8X_FS_I_VMON3_OV_FS_IMPACT_NO_EFFECT
void MCU_delay_us(uint32_t delay_us)
Wait blocking a certain time in microseconds.
#define FS8X_FS_I_WD_RFR_LIMIT_2
#define FS8X_FS_WDW_RECOVERY_128MS
#define FS8X_FS_DBG_MODE_NO_DEBUG
uint16_t iOvervoltageUndervolateSafeReaction1
uint16_t iFailSafeSateMachine
#define FS8X_FS_I_WD_RFR_CNT_SHIFT
Headers for the driver for the MCU module.
#define FS8X_M_VBOOSTUVH_EVENT_OCCURRED
#define FS8x_WD_SEED_DEFAULT
Watchdog seed default value.
#define FS8X_FS_I_VCOREMON_OV_FS_IMPACT_NO_EFFECT
static STD_RETURN_TYPE_e SBC_CheckRegisterValues(uint32_t registerValue, uint32_t expectedRegisterValue)
Checks register value against expected value.
uint16_t analogMultiplexer
#define FS8X_FS_I_OVUV_SAFE_REACTION1_ADDR
#define FS8X_FS_VDDIO_OV_OVERVOLTAGE_REPORTED
#define FS8X_FS_I2C_FS_CRC_ERROR_DETECTED
FS85xx_STATE_s fs85xx_mcuSupervisor
#define FS8X_FS_RSTB_EVENT_MASK
#define FS8X_FS_LBIST_OK_PASS
#define FS8X_FS_STATES_ADDR
#define FS8X_FS_RSTB_SNS_PAD_SENSED_HIGH
fs8x_status_t FS8x_ReadRegister(SPI_INTERFACE_CONFIG_s *pSpiInterface, fs8x_drv_data_t *drvData, bool isFailSafe, uint8_t address, fs8x_rx_frame_t *rxData)
Performs a read from a single FS8x register.
#define FS8X_FS_I_FSSM_ADDR
@ FRAM_BLOCK_ID_SBC_INIT_STATE
#define FS8X_FS_I_ERRMON_FLT_POLARITY_POSITIVE_EDGE
#define FS8X_FS_LBIST_OK_MASK
static STD_RETURN_TYPE_e SBC_ClearRegisterFlags(FS85xx_STATE_s *pInstance, uint8_t registerAddress, bool isFailSafe, uint16_t registerValue)
Clears flags in register.
#define FS8X_FS_I_VDDIO_OV_FS_IMPACT_NO_EFFECT
Function to switch between user mode and privilege mode.
#define FS8X_FS_BAD_WD_TIMING_BAD_WD_REFRESH
#define FS8X_FS_ABIST2_OK_MASK
#define FS8X_FS_I_VMON1_OV_FS_IMPACT_NO_EFFECT
FS85X_FIN_CONFIGURATION_s fin
#define FS8X_FS_I_VMON3_UV_FS_IMPACT_NO_EFFECT
FRAM_SBC_INIT_s fram_sbcInit
UNIT_TEST_WEAK_IMPL fs8x_status_t MCU_SPI_TransferData(SPI_INTERFACE_CONFIG_s *pSpiInterface, uint8_t *txFrame, uint16_t frameLengthBytes, uint8_t *rxFrame)
This function transfers single frame through blocking SPI communication in both directions....
#define FS8X_M_MEMORY1_ADDR
#define FS8X_FS_OVUVREG_STATUS_ADDR
STD_RETURN_TYPE_e FRAM_Write(FRAM_BLOCK_ID_e blockId)
Writes a variable to the FRAM.
void IO_PinReset(uint32_t *pRegisterAddress, uint32_t pin)
Set pin by writing in pin output register.
SPI_INTERFACE_CONFIG_s * pSpiInterface
#define FS8X_FS_I_VCOREMON_ABIST2_VCOREMON_BIST
#define FS8X_FS_I_FCCU1_FLT_POL_FCCU1_L
static void SBC_UpdateRegister(FS85xx_STATE_s *pInstance, bool isFailSafe, uint32_t registerAddress, uint32_t registerValue)
Updates register values.
#define FS8X_FS_I_FS0B_SC_HIGH_CFG_NO_ASSERTION
static STD_RETURN_TYPE_e SBC_PerformPathCheckRSTB(FS85xx_STATE_s *pInstance)
Perform RSTB safety path check.
#define FS8x_COMM_FRAME_SIZE
uint16_t readData
Content of a read register.
#define FS8X_M_REG_CTRL2_ADDR
STD_RETURN_TYPE_e FS85X_SafetyPathChecks(FS85xx_STATE_s *pInstance)
Performs SBC safety path checks.
#define FS8X_M_LVB1_SVS_ADDR
fs8x_status_t FS8x_FS0B_Release(SPI_INTERFACE_CONFIG_s *spiInterface, fs8x_drv_data_t *drvData)
FS0B release routine.
#define FS8X_FS_I_ERRMON_ACK_TIME_32MS
#define NULL_PTR
Null pointer.
#define FS8X_FS_RSTB_DRV_MASK
uint16_t registerControl2
#define FS8X_FS_RSTB_DRV_COMMAND_SENSED_HIGH
STD_RETURN_TYPE_e FRAM_Read(FRAM_BLOCK_ID_e blockId)
Reads a variable from the FRAM.
Header for the driver for the IO module.
#define FS8X_FS_WD_WINDOW_ADDR
#define FS8X_FS_ABIST1_OK_MASK
#define FS8X_FS_RSTB_SNS_MASK
#define FS8X_M_VMON_REGX_ADDR
#define FS8X_FS_I_VDDIO_ABIST2_VDDIO_BIST
#define FS8X_FS_BAD_WD_DATA_MASK
#define FS8X_FS_ABIST1_OK_PASS
void MINFO_SetDebugProbeConnectionState(MINFO_DEBUG_PROBE_CONNECTION_STATE_e state)
Check if debug probe is connected.
#define FS8X_FS_SPI_FS_REQ_SPI_VIOLATION
#define FS8X_M_DEVICEID_ADDR
General foxBMS-master system information.
STD_RETURN_TYPE_e FS85X_CheckFaultErrorCounter(FS85xx_STATE_s *pInstance)
Checks if fault error counter is zero.
#define FS8X_FS_I_OVUV_SAFE_REACTION2_ADDR
static STD_RETURN_TYPE_e SBC_WriteBackRegisterFsInit(FS85xx_STATE_s *pInstance, uint8_t registerAddress, uint16_t registerValue)
Write to fail-safe register.
#define FS8X_FS_I_SAFE_INPUTS_ADDR
#define FS8X_FS_VCOREMON_UV_UNDERVOLTAGE_REPORTED
STD_RETURN_TYPE_e finState
#define FS8X_M_VPREUVH_EVENT_OCCURRED
STD_RETURN_TYPE_e FS85X_Init_ReqWDGRefreshes(FS85xx_STATE_s *pInstance, uint8_t *requiredWatchdogRefreshes)
Calculates the number of required watchdog refresh to reset fault error counter.
#define FS8X_FS_FS_WD_G_GOOD_WD_REFRESH
@ MINFO_DEBUG_PROBE_CONNECTED
#define FS8X_FS_RSTB_DIAG_MASK
void IO_PinSet(uint32_t *pRegisterAddress, uint32_t pin)
Set pin by writing in pin output register.
#define FS8X_FS_VMON2_OV_OVERVOLTAGE_REPORTED
#define FS8X_FS_GO_TO_INITFS_GO_BACK_TO_INIT_FS
uint16_t registerControl1
#define FS8X_FS_FCCU1_ERROR_DETECTED
#define FAS_TRAP
Define that evaluates to essential boolean false thus tripping an assert.
#define FS8X_M_CLOCK_ADDR
#define FS8X_FS_VMON4_UV_UNDERVOLTAGE_REPORTED
#define FS8X_FS_OTP_CORRUPT_MASK
#define FS8X_FS_FSM_STATE_INIT_FS
#define FS8X_FS_BAD_WD_DATA_BAD_WD_REFRESH
#define FS8X_M_VPREUVL_EVENT_OCCURRED
#define FS8X_FS_I_FCCU_CFG_NO_MONITORING
#define UNIT_TEST_WEAK_IMPL
#define FS8X_FS_I_FCCU1_FS_REACT_FS0B
#define FS8X_FS_I_FLT_ERR_CNT_LIMIT_8
#define FS8X_FS_BAD_WD_TIMING_MASK
#define FSYS_SwitchToUserMode()
Switch back to user mode.
static STD_RETURN_TYPE_e SBC_PerformPathCheckFS0B(FS85xx_STATE_s *pInstance)
Perform FS0B safety path check.
#define FS8X_FS_GRL_FLAGS_ADDR
STD_RETURN_TYPE_e finState
STD_RETURN_TYPE_e SBC_TriggerWatchdog(FS85xx_STATE_s *pInstance)
Trigger watchdog.
#define FS8X_FS_I_VMON1_ABIST2_VMON1_BIST
#define FS8X_M_INT_MASK1_ADDR
#define FS8X_FS_I2C_FS_REQ_I2C_VIOLATION
fs8x_status_t FS8x_WriteRegister(SPI_INTERFACE_CONFIG_s *pSpiInterface, fs8x_drv_data_t *drvData, bool isFailSafe, uint8_t address, uint16_t writeData)
Sends write command to the FS8x.
uint16_t iWatchdogConfiguration
#define FS8X_FS_FS_WD_G_MASK
fs8x_status_t FS8x_WriteRegisterInit(SPI_INTERFACE_CONFIG_s *pSpiInterface, fs8x_drv_data_t *drvData, uint8_t address, uint16_t writeData)
Performs a write to a single FS8x FS init register (during the INIT_FS phase only).
Header for the driver for the FRAM module.