foxBMS - Unit Tests  1.2.1
The foxBMS Unit Tests API Documentation
sbc.c File Reference

Driver for the SBC module. More...

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

Go to the source code of this file.

Typedefs

typedef enum SBC_CHECK_REENTRANCE SBC_CHECK_REENTRANCE_e
 

Enumerations

enum  SBC_CHECK_REENTRANCE { 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...
 
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
2021-03-24 (date of last update)
Prefix
SBC

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

Definition in file sbc.c.

Typedef Documentation

◆ SBC_CHECK_REENTRANCE_e

Symbolic names to check re-entrance in SBC_Trigger

Enumeration Type Documentation

◆ SBC_CHECK_REENTRANCE

Symbolic names to check re-entrance in SBC_Trigger

Enumerator
SBC_REENTRANCE_NO 

no re-entrance

SBC_REENTRANCE_YES 

re-entrance

Definition at line 66 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.

re-entrance check of SYS 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

This function is not re-entrant and should only be called time- or event-triggered. It increments the triggerentry counter from the state variable sys_systemState. 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
retval 0 if no further instance of the function is active, 0xff else

Definition at line 184 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 149 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 230 of file sbc.c.

◆ 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 135 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 214 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
retVal current state request, taken from SYS_STATE_REQUEST_e

Definition at line 200 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 236 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,
}
FS85xx_STATE_s fs85xx_mcuSupervisor
Definition: nxpfs85xx.c:80
@ SBC_STATEMACHINE_UNINITIALIZED
Definition: sbc.h:133
@ SBC_STATE_NO_REQUEST
Definition: sbc.h:111
@ SBC_ENTRY
Definition: sbc.h:142
@ SBC_PERIODIC_WATCHDOG_DEACTIVATED
Definition: sbc.h:117

state of the SBC module

Definition at line 75 of file sbc.c.