foxBMS - Unit Tests
1.3.0
The foxBMS Unit Tests API Documentation
|
Driver for the insulation monitoring. More...
#include "bender_iso165c.h"
#include "database_cfg.h"
#include "can.h"
#include "can_helper.h"
#include "database.h"
#include "ftask.h"
Go to the source code of this file.
Data Structures | |
struct | I165C_INITIALIZATION_STATE_s |
struct | I165C_ENABLE_STATE_s |
struct | I165C_RUNNING_STATE_s |
struct | I165C_DISABLE_STATE_s |
Macros | |
#define | I165C_FSM_SHORT_TIME (1u) |
Functions | |
static void | I165C_SetInitializationState (I165C_INITIALIZATION_STATE_s *pImdState, I165C_FSM_INITIALIZATION_STATES_e nextState, uint16_t idleTime) |
Sets the next state the timer value of the initialization state variable. More... | |
static void | I165C_SetEnableState (I165C_ENABLE_STATE_s *pImdState, I165C_FSM_ENABLE_STATES_e nextState, uint16_t idleTime) |
Sets the next state the timer value of the enable state variable. More... | |
static void | I165C_SetRunningState (I165C_RUNNING_STATE_s *pImdState, I165C_FSM_RUNNING_STATES_e nextState, uint16_t idleTime) |
Sets the next state the timer value of the running state variable. More... | |
static void | I165C_SetDisableState (I165C_DISABLE_STATE_s *pImdState, I165C_FSM_DISABLE_STATES_e nextState, uint16_t idleTime) |
Sets the next state the timer value of the disable state variable. More... | |
static IMD_FSM_STATES_e | I165C_Initialize (void) |
static IMD_FSM_STATES_e | I165C_Enable (void) |
static IMD_FSM_STATES_e | I165C_Disable (void) |
static IMD_FSM_STATES_e | I165C_Running (DATA_BLOCK_INSULATION_MONITORING_s *pTableInsulationMonitoring) |
trigger function for the i165c driver state machine. More... | |
static void | I165C_ResetCanData (CAN_BUFFERELEMENT_s *pCanMessage) |
Reset CAN data. More... | |
static void | I165C_WriteDataWord (uint8_t dataWord, uint16_t data, CAN_BUFFERELEMENT_s *pCanMessage) |
Write data in data word for CAN transmission. More... | |
static void | I165C_ReadDataWord (uint8_t dataWord, uint16_t *pData, CAN_BUFFERELEMENT_s canMessage) |
Get data in data word from CAN transmission. More... | |
static void | I165C_ReadDataWordImdInfo (uint8_t dataWord, uint16_t *pData, CAN_BUFFERELEMENT_s canMessage) |
Get data in data word from CAN transmission, for the specific IMD_Info message. More... | |
static void | I165C_ReadDataByte (uint8_t dataByte, uint8_t *pData, CAN_BUFFERELEMENT_s canMessage) |
Get data in data byte from CAN transmission. More... | |
static void | I165C_WriteCmd (uint8_t id, uint8_t command, CAN_BUFFERELEMENT_s *pCanMessage) |
Compose CAN message for CAN transmission. More... | |
static bool | I165C_CheckResponse (uint8_t command, CAN_BUFFERELEMENT_s *pCanMessage) |
Check if iso165c acknowledged reception of sent message and get corresponding data. More... | |
static bool | I165C_GetImdInfo (CAN_BUFFERELEMENT_s *pCanMessage) |
Get IMD Info from iso165c. More... | |
static bool | I165C_IsSelfTestFinished (CAN_BUFFERELEMENT_s canMessage) |
Check if iso165c was initialized and is running. More... | |
static bool | I165C_HasSelfTestBeenExecuted (CAN_BUFFERELEMENT_s canMessage) |
Check if iso165c has already been performed previously. More... | |
static void | I165C_SetRelayState (uint8_t relay, uint8_t relayState) |
Set state of HV relay. More... | |
static void | I165C_RequestRelayState (uint8_t relay) |
Request state of HV relay. More... | |
static bool | I165C_CheckRelayState (CAN_BUFFERELEMENT_s canMessage, uint8_t relay, uint8_t relayState) |
Check state of HV relay. More... | |
static void | I165C_SetMeasurementMode (uint8_t mode) |
Set measurement mode. More... | |
static bool | I165C_CheckMeasurementMode (CAN_BUFFERELEMENT_s canMessage, uint8_t mode) |
Check measurement mode. More... | |
static void | I165C_SetAveragingFactor (uint8_t averagingFactor) |
Set average factor of the insulation resistance averaging algorithm. More... | |
static bool | I165C_CheckAcknowledgeArrived (uint8_t command, uint8_t *pTries, CAN_BUFFERELEMENT_s *pCanMessage) |
Check if iso165c acknowledged reception of command. More... | |
IMD_FSM_STATES_e | IMD_ProcessInitializationState (void) |
Processes the initialization state. More... | |
IMD_FSM_STATES_e | IMD_ProcessEnableState (void) |
Processes the IMD enable state. More... | |
IMD_FSM_STATES_e | IMD_ProcessRunningState (DATA_BLOCK_INSULATION_MONITORING_s *pTableInsulationMonitoring) |
Processes the running state. More... | |
IMD_FSM_STATES_e | IMD_ProcessShutdownState (void) |
Processes the shutdown state. More... | |
void | TEST_I165C_ResetCanData (CAN_BUFFERELEMENT_s *canMessage) |
void | TEST_I165C_WriteDataWord (uint8_t dataWord, uint16_t data, CAN_BUFFERELEMENT_s *canMessage) |
void | TEST_I165C_ReadDataWord (uint8_t dataWord, uint16_t *data, CAN_BUFFERELEMENT_s canMessage) |
void | TEST_I165C_ReadDataWordImdInfo (uint8_t dataWord, uint16_t *data, CAN_BUFFERELEMENT_s canMessage) |
void | TEST_I165C_ReadDataByte (uint8_t dataByte, uint8_t *data, CAN_BUFFERELEMENT_s canMessage) |
void | TEST_I165C_WriteCmd (uint8_t id, uint8_t command, CAN_BUFFERELEMENT_s *canMessage) |
bool | TEST_I165C_CheckResponse (uint8_t command, CAN_BUFFERELEMENT_s *canMessage) |
bool | TEST_I165C_GetImdInfo (CAN_BUFFERELEMENT_s *canMessage) |
bool | TEST_I165C_IsSelfTestFinished (CAN_BUFFERELEMENT_s canMessage) |
bool | TEST_I165C_CheckAcknowledgeArrived (uint8_t command, uint8_t *tries, CAN_BUFFERELEMENT_s *canMessage) |
Variables | |
static I165C_INITIALIZATION_STATE_s | i165c_initializationState |
static I165C_ENABLE_STATE_s | i165c_enableState |
static I165C_RUNNING_STATE_s | i165c_runningState |
static I165C_DISABLE_STATE_s | i165c_disableState |
static CAN_BUFFERELEMENT_s | i165c_canTxMessage = {0u} |
static CAN_BUFFERELEMENT_s | i165c_canRxMessage = {0u} |
Driver for the insulation monitoring.
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:
main file of bender iso165C and iso165C-1 driver
Definition in file bender_iso165c.c.
#define I165C_FSM_SHORT_TIME (1u) |
statemachine short time definition in trigger calls until next state is processed
Definition at line 69 of file bender_iso165c.c.
States of the disable state machine
Definition at line 118 of file bender_iso165c.c.
States of the enable state machine
Definition at line 98 of file bender_iso165c.c.
States of the initialization state machine
Definition at line 74 of file bender_iso165c.c.
States of the running state machine
Definition at line 109 of file bender_iso165c.c.
|
static |
Check if iso165c acknowledged reception of command.
command | command to be acknowledged | |
[out] | pTries | pointer to variable counting the number of tries for reception |
[in] | pCanMessage | pointer to CAN data sent by the iso165c |
Definition at line 785 of file bender_iso165c.c.
|
static |
Check measurement mode.
[in] | canMessage | IMD_Info to be checked, sent by the iso165c |
[in] | mode | IMD measurement mode (activated or deactivated) |
Definition at line 753 of file bender_iso165c.c.
|
static |
Check state of HV relay.
[in] | canMessage | IMD_Info to be checked, sent by the iso165c |
[in] | relay | positive or negative relay |
[in] | relayState | relay opened or closed |
Definition at line 720 of file bender_iso165c.c.
|
static |
Check if iso165c acknowledged reception of sent message and get corresponding data.
Gets data from the CAN module through a queue.
command | check if this command is sent by iso165c to acknowledge reception | |
[in] | pCanMessage | pointer to CAN data sent by the iso165c |
Definition at line 587 of file bender_iso165c.c.
|
static |
Disable state machine
Definition at line 1368 of file bender_iso165c.c.
|
static |
Enable state machine
Definition at line 1121 of file bender_iso165c.c.
|
static |
Get IMD Info from iso165c.
Gets data from the CAN module through a queue.
[in] | pCanMessage | pointer to CAN data sent by the iso165c |
Definition at line 611 of file bender_iso165c.c.
|
static |
Check if iso165c has already been performed previously.
Check is made using the CAN IMD_Info data sent by the iso165c.
[in] | canMessage | IMD_Info to be checked, sent by the iso165c |
Definition at line 674 of file bender_iso165c.c.
|
static |
Initialization state machine
Definition at line 800 of file bender_iso165c.c.
|
static |
Check if iso165c was initialized and is running.
Check is made using the CAN IMD_Info data sent by the iso165c.
[in] | canMessage | IMD_Info to be checked, sent by the iso165c |
Definition at line 635 of file bender_iso165c.c.
|
static |
Get data in data byte from CAN transmission.
dataByte | data byte ("position") in CAN structure to be read from (see data sheet page 15) | |
[out] | pData | pointer where to put read data from data byte |
canMessage | CAN structure used for transmission |
Definition at line 557 of file bender_iso165c.c.
|
static |
Get data in data word from CAN transmission.
dataWord | data word ("position") in CAN structure to be read from (see data sheet page 15) | |
[out] | pData | pointer where to put read data from data word |
canMessage | CAN structure used for transmission |
Definition at line 523 of file bender_iso165c.c.
|
static |
Get data in data word from CAN transmission, for the specific IMD_Info message.
dataWord | data word ("position") in CAN structure to be read from (see data sheet page 15) | |
[out] | pData | pointer where to put read data from data word |
canMessage | CAN structure used for transmission |
Definition at line 540 of file bender_iso165c.c.
|
static |
Request state of HV relay.
[in] | relay | positive or negative relay |
Definition at line 709 of file bender_iso165c.c.
|
static |
Reset CAN data.
Used before starting a new transmission.
[in,out] | pCanMessage | pointer to CAN data to be reset |
Definition at line 503 of file bender_iso165c.c.
|
static |
trigger function for the i165c driver state machine.
This function contains the sequence of events in the i165c state machine. It must be called time-triggered, every 100ms.
pTableInsulationMonitoring | pointer to insulation database entry |
Definition at line 1224 of file bender_iso165c.c.
|
static |
Set average factor of the insulation resistance averaging algorithm.
[in] | averagingFactor | set IMD averaging factor |
Definition at line 771 of file bender_iso165c.c.
|
static |
Sets the next state the timer value of the disable state variable.
[in,out] | pImdState | state of the enable state machine |
[in] | nextState | state to be transferred into |
[in] | idleTime | wait time for the state machine |
Definition at line 486 of file bender_iso165c.c.
|
static |
Sets the next state the timer value of the enable state variable.
[in,out] | pImdState | state of the enable state machine |
[in] | nextState | state to be transferred into |
[in] | idleTime | wait time for the state machine |
Definition at line 452 of file bender_iso165c.c.
|
static |
Sets the next state the timer value of the initialization state variable.
[in,out] | pImdState | state of the initialization state machine |
[in] | nextState | state to be transferred into |
[in] | idleTime | wait time for the state machine |
Definition at line 435 of file bender_iso165c.c.
|
static |
Set measurement mode.
[in] | mode | set IMD measurement mode |
Definition at line 742 of file bender_iso165c.c.
|
static |
Set state of HV relay.
[in] | relay | set state of positive or negative relay |
[in] | relayState | open or close relay |
Definition at line 696 of file bender_iso165c.c.
|
static |
Sets the next state the timer value of the running state variable.
[in,out] | pImdState | state of the enable state machine |
[in] | nextState | state to be transferred into |
[in] | idleTime | wait time for the state machine |
Definition at line 469 of file bender_iso165c.c.
|
static |
Compose CAN message for CAN transmission.
Write CMD byte.
id | CAN ID to use | |
command | command to be used (see data page 15 section 6.3 and further) | |
[out] | pCanMessage | pointer to CAN structure to be used for transmission |
Definition at line 579 of file bender_iso165c.c.
|
static |
Write data in data word for CAN transmission.
dataWord | data word ("position") in CAN structure to be written to (see data sheet page 15) | |
data | data to be written in data word | |
[in] | pCanMessage | CAN structure to be used for transmission |
Definition at line 510 of file bender_iso165c.c.
IMD_FSM_STATES_e IMD_ProcessEnableState | ( | void | ) |
Processes the IMD enable state.
This function needs to be implemented in the dedicated driver. This function enables the actual IMD device to start the insulation measurement. Functionality need to be fullfilled after one call.
Definition at line 1477 of file bender_iso165c.c.
IMD_FSM_STATES_e IMD_ProcessInitializationState | ( | void | ) |
Processes the initialization state.
This function needs to be implemented in the dedicated driver. This function initializes the required SW modules and peripherals but does not start the actual IMD measurement.
Definition at line 1473 of file bender_iso165c.c.
IMD_FSM_STATES_e IMD_ProcessRunningState | ( | DATA_BLOCK_INSULATION_MONITORING_s * | pTableInsulationMonitoring | ) |
Processes the running state.
This function needs to be implemented in the dedicated driver
pTableInsulationMonitoring | pointer to insulation monitoring database entry |
Definition at line 1481 of file bender_iso165c.c.
IMD_FSM_STATES_e IMD_ProcessShutdownState | ( | void | ) |
Processes the shutdown state.
This function needs to be implemented in the dedicated driver. This function disables the actual IMD device to stop the insulation measurement.
Definition at line 1486 of file bender_iso165c.c.
bool TEST_I165C_CheckAcknowledgeArrived | ( | uint8_t | command, |
uint8_t * | tries, | ||
CAN_BUFFERELEMENT_s * | canMessage | ||
) |
bool TEST_I165C_CheckResponse | ( | uint8_t | command, |
CAN_BUFFERELEMENT_s * | canMessage | ||
) |
bool TEST_I165C_GetImdInfo | ( | CAN_BUFFERELEMENT_s * | canMessage | ) |
bool TEST_I165C_IsSelfTestFinished | ( | CAN_BUFFERELEMENT_s | canMessage | ) |
void TEST_I165C_ReadDataByte | ( | uint8_t | dataByte, |
uint8_t * | data, | ||
CAN_BUFFERELEMENT_s | canMessage | ||
) |
void TEST_I165C_ReadDataWord | ( | uint8_t | dataWord, |
uint16_t * | data, | ||
CAN_BUFFERELEMENT_s | canMessage | ||
) |
void TEST_I165C_ReadDataWordImdInfo | ( | uint8_t | dataWord, |
uint16_t * | data, | ||
CAN_BUFFERELEMENT_s | canMessage | ||
) |
void TEST_I165C_ResetCanData | ( | CAN_BUFFERELEMENT_s * | canMessage | ) |
void TEST_I165C_WriteCmd | ( | uint8_t | id, |
uint8_t | command, | ||
CAN_BUFFERELEMENT_s * | canMessage | ||
) |
void TEST_I165C_WriteDataWord | ( | uint8_t | dataWord, |
uint16_t | data, | ||
CAN_BUFFERELEMENT_s * | canMessage | ||
) |
|
static |
Definition at line 219 of file bender_iso165c.c.
|
static |
Definition at line 218 of file bender_iso165c.c.
|
static |
Definition at line 208 of file bender_iso165c.c.
|
static |
Definition at line 189 of file bender_iso165c.c.
|
static |
Definition at line 171 of file bender_iso165c.c.
|
static |
Definition at line 198 of file bender_iso165c.c.