foxBMS - Unit Tests
1.5.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_cfg_rx-message-definitions.h"
#include "can_cfg_tx-message-definitions.h"
#include "can_helper.h"
#include "database.h"
#include "ftask.h"
#include <stdbool.h>
#include <stdint.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_BUFFER_ELEMENT_s *pCanMessage) |
Reset CAN data. More... | |
static void | I165C_WriteDataWord (uint8_t dataWord, uint16_t data, CAN_BUFFER_ELEMENT_s *pCanMessage) |
Write data in data word for CAN transmission. More... | |
static void | I165C_ReadDataWord (uint8_t dataWord, uint16_t *pData, CAN_BUFFER_ELEMENT_s canMessage) |
Get data in data word from CAN transmission. More... | |
static void | I165C_ReadDataWordImdInfo (uint8_t dataWord, uint16_t *pData, CAN_BUFFER_ELEMENT_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_BUFFER_ELEMENT_s canMessage) |
Get data in data byte from CAN transmission. More... | |
static void | I165C_WriteCmd (uint8_t id, uint8_t command, CAN_BUFFER_ELEMENT_s *pCanMessage) |
Compose CAN message for CAN transmission. More... | |
static bool | I165C_CheckResponse (uint8_t command, CAN_BUFFER_ELEMENT_s *pCanMessage) |
Check if iso165c acknowledged reception of sent message and get corresponding data. More... | |
static bool | I165C_GetImdInfo (CAN_BUFFER_ELEMENT_s *pCanMessage) |
Get IMD Info from iso165c. More... | |
static bool | I165C_IsSelfTestFinished (CAN_BUFFER_ELEMENT_s canMessage) |
Check if iso165c was initialized and is running. More... | |
static bool | I165C_HasSelfTestBeenExecuted (CAN_BUFFER_ELEMENT_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_BUFFER_ELEMENT_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_BUFFER_ELEMENT_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_BUFFER_ELEMENT_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_BUFFER_ELEMENT_s *canMessage) |
void | TEST_I165C_WriteDataWord (uint8_t dataWord, uint16_t data, CAN_BUFFER_ELEMENT_s *canMessage) |
void | TEST_I165C_ReadDataWord (uint8_t dataWord, uint16_t *data, CAN_BUFFER_ELEMENT_s canMessage) |
void | TEST_I165C_ReadDataWordImdInfo (uint8_t dataWord, uint16_t *data, CAN_BUFFER_ELEMENT_s canMessage) |
void | TEST_I165C_ReadDataByte (uint8_t dataByte, uint8_t *data, CAN_BUFFER_ELEMENT_s canMessage) |
void | TEST_I165C_WriteCmd (uint8_t id, uint8_t command, CAN_BUFFER_ELEMENT_s *canMessage) |
bool | TEST_I165C_CheckResponse (uint8_t command, CAN_BUFFER_ELEMENT_s *canMessage) |
bool | TEST_I165C_GetImdInfo (CAN_BUFFER_ELEMENT_s *canMessage) |
bool | TEST_I165C_IsSelfTestFinished (CAN_BUFFER_ELEMENT_s canMessage) |
bool | TEST_I165C_CheckAcknowledgeArrived (uint8_t command, uint8_t *tries, CAN_BUFFER_ELEMENT_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_BUFFER_ELEMENT_s | i165c_canTxMessage = {0u} |
static CAN_BUFFER_ELEMENT_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) |
state machine short time definition in trigger calls until next state is processed
Definition at line 74 of file bender_iso165c.c.
States of the disable state machine
Definition at line 123 of file bender_iso165c.c.
States of the enable state machine
Definition at line 103 of file bender_iso165c.c.
States of the initialization state machine
Definition at line 79 of file bender_iso165c.c.
States of the running state machine
Definition at line 114 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 790 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 758 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 725 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 591 of file bender_iso165c.c.
|
static |
Disable state machine
Definition at line 1373 of file bender_iso165c.c.
|
static |
Enable state machine
Definition at line 1126 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 616 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 679 of file bender_iso165c.c.
|
static |
Initialization state machine
Definition at line 805 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 640 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 560 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 526 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 543 of file bender_iso165c.c.
|
static |
Request state of HV relay.
[in] | relay | positive or negative relay |
Definition at line 714 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 506 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 1229 of file bender_iso165c.c.
|
static |
Set average factor of the insulation resistance averaging algorithm.
[in] | averagingFactor | set IMD averaging factor |
Definition at line 776 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 489 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 455 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 438 of file bender_iso165c.c.
|
static |
Set measurement mode.
[in] | mode | set IMD measurement mode |
Definition at line 747 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 701 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 472 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 582 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 513 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 1482 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 1478 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 1486 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 1491 of file bender_iso165c.c.
bool TEST_I165C_CheckAcknowledgeArrived | ( | uint8_t | command, |
uint8_t * | tries, | ||
CAN_BUFFER_ELEMENT_s * | canMessage | ||
) |
bool TEST_I165C_CheckResponse | ( | uint8_t | command, |
CAN_BUFFER_ELEMENT_s * | canMessage | ||
) |
bool TEST_I165C_GetImdInfo | ( | CAN_BUFFER_ELEMENT_s * | canMessage | ) |
bool TEST_I165C_IsSelfTestFinished | ( | CAN_BUFFER_ELEMENT_s | canMessage | ) |
void TEST_I165C_ReadDataByte | ( | uint8_t | dataByte, |
uint8_t * | data, | ||
CAN_BUFFER_ELEMENT_s | canMessage | ||
) |
void TEST_I165C_ReadDataWord | ( | uint8_t | dataWord, |
uint16_t * | data, | ||
CAN_BUFFER_ELEMENT_s | canMessage | ||
) |
void TEST_I165C_ReadDataWordImdInfo | ( | uint8_t | dataWord, |
uint16_t * | data, | ||
CAN_BUFFER_ELEMENT_s | canMessage | ||
) |
void TEST_I165C_ResetCanData | ( | CAN_BUFFER_ELEMENT_s * | canMessage | ) |
void TEST_I165C_WriteCmd | ( | uint8_t | id, |
uint8_t | command, | ||
CAN_BUFFER_ELEMENT_s * | canMessage | ||
) |
void TEST_I165C_WriteDataWord | ( | uint8_t | dataWord, |
uint16_t | data, | ||
CAN_BUFFER_ELEMENT_s * | canMessage | ||
) |
|
static |
Definition at line 222 of file bender_iso165c.c.
|
static |
Definition at line 221 of file bender_iso165c.c.
|
static |
Definition at line 212 of file bender_iso165c.c.
|
static |
Definition at line 194 of file bender_iso165c.c.
|
static |
Definition at line 176 of file bender_iso165c.c.
|
static |
Definition at line 203 of file bender_iso165c.c.