foxBMS - Unit Tests  1.3.0
The foxBMS Unit Tests API Documentation
imd.c
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2022, 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 2022-05-30 (date of last update)
47  * @version v1.3.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 /*========== Macros and Definitions =========================================*/
67 
68 /**
69  * statemachine short time definition in #IMD_Trigger calls until next state is
70  * processed
71  */
72 #define IMD_FSM_SHORT_TIME (1u)
73 
74 /** Substates of the state machine */
75 typedef enum {
76  IMD_FSM_SUBSTATE_DUMMY, /*!< dummy state - always the first substate */
77  IMD_FSM_SUBSTATE_ENTRY, /*!< entry state - always the second substate */
78  IMD_FSM_SUBSTATE_INITIALIZATION_0, /*!< fist initialization substate */
79  IMD_FSM_SUBSTATE_INITIALIZATION_1, /*!< second initialization substate */
80  IMD_FSM_SUBSTATE_INITIALIZATION_EXIT, /*!< last initialization substate */
81  IMD_FSM_SUBSTATE_RUNNING_0, /*!< fist running substate */
82  IMD_FSM_SUBSTATE_RUNNING_1, /*!< second running substate */
83  IMD_FSM_SUBSTATE_RUNNING_2, /*!< third running substate */
85 
86 /** Symbolic names to check for multiple calls of #IMD_Trigger */
87 typedef enum {
88  IMD_MULTIPLE_CALLS_NO, /*!< no multiple calls, OK */
89  IMD_MULTIPLE_CALLS_YES, /*!< multiple calls, not OK */
91 
92 /** some struct with some information */
93 typedef struct {
94  bool isStatemachineInitialized; /*!< true if initialized, otherwise false */
95  bool switchImdDeviceOn; /*!< true if enabling process is ongoing */
97 
98 /** This struct describes the state of the monitoring instance */
99 typedef struct {
100  uint8_t counter; /*!< general purpose counter */
101  uint16_t timer; /*!< timer of the state */
102  uint8_t triggerEntry; /*!< trigger entry of the state */
103  IMD_STATE_REQUEST_e stateRequest; /*!< current state request made to the state machine */
104  IMD_FSM_STATES_e nextState; /*!< next state of the FSM */
105  IMD_FSM_STATES_e currentState; /*!< current state of the FSM */
106  IMD_FSM_STATES_e previousState; /*!< previous state of the FSM */
107  IMD_FSM_SUBSTATES_e nextSubstate; /*!< next substate of the FSM */
108  IMD_FSM_SUBSTATES_e currentSubstate; /*!< current substate of the FSM */
109  IMD_FSM_SUBSTATES_e previousSubstate; /*!< previous substate of the FSM */
110  IMD_INFORMATION_s information; /*!< Some information to be stored */
111  DATA_BLOCK_INSULATION_MONITORING_s *pTableImd; /*!< Pointer to IMD database entry */
112 } IMD_STATE_s;
113 
114 /*========== Static Constant and Variable Definitions =======================*/
117 
119  .timer = 0u,
120  .triggerEntry = 0u,
121  .nextState = IMD_FSM_STATE_DUMMY,
122  .stateRequest = IMD_STATE_NO_REQUEST,
123  .currentState = IMD_FSM_STATE_HAS_NEVER_RUN,
124  .previousState = IMD_FSM_STATE_DUMMY,
125  .nextSubstate = IMD_FSM_SUBSTATE_DUMMY,
126  .currentSubstate = IMD_FSM_SUBSTATE_DUMMY,
127  .previousSubstate = IMD_FSM_SUBSTATE_DUMMY,
128  .information.isStatemachineInitialized = false,
129  .information.switchImdDeviceOn = false,
130  .pTableImd = &imd_tableInsulationMonitoring,
131 };
132 
133 /*========== Extern Constant and Variable Definitions =======================*/
134 
135 /*========== Static Function Prototypes =====================================*/
136 /**
137  * @brief sets the current state request of the state variable #imd_state.
138  * @details This function is used to make a state request to the state machine,
139  * e.g, initialize state machine or shut-down state machine.
140  * It calls #IMD_CheckStateRequest() to check if the request is valid.
141  * The state request is rejected if is not valid. The result of the
142  * check is returned immediately, so that the requester can act in
143  * case it made a non-valid state request.
144  * @param[in] stateRequest state request to set
145  * @param[in,out] pImdState pointer to state variable of IMD state machine
146  * @return OK if request has been accepted, otherwise error reason
147  */
149 
150 /**
151  * @brief checks the state requests that are made.
152  * @details This function checks the validity of the state requests. The
153  * results of the checked staterequest is returned immediately.
154  * @param[in] stateRequest state request to be checked
155  * @param[in,out] pImdState pointer to state variable of IMD state machine
156  * @return result of the state request that was made
157  */
159 
160 /**
161  * @brief transfers the current state request to the state machine.
162  * @details This function takes the current state request from #imd_state
163  * transfers it to the state machine. It resets the value from
164  * #imd_state to #IMD_STATE_NO_REQUEST
165  * @param[in,out] pImdState pointer to state variable of IMD state machine
166  * @return current state request
167  */
169 
170 /**
171  * @brief check for multiple calls of state machine trigger function
172  * @details The trigger function is not reentrant, which means it cannot
173  * be called multiple times. This functions increments the
174  * triggerEntry counter once and must be called each time the
175  * trigger function is called. If triggerEntry is greater than
176  * one, there were multiple calls. For this function to work,
177  * triggerEntry must be decremented each time the trigger function
178  * is called, even if no processing do because the timer is
179  * non-zero.
180  * @param[in,out] pImdState pointer to state variable of IMD state machine
181  * @return #IMD_MULTIPLE_CALLS_YES if there were multiple calls,
182  * #IMD_MULTIPLE_CALLS_NO otherwise
183  */
185 
186 /**
187  * @brief Sets the next state, the next substate and the timer value
188  * of the state variable.
189  * @param[in,out] pImdState state of the example state machine
190  * @param[in] nextState state to be transferred into
191  * @param[in] nextSubstate substate to be transferred into
192  * @param[in] idleTime wait time for the state machine
193  */
194 static void IMD_SetState(
195  IMD_STATE_s *pImdState,
196  IMD_FSM_STATES_e nextState,
197  IMD_FSM_SUBSTATES_e nextSubstate,
198  uint16_t idleTime);
199 
200 /**
201  * @brief Sets the next substate and the timer value
202  * of the state variable.
203  * @param[in,out] pImdState state of the example state machine
204  * @param[in] nextSubstate substate to be transferred into
205  * @param[in] idleTime wait time for the state machine
206  */
207 static void IMD_SetSubstate(IMD_STATE_s *pImdState, IMD_FSM_SUBSTATES_e nextSubstate, uint16_t idleTime);
208 
209 /**
210  * @brief Defines the state transitions
211  * @details This function contains the implementation of the state
212  * machine, i.e., the sequence of states and substates.
213  * It is called by the trigger function every time
214  * the state machine timer has a non-zero value.
215  * @param[in,out] pImdState state of the example state machine
216  * @return Always #STD_OK
217  */
219 
220 /**
221  * @brief Evaluates measurement perform by IMD driver
222  * @details This function evaluates the insulation measurement performed by the
223  * selected IMD driver and updates the database entry.
224  * @param[in,out] pTableInsulationMonitoring pointer to insulation monitoring
225  * database entry
226  * @return Always #IMD_REQUEST_OK
227  */
229  DATA_BLOCK_INSULATION_MONITORING_s *pTableInsulationMonitoring);
230 
231 /*========== Static Function Implementations ================================*/
233  FAS_ASSERT(pImdState != NULL_PTR);
234  /* AXIVION Routine Generic-MissingParameterAssert: stateRequest: parameter accepts whole range */
236 
238  retVal = IMD_CheckStateRequest(pImdState, stateRequest);
239 
240  if (retVal == IMD_REQUEST_OK) {
241  pImdState->stateRequest = stateRequest;
242  }
244 
245  return retVal;
246 }
247 
249  FAS_ASSERT(pImdState != NULL_PTR);
250  /* AXIVION Routine Generic-MissingParameterAssert: stateRequest: parameter accepts whole range */
252  if (pImdState->stateRequest == IMD_STATE_NO_REQUEST) {
253  /* init only allowed from the uninitialized state */
254  if (stateRequest == IMD_STATE_INITIALIZE_REQUEST) {
255  if (pImdState->currentState == IMD_FSM_STATE_UNINITIALIZED) {
256  retval = IMD_REQUEST_OK;
257  } else {
258  retval = IMD_ALREADY_INITIALIZED;
259  }
260  } else if (stateRequest == IMD_STATE_SWITCH_ON_REQUEST) {
261  if (pImdState->currentState == IMD_FSM_STATE_SHUTDOWN) {
262  retval = IMD_REQUEST_OK;
263  } else if (pImdState->currentState == IMD_FSM_STATE_IMD_ENABLE) {
264  retval = IMD_REQUEST_OK;
265  } else {
266  retval = IMD_ILLEGAL_REQUEST;
267  }
268  } else {
269  retval = IMD_ILLEGAL_REQUEST;
270  }
271  } else {
272  /* Request pending */
273  }
274  return retval;
275 }
276 
278  FAS_ASSERT(pImdState != NULL_PTR);
280  IMD_STATE_REQUEST_e retval = pImdState->stateRequest;
281  pImdState->stateRequest = IMD_STATE_NO_REQUEST;
283  return retval;
284 }
285 
287  FAS_ASSERT(pImdState != NULL_PTR);
290  if (pImdState->triggerEntry == 0u) {
291  pImdState->triggerEntry++;
292  } else {
293  multipleCalls = IMD_MULTIPLE_CALLS_YES; /* multiple call of function IMD_Trigger for instance pImdState */
294  }
296  return multipleCalls;
297 }
298 
299 static void IMD_SetState(
300  IMD_STATE_s *pImdState,
301  IMD_FSM_STATES_e nextState,
302  IMD_FSM_SUBSTATES_e nextSubstate,
303  uint16_t idleTime) {
304  FAS_ASSERT(pImdState != NULL_PTR);
305  /* AXIVION Routine Generic-MissingParameterAssert: idleTime: parameter accepts whole range */
306  /* AXIVION Routine Generic-MissingParameterAssert: nextState: parameter accepts whole range */
307  /* AXIVION Routine Generic-MissingParameterAssert: nextSubstate: parameter accepts whole range */
308  bool earlyExit = false;
309 
310  pImdState->timer = idleTime;
311 
312  if ((pImdState->currentState == nextState) && (pImdState->currentSubstate == nextSubstate)) {
313  /* Next state and next substate equal to current state and substate: nothing to do */
314  pImdState->nextState = IMD_FSM_STATE_DUMMY; /* no state transistion required -> reset */
315  pImdState->nextSubstate = IMD_FSM_SUBSTATE_DUMMY; /* no substate transistion required -> reset */
316  earlyExit = true;
317  }
318 
319  if (earlyExit == false) {
320  if (pImdState->currentState != nextState) {
321  /* Next state is different: switch to it and set substate to entry value */
322  pImdState->previousState = pImdState->currentState;
323  pImdState->currentState = nextState;
324  pImdState->previousSubstate = pImdState->currentSubstate;
325  pImdState->currentSubstate = IMD_FSM_SUBSTATE_ENTRY; /* Use entry state after a top level state change */
326  pImdState->nextState = IMD_FSM_STATE_DUMMY; /* no state transistion required -> reset */
327  pImdState->nextSubstate = IMD_FSM_SUBSTATE_DUMMY; /* no substate transistion required -> reset */
328  } else if (pImdState->currentSubstate != nextSubstate) {
329  /* Only the next substate is different, switch to it */
330  IMD_SetSubstate(pImdState, nextSubstate, idleTime);
331  } else {
332  ;
333  }
334  }
335 }
336 
337 static void IMD_SetSubstate(IMD_STATE_s *pImdState, IMD_FSM_SUBSTATES_e nextSubstate, uint16_t idleTime) {
338  FAS_ASSERT(pImdState != NULL_PTR);
339  /* AXIVION Routine Generic-MissingParameterAssert: nextSubstate: parameter accepts whole range */
340  /* AXIVION Routine Generic-MissingParameterAssert: idleTime: parameter accepts whole range */
341  pImdState->timer = idleTime;
342  pImdState->previousSubstate = pImdState->currentSubstate;
343  pImdState->currentSubstate = nextSubstate;
344  pImdState->nextSubstate = IMD_FSM_SUBSTATE_DUMMY; /* substate has been set, now reset value for nextSubstate */
345 }
346 
348  FAS_ASSERT(pImdState != NULL_PTR);
349  STD_RETURN_TYPE_e ranStateMachine = STD_OK;
352  switch (pImdState->currentState) {
353  /********************************************** STATE: HAS NEVER RUN */
355  /* Nothing to do, just transfer */
357  break;
358 
359  /********************************************** STATE: UNINITIALIZED */
361  /* Transition to initialization state, one the state request has been received */
362  stateRequest = IMD_TransferStateRequest(pImdState);
363  if (stateRequest == IMD_STATE_INITIALIZE_REQUEST) {
365  } else {
366  /* Do nothing. Stay in state. */
367  }
368  break;
369 
370  /********************************************* STATE: INITIALIZATION */
372  nextState = IMD_ProcessInitializationState();
373  if (nextState == IMD_FSM_STATE_INITIALIZATION) {
374  /* staying in state, processed by state function */
375  } else if (nextState == IMD_FSM_STATE_ERROR) {
377  } else if (nextState == IMD_FSM_STATE_IMD_ENABLE) {
378  pImdState->information.isStatemachineInitialized = true;
380  } else {
381  FAS_ASSERT(FAS_TRAP); /* Something went wrong */
382  }
383  break;
384 
386  /* Transition to running state, once the state request has been received */
387  stateRequest = IMD_TransferStateRequest(pImdState);
388  if (stateRequest == IMD_STATE_SWITCH_ON_REQUEST) {
389  pImdState->information.switchImdDeviceOn = true;
390  }
391  if (pImdState->information.switchImdDeviceOn == true) {
392  nextState = IMD_ProcessEnableState();
393  if (nextState == IMD_FSM_STATE_RUNNING) {
394  /* Set flag that IMD is running. Do not update the database entry here. The database entry will be
395  * updated after first successful measurement in IMD_FSM_STATE_RUNNING state */
396  pImdState->pTableImd->isImdRunning = true;
397  pImdState->information.switchImdDeviceOn = false;
399  } else if (nextState == IMD_FSM_STATE_ERROR) {
401  } else {
402  /* Do nothing as the process to activate the IMD device is ongoing */
403  }
404  } else {
405  /* Do nothing. Stay in state. */
406  }
407  break;
408 
409  /**************************************************** STATE: RUNNING */
411  stateRequest = IMD_TransferStateRequest(pImdState);
412  if (stateRequest == IMD_STATE_SHUTDOWN_REQUEST) {
414  } else {
415  nextState = IMD_ProcessRunningState(pImdState->pTableImd);
416  /* Evaluate measurement results */
418  if (nextState == IMD_FSM_STATE_RUNNING) {
419  /* staying in state, processed by state function */
420  } else {
422  }
423  }
424  break;
425 
427  nextState = IMD_ProcessShutdownState();
428  if (nextState == IMD_FSM_STATE_IMD_ENABLE) {
429  /* Set flag, that IMD is deactivated. Update database entry */
430  pImdState->pTableImd->isImdRunning = false;
433  } else if (nextState == IMD_FSM_STATE_ERROR) {
435  } else {
436  /* staying in state, processed by state function */
437  }
438  break;
439 
440  /****************************************************** STATE: ERROR */
441  case IMD_FSM_STATE_ERROR:
442  /* Issue: 621 */
444  break;
445 
446  /**************************************************** STATE: DEFAULT */
447  default:
448  /* all cases must be processed, trap if unknown state arrives */
450  break;
451  }
452  /* Increment general purpose counter */
453  pImdState->counter++;
454  return ranStateMachine;
455 }
456 
458  DATA_BLOCK_INSULATION_MONITORING_s *pTableInsulationMonitoring) {
459  FAS_ASSERT(pTableInsulationMonitoring != NULL_PTR);
460  /* Assume resistance value as good if no valid measurement values are detected */
461  bool lowResistanceDetected = false;
462 
463  /* Check if measured resistance value is valid */
464  if (pTableInsulationMonitoring->isInsulationMeasurementValid == true) {
467  lowResistanceDetected = true;
468  }
469  } else {
471  }
472 
473  /* Check if flags of IMD are valid, e.g. status pin */
474  if (pTableInsulationMonitoring->areDeviceFlagsValid == true) {
475  if (pTableInsulationMonitoring->dfIsCriticalResistanceDetected == true) {
476  lowResistanceDetected = true;
477  }
478  if (pTableInsulationMonitoring->dfIsChassisFaultDetected == true) {
480  } else {
482  }
483  }
484 
485  /* Set diagnosis entry depending on measured insulation resistance and critical threshold flag */
486  if (lowResistanceDetected == true) {
488  } else {
490  }
491 
492  /* Set warning threshold flag depending on flag */
493  if (pTableInsulationMonitoring->dfIsWarnableResistanceDetected == true) {
495  } else {
497  }
498 
499  /* Write database entry */
500  DATA_WRITE_DATA(pTableInsulationMonitoring);
501 
502  /* Issue: 621 */
503 
504  return STD_OK;
505 }
506 
507 /*========== Extern Function Implementations ================================*/
510 }
511 
514 }
515 
518 }
519 
520 extern bool IMD_GetInitializationState(void) {
522 }
523 
525  bool earlyExit = false;
526  STD_RETURN_TYPE_e returnValue = STD_OK;
527 
528  /* Check multiple calls of function */
530  returnValue = STD_NOT_OK;
531  earlyExit = true;
532  }
533 
534  if (earlyExit == false) {
535  if (imd_state.timer > 0u) {
536  if ((--imd_state.timer) > 0u) {
538  returnValue = STD_OK;
539  earlyExit = true;
540  }
541  }
542  }
543 
544  if (earlyExit == false) {
547  }
548  return returnValue;
549 }
550 
551 /*========== Externalized Static Function Implementations (Unit Test) =======*/
IMD_FSM_STATES_e IMD_ProcessInitializationState(void)
Processes the initialization state.
Definition: bender_ir155.c:207
IMD_FSM_STATES_e IMD_ProcessShutdownState(void)
Processes the shutdown state.
Definition: bender_ir155.c:222
IMD_FSM_STATES_e IMD_ProcessEnableState(void)
Processes the IMD enable state.
Definition: bender_ir155.c:211
IMD_FSM_STATES_e IMD_ProcessRunningState(DATA_BLOCK_INSULATION_MONITORING_s *pTableInsulationMonitoring)
Processes the running state.
Definition: bender_ir155.c:217
#define DATA_WRITE_DATA(...)
Definition: database.h:93
@ DATA_BLOCK_ID_INSULATION_MONITORING
Definition: database_cfg.h:104
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.
Definition: diag.c:229
Diagnosis driver header.
@ DIAG_EVENT_NOT_OK
Definition: diag_cfg.h:239
@ DIAG_EVENT_OK
Definition: diag_cfg.h:238
@ DIAG_SYSTEM
Definition: diag_cfg.h:251
@ DIAG_ID_INSULATION_MEASUREMENT_VALID
Definition: diag_cfg.h:227
@ DIAG_ID_INSULATION_GROUND_ERROR
Definition: diag_cfg.h:230
@ DIAG_ID_LOW_INSULATION_RESISTANCE_ERROR
Definition: diag_cfg.h:228
@ DIAG_ID_LOW_INSULATION_RESISTANCE_WARNING
Definition: diag_cfg.h:229
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
Definition: fassert.h:237
#define FAS_TRAP
Define that evaluates to essential boolean false thus tripping an assert.
Definition: fassert.h:115
STD_RETURN_TYPE_e
Definition: fstd_types.h:81
@ STD_NOT_OK
Definition: fstd_types.h:83
@ STD_OK
Definition: fstd_types.h:82
#define NULL_PTR
Null pointer.
Definition: fstd_types.h:76
IMD_RETURN_TYPE_e IMD_RequestInsulationMeasurement(void)
Request to activate the actual IMD measurement.
Definition: imd.c:512
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:299
IMD_FSM_SUBSTATES_e
Definition: imd.c:75
@ IMD_FSM_SUBSTATE_RUNNING_0
Definition: imd.c:81
@ IMD_FSM_SUBSTATE_RUNNING_1
Definition: imd.c:82
@ IMD_FSM_SUBSTATE_INITIALIZATION_EXIT
Definition: imd.c:80
@ IMD_FSM_SUBSTATE_RUNNING_2
Definition: imd.c:83
@ IMD_FSM_SUBSTATE_DUMMY
Definition: imd.c:76
@ IMD_FSM_SUBSTATE_ENTRY
Definition: imd.c:77
@ IMD_FSM_SUBSTATE_INITIALIZATION_1
Definition: imd.c:79
@ IMD_FSM_SUBSTATE_INITIALIZATION_0
Definition: imd.c:78
bool IMD_GetInitializationState(void)
Gets the initialization state.
Definition: imd.c:520
static DATA_BLOCK_INSULATION_MONITORING_s imd_tableInsulationMonitoring
Definition: imd.c:115
static STD_RETURN_TYPE_e IMD_EvaluateInsulationMeasurement(DATA_BLOCK_INSULATION_MONITORING_s *pTableInsulationMonitoring)
Evaluates measurement perform by IMD driver.
Definition: imd.c:457
STD_RETURN_TYPE_e IMD_Trigger(void)
trigger function for the IMD driver state machine.
Definition: imd.c:524
static IMD_STATE_s imd_state
Definition: imd.c:118
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:248
IMD_CHECK_MULTIPLE_CALLS_e
Definition: imd.c:87
@ IMD_MULTIPLE_CALLS_NO
Definition: imd.c:88
@ IMD_MULTIPLE_CALLS_YES
Definition: imd.c:89
#define IMD_FSM_SHORT_TIME
Definition: imd.c:72
static IMD_CHECK_MULTIPLE_CALLS_e IMD_CheckMultipleCalls(IMD_STATE_s *pImdState)
check for multiple calls of state machine trigger function
Definition: imd.c:286
static STD_RETURN_TYPE_e IMD_RunStateMachine(IMD_STATE_s *pImdState)
Defines the state transitions.
Definition: imd.c:347
IMD_RETURN_TYPE_e IMD_RequestMeasurementStop(void)
Request to deactivate the actual IMD measurement.
Definition: imd.c:516
IMD_RETURN_TYPE_e IMD_RequestInitialization(void)
Request initialization of IMD statemachine.
Definition: imd.c:508
static IMD_STATE_REQUEST_e IMD_TransferStateRequest(IMD_STATE_s *pImdState)
transfers the current state request to the state machine.
Definition: imd.c:277
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:337
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:232
API header for the insulation monitoring device.
IMD_FSM_STATES_e
Definition: imd.h:92
@ IMD_FSM_STATE_RUNNING
Definition: imd.h:99
@ IMD_FSM_STATE_SHUTDOWN
Definition: imd.h:98
@ IMD_FSM_STATE_INITIALIZATION
Definition: imd.h:96
@ IMD_FSM_STATE_HAS_NEVER_RUN
Definition: imd.h:94
@ IMD_FSM_STATE_IMD_ENABLE
Definition: imd.h:97
@ IMD_FSM_STATE_DUMMY
Definition: imd.h:93
@ IMD_FSM_STATE_UNINITIALIZED
Definition: imd.h:95
@ IMD_FSM_STATE_ERROR
Definition: imd.h:100
IMD_STATE_REQUEST_e
Definition: imd.h:84
@ IMD_STATE_SWITCH_ON_REQUEST
Definition: imd.h:86
@ IMD_STATE_SHUTDOWN_REQUEST
Definition: imd.h:87
@ IMD_STATE_INITIALIZE_REQUEST
Definition: imd.h:85
@ IMD_STATE_NO_REQUEST
Definition: imd.h:88
IMD_RETURN_TYPE_e
Definition: imd.h:76
@ IMD_ALREADY_INITIALIZED
Definition: imd.h:80
@ IMD_ILLEGAL_REQUEST
Definition: imd.h:79
@ IMD_REQUEST_PENDING
Definition: imd.h:78
@ IMD_REQUEST_OK
Definition: imd.h:77
#define IMD_ERROR_THRESHOLD_INSULATION_RESISTANCE_kOhm
Definition: imd.h:70
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:135
void OS_EnterTaskCritical(void)
Enter Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.
Definition: os_freertos.c:131
DATA_BLOCK_ID_e uniqueId
Definition: database_cfg.h:119
bool isStatemachineInitialized
Definition: imd.c:94
bool switchImdDeviceOn
Definition: imd.c:95
DATA_BLOCK_INSULATION_MONITORING_s * pTableImd
Definition: imd.c:111
IMD_FSM_STATES_e previousState
Definition: imd.c:106
IMD_INFORMATION_s information
Definition: imd.c:110
IMD_FSM_SUBSTATES_e previousSubstate
Definition: imd.c:109
IMD_FSM_STATES_e nextState
Definition: imd.c:104
IMD_STATE_REQUEST_e stateRequest
Definition: imd.c:103
IMD_FSM_SUBSTATES_e nextSubstate
Definition: imd.c:107
uint8_t triggerEntry
Definition: imd.c:102
IMD_FSM_SUBSTATES_e currentSubstate
Definition: imd.c:108
uint8_t counter
Definition: imd.c:100
IMD_FSM_STATES_e currentState
Definition: imd.c:105
uint16_t timer
Definition: imd.c:101