foxBMS - Unit Tests  1.3.0
The foxBMS Unit Tests API Documentation
imd.h File Reference

API header for the insulation monitoring device. More...

#include "general.h"
#include "can_cfg.h"
#include "ftask_cfg.h"
#include "database.h"
Include dependency graph for imd.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define IMD_PERIODIC_CALL_TIME_ms   (FTSK_TASK_CYCLIC_100MS_CYCLE_TIME)
 
#define IMD_ERROR_THRESHOLD_INSULATION_RESISTANCE_kOhm   (500u)
 
#define IMD_WARNING_THRESHOLD_INSULATION_RESISTANCE_kOhm   (750u)
 

Enumerations

enum  IMD_RETURN_TYPE_e { IMD_REQUEST_OK , IMD_REQUEST_PENDING , IMD_ILLEGAL_REQUEST , IMD_ALREADY_INITIALIZED }
 
enum  IMD_STATE_REQUEST_e { IMD_STATE_INITIALIZE_REQUEST , IMD_STATE_SWITCH_ON_REQUEST , IMD_STATE_SHUTDOWN_REQUEST , IMD_STATE_NO_REQUEST }
 
enum  IMD_FSM_STATES_e {
  IMD_FSM_STATE_DUMMY , IMD_FSM_STATE_HAS_NEVER_RUN , IMD_FSM_STATE_UNINITIALIZED , IMD_FSM_STATE_INITIALIZATION ,
  IMD_FSM_STATE_IMD_ENABLE , IMD_FSM_STATE_SHUTDOWN , IMD_FSM_STATE_RUNNING , IMD_FSM_STATE_ERROR
}
 

Functions

IMD_RETURN_TYPE_e IMD_RequestInitialization (void)
 Request initialization of IMD statemachine. More...
 
IMD_RETURN_TYPE_e IMD_RequestInsulationMeasurement (void)
 Request to activate the actual IMD measurement. More...
 
IMD_RETURN_TYPE_e IMD_RequestMeasurementStop (void)
 Request to deactivate the actual IMD measurement. More...
 
bool IMD_GetInitializationState (void)
 Gets the initialization state. More...
 
STD_RETURN_TYPE_e IMD_Trigger (void)
 trigger function for the IMD driver state machine. 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...
 

Detailed Description

API header for the insulation monitoring device.

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:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

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:

  • ″This product uses parts of foxBMS®″
  • ″This product includes parts of foxBMS®″
  • ″This product is derived from foxBMS®″
Author
foxBMS Team
Date
2020-11-20 (date of creation)
Updated
2022-05-30 (date of last update)
Version
v1.3.0
Prefix
IMD

Definition in file imd.h.

Macro Definition Documentation

◆ IMD_ERROR_THRESHOLD_INSULATION_RESISTANCE_kOhm

#define IMD_ERROR_THRESHOLD_INSULATION_RESISTANCE_kOhm   (500u)

Minimum required insulation resistance - Error threshold

Definition at line 70 of file imd.h.

◆ IMD_PERIODIC_CALL_TIME_ms

#define IMD_PERIODIC_CALL_TIME_ms   (FTSK_TASK_CYCLIC_100MS_CYCLE_TIME)

Definition at line 67 of file imd.h.

◆ IMD_WARNING_THRESHOLD_INSULATION_RESISTANCE_kOhm

#define IMD_WARNING_THRESHOLD_INSULATION_RESISTANCE_kOhm   (750u)

Minimum required insulation resistance - Warning threshold

Definition at line 73 of file imd.h.

Enumeration Type Documentation

◆ IMD_FSM_STATES_e

States of the state machine

Enumerator
IMD_FSM_STATE_DUMMY 

dummy state - always the first state

IMD_FSM_STATE_HAS_NEVER_RUN 

never run state - always the second state

IMD_FSM_STATE_UNINITIALIZED 

uninitialized state

IMD_FSM_STATE_INITIALIZATION 

initializing the state machine

IMD_FSM_STATE_IMD_ENABLE 

switch on IMD

IMD_FSM_STATE_SHUTDOWN 

shut down state of IMD state machine

IMD_FSM_STATE_RUNNING 

operational mode of the state machine

IMD_FSM_STATE_ERROR 

state for error processing

Definition at line 92 of file imd.h.

◆ IMD_RETURN_TYPE_e

Possible return values when state requests are made to the IMD statemachine

Enumerator
IMD_REQUEST_OK 

request was successful

IMD_REQUEST_PENDING 

requested to be executed

IMD_ILLEGAL_REQUEST 

Request can not be executed

IMD_ALREADY_INITIALIZED 

IMD statemachine already initialized

Definition at line 76 of file imd.h.

◆ IMD_STATE_REQUEST_e

State requests for the IMD statemachine

Enumerator
IMD_STATE_INITIALIZE_REQUEST 

request for initialization

IMD_STATE_SWITCH_ON_REQUEST 

request to switch on IMD device

IMD_STATE_SHUTDOWN_REQUEST 

request for shut down

IMD_STATE_NO_REQUEST 

dummy request for no request

Definition at line 84 of file imd.h.

Function Documentation

◆ IMD_GetInitializationState()

bool IMD_GetInitializationState ( void  )

Gets the initialization state.

This function is used for getting the IMD initialization state.

Returns
true if statemachine initialized, otherwise false

Definition at line 520 of file imd.c.

◆ IMD_ProcessEnableState()

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.

Returns
IMD_FSM_STATE_RUNNING if startup has been completed. Returns IMD_FSM_STATE_ERROR if an error is detected that prohibits a working IMD driver.

Definition at line 211 of file bender_ir155.c.

Here is the call graph for this function:

◆ IMD_ProcessInitializationState()

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.

Returns
IMD_FSM_STATE_INITIALIZATION if initialization not fininished and another call is required. IMD_FSM_STATE_IMD_ENABLE if initialization is finished and IMD_FSM_STATE_ERROR if an error is detected that prohibits a working IMD driver.

Definition at line 207 of file bender_ir155.c.

Here is the call graph for this function:

◆ IMD_ProcessRunningState()

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

Parameters
pTableInsulationMonitoringpointer to insulation monitoring database entry
Returns
IMD_FSM_STATE_RUNNING if measurement works as expected, otherwise IMD_FSM_STATE_ERROR if an error is detected that prohibits a further execution of the IMD driver.

Definition at line 217 of file bender_ir155.c.

Here is the call graph for this function:

◆ IMD_ProcessShutdownState()

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.

Returns
IMD_FSM_STATE_SHUTDOWN if shutdown state is not fininished and another call is required. IMD_FSM_STATE_IMD_ENABLE if shut down has been completed and IMD_FSM_STATE_ERROR if an error is detected that prohibits a working IMD driver.

Definition at line 222 of file bender_ir155.c.

Here is the call graph for this function:

◆ IMD_RequestInitialization()

IMD_RETURN_TYPE_e IMD_RequestInitialization ( void  )

Request initialization of IMD statemachine.

Returns
Always IMD_REQUEST_OK

Definition at line 508 of file imd.c.

Here is the call graph for this function:

◆ IMD_RequestInsulationMeasurement()

IMD_RETURN_TYPE_e IMD_RequestInsulationMeasurement ( void  )

Request to activate the actual IMD measurement.

Returns
Always IMD_REQUEST_OK

Definition at line 512 of file imd.c.

Here is the call graph for this function:

◆ IMD_RequestMeasurementStop()

IMD_RETURN_TYPE_e IMD_RequestMeasurementStop ( void  )

Request to deactivate the actual IMD measurement.

Returns
Always IMD_REQUEST_OK

Definition at line 516 of file imd.c.

Here is the call graph for this function:

◆ IMD_Trigger()

STD_RETURN_TYPE_e IMD_Trigger ( void  )

trigger function for the IMD driver state machine.

This function contains the sequence of events in the IMD state machine. It must be called time-triggered, every 100ms.

Returns
returns STD_OK if trigger called successfully

Definition at line 524 of file imd.c.

Here is the call graph for this function: