74 #define I165C_FSM_SHORT_TIME (1u)
181 .receptionTries = 0u,
182 .receptionTriesMessage = 0u,
183 #if false == I165C_IS_165C_USED
185 .negativeRelayClosed =
true,
186 .positiveRelayClosed =
true,
189 .negativeRelayClosed =
false,
190 .positiveRelayClosed =
false,
199 .receptionTries = 0u,
200 .receptionTriesMessage = 0u,
208 .receptionTries = 0u,
209 .receptionTriesMessage = 0u,
217 .receptionTries = 0u,
218 .receptionTriesMessage = 0u,
444 pImdState->
timer = idleTime;
461 pImdState->
timer = idleTime;
478 pImdState->
timer = idleTime;
495 pImdState->
timer = idleTime;
509 pCanMessage->
data[i] = 0u;
585 pCanMessage->
id = id;
593 bool messageReceived =
false;
594 uint8_t numberItems = 0u;
600 if (numberItems > 0u) {
605 messageReceived =
true;
611 }
while ((numberItems > 0u) && (queueReadTries > 0u));
613 return messageReceived;
618 bool imdInfoReceived =
false;
619 uint8_t numberItems = 0u;
625 if (numberItems > 0u) {
629 imdInfoReceived =
true;
635 }
while ((numberItems > 0u) && (queueReadTries > 0u));
637 return imdInfoReceived;
641 bool initialized =
true;
657 if (insulationMeasurementState != 0u) {
661 #ifdef I165C_SELF_TEST_LONG
664 if (selfTestExecuted != 0u) {
671 if (selfTestExecuted != 0u) {
680 bool anySelfTestExecuted =
false;
688 if (overallSelfTestExecuted == 0u) {
690 anySelfTestExecuted =
true;
694 if (parameterSelfTestExecuted == 0u) {
696 anySelfTestExecuted =
true;
698 return anySelfTestExecuted;
728 bool checkSuccess =
true;
735 checkSuccess =
false;
740 if (relayState != data) {
742 checkSuccess =
false;
760 bool measurementModeMatches =
false;
761 uint16_t dVIFCStatus = 0u;
769 if (actualMeasurementMode == mode) {
771 measurementModeMatches =
true;
773 return measurementModeMatches;
795 bool acknowledgeReceived =
false;
800 acknowledgeReceived =
true;
802 return acknowledgeReceived;
807 bool earlyExit =
false;
816 if (earlyExit ==
false) {
953 #ifdef I165C_SELF_TEST_LONG
1128 bool earlyExit =
false;
1137 if (earlyExit ==
false) {
1232 bool earlyExit =
false;
1233 uint16_t resistance_kOhm = 0u;
1234 uint16_t statusFlags = 0u;
1245 if (earlyExit ==
false) {
1375 bool earlyExit =
false;
1384 if (earlyExit ==
false) {
1496 #ifdef UNITY_UNIT_TEST
static bool I165C_CheckRelayState(CAN_BUFFER_ELEMENT_s canMessage, uint8_t relay, uint8_t relayState)
Check state of HV relay.
static IMD_FSM_STATES_e I165C_Initialize(void)
static CAN_BUFFER_ELEMENT_s i165c_canTxMessage
static void I165C_WriteCmd(uint8_t id, uint8_t command, CAN_BUFFER_ELEMENT_s *pCanMessage)
Compose CAN message for CAN transmission.
static void I165C_ReadDataByte(uint8_t dataByte, uint8_t *pData, CAN_BUFFER_ELEMENT_s canMessage)
Get data in data byte from CAN transmission.
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.
IMD_FSM_STATES_e IMD_ProcessInitializationState(void)
Processes the initialization state.
static bool I165C_HasSelfTestBeenExecuted(CAN_BUFFER_ELEMENT_s canMessage)
Check if iso165c has already been performed previously.
static IMD_FSM_STATES_e I165C_Disable(void)
static bool I165C_CheckAcknowledgeArrived(uint8_t command, uint8_t *pTries, CAN_BUFFER_ELEMENT_s *pCanMessage)
Check if iso165c acknowledged reception of command.
I165C_FSM_INITIALIZATION_STATES_e
@ I165C_FSM_STATE_INITIALIZATION_SET_ERROR_THRESHOLD
@ I165C_FSM_STATE_INITIALIZATION_UNLOCK_WAIT_ACK
@ I165C_FSM_STATE_INITIALIZATION_DUMMY
@ I165C_FSM_STATE_INITIALIZATION_ERROR_THRESHOLD_WAIT_ACK
@ I165C_FSM_STATE_INITIALIZATION_AVERAGING_FACTOR_WAIT_ACK
@ I165C_FSM_STATE_INITIALIZATION_SET_WARNING_THRESHOLD
@ I165C_FSM_STATE_INITIALIZATION_WARNING_THRESHOLD_WAIT_ACK
@ I165C_FSM_STATE_INITIALIZATION_CHECK_MEASUREMENT_STATE
@ I165C_FSM_STATE_INITIALIZATION_DISABLE_MEASUREMENT_WAIT_ACK
@ I165C_FSM_STATE_INITIALIZATION_DISABLE_MEASUREMENT
@ I165C_FSM_STATE_INITIALIZATION_REQUEST_HV_RELAY_OPENING
@ I165C_FSM_STATE_INITIALIZATION_SELF_TEST_WAIT_ACK
@ I165C_FSM_STATE_INITIALIZATION_ENABLE_MEASUREMENT_WAIT_ACK
@ I165C_FSM_STATE_INITIALIZATION_CHECK_NEGATIVE_HV_RELAY_STATE
@ I165C_FSM_STATE_INITIALIZATION_SET_AVERAGING_FACTOR
@ I165C_FSM_STATE_INITIALIZATION_WAIT_SELF_TEST
@ I165C_FSM_STATE_INITIALIZATION_REQUEST_SELF_TEST
@ I165C_FSM_STATE_INITIALIZATION_CHECK_POSITIVE_HV_RELAY_STATE
@ I165C_FSM_STATE_INITIALIZATION_REQUEST_NEGATIVE_HV_RELAY_STATE
@ I165C_FSM_STATE_INITIALIZATION_HAS_NEVER_RUN
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.
static I165C_INITIALIZATION_STATE_s i165c_initializationState
void TEST_I165C_WriteCmd(uint8_t id, uint8_t command, CAN_BUFFER_ELEMENT_s *canMessage)
void TEST_I165C_ReadDataByte(uint8_t dataByte, uint8_t *data, CAN_BUFFER_ELEMENT_s canMessage)
static void I165C_SetMeasurementMode(uint8_t mode)
Set measurement mode.
IMD_FSM_STATES_e IMD_ProcessShutdownState(void)
Processes the shutdown state.
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.
bool TEST_I165C_GetImdInfo(CAN_BUFFER_ELEMENT_s *canMessage)
I165C_FSM_DISABLE_STATES_e
@ I165C_FSM_STATE_DISABLE_SET_HV_RELAY_STATE
@ I165C_FSM_STATE_MEASUREMENT_STOPPED_WAIT_ACK
@ I165C_FSM_STATE_DISABLE_CHECK_NEGATIVE_HV_RELAY_STATE
@ I165C_FSM_STATE_DISABLE_HAS_NEVER_RUN
@ I165C_FSM_STATE_DISABLE_DUMMY
@ I165C_FSM_STATE_DISABLE_REQUEST_NEGATIVE_HV_RELAY_STATE
@ I165C_FSM_STATE_DISABLE_CHECK_POSITIVE_HV_RELAY_STATE
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.
I165C_FSM_RUNNING_STATES_e
@ I165C_FSM_STATE_RUNNING_HAS_NEVER_RUN
@ I165C_FSM_STATE_RUNNING_GET_MEASUREMENT
@ I165C_FSM_STATE_RUNNING_READ_RESISTANCE_WAIT_ACK
@ I165C_FSM_STATE_RUNNING_DUMMY
@ I165C_FSM_STATE_RUNNING_READ_RESISTANCE
I165C_FSM_ENABLE_STATES_e
@ I165C_FSM_STATE_ENABLE_HAS_NEVER_RUN
@ I165C_FSM_STATE_ENABLE_CHECK_NEGATIVE_HV_RELAY_STATE
@ I165C_FSM_STATE_ENABLE_START_MEASUREMENT_WAIT_ACK
@ I165C_FSM_STATE_ENABLE_DUMMY
@ I165C_FSM_STATE_ENABLE_START_MEASUREMENT
@ I165C_FSM_STATE_ENABLE_REQUEST_NEGATIVE_HV_RELAY_STATE
@ I165C_FSM_STATE_ENABLE_CHECK_POSITIVE_HV_RELAY_STATE
bool TEST_I165C_IsSelfTestFinished(CAN_BUFFER_ELEMENT_s canMessage)
IMD_FSM_STATES_e IMD_ProcessEnableState(void)
Processes the IMD enable state.
void TEST_I165C_ResetCanData(CAN_BUFFER_ELEMENT_s *canMessage)
static IMD_FSM_STATES_e I165C_Running(DATA_BLOCK_INSULATION_MONITORING_s *pTableInsulationMonitoring)
trigger function for the i165c driver state machine.
static void I165C_WriteDataWord(uint8_t dataWord, uint16_t data, CAN_BUFFER_ELEMENT_s *pCanMessage)
Write data in data word for CAN transmission.
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.
void TEST_I165C_ReadDataWordImdInfo(uint8_t dataWord, uint16_t *data, CAN_BUFFER_ELEMENT_s canMessage)
static I165C_RUNNING_STATE_s i165c_runningState
static I165C_DISABLE_STATE_s i165c_disableState
static void I165C_SetRelayState(uint8_t relay, uint8_t relayState)
Set state of HV relay.
#define I165C_FSM_SHORT_TIME
bool TEST_I165C_CheckAcknowledgeArrived(uint8_t command, uint8_t *tries, CAN_BUFFER_ELEMENT_s *canMessage)
static void I165C_RequestRelayState(uint8_t relay)
Request state of HV relay.
static bool I165C_IsSelfTestFinished(CAN_BUFFER_ELEMENT_s canMessage)
Check if iso165c was initialized and is running.
static bool I165C_CheckMeasurementMode(CAN_BUFFER_ELEMENT_s canMessage, uint8_t mode)
Check measurement mode.
void TEST_I165C_ReadDataWord(uint8_t dataWord, uint16_t *data, CAN_BUFFER_ELEMENT_s canMessage)
static void I165C_ReadDataWord(uint8_t dataWord, uint16_t *pData, CAN_BUFFER_ELEMENT_s canMessage)
Get data in data word from CAN transmission.
bool TEST_I165C_CheckResponse(uint8_t command, CAN_BUFFER_ELEMENT_s *canMessage)
static void I165C_ResetCanData(CAN_BUFFER_ELEMENT_s *pCanMessage)
Reset CAN data.
static IMD_FSM_STATES_e I165C_Enable(void)
static void I165C_SetAveragingFactor(uint8_t averagingFactor)
Set average factor of the insulation resistance averaging algorithm.
static bool I165C_CheckResponse(uint8_t command, CAN_BUFFER_ELEMENT_s *pCanMessage)
Check if iso165c acknowledged reception of sent message and get corresponding data.
static CAN_BUFFER_ELEMENT_s i165c_canRxMessage
static bool I165C_GetImdInfo(CAN_BUFFER_ELEMENT_s *pCanMessage)
Get IMD Info from iso165c.
void TEST_I165C_WriteDataWord(uint8_t dataWord, uint16_t data, CAN_BUFFER_ELEMENT_s *canMessage)
static I165C_ENABLE_STATE_s i165c_enableState
IMD_FSM_STATES_e IMD_ProcessRunningState(DATA_BLOCK_INSULATION_MONITORING_s *pTableInsulationMonitoring)
Processes the running state.
Headers for the driver for the insulation monitoring.
#define I165C_D_VIFC_HV_RELAIS_STATE_GET_RESPONSE
#define I165C_INSULATION_FAULT_SHIFT
#define I165C_D_VIFC_HV_RELAIS_SET_REQUEST
#define I165C_D_IMC_MEAN_FACTOR_SET_REQUEST
#define I165C_D_VIFC_HV_RELAIS_POSITIVE
#define I165C_BIAS_TO_HV_PLUS
#define I165C_UNLOCK_PASSWORD
#define I165C_IMC_SELFTEST_PARAMETERCONFIG_SCENARIO_SHIFT
#define I165C_CMD_S_IMC_SET_R_ISO_ERR_THR
#define I165C_RELAY_STATE_CLOSED
#define I165C_D_VIFC_HV_RELAIS_GET_REQUEST
#define I165C_INSULATION_MEASUREMENT_STATUS_SHIFT
#define I165C_LOCKMODE_UNLOCKED
#define I165C_DW_VIFC_CTL_MEASUREMENT_REQUEST
#define I165C_CMD_S_VIFC_CTL_MEASUREMENT
#define I165C_CMD_S_IMC_SET_R_ISO_ERR_WRN
#define I165C_CMD_S_IMC_SET_MEAN_FACTOR
#define I165C_D_IMC_R_ISO_CNT_GET_RESPONSE
#define I165C_CMD_S_IMC_CTL_SELFTEST
#define I165C_MAX_QUEUE_READS
#define I165C_SELFTEST_SCENARIO_PARAMETERCONFIG
#define I165C_SELFTEST_SCENARIO_OVERALL
#define I165C_CMD_S_IMC_GET_R_ISO
#define I165C_D_VIFC_HV_RELAIS_GET_RESPONSE
#define I165C_D_IMC_SELFTEST_SCR_CTL_REQUEST
#define I165C_SYSTEM_FAILURE_SHIFT
#define I165C_D_VIFC_LOCK_MODE_CTL_REQUEST
#define I165C_TRANSMISSION_ATTEMPTS
#define I165C_RX_MESSAGE_IDENTIFIER_TYPE
#define I165C_MESSAGETYPE_IMD_INFO
#define I165C_CMD_S_VIFC_SET_HV_RELAIS
#define I165C_WARNING_THRESHOLD_kOhm
#define I165C_BIAS_TO_HV_MINUS
#define I165C_MESSAGETYPE_IMD_REQUEST
#define I165C_D_IMC_R_ISO_ERR_WRN_SET_REQUEST
#define I165C_TX_MESSAGE_IDENTIFIER_TYPE
#define I165C_DISABLE_MEASUREMENT
#define I165C_SELFTEST_RUNNING_SHIFT
#define I165C_IMD_INFO_RECEIVE_ATTEMPTS
#define I165C_RELAY_STATE_OPEN
#define I165C_CHASSIS_FAULT_SHIFT
#define I165C_D_VIFC_HV_RELAIS_STATE_SET_REQUEST
#define I165C_ERROR_THRESHOLD_kOhm
#define I165C_INSULATION_WARNING_SHIFT
#define I165C_D_VIFC_LOCK_PWD_CTL_REQUEST
#define I165C_D_IMC_R_ISO_BIAS_GET_RESPONSE
#define I165C_IMC_SELFTEST_OVERALL_SCENARIO_SHIFT
#define I165C_CMD_S_VIFC_GET_HV_RELAIS
#define I165C_ENABLE_MEASUREMENT
#define I165C_D_VIFC_HV_RELAIS_NEGATIVE
#define I165C_RESISTANCE_VALUE_OUTDATED_SHIFT
#define I165C_CMD_S_VIFC_CTL_LOCK
#define I165C_MEASUREMENT_AVERAGING_FACTOR
#define I165C_D_IMC_R_ISO_ERR_THR_SET_REQUEST
STD_RETURN_TYPE_e CAN_DataSend(CAN_NODE_s *pNode, uint32_t id, CAN_IDENTIFIER_TYPE_e idType, uint8 *pData)
Sends over CAN the data passed in parameters. This function goes over the message boxes and marks the...
Header for the driver for the CAN module.
Header for the driver for the CAN module.
#define CANRX_IMD_RESPONSE_ID
Header for the driver for the CAN module.
Headers for the helper functions for the CAN module.
#define CAN_BYTE_2_POSITION
#define CAN_BYTE_4_POSITION
#define CAN_BYTE_0_POSITION
#define CAN_BYTE_6_POSITION
#define CAN_BYTE_3_POSITION
#define CAN_BYTE_5_POSITION
#define CAN_BYTE_1_POSITION
Database configuration header.
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
#define FAS_TRAP
Define that evaluates to essential boolean false thus tripping an assert.
#define NULL_PTR
Null pointer.
Header of task driver implementation.
OS_QUEUE ftsk_imdCanDataQueue
@ IMD_FSM_STATE_INITIALIZATION
@ IMD_FSM_STATE_IMD_ENABLE
OS_STD_RETURN_e OS_ReceiveFromQueue(OS_QUEUE xQueue, void *const pvBuffer, uint32_t ticksToWait)
Receive an item from a queue.
uint32_t OS_GetNumberOfStoredMessagesInQueue(OS_QUEUE xQueue)
Check if messages are waiting for queue.
uint8_t data[CAN_MAX_DLC]
CAN_IDENTIFIER_TYPE_e idType
bool dfIsDeviceErrorDetected
bool dfIsWarnableResistanceDetected
bool dfIsCriticalResistanceDetected
bool dfIsMeasurementUpToDate
bool isInsulationMeasurementValid
uint32_t insulationResistance_kOhm
bool dfIsChassisFaultDetected
bool dfIsChassisShortToHvPlus
bool dfIsChassisShortToHvMinus
uint8_t receptionTriesMessage
I165C_FSM_DISABLE_STATES_e previousState
I165C_FSM_DISABLE_STATES_e currentState
I165C_FSM_ENABLE_STATES_e previousState
I165C_FSM_ENABLE_STATES_e currentState
uint8_t receptionTriesMessage
I165C_FSM_INITIALIZATION_STATES_e currentState
uint8_t receptionTriesMessage
I165C_FSM_INITIALIZATION_STATES_e previousState
uint8_t receptionTriesMessage
I165C_FSM_RUNNING_STATES_e currentState
I165C_FSM_RUNNING_STATES_e previousState