foxBMS  1.6.0
The foxBMS Battery Management System API Documentation
sbc.c File Reference

Driver for the SBC module. More...

#include "sbc.h"
#include "HL_gio.h"
#include "os.h"
#include <stdint.h>
Include dependency graph for sbc.c:

Go to the source code of this file.

Enumerations

enum  SBC_CHECK_REENTRANCE_e { SBC_REENTRANCE_NO , SBC_REENTRANCE_YES }
 

Functions

static void SBC_SaveLastStates (SBC_STATE_s *pInstance)
 Saves the last state and last substate. More...
 
static SBC_RETURN_TYPE_e SBC_CheckStateRequest (SBC_STATE_s *pInstance, SBC_STATE_REQUEST_e stateRequest)
 checks the state requests that are made. More...
 
static SBC_CHECK_REENTRANCE_e SBC_CheckReEntrance (SBC_STATE_s *pInstance)
 Re-entrance check of SBC state machine trigger function. More...
 
static SBC_STATE_REQUEST_e SBC_TransferStateRequest (SBC_STATE_s *pInstance)
 Transfers the current state request to the state machine. More...
 
static bool SBC_TriggerWatchdogIfRequired (SBC_STATE_s *pInstance)
 Triggers the watchdog if the timing requires it. More...
 
static bool SBC_IsIgnitionSignalDetected (SBC_STATE_s *pInstance)
 Handle ignition/clamp 15 signal. More...
 
SBC_RETURN_TYPE_e SBC_SetStateRequest (SBC_STATE_s *pInstance, SBC_STATE_REQUEST_e stateRequest)
 sets the current state request of passed state variable More...
 
SBC_STATEMACHINE_e SBC_GetState (SBC_STATE_s *pInstance)
 gets the current state of passed state variable More...
 
void SBC_Trigger (SBC_STATE_s *pInstance)
 trigger function for the SYS driver state machine. More...
 

Variables

SBC_STATE_s sbc_stateMcuSupervisor
 

Detailed Description

Driver for the SBC module.

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

It must always be used when creating new c source files.

Definition in file sbc.c.

Enumeration Type Documentation

◆ SBC_CHECK_REENTRANCE_e

Symbolic names to check re-entrance in SBC_Trigger

Enumerator
SBC_REENTRANCE_NO 

no re-entrance

SBC_REENTRANCE_YES 

re-entrance

Definition at line 69 of file sbc.c.

Function Documentation

◆ SBC_CheckReEntrance()

static SBC_CHECK_REENTRANCE_e SBC_CheckReEntrance ( SBC_STATE_s pInstance)
static

Re-entrance check of SBC 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 pInstance->triggerEntry. 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
SBC_REENTRANCE_NO if no further instance of the function is active, otherwise SBC_REENTRANCE_YES

Definition at line 196 of file sbc.c.

Here is the call graph for this function:

◆ SBC_CheckStateRequest()

static SBC_RETURN_TYPE_e SBC_CheckStateRequest ( SBC_STATE_s pInstance,
SBC_STATE_REQUEST_e  stateRequest 
)
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
[in,out]pInstance
[in]stateRequeststate request to be checked
Returns
result of the state request that was made, taken from SBC_RETURN_TYPE_e

Definition at line 171 of file sbc.c.

◆ SBC_GetState()

SBC_STATEMACHINE_e SBC_GetState ( SBC_STATE_s pInstance)

gets the current state of passed state variable

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

Parameters
[in]pInstanceSBC instance where the current state is requested
Returns
current state, taken from SBC_STATEMACHINE_e

Definition at line 269 of file sbc.c.

◆ SBC_IsIgnitionSignalDetected()

static bool SBC_IsIgnitionSignalDetected ( SBC_STATE_s pInstance)
static

Handle ignition/clamp 15 signal.

Checks ignition signal (clamp 15) and put BMS in shutdown mode if ignition signal is not detected anymore.

Parameters
[in,out]pInstanceSBC instance where ignition signal is connected
Returns
true if ignition signal is detected, false otherwise

Definition at line 246 of file sbc.c.

Here is the call graph for this function:

◆ SBC_SaveLastStates()

static void SBC_SaveLastStates ( SBC_STATE_s pInstance)
static

Saves the last state and last substate.

Parameters
[in,out]pInstance

Definition at line 157 of file sbc.c.

◆ SBC_SetStateRequest()

SBC_RETURN_TYPE_e SBC_SetStateRequest ( SBC_STATE_s pInstance,
SBC_STATE_REQUEST_e  stateRequest 
)

sets the current state request of passed state variable

This function is used to make a state request to the state machine, e.g., start initialization. It calls SBC_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
[in,out]pInstanceSBC instance where different state is requested
[in]stateRequestrequested state
Returns
If the request was successfully set, it returns the SBC_OK, else the current state of requests (type SBC_STATE_REQUEST_e)

Definition at line 253 of file sbc.c.

Here is the call graph for this function:

◆ SBC_TransferStateRequest()

static SBC_STATE_REQUEST_e SBC_TransferStateRequest ( SBC_STATE_s pInstance)
static

Transfers the current state request to the state machine.

This function takes the current state request from pInstance->stateRequest and transfers it to the state machine. It resets the value from stateRequest to SBC_STATE_NO_REQUEST

Parameters
[in,out]pInstance
Returns
current state request, taken from SBC_STATE_REQUEST_e

Definition at line 212 of file sbc.c.

Here is the call graph for this function:

◆ SBC_Trigger()

void SBC_Trigger ( SBC_STATE_s pInstance)

trigger function for the SYS driver state machine.

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

Parameters
[in,out]pInstanceSBC instance that is controlled

Definition at line 275 of file sbc.c.

Here is the call graph for this function:

◆ SBC_TriggerWatchdogIfRequired()

static bool SBC_TriggerWatchdogIfRequired ( SBC_STATE_s pInstance)
static

Triggers the watchdog if the timing requires it.

This function checks whether the watchdog timer elapses, and triggers the watchdog in that case.

Parameters
[in,out]pInstance
Returns
true if watchdog has been triggered, false otherwise SYS_STATE_REQUEST_e

Definition at line 225 of file sbc.c.

Here is the call graph for this function:

Variable Documentation

◆ sbc_stateMcuSupervisor

SBC_STATE_s sbc_stateMcuSupervisor
Initial value:
= {
.timer = 0u,
.stateRequest = SBC_STATE_NO_REQUEST,
.substate = SBC_ENTRY,
.lastSubstate = SBC_ENTRY,
.illegalRequestsCounter = 0u,
.retryCounter = 0u,
.requestWatchdogTrigger = 0u,
.triggerEntry = 0u,
.pFs85xxInstance = &fs85xx_mcuSupervisor,
.watchdogPeriod_10ms = 10u,
.useIgnitionForPowerDown = true,
}
FS85_STATE_s fs85xx_mcuSupervisor
Definition: nxpfs85xx.c:87
@ SBC_STATEMACHINE_UNINITIALIZED
Definition: sbc.h:135
@ SBC_STATE_NO_REQUEST
Definition: sbc.h:113
@ SBC_PERIODIC_WATCHDOG_DEACTIVATED
Definition: sbc.h:119
@ SBC_ENTRY
Definition: sbc.h:144

state of the SBC module

Definition at line 78 of file sbc.c.