foxBMS  1.4.1
The foxBMS Battery Management System 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-10-27 (date of last update)
47  * @version v1.4.1
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  * state machine 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 
118 /** global IMD state */
120  .timer = 0u,
121  .triggerEntry = 0u,
122  .nextState = IMD_FSM_STATE_DUMMY,
123  .stateRequest = IMD_STATE_NO_REQUEST,
124  .currentState = IMD_FSM_STATE_HAS_NEVER_RUN,
125  .previousState = IMD_FSM_STATE_DUMMY,
126  .nextSubstate = IMD_FSM_SUBSTATE_DUMMY,
127  .currentSubstate = IMD_FSM_SUBSTATE_DUMMY,
128  .previousSubstate = IMD_FSM_SUBSTATE_DUMMY,
129  .information.isStatemachineInitialized = false,
130  .information.switchImdDeviceOn = false,
131  .pTableImd = &imd_tableInsulationMonitoring,
132 };
133 
134 /*========== Extern Constant and Variable Definitions =======================*/
135 
136 /*========== Static Function Prototypes =====================================*/
137 /**
138  * @brief sets the current state request of the state variable #imd_state.
139  * @details This function is used to make a state request to the state machine,
140  * e.g, initialize state machine or shut-down state machine.
141  * It calls #IMD_CheckStateRequest() to check if the request is valid.
142  * The state request is rejected if is not valid. The result of the
143  * check is returned immediately, so that the requester can act in
144  * case it made a non-valid state request.
145  * @param[in] stateRequest state request to set
146  * @param[in,out] pImdState pointer to state variable of IMD state machine
147  * @return OK if request has been accepted, otherwise error reason
148  */
150 
151 /**
152  * @brief checks the state requests that are made.
153  * @details This function checks the validity of the state requests. The
154  * results of the checked state request is returned immediately.
155  * @param[in] stateRequest state request to be checked
156  * @param[in,out] pImdState pointer to state variable of IMD state machine
157  * @return result of the state request that was made
158  */
160 
161 /**
162  * @brief transfers the current state request to the state machine.
163  * @details This function takes the current state request from #imd_state
164  * transfers it to the state machine. It resets the value from
165  * #imd_state to #IMD_STATE_NO_REQUEST
166  * @param[in,out] pImdState pointer to state variable of IMD state machine
167  * @return current state request
168  */
170 
171 /**
172  * @brief check for multiple calls of state machine trigger function
173  * @details The trigger function is not reentrant, which means it cannot
174  * be called multiple times. This functions increments the
175  * triggerEntry counter once and must be called each time the
176  * trigger function is called. If triggerEntry is greater than
177  * one, there were multiple calls. For this function to work,
178  * triggerEntry must be decremented each time the trigger function
179  * is called, even if no processing do because the timer is
180  * non-zero.
181  * @param[in,out] pImdState pointer to state variable of IMD state machine
182  * @return #IMD_MULTIPLE_CALLS_YES if there were multiple calls,
183  * #IMD_MULTIPLE_CALLS_NO otherwise
184  */
186 
187 /**
188  * @brief Sets the next state, the next substate and the timer value
189  * of the state variable.
190  * @param[in,out] pImdState state of the example state machine
191  * @param[in] nextState state to be transferred into
192  * @param[in] nextSubstate substate to be transferred into
193  * @param[in] idleTime wait time for the state machine
194  */
195 static void IMD_SetState(
196  IMD_STATE_s *pImdState,
197  IMD_FSM_STATES_e nextState,
198  IMD_FSM_SUBSTATES_e nextSubstate,
199  uint16_t idleTime);
200 
201 /**
202  * @brief Sets the next substate and the timer value
203  * of the state variable.
204  * @param[in,out] pImdState state of the example state machine
205  * @param[in] nextSubstate substate to be transferred into
206  * @param[in] idleTime wait time for the state machine
207  */
208 static void IMD_SetSubstate(IMD_STATE_s *pImdState, IMD_FSM_SUBSTATES_e nextSubstate, uint16_t idleTime);
209 
210 /**
211  * @brief Defines the state transitions
212  * @details This function contains the implementation of the state
213  * machine, i.e., the sequence of states and substates.
214  * It is called by the trigger function every time
215  * the state machine timer has a non-zero value.
216  * @param[in,out] pImdState state of the example state machine
217  * @return Always #STD_OK
218  */
220 
221 /**
222  * @brief Evaluates measurement perform by IMD driver
223  * @details This function evaluates the insulation measurement performed by the
224  * selected IMD driver and updates the database entry.
225  * @param[in,out] pTableInsulationMonitoring pointer to insulation monitoring
226  * database entry
227  * @return Always #IMD_REQUEST_OK
228  */
230  DATA_BLOCK_INSULATION_MONITORING_s *pTableInsulationMonitoring);
231 
232 /*========== Static Function Implementations ================================*/
234  FAS_ASSERT(pImdState != NULL_PTR);
235  /* AXIVION Routine Generic-MissingParameterAssert: stateRequest: parameter accepts whole range */
237 
239  retVal = IMD_CheckStateRequest(pImdState, stateRequest);
240 
241  if (retVal == IMD_REQUEST_OK) {
242  pImdState->stateRequest = stateRequest;
243  }
245 
246  return retVal;
247 }
248 
250  FAS_ASSERT(pImdState != NULL_PTR);
251  /* AXIVION Routine Generic-MissingParameterAssert: stateRequest: parameter accepts whole range */
253  if (pImdState->stateRequest == IMD_STATE_NO_REQUEST) {
254  /* init only allowed from the uninitialized state */
255  if (stateRequest == IMD_STATE_INITIALIZE_REQUEST) {
256  if (pImdState->currentState == IMD_FSM_STATE_UNINITIALIZED) {
257  retval = IMD_REQUEST_OK;
258  } else {
259  retval = IMD_ALREADY_INITIALIZED;
260  }
261  } else if (stateRequest == IMD_STATE_SWITCH_ON_REQUEST) {
262  if (pImdState->currentState == IMD_FSM_STATE_SHUTDOWN) {
263  retval = IMD_REQUEST_OK;
264  } else if (pImdState->currentState == IMD_FSM_STATE_IMD_ENABLE) {
265  retval = IMD_REQUEST_OK;
266  } else {
267  retval = IMD_ILLEGAL_REQUEST;
268  }
269  } else {
270  retval = IMD_ILLEGAL_REQUEST;
271  }
272  } else {
273  /* Request pending */
274  }
275  return retval;
276 }
277 
279  FAS_ASSERT(pImdState != NULL_PTR);
281  IMD_STATE_REQUEST_e retval = pImdState->stateRequest;
282  pImdState->stateRequest = IMD_STATE_NO_REQUEST;
284  return retval;
285 }
286 
288  FAS_ASSERT(pImdState != NULL_PTR);
291  if (pImdState->triggerEntry == 0u) {
292  pImdState->triggerEntry++;
293  } else {
294  multipleCalls = IMD_MULTIPLE_CALLS_YES; /* multiple call of function IMD_Trigger for instance pImdState */
295  }
297  return multipleCalls;
298 }
299 
300 static void IMD_SetState(
301  IMD_STATE_s *pImdState,
302  IMD_FSM_STATES_e nextState,
303  IMD_FSM_SUBSTATES_e nextSubstate,
304  uint16_t idleTime) {
305  FAS_ASSERT(pImdState != NULL_PTR);
306  /* AXIVION Routine Generic-MissingParameterAssert: idleTime: parameter accepts whole range */
307  /* AXIVION Routine Generic-MissingParameterAssert: nextState: parameter accepts whole range */
308  /* AXIVION Routine Generic-MissingParameterAssert: nextSubstate: parameter accepts whole range */
309  bool earlyExit = false;
310 
311  pImdState->timer = idleTime;
312 
313  if ((pImdState->currentState == nextState) && (pImdState->currentSubstate == nextSubstate)) {
314  /* Next state and next substate equal to current state and substate: nothing to do */
315  pImdState->nextState = IMD_FSM_STATE_DUMMY; /* no state transistion required -> reset */
316  pImdState->nextSubstate = IMD_FSM_SUBSTATE_DUMMY; /* no substate transistion required -> reset */
317  earlyExit = true;
318  }
319 
320  if (earlyExit == false) {
321  if (pImdState->currentState != nextState) {
322  /* Next state is different: switch to it and set substate to entry value */
323  pImdState->previousState = pImdState->currentState;
324  pImdState->currentState = nextState;
325  pImdState->previousSubstate = pImdState->currentSubstate;
326  pImdState->currentSubstate = IMD_FSM_SUBSTATE_ENTRY; /* Use entry state after a top level state change */
327  pImdState->nextState = IMD_FSM_STATE_DUMMY; /* no state transistion required -> reset */
328  pImdState->nextSubstate = IMD_FSM_SUBSTATE_DUMMY; /* no substate transistion required -> reset */
329  } else if (pImdState->currentSubstate != nextSubstate) {
330  /* Only the next substate is different, switch to it */
331  IMD_SetSubstate(pImdState, nextSubstate, idleTime);
332  } else {
333  ;
334  }
335  }
336 }
337 
338 static void IMD_SetSubstate(IMD_STATE_s *pImdState, IMD_FSM_SUBSTATES_e nextSubstate, uint16_t idleTime) {
339  FAS_ASSERT(pImdState != NULL_PTR);
340  /* AXIVION Routine Generic-MissingParameterAssert: nextSubstate: parameter accepts whole range */
341  /* AXIVION Routine Generic-MissingParameterAssert: idleTime: parameter accepts whole range */
342  pImdState->timer = idleTime;
343  pImdState->previousSubstate = pImdState->currentSubstate;
344  pImdState->currentSubstate = nextSubstate;
345  pImdState->nextSubstate = IMD_FSM_SUBSTATE_DUMMY; /* substate has been set, now reset value for nextSubstate */
346 }
347 
349  FAS_ASSERT(pImdState != NULL_PTR);
350  STD_RETURN_TYPE_e ranStateMachine = STD_OK;
353  switch (pImdState->currentState) {
354  /********************************************** STATE: HAS NEVER RUN */
356  /* Nothing to do, just transfer */
358  break;
359 
360  /********************************************** STATE: UNINITIALIZED */
362  /* Transition to initialization state, one the state request has been received */
363  stateRequest = IMD_TransferStateRequest(pImdState);
364  if (stateRequest == IMD_STATE_INITIALIZE_REQUEST) {
366  } else {
367  /* Do nothing. Stay in state. */
368  }
369  break;
370 
371  /********************************************* STATE: INITIALIZATION */
373  nextState = IMD_ProcessInitializationState();
374  if (nextState == IMD_FSM_STATE_INITIALIZATION) {
375  /* staying in state, processed by state function */
376  } else if (nextState == IMD_FSM_STATE_ERROR) {
378  } else if (nextState == IMD_FSM_STATE_IMD_ENABLE) {
379  pImdState->information.isStatemachineInitialized = true;
381  } else {
382  FAS_ASSERT(FAS_TRAP); /* Something went wrong */
383  }
384  break;
385 
387  /* Transition to running state, once the state request has been received */
388  stateRequest = IMD_TransferStateRequest(pImdState);
389  if (stateRequest == IMD_STATE_SWITCH_ON_REQUEST) {
390  pImdState->information.switchImdDeviceOn = true;
391  }
392  if (pImdState->information.switchImdDeviceOn == true) {
393  nextState = IMD_ProcessEnableState();
394  if (nextState == IMD_FSM_STATE_RUNNING) {
395  /* Set flag that IMD is running. Do not update the database entry here. The database entry will be
396  * updated after first successful measurement in IMD_FSM_STATE_RUNNING state */
397  pImdState->pTableImd->isImdRunning = true;
398  pImdState->information.switchImdDeviceOn = false;
400  } else if (nextState == IMD_FSM_STATE_ERROR) {
402  } else {
403  /* Do nothing as the process to activate the IMD device is ongoing */
404  }
405  } else {
406  /* Do nothing. Stay in state. */
407  }
408  break;
409 
410  /**************************************************** STATE: RUNNING */
412  stateRequest = IMD_TransferStateRequest(pImdState);
413  if (stateRequest == IMD_STATE_SHUTDOWN_REQUEST) {
415  } else {
416  nextState = IMD_ProcessRunningState(pImdState->pTableImd);
417  /* Evaluate measurement results */
419  if (nextState == IMD_FSM_STATE_RUNNING) {
420  /* staying in state, processed by state function */
421  } else {
423  }
424  }
425  break;
426 
428  nextState = IMD_ProcessShutdownState();
429  if (nextState == IMD_FSM_STATE_IMD_ENABLE) {
430  /* Set flag, that IMD is deactivated. Update database entry */
431  pImdState->pTableImd->isImdRunning = false;
434  } else if (nextState == IMD_FSM_STATE_ERROR) {
436  } else {
437  /* staying in state, processed by state function */
438  }
439  break;
440 
441  /****************************************************** STATE: ERROR */
442  case IMD_FSM_STATE_ERROR:
443  /* Issue: 621 */
445  break;
446 
447  /**************************************************** STATE: DEFAULT */
448  default:
449  /* all cases must be processed, trap if unknown state arrives */
451  break;
452  }
453  /* Increment general purpose counter */
454  pImdState->counter++;
455  return ranStateMachine;
456 }
457 
459  DATA_BLOCK_INSULATION_MONITORING_s *pTableInsulationMonitoring) {
460  FAS_ASSERT(pTableInsulationMonitoring != NULL_PTR);
461  /* Assume resistance value as good if no valid measurement values are detected */
462  bool lowResistanceDetected = false;
463 
464  /* Check if measured resistance value is valid */
465  if (pTableInsulationMonitoring->isInsulationMeasurementValid == true) {
468  lowResistanceDetected = true;
469  }
470  } else {
472  }
473 
474  /* Check if flags of IMD are valid, e.g. status pin */
475  if (pTableInsulationMonitoring->areDeviceFlagsValid == true) {
476  if (pTableInsulationMonitoring->dfIsCriticalResistanceDetected == true) {
477  lowResistanceDetected = true;
478  }
479  if (pTableInsulationMonitoring->dfIsChassisFaultDetected == true) {
481  } else {
483  }
484  }
485 
486  /* Set diagnosis entry depending on measured insulation resistance and critical threshold flag */
487  if (lowResistanceDetected == true) {
489  } else {
491  }
492 
493  /* Set warning threshold flag depending on flag */
494  if (pTableInsulationMonitoring->dfIsWarnableResistanceDetected == true) {
496  } else {
498  }
499 
500  /* Write database entry */
501  DATA_WRITE_DATA(pTableInsulationMonitoring);
502 
503  /* Issue: 621 */
504 
505  return STD_OK;
506 }
507 
508 /*========== Extern Function Implementations ================================*/
511 }
512 
515 }
516 
519 }
520 
521 extern bool IMD_GetInitializationState(void) {
523 }
524 
526  bool earlyExit = false;
527  STD_RETURN_TYPE_e returnValue = STD_OK;
528 
529  /* Check multiple calls of function */
531  returnValue = STD_NOT_OK;
532  earlyExit = true;
533  }
534 
535  if (earlyExit == false) {
536  if (imd_state.timer > 0u) {
537  if ((--imd_state.timer) > 0u) {
539  returnValue = STD_OK;
540  earlyExit = true;
541  }
542  }
543  }
544 
545  if (earlyExit == false) {
548  }
549  return returnValue;
550 }
551 
552 /*========== 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 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:243
Diagnosis driver header.
@ DIAG_EVENT_NOT_OK
Definition: diag_cfg.h:258
@ DIAG_EVENT_OK
Definition: diag_cfg.h:257
@ DIAG_SYSTEM
Definition: diag_cfg.h:270
@ DIAG_ID_INSULATION_MEASUREMENT_VALID
Definition: diag_cfg.h:245
@ DIAG_ID_INSULATION_GROUND_ERROR
Definition: diag_cfg.h:248
@ DIAG_ID_LOW_INSULATION_RESISTANCE_ERROR
Definition: diag_cfg.h:246
@ DIAG_ID_LOW_INSULATION_RESISTANCE_WARNING
Definition: diag_cfg.h:247
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
Definition: fassert.h:252
#define FAS_TRAP
Define that evaluates to essential boolean false thus tripping an assert.
Definition: fassert.h:126
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:513
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:300
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:521
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:458
STD_RETURN_TYPE_e IMD_Trigger(void)
trigger function for the IMD driver state machine.
Definition: imd.c:525
static IMD_STATE_s imd_state
Definition: imd.c:119
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:249
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:287
static STD_RETURN_TYPE_e IMD_RunStateMachine(IMD_STATE_s *pImdState)
Defines the state transitions.
Definition: imd.c:348
IMD_RETURN_TYPE_e IMD_RequestMeasurementStop(void)
Request to deactivate the actual IMD measurement.
Definition: imd.c:517
IMD_RETURN_TYPE_e IMD_RequestInitialization(void)
Request initialization of IMD statemachine.
Definition: imd.c:509
static IMD_STATE_REQUEST_e IMD_TransferStateRequest(IMD_STATE_s *pImdState)
transfers the current state request to the state machine.
Definition: imd.c:278
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:338
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:233
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