foxBMS - Unit Tests  1.6.0
The foxBMS Unit Tests API Documentation
interlock.c File Reference

Driver for the interlock. More...

#include "interlock.h"
#include "database.h"
#include "diag.h"
#include "io.h"
#include "os.h"
#include <stdbool.h>
#include <stdint.h>
Include dependency graph for interlock.c:

Go to the source code of this file.

Macros

#define ILCK_SAVELASTSTATES()
 

Functions

static ILCK_RETURN_TYPE_e ILCK_CheckStateRequest (ILCK_STATE_REQUEST_e statereq)
 checks the state requests that are made. More...
 
static ILCK_STATE_REQUEST_e ILCK_TransferStateRequest (void)
 transfers the current state request to the state machine. More...
 
static uint8_t ILCK_CheckReEntrance (void)
 re-entrance check of ILCK state machine trigger function More...
 
static void ILCK_InitializePins (void)
 Initializes required pins for interlock evaluation. More...
 
static ILCK_ELECTRICAL_STATE_TYPE_e ILCK_GetInterlockFeedback (void)
 Reads the feedback pin of the interlock and returns its current value (ILCK_SWITCH_OFF/ILCK_SWITCH_ON) More...
 
ILCK_STATEMACH_e ILCK_GetState (void)
 gets the current state. More...
 
ILCK_RETURN_TYPE_e ILCK_SetStateRequest (ILCK_STATE_REQUEST_e statereq)
 sets the current state request of the state variable ilck_state. More...
 
void ILCK_Trigger (void)
 trigger function for the ILCK driver state machine. More...
 
void TEST_ILCK_SetStateStruct (ILCK_STATE_s state)
 
ILCK_ELECTRICAL_STATE_TYPE_e TEST_ILCK_GetInterlockFeedback (void)
 

Variables

static ILCK_STATE_s ilck_state
 
static DATA_BLOCK_INTERLOCK_FEEDBACK_s ilck_tableFeedback = {.header.uniqueId = DATA_BLOCK_ID_INTERLOCK_FEEDBACK}
 

Detailed Description

Driver for the interlock.

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-02-24 (date of creation)
Updated
2023-10-12 (date of last update)
Version
v1.6.0
Prefix
ILCK

The interlock driver measures the relevant hardware signals from the interlock circuit. For details on available hardware signals please refer to the section on this module in the foxBMS documentation.

In reference to the names in the foxBMS schematic, this module uses the following names:

shorthand meaning
IL interlock
HS high-side
LS low-side
VS voltage sense
CS current sense

Definition in file interlock.c.

Macro Definition Documentation

◆ ILCK_SAVELASTSTATES

#define ILCK_SAVELASTSTATES ( )
Value:
ilck_state.lastsubstate = ilck_state.substate
static ILCK_STATE_s ilck_state
Definition: interlock.c:93
ILCK_STATEMACH_e state
Definition: interlock.h:107
ILCK_STATEMACH_e laststate
Definition: interlock.h:109
ILCK_STATEMACH_SUB_e substate
Definition: interlock.h:108

Saves the last state and the last substate

Definition at line 85 of file interlock.c.

Function Documentation

◆ ILCK_CheckReEntrance()

static uint8_t ILCK_CheckReEntrance ( void  )
static

re-entrance check of ILCK state machine trigger function

This function is not re-entrant and should only be called time- or event-triggered. It increments the triggerentry counter from the state variable ilck_state. It should never be called by two different processes, so if it is the case, triggerentry should never be higher than 0 when this function is called.

Returns
0 if no further instance of the function is active, 0xFF else

Definition at line 184 of file interlock.c.

Here is the call graph for this function:

◆ ILCK_CheckStateRequest()

static ILCK_RETURN_TYPE_e ILCK_CheckStateRequest ( ILCK_STATE_REQUEST_e  statereq)
static

checks the state requests that are made.

This function checks the validity of the state requests. The results of the checked is returned immediately.

Parameters
statereqstate request to be checked
Returns
result of the state request that was made, taken from ILCK_RETURN_TYPE_e

Definition at line 154 of file interlock.c.

◆ ILCK_GetInterlockFeedback()

static ILCK_ELECTRICAL_STATE_TYPE_e ILCK_GetInterlockFeedback ( void  )
static

Reads the feedback pin of the interlock and returns its current value (ILCK_SWITCH_OFF/ILCK_SWITCH_ON)

Returns
measuredInterlockState (type: ILCK_ELECTRICAL_STATE_TYPE_e)

Local variable containing voltages measured on TMS570 ADC1 inputs

Pin low: interlock closed, pin high: interlock open

Definition at line 207 of file interlock.c.

Here is the call graph for this function:

◆ ILCK_GetState()

ILCK_STATEMACH_e ILCK_GetState ( void  )

gets the current state.

This function is used in the functioning of the ILCK state machine.

Returns
current state, taken from ILCK_STATEMACH_e

Definition at line 250 of file interlock.c.

◆ ILCK_InitializePins()

static void ILCK_InitializePins ( void  )
static

Initializes required pins for interlock evaluation.

Definition at line 198 of file interlock.c.

Here is the call graph for this function:

◆ ILCK_SetStateRequest()

ILCK_RETURN_TYPE_e ILCK_SetStateRequest ( ILCK_STATE_REQUEST_e  statereq)

sets the current state request of the state variable ilck_state.

This function is used to make a state request to the state machine,e.g, start voltage measurement, read result of voltage measurement, re-initialization It calls ILCK_CheckStateRequest() to check if the request is valid. The state request is rejected if is not valid. The result of the check is returned immediately, so that the requester can act in case it made a non-valid state request.

Parameters
statereqstate request to set
Returns
retVal current state request, taken from ILCK_STATE_REQUEST_e

Definition at line 254 of file interlock.c.

Here is the call graph for this function:

◆ ILCK_TransferStateRequest()

static ILCK_STATE_REQUEST_e ILCK_TransferStateRequest ( void  )
static

transfers the current state request to the state machine.

This function takes the current state request from ilck_state and transfers it to the state machine. It resets the value from ilck_state to ILCK_STATE_NO_REQUEST

Returns
current state request, taken from ILCK_STATE_REQUEST_e

Definition at line 173 of file interlock.c.

Here is the call graph for this function:

◆ ILCK_Trigger()

void ILCK_Trigger ( void  )

trigger function for the ILCK driver state machine.

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

Definition at line 268 of file interlock.c.

Here is the call graph for this function:

◆ TEST_ILCK_GetInterlockFeedback()

ILCK_ELECTRICAL_STATE_TYPE_e TEST_ILCK_GetInterlockFeedback ( void  )

Definition at line 332 of file interlock.c.

Here is the call graph for this function:

◆ TEST_ILCK_SetStateStruct()

void TEST_ILCK_SetStateStruct ( ILCK_STATE_s  state)

Definition at line 325 of file interlock.c.

Variable Documentation

◆ ilck_state

ILCK_STATE_s ilck_state
static
Initial value:
= {
.timer = 0,
.statereq = ILCK_STATE_NO_REQUEST,
.substate = ILCK_ENTRY,
.lastsubstate = ILCK_ENTRY,
.triggerentry = 0,
.ErrRequestCounter = 0,
.counter = 0,
}
@ ILCK_STATEMACHINE_UNINITIALIZED
Definition: interlock.h:70
@ ILCK_ENTRY
Definition: interlock.h:79
@ ILCK_STATE_NO_REQUEST
Definition: interlock.h:87

contains the state of the contactor state machine

Definition at line 93 of file interlock.c.

◆ ilck_tableFeedback

DATA_BLOCK_INTERLOCK_FEEDBACK_s ilck_tableFeedback = {.header.uniqueId = DATA_BLOCK_ID_INTERLOCK_FEEDBACK}
static

Local variable containing interlock feedback

Definition at line 106 of file interlock.c.