foxBMS - Unit Tests  1.6.0
The foxBMS Unit Tests API Documentation
imd.c
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2023, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V.
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright notice, this
12  * list of conditions and the following disclaimer.
13  *
14  * 2. Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  *
18  * 3. Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from
20  * this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *
33  * We kindly request you to use one or more of the following phrases to refer to
34  * foxBMS in your hardware, software, documentation or advertising materials:
35  *
36  * - ″This product uses parts of foxBMS®″
37  * - ″This product includes parts of foxBMS®″
38  * - ″This product is derived from foxBMS®″
39  *
40  */
41 
42 /**
43  * @file imd.c
44  * @author foxBMS Team
45  * @date 2021-11-04 (date of creation)
46  * @updated 2023-10-12 (date of last update)
47  * @version v1.6.0
48  * @ingroup DRIVERS
49  * @prefix IMD
50  *
51  * @brief Main driver state machine for insulation monitoring driver
52  *
53  * @details This superimposed state machine initializes, enables and disables
54  * the selected Insulation Monitoring Device. Furthermore, the
55  * measurement results are evaluated and saved in the database.
56  * Requests are used to control the IMD state machine and with that
57  * the behavior of the IMDs.
58  */
59 
60 /*========== Includes =======================================================*/
61 #include "imd.h"
62 
63 #include "diag.h"
64 #include "os.h"
65 
66 #include <stdbool.h>
67 #include <stdint.h>
68 
69 /*========== Macros and Definitions =========================================*/
70 
71 /**
72  * state machine short time definition in #IMD_Trigger calls until next state is
73  * processed
74  */
75 #define IMD_FSM_SHORT_TIME (1u)
76 
77 /** Substates of the state machine */
78 typedef enum {
79  IMD_FSM_SUBSTATE_DUMMY, /*!< dummy state - always the first substate */
80  IMD_FSM_SUBSTATE_ENTRY, /*!< entry state - always the second substate */
81  IMD_FSM_SUBSTATE_INITIALIZATION_0, /*!< fist initialization substate */
82  IMD_FSM_SUBSTATE_INITIALIZATION_1, /*!< second initialization substate */
83  IMD_FSM_SUBSTATE_INITIALIZATION_EXIT, /*!< last initialization substate */
84  IMD_FSM_SUBSTATE_RUNNING_0, /*!< fist running substate */
85  IMD_FSM_SUBSTATE_RUNNING_1, /*!< second running substate */
86  IMD_FSM_SUBSTATE_RUNNING_2, /*!< third running substate */
88 
89 /** Symbolic names to check for multiple calls of #IMD_Trigger */
90 typedef enum {
91  IMD_MULTIPLE_CALLS_NO, /*!< no multiple calls, OK */
92  IMD_MULTIPLE_CALLS_YES, /*!< multiple calls, not OK */
94 
95 /** some struct with some information */
96 typedef struct {
97  bool isStatemachineInitialized; /*!< true if initialized, otherwise false */
98  bool switchImdDeviceOn; /*!< true if enabling process is ongoing */
100 
101 /** This struct describes the state of the monitoring instance */
102 typedef struct {
103  uint8_t counter; /*!< general purpose counter */
104  uint16_t timer; /*!< timer of the state */
105  uint8_t triggerEntry; /*!< trigger entry of the state */
106  IMD_STATE_REQUEST_e stateRequest; /*!< current state request made to the state machine */
107  IMD_FSM_STATES_e nextState; /*!< next state of the FSM */
108  IMD_FSM_STATES_e currentState; /*!< current state of the FSM */
109  IMD_FSM_STATES_e previousState; /*!< previous state of the FSM */
110  IMD_FSM_SUBSTATES_e nextSubstate; /*!< next substate of the FSM */
111  IMD_FSM_SUBSTATES_e currentSubstate; /*!< current substate of the FSM */
112  IMD_FSM_SUBSTATES_e previousSubstate; /*!< previous substate of the FSM */
113  IMD_INFORMATION_s information; /*!< Some information to be stored */
114  DATA_BLOCK_INSULATION_MONITORING_s *pTableImd; /*!< Pointer to IMD database entry */
115 } IMD_STATE_s;
116 
117 /*========== Static Constant and Variable Definitions =======================*/
120 
121 /** global IMD state */
123  .timer = 0u,
124  .triggerEntry = 0u,
125  .nextState = IMD_FSM_STATE_DUMMY,
126  .stateRequest = IMD_STATE_NO_REQUEST,
127  .currentState = IMD_FSM_STATE_HAS_NEVER_RUN,
128  .previousState = IMD_FSM_STATE_DUMMY,
129  .nextSubstate = IMD_FSM_SUBSTATE_DUMMY,
130  .currentSubstate = IMD_FSM_SUBSTATE_DUMMY,
131  .previousSubstate = IMD_FSM_SUBSTATE_DUMMY,
132  .information.isStatemachineInitialized = false,
133  .information.switchImdDeviceOn = false,
134  .pTableImd = &imd_tableInsulationMonitoring,
135 };
136 
137 /*========== Extern Constant and Variable Definitions =======================*/
138 
139 /*========== Static Function Prototypes =====================================*/
140 /**
141  * @brief sets the current state request of the state variable #imd_state.
142  * @details This function is used to make a state request to the state machine,
143  * e.g, initialize state machine or shut-down state machine.
144  * It calls #IMD_CheckStateRequest() to check if the request is valid.
145  * The state request is rejected if is not valid. The result of the
146  * check is returned immediately, so that the requester can act in
147  * case it made a non-valid state request.
148  * @param[in] stateRequest state request to set
149  * @param[in,out] pImdState pointer to state variable of IMD state machine
150  * @return OK if request has been accepted, otherwise error reason
151  */
153 
154 /**
155  * @brief checks the state requests that are made.
156  * @details This function checks the validity of the state requests. The
157  * results of the checked state request is returned immediately.
158  * @param[in] stateRequest state request to be checked
159  * @param[in,out] pImdState pointer to state variable of IMD state machine
160  * @return result of the state request that was made
161  */
163 
164 /**
165  * @brief transfers the current state request to the state machine.
166  * @details This function takes the current state request from #imd_state
167  * transfers it to the state machine. It resets the value from
168  * #imd_state to #IMD_STATE_NO_REQUEST
169  * @param[in,out] pImdState pointer to state variable of IMD state machine
170  * @return current state request
171  */
173 
174 /**
175  * @brief check for multiple calls of state machine trigger function
176  * @details The trigger function is not reentrant, which means it cannot
177  * be called multiple times. This functions increments the
178  * triggerEntry counter once and must be called each time the
179  * trigger function is called. If triggerEntry is greater than
180  * one, there were multiple calls. For this function to work,
181  * triggerEntry must be decremented each time the trigger function
182  * is called, even if no processing do because the timer is
183  * non-zero.
184  * @param[in,out] pImdState pointer to state variable of IMD state machine
185  * @return #IMD_MULTIPLE_CALLS_YES if there were multiple calls,
186  * #IMD_MULTIPLE_CALLS_NO otherwise
187  */
189 
190 /**
191  * @brief Sets the next state, the next substate and the timer value
192  * of the state variable.
193  * @param[in,out] pImdState state of the example state machine
194  * @param[in] nextState state to be transferred into
195  * @param[in] nextSubstate substate to be transferred into
196  * @param[in] idleTime wait time for the state machine
197  */
198 static void IMD_SetState(
199  IMD_STATE_s *pImdState,
200  IMD_FSM_STATES_e nextState,
201  IMD_FSM_SUBSTATES_e nextSubstate,
202  uint16_t idleTime);
203 
204 /**
205  * @brief Sets the next substate and the timer value
206  * of the state variable.
207  * @param[in,out] pImdState state of the example state machine
208  * @param[in] nextSubstate substate to be transferred into
209  * @param[in] idleTime wait time for the state machine
210  */
211 static void IMD_SetSubstate(IMD_STATE_s *pImdState, IMD_FSM_SUBSTATES_e nextSubstate, uint16_t idleTime);
212 
213 /**
214  * @brief Defines the state transitions
215  * @details This function contains the implementation of the state
216  * machine, i.e., the sequence of states and substates.
217  * It is called by the trigger function every time
218  * the state machine timer has a non-zero value.
219  * @param[in,out] pImdState state of the example state machine
220  * @return Always #STD_OK
221  */
223 
224 /**
225  * @brief Evaluates measurement perform by IMD driver
226  * @details This function evaluates the insulation measurement performed by the
227  * selected IMD driver and updates the database entry.
228  * @param[in,out] pTableInsulationMonitoring pointer to insulation monitoring
229  * database entry
230  * @return Always #IMD_REQUEST_OK
231  */
233  DATA_BLOCK_INSULATION_MONITORING_s *pTableInsulationMonitoring);
234 
235 /*========== Static Function Implementations ================================*/
237  FAS_ASSERT(pImdState != NULL_PTR);
238  /* AXIVION Routine Generic-MissingParameterAssert: stateRequest: parameter accepts whole range */
240 
242  retVal = IMD_CheckStateRequest(pImdState, stateRequest);
243 
244  if (retVal == IMD_REQUEST_OK) {
245  pImdState->stateRequest = stateRequest;
246  }
248 
249  return retVal;
250 }
251 
253  FAS_ASSERT(pImdState != NULL_PTR);
254  /* AXIVION Routine Generic-MissingParameterAssert: stateRequest: parameter accepts whole range */
256  if (pImdState->stateRequest == IMD_STATE_NO_REQUEST) {
257  /* init only allowed from the uninitialized state */
258  if (stateRequest == IMD_STATE_INITIALIZE_REQUEST) {
259  if (pImdState->currentState == IMD_FSM_STATE_UNINITIALIZED) {
260  retval = IMD_REQUEST_OK;
261  } else {
262  retval = IMD_ALREADY_INITIALIZED;
263  }
264  } else if (stateRequest == IMD_STATE_SWITCH_ON_REQUEST) {
265  if (pImdState->currentState == IMD_FSM_STATE_SHUTDOWN) {
266  retval = IMD_REQUEST_OK;
267  } else if (pImdState->currentState == IMD_FSM_STATE_IMD_ENABLE) {
268  retval = IMD_REQUEST_OK;
269  } else {
270  retval = IMD_ILLEGAL_REQUEST;
271  }
272  } else {
273  retval = IMD_ILLEGAL_REQUEST;
274  }
275  } else {
276  /* Request pending */
277  }
278  return retval;
279 }
280 
282  FAS_ASSERT(pImdState != NULL_PTR);
284  IMD_STATE_REQUEST_e retval = pImdState->stateRequest;
285  pImdState->stateRequest = IMD_STATE_NO_REQUEST;
287  return retval;
288 }
289 
291  FAS_ASSERT(pImdState != NULL_PTR);
294  if (pImdState->triggerEntry == 0u) {
295  pImdState->triggerEntry++;
296  } else {
297  multipleCalls = IMD_MULTIPLE_CALLS_YES; /* multiple call of function IMD_Trigger for instance pImdState */
298  }
300  return multipleCalls;
301 }
302 
303 static void IMD_SetState(
304  IMD_STATE_s *pImdState,
305  IMD_FSM_STATES_e nextState,
306  IMD_FSM_SUBSTATES_e nextSubstate,
307  uint16_t idleTime) {
308  FAS_ASSERT(pImdState != NULL_PTR);
309  /* AXIVION Routine Generic-MissingParameterAssert: idleTime: parameter accepts whole range */
310  /* AXIVION Routine Generic-MissingParameterAssert: nextState: parameter accepts whole range */
311  /* AXIVION Routine Generic-MissingParameterAssert: nextSubstate: parameter accepts whole range */
312  bool earlyExit = false;
313 
314  pImdState->timer = idleTime;
315 
316  if ((pImdState->currentState == nextState) && (pImdState->currentSubstate == nextSubstate)) {
317  /* Next state and next substate equal to current state and substate: nothing to do */
318  pImdState->nextState = IMD_FSM_STATE_DUMMY; /* no state transition required -> reset */
319  pImdState->nextSubstate = IMD_FSM_SUBSTATE_DUMMY; /* no substate transition required -> reset */
320  earlyExit = true;
321  }
322 
323  if (earlyExit == false) {
324  if (pImdState->currentState != nextState) {
325  /* Next state is different: switch to it and set substate to entry value */
326  pImdState->previousState = pImdState->currentState;
327  pImdState->currentState = nextState;
328  pImdState->previousSubstate = pImdState->currentSubstate;
329  pImdState->currentSubstate = IMD_FSM_SUBSTATE_ENTRY; /* Use entry state after a top level state change */
330  pImdState->nextState = IMD_FSM_STATE_DUMMY; /* no state transition required -> reset */
331  pImdState->nextSubstate = IMD_FSM_SUBSTATE_DUMMY; /* no substate transition required -> reset */
332  } else if (pImdState->currentSubstate != nextSubstate) {
333  /* Only the next substate is different, switch to it */
334  IMD_SetSubstate(pImdState, nextSubstate, idleTime);
335  } else {
336  ;
337  }
338  }
339 }
340 
341 static void IMD_SetSubstate(IMD_STATE_s *pImdState, IMD_FSM_SUBSTATES_e nextSubstate, uint16_t idleTime) {
342  FAS_ASSERT(pImdState != NULL_PTR);
343  /* AXIVION Routine Generic-MissingParameterAssert: nextSubstate: parameter accepts whole range */
344  /* AXIVION Routine Generic-MissingParameterAssert: idleTime: parameter accepts whole range */
345  pImdState->timer = idleTime;
346  pImdState->previousSubstate = pImdState->currentSubstate;
347  pImdState->currentSubstate = nextSubstate;
348  pImdState->nextSubstate = IMD_FSM_SUBSTATE_DUMMY; /* substate has been set, now reset value for nextSubstate */
349 }
350 
352  FAS_ASSERT(pImdState != NULL_PTR);
353  STD_RETURN_TYPE_e ranStateMachine = STD_OK;
356  switch (pImdState->currentState) {
357  /********************************************** STATE: HAS NEVER RUN */
359  /* Nothing to do, just transfer */
361  break;
362 
363  /********************************************** STATE: UNINITIALIZED */
365  /* Transition to initialization state, one the state request has been received */
366  stateRequest = IMD_TransferStateRequest(pImdState);
367  if (stateRequest == IMD_STATE_INITIALIZE_REQUEST) {
369  } else {
370  /* Do nothing. Stay in state. */
371  }
372  break;
373 
374  /********************************************* STATE: INITIALIZATION */
376  nextState = IMD_ProcessInitializationState();
377  if (nextState == IMD_FSM_STATE_INITIALIZATION) {
378  /* staying in state, processed by state function */
379  } else if (nextState == IMD_FSM_STATE_ERROR) {
381  } else if (nextState == IMD_FSM_STATE_IMD_ENABLE) {
382  pImdState->information.isStatemachineInitialized = true;
384  } else {
385  FAS_ASSERT(FAS_TRAP); /* Something went wrong */
386  }
387  break;
388 
390  /* Transition to running state, once the state request has been received */
391  stateRequest = IMD_TransferStateRequest(pImdState);
392  if (stateRequest == IMD_STATE_SWITCH_ON_REQUEST) {
393  pImdState->information.switchImdDeviceOn = true;
394  }
395  if (pImdState->information.switchImdDeviceOn == true) {
396  nextState = IMD_ProcessEnableState();
397  if (nextState == IMD_FSM_STATE_RUNNING) {
398  /* Set flag that IMD is running. Do not update the database entry here. The database entry will be
399  * updated after first successful measurement in IMD_FSM_STATE_RUNNING state */
400  pImdState->pTableImd->isImdRunning = true;
401  pImdState->information.switchImdDeviceOn = false;
403  } else if (nextState == IMD_FSM_STATE_ERROR) {
405  } else {
406  /* Do nothing as the process to activate the IMD device is ongoing */
407  }
408  } else {
409  /* Do nothing. Stay in state. */
410  }
411  break;
412 
413  /**************************************************** STATE: RUNNING */
415  stateRequest = IMD_TransferStateRequest(pImdState);
416  if (stateRequest == IMD_STATE_SHUTDOWN_REQUEST) {
418  } else {
419  nextState = IMD_ProcessRunningState(pImdState->pTableImd);
420  /* Evaluate measurement results */
422  if (nextState == IMD_FSM_STATE_RUNNING) {
423  /* staying in state, processed by state function */
424  } else {
426  }
427  }
428  break;
429 
431  nextState = IMD_ProcessShutdownState();
432  if (nextState == IMD_FSM_STATE_IMD_ENABLE) {
433  /* Set flag, that IMD is deactivated. Update database entry */
434  pImdState->pTableImd->isImdRunning = false;
437  } else if (nextState == IMD_FSM_STATE_ERROR) {
439  } else {
440  /* staying in state, processed by state function */
441  }
442  break;
443 
444  /****************************************************** STATE: ERROR */
445  case IMD_FSM_STATE_ERROR:
446  /* Issue: 621 */
448  break;
449 
450  /**************************************************** STATE: DEFAULT */
451  default:
452  /* all cases must be processed, trap if unknown state arrives */
454  break;
455  }
456  /* Increment general purpose counter */
457  pImdState->counter++;
458  return ranStateMachine;
459 }
460 
462  DATA_BLOCK_INSULATION_MONITORING_s *pTableInsulationMonitoring) {
463  FAS_ASSERT(pTableInsulationMonitoring != NULL_PTR);
464  /* Assume resistance value as good if no valid measurement values are detected */
465  bool lowResistanceDetected = false;
466 
467  /* Check if measured resistance value is valid */
468  if (pTableInsulationMonitoring->isInsulationMeasurementValid == true) {
471  lowResistanceDetected = true;
472  }
473  } else {
475  }
476 
477  /* Check if flags of IMD are valid, e.g. status pin */
478  if (pTableInsulationMonitoring->areDeviceFlagsValid == true) {
479  if (pTableInsulationMonitoring->dfIsCriticalResistanceDetected == true) {
480  lowResistanceDetected = true;
481  }
482  if (pTableInsulationMonitoring->dfIsChassisFaultDetected == true) {
484  } else {
486  }
487  }
488 
489  /* Set diagnosis entry depending on measured insulation resistance and critical threshold flag */
490  if (lowResistanceDetected == true) {
492  } else {
494  }
495 
496  /* Set warning threshold flag depending on flag */
497  if (pTableInsulationMonitoring->dfIsWarnableResistanceDetected == true) {
499  } else {
501  }
502 
503  /* Write database entry */
504  DATA_WRITE_DATA(pTableInsulationMonitoring);
505 
506  /* Issue: 621 */
507 
508  return STD_OK;
509 }
510 
511 /*========== Extern Function Implementations ================================*/
514 }
515 
518 }
519 
522 }
523 
524 extern bool IMD_GetInitializationState(void) {
526 }
527 
529  bool earlyExit = false;
530  STD_RETURN_TYPE_e returnValue = STD_OK;
531 
532  /* Check multiple calls of function */
534  returnValue = STD_NOT_OK;
535  earlyExit = true;
536  }
537 
538  if (earlyExit == false) {
539  if (imd_state.timer > 0u) {
540  if ((--imd_state.timer) > 0u) {
542  returnValue = STD_OK;
543  earlyExit = true;
544  }
545  }
546  }
547 
548  if (earlyExit == false) {
551  }
552  return returnValue;
553 }
554 
555 /*========== Externalized Static Function Implementations (Unit Test) =======*/
556 #ifdef UNITY_UNIT_TEST
557 #endif
IMD_FSM_STATES_e IMD_ProcessInitializationState(void)
Processes the initialization state.
Definition: bender_ir155.c:210
IMD_FSM_STATES_e IMD_ProcessShutdownState(void)
Processes the shutdown state.
Definition: bender_ir155.c:225
IMD_FSM_STATES_e IMD_ProcessEnableState(void)
Processes the IMD enable state.
Definition: bender_ir155.c:214
IMD_FSM_STATES_e IMD_ProcessRunningState(DATA_BLOCK_INSULATION_MONITORING_s *pTableInsulationMonitoring)
Processes the running state.
Definition: bender_ir155.c:220
#define DATA_WRITE_DATA(...)
Definition: database.h:96
@ DATA_BLOCK_ID_INSULATION_MONITORING
Definition: database_cfg.h:97
DIAG_RETURNTYPE_e DIAG_Handler(DIAG_ID_e diagId, DIAG_EVENT_e event, DIAG_IMPACT_LEVEL_e impact, uint32_t data)
DIAG_Handler provides generic error handling, based on diagnosis group.
Definition: diag.c:246
Diagnosis driver header.
@ DIAG_EVENT_NOT_OK
Definition: diag_cfg.h:268
@ DIAG_EVENT_OK
Definition: diag_cfg.h:267
@ DIAG_SYSTEM
Definition: diag_cfg.h:280
@ DIAG_ID_INSULATION_MEASUREMENT_VALID
Definition: diag_cfg.h:251
@ DIAG_ID_INSULATION_GROUND_ERROR
Definition: diag_cfg.h:254
@ DIAG_ID_LOW_INSULATION_RESISTANCE_ERROR
Definition: diag_cfg.h:252
@ DIAG_ID_LOW_INSULATION_RESISTANCE_WARNING
Definition: diag_cfg.h:253
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
Definition: fassert.h:251
#define FAS_TRAP
Define that evaluates to essential boolean false thus tripping an assert.
Definition: fassert.h:129
STD_RETURN_TYPE_e
Definition: fstd_types.h:82
@ STD_NOT_OK
Definition: fstd_types.h:84
@ STD_OK
Definition: fstd_types.h:83
#define NULL_PTR
Null pointer.
Definition: fstd_types.h:77
IMD_RETURN_TYPE_e IMD_RequestInsulationMeasurement(void)
Request to activate the actual IMD measurement.
Definition: imd.c:516
static void IMD_SetState(IMD_STATE_s *pImdState, IMD_FSM_STATES_e nextState, IMD_FSM_SUBSTATES_e nextSubstate, uint16_t idleTime)
Sets the next state, the next substate and the timer value of the state variable.
Definition: imd.c:303
IMD_FSM_SUBSTATES_e
Definition: imd.c:78
@ IMD_FSM_SUBSTATE_RUNNING_0
Definition: imd.c:84
@ IMD_FSM_SUBSTATE_RUNNING_1
Definition: imd.c:85
@ IMD_FSM_SUBSTATE_INITIALIZATION_EXIT
Definition: imd.c:83
@ IMD_FSM_SUBSTATE_RUNNING_2
Definition: imd.c:86
@ IMD_FSM_SUBSTATE_DUMMY
Definition: imd.c:79
@ IMD_FSM_SUBSTATE_ENTRY
Definition: imd.c:80
@ IMD_FSM_SUBSTATE_INITIALIZATION_1
Definition: imd.c:82
@ IMD_FSM_SUBSTATE_INITIALIZATION_0
Definition: imd.c:81
bool IMD_GetInitializationState(void)
Gets the initialization state.
Definition: imd.c:524
static DATA_BLOCK_INSULATION_MONITORING_s imd_tableInsulationMonitoring
Definition: imd.c:118
static STD_RETURN_TYPE_e IMD_EvaluateInsulationMeasurement(DATA_BLOCK_INSULATION_MONITORING_s *pTableInsulationMonitoring)
Evaluates measurement perform by IMD driver.
Definition: imd.c:461
STD_RETURN_TYPE_e IMD_Trigger(void)
trigger function for the IMD driver state machine.
Definition: imd.c:528
static IMD_STATE_s imd_state
Definition: imd.c:122
static IMD_RETURN_TYPE_e IMD_CheckStateRequest(IMD_STATE_s *pImdState, IMD_STATE_REQUEST_e stateRequest)
checks the state requests that are made.
Definition: imd.c:252
IMD_CHECK_MULTIPLE_CALLS_e
Definition: imd.c:90
@ IMD_MULTIPLE_CALLS_NO
Definition: imd.c:91
@ IMD_MULTIPLE_CALLS_YES
Definition: imd.c:92
#define IMD_FSM_SHORT_TIME
Definition: imd.c:75
static IMD_CHECK_MULTIPLE_CALLS_e IMD_CheckMultipleCalls(IMD_STATE_s *pImdState)
check for multiple calls of state machine trigger function
Definition: imd.c:290
static STD_RETURN_TYPE_e IMD_RunStateMachine(IMD_STATE_s *pImdState)
Defines the state transitions.
Definition: imd.c:351
IMD_RETURN_TYPE_e IMD_RequestMeasurementStop(void)
Request to deactivate the actual IMD measurement.
Definition: imd.c:520
IMD_RETURN_TYPE_e IMD_RequestInitialization(void)
Request initialization of IMD state machine.
Definition: imd.c:512
static IMD_STATE_REQUEST_e IMD_TransferStateRequest(IMD_STATE_s *pImdState)
transfers the current state request to the state machine.
Definition: imd.c:281
static void IMD_SetSubstate(IMD_STATE_s *pImdState, IMD_FSM_SUBSTATES_e nextSubstate, uint16_t idleTime)
Sets the next substate and the timer value of the state variable.
Definition: imd.c:341
static IMD_RETURN_TYPE_e IMD_SetStateRequest(IMD_STATE_s *pImdState, IMD_STATE_REQUEST_e stateRequest)
sets the current state request of the state variable imd_state.
Definition: imd.c:236
API header for the insulation monitoring device.
IMD_FSM_STATES_e
Definition: imd.h:93
@ IMD_FSM_STATE_RUNNING
Definition: imd.h:100
@ IMD_FSM_STATE_SHUTDOWN
Definition: imd.h:99
@ IMD_FSM_STATE_INITIALIZATION
Definition: imd.h:97
@ IMD_FSM_STATE_HAS_NEVER_RUN
Definition: imd.h:95
@ IMD_FSM_STATE_IMD_ENABLE
Definition: imd.h:98
@ IMD_FSM_STATE_DUMMY
Definition: imd.h:94
@ IMD_FSM_STATE_UNINITIALIZED
Definition: imd.h:96
@ IMD_FSM_STATE_ERROR
Definition: imd.h:101
IMD_STATE_REQUEST_e
Definition: imd.h:85
@ IMD_STATE_SWITCH_ON_REQUEST
Definition: imd.h:87
@ IMD_STATE_SHUTDOWN_REQUEST
Definition: imd.h:88
@ IMD_STATE_INITIALIZE_REQUEST
Definition: imd.h:86
@ IMD_STATE_NO_REQUEST
Definition: imd.h:89
IMD_RETURN_TYPE_e
Definition: imd.h:77
@ IMD_ALREADY_INITIALIZED
Definition: imd.h:81
@ IMD_ILLEGAL_REQUEST
Definition: imd.h:80
@ IMD_REQUEST_PENDING
Definition: imd.h:79
@ IMD_REQUEST_OK
Definition: imd.h:78
#define IMD_ERROR_THRESHOLD_INSULATION_RESISTANCE_kOhm
Definition: imd.h:71
Declaration of the OS wrapper interface.
void OS_ExitTaskCritical(void)
Exit Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.
Definition: os_freertos.c:154
void OS_EnterTaskCritical(void)
Enter Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.
Definition: os_freertos.c:150
DATA_BLOCK_ID_e uniqueId
Definition: database_cfg.h:125
bool isStatemachineInitialized
Definition: imd.c:97
bool switchImdDeviceOn
Definition: imd.c:98
DATA_BLOCK_INSULATION_MONITORING_s * pTableImd
Definition: imd.c:114
IMD_FSM_STATES_e previousState
Definition: imd.c:109
IMD_INFORMATION_s information
Definition: imd.c:113
IMD_FSM_SUBSTATES_e previousSubstate
Definition: imd.c:112
IMD_FSM_STATES_e nextState
Definition: imd.c:107
IMD_STATE_REQUEST_e stateRequest
Definition: imd.c:106
IMD_FSM_SUBSTATES_e nextSubstate
Definition: imd.c:110
uint8_t triggerEntry
Definition: imd.c:105
IMD_FSM_SUBSTATES_e currentSubstate
Definition: imd.c:111
uint8_t counter
Definition: imd.c:103
IMD_FSM_STATES_e currentState
Definition: imd.c:108
uint16_t timer
Definition: imd.c:104