foxBMS-UnitTests  1.0.0
The foxBMS Unit Tests API Documentation
contactor.c File Reference

Driver for the contactors. More...

#include "contactor.h"
#include "mcu.h"
#include "sps.h"
Include dependency graph for contactor.c:

Go to the source code of this file.

Functions

static CONT_CONTACTOR_INDEX CONT_ResolveContactorName (const CONT_NAMES_e name)
 Resolves the contactor index from a contactor name. More...
 
static CONT_NAMES_e CONT_GetContactorName (const CONT_CONTACTOR_INDEX index)
 Gets the contactor name from a contactor index. More...
 
static SPS_CHANNEL_INDEX CONT_GetSpsChannelIndexFromContactor (const CONT_CONTACTOR_INDEX contactor)
 Returns the sps channel index from a contactor index. More...
 
static void CONT_SetSpsChannelFromContactor (const CONT_CONTACTOR_INDEX contactor)
 Sets SPS channels according to contactors. More...
 
static void CONT_InitializationCheckOfContactorRegistry (void)
 
CONT_ELECTRICAL_STATE_TYPE_e CONT_GetContactorSetValue (const CONT_NAMES_e name)
 Gets the latest value the contactors were set to. More...
 
void CONT_GetContactorFeedback (void)
 Reads the feedback pin of every contactor and returns its current value (CONT_SWITCH_OFF/CONT_SWITCH_ON). More...
 
STD_RETURN_TYPE_e CONT_SetContactorState (const CONT_NAMES_e name, CONT_ELECTRICAL_STATE_TYPE_e requestedContactorState)
 Sets the contactor state to its requested state, if the contactor is at that time not in the requested state. More...
 
void CONT_CheckFeedback (void)
 checks the feedback of the contactors More...
 
STD_RETURN_TYPE_e CONT_CloseString (uint8_t stringNumber)
 Closes the contactor of a string. More...
 
STD_RETURN_TYPE_e CONT_OpenString (uint8_t stringNumber)
 Opens the contactor of a string. More...
 
STD_RETURN_TYPE_e CONT_ClosePrecharge (uint8_t stringNumber)
 Closes precharge. More...
 
STD_RETURN_TYPE_e CONT_OpenPrecharge (uint8_t stringNumber)
 Opens precharge. More...
 
CONT_ELECTRICAL_STATE_TYPE_e CONT_GetState (uint8_t contactorNumber)
 Gets the current state. More...
 
void CONT_Initialize (void)
 initializes the contactor module More...
 
void TEST_CONT_InitializationCheckOfContactorRegistry ()
 
CONT_CONTACTOR_INDEX TEST_CONT_ResolveContactorName (const CONT_NAMES_e name)
 

Detailed Description

Driver for the contactors.

BSD 3-Clause License 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-11 (date of creation)
Updated
2021-03-24 (date of last update)
Prefix
CONT

Definition in file contactor.c.

Function Documentation

◆ CONT_CheckFeedback()

void CONT_CheckFeedback ( void  )

checks the feedback of the contactors

makes a DIAG entry for each contactor when the feedback does not match the set value

Definition at line 212 of file contactor.c.

Here is the call graph for this function:

◆ CONT_ClosePrecharge()

STD_RETURN_TYPE_e CONT_ClosePrecharge ( uint8_t  stringNumber)

Closes precharge.

This function makes a close state request to the precharge contactor.

Parameters
stringNumberString addressed

Definition at line 234 of file contactor.c.

Here is the call graph for this function:

◆ CONT_CloseString()

STD_RETURN_TYPE_e CONT_CloseString ( uint8_t  stringNumber)

Closes the contactor of a string.

This function makes a close state request to the contactor of a specific string.

Parameters
stringNumberString addressed

Definition at line 217 of file contactor.c.

Here is the call graph for this function:

◆ CONT_GetContactorFeedback()

void CONT_GetContactorFeedback ( void  )

Reads the feedback pin of every contactor and returns its current value (CONT_SWITCH_OFF/CONT_SWITCH_ON).

If the contactor has a feedback pin the measured feedback is returned. If the contactor has no feedback pin, it is assumed that after a certain time the contactor has reached the requested state.

Definition at line 168 of file contactor.c.

Here is the call graph for this function:

◆ CONT_GetContactorName()

static CONT_NAMES_e CONT_GetContactorName ( const CONT_CONTACTOR_INDEX  index)
static

Gets the contactor name from a contactor index.

Parameters
[in]indexindex number of the contactor
Returns
Returns the name of the contactor

Definition at line 119 of file contactor.c.

◆ CONT_GetContactorSetValue()

CONT_ELECTRICAL_STATE_TYPE_e CONT_GetContactorSetValue ( const CONT_NAMES_e  name)

Gets the latest value the contactors were set to.

Parameters
[in]namename of the contactor
Returns
returns CONT_SWITCH_OFF or CONT_SWITCH_ON

Definition at line 162 of file contactor.c.

Here is the call graph for this function:

◆ CONT_GetSpsChannelIndexFromContactor()

static SPS_CHANNEL_INDEX CONT_GetSpsChannelIndexFromContactor ( const CONT_CONTACTOR_INDEX  contactor)
static

Returns the sps channel index from a contactor index.

Currently this implementation maps simply in ascending order

Definition at line 124 of file contactor.c.

◆ CONT_GetState()

CONT_ELECTRICAL_STATE_TYPE_e CONT_GetState ( uint8_t  contactorNumber)

Gets the current state.

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

Parameters
contactorNumbercontactor to be addressed
Returns
current state, taken from CONT_ELECTRICAL_STATE_TYPE_e

Definition at line 286 of file contactor.c.

◆ CONT_InitializationCheckOfContactorRegistry()

static void CONT_InitializationCheckOfContactorRegistry ( void  )
static

conducts an initialization test of the contactor registry and asserts at failure

Definition at line 145 of file contactor.c.

Here is the call graph for this function:

◆ CONT_Initialize()

void CONT_Initialize ( void  )

initializes the contactor module

Definition at line 291 of file contactor.c.

Here is the call graph for this function:

◆ CONT_OpenPrecharge()

STD_RETURN_TYPE_e CONT_OpenPrecharge ( uint8_t  stringNumber)

Opens precharge.

This function makes an open state request to the precharge contactor.

Parameters
stringNumberString addressed

Definition at line 260 of file contactor.c.

Here is the call graph for this function:

◆ CONT_OpenString()

STD_RETURN_TYPE_e CONT_OpenString ( uint8_t  stringNumber)

Opens the contactor of a string.

This function makes an open state request to the contactor of a specific string.

Parameters
stringNumberString addressed

Definition at line 225 of file contactor.c.

Here is the call graph for this function:

◆ CONT_ResolveContactorName()

static CONT_CONTACTOR_INDEX CONT_ResolveContactorName ( const CONT_NAMES_e  name)
static

Resolves the contactor index from a contactor name.

Searches in the contactor index by iteration from front to back for the contactor name and returns the first hit.

Parameters
[in]nameName of the contactor
Returns
index number of the entry in the contactor array

Definition at line 100 of file contactor.c.

◆ CONT_SetContactorState()

STD_RETURN_TYPE_e CONT_SetContactorState ( const CONT_NAMES_e  name,
CONT_ELECTRICAL_STATE_TYPE_e  requestedContactorState 
)

Sets the contactor state to its requested state, if the contactor is at that time not in the requested state.

If the new state was already requested, but not reached (meaning the measured feedback does not return the requested state), there are two states: it can be still ok (STD_OK), because the contactor has some time left to get physically in the requested state (passed time since the request is lower than the limit) or it can be not ok (STD_NOT_OK), because there is timing violation, i.e. the contactor has surpassed the maximum time for getting in the requested state. It returns STD_OK if the requested state was successfully set or if the contactor was at the requested state before.

Parameters
name
requestedContactorState
Returns
retVal (type: STD_RETURN_TYPE_e)

Definition at line 183 of file contactor.c.

Here is the call graph for this function:

◆ CONT_SetSpsChannelFromContactor()

static void CONT_SetSpsChannelFromContactor ( const CONT_CONTACTOR_INDEX  contactor)
static

Sets SPS channels according to contactors.

Currently this implementation assumes simple ascending order.

Parameters
[in]contactorindex of the contactor that should be set

Definition at line 129 of file contactor.c.

Here is the call graph for this function:

◆ TEST_CONT_InitializationCheckOfContactorRegistry()

void TEST_CONT_InitializationCheckOfContactorRegistry ( void  )

Definition at line 297 of file contactor.c.

Here is the call graph for this function:

◆ TEST_CONT_ResolveContactorName()

CONT_CONTACTOR_INDEX TEST_CONT_ResolveContactorName ( const CONT_NAMES_e  name)

Definition at line 300 of file contactor.c.

Here is the call graph for this function: