foxBMS  1.1.0
The foxBMS Battery Management System API Documentation
sbc.h File Reference

Header for the driver for the SBC module. More...

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

Go to the source code of this file.

Data Structures

struct  SBC_STATE
 

Macros

#define SBC_STATEMACHINE_TASK_CYCLE_CONTEXT_MS   (10u)
 
#define SBC_STATEMACHINE_SHORTTIME   (1u)
 
#define SBC_STATEMACHINE_MEDIUMTIME   (5u)
 
#define SBC_STATEMACHINE_LONGTIME   (10u)
 
#define SBC_WINDOW_WATCHDOG_PERIOD_MS   (100u)
 

Typedefs

typedef enum SBC_STATE_REQUEST SBC_STATE_REQUEST_e
 
typedef enum SBC_PERIODIC_WATCHDOG_STATE SBC_PERIODIC_WATCHDOG_STATE_e
 
typedef enum SBC_RETURN_TYPE SBC_RETURN_TYPE_e
 
typedef enum SBC_STATEMACHINE SBC_STATEMACHINE_e
 
typedef enum SBC_STATEMACHINE_SUB SBC_STATEMACHINE_SUB_e
 
typedef struct SBC_STATE SBC_STATE_s
 

Enumerations

enum  SBC_STATE_REQUEST { SBC_STATE_INIT_REQUEST , SBC_STATE_ERROR_REQUEST , SBC_STATE_NO_REQUEST }
 
enum  SBC_PERIODIC_WATCHDOG_STATE { SBC_PERIODIC_WATCHDOG_ACTIVATED , SBC_PERIODIC_WATCHDOG_DEACTIVATED }
 
enum  SBC_RETURN_TYPE {
  SBC_OK , SBC_BUSY_OK , SBC_REQUEST_PENDING , SBC_ILLEGAL_REQUEST ,
  SBC_ALREADY_INITIALIZED , SBC_ILLEGAL_TASK_TYPE
}
 
enum  SBC_STATEMACHINE {
  SBC_STATEMACHINE_UNINITIALIZED , SBC_STATEMACHINE_INITIALIZATION , SBC_STATEMACHINE_RUNNING , SBC_STATEMACHINE_ERROR ,
  SBC_STATEMACHINE_UNDEFINED
}
 
enum  SBC_STATEMACHINE_SUB {
  SBC_ENTRY , SBC_INIT_RESET_FAULT_ERROR_COUNTER_PART1 , SBC_INIT_RESET_FAULT_ERROR_COUNTER_PART2 , SBC_INITIALIZE_SAFETY_PATH_CHECK ,
  SBC_INITIALIZE_VOLTAGE_SUPERVISOR_PART3 , SBC_INITIALIZE_VOLTAGE_SUPERVISOR_PART4
}
 

Functions

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

Header for the 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-07-23 (date of last update)
Prefix
SBC

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

Definition in file sbc.h.

Macro Definition Documentation

◆ SBC_STATEMACHINE_LONGTIME

#define SBC_STATEMACHINE_LONGTIME   (10u)

SBC statemachine long time definition in SBC_Trigger() calls until next state/substate is processed

Definition at line 100 of file sbc.h.

◆ SBC_STATEMACHINE_MEDIUMTIME

#define SBC_STATEMACHINE_MEDIUMTIME   (5u)

SBC statemachine medium time definition in SBC_Trigger() calls until next state/substate is processed

Definition at line 94 of file sbc.h.

◆ SBC_STATEMACHINE_SHORTTIME

#define SBC_STATEMACHINE_SHORTTIME   (1u)

SBC statemachine short time definition in SBC_Trigger() calls until next state/substate is processed

Definition at line 88 of file sbc.h.

◆ SBC_STATEMACHINE_TASK_CYCLE_CONTEXT_MS

#define SBC_STATEMACHINE_TASK_CYCLE_CONTEXT_MS   (10u)

This define MUST represent the cycle time of the task in which context the functions run, e.g., if the SBC_Trigger() is running in the 10 ms task then the define must be set to 10.

This sets the minimum time between two subsequent executed states/substates.

Define is only used for compile-time assertion, it has no programatic influence on the actual code.

Definition at line 78 of file sbc.h.

◆ SBC_WINDOW_WATCHDOG_PERIOD_MS

#define SBC_WINDOW_WATCHDOG_PERIOD_MS   (100u)

trigger period of SBC watchdog

Definition at line 105 of file sbc.h.

Typedef Documentation

◆ SBC_PERIODIC_WATCHDOG_STATE_e

State of watchdog state

◆ SBC_RETURN_TYPE_e

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

◆ SBC_STATE_REQUEST_e

State requests for the SYS statemachine

◆ SBC_STATE_s

typedef struct SBC_STATE SBC_STATE_s

This structure contains all the variables relevant for the SBC state machine. The user can get the current state of the SBC state machine with this variable

◆ SBC_STATEMACHINE_e

States of the SBC state machine

◆ SBC_STATEMACHINE_SUB_e

Substates of the SBC state machine

Enumeration Type Documentation

◆ SBC_PERIODIC_WATCHDOG_STATE

State of watchdog state

Enumerator
SBC_PERIODIC_WATCHDOG_ACTIVATED 
SBC_PERIODIC_WATCHDOG_DEACTIVATED 

Definition at line 115 of file sbc.h.

◆ SBC_RETURN_TYPE

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

Enumerator
SBC_OK 

sys --> ok

SBC_BUSY_OK 

sys busy --> ok

SBC_REQUEST_PENDING 

requested to be executed

SBC_ILLEGAL_REQUEST 

Request can not be executed

SBC_ALREADY_INITIALIZED 

Initialization of SBC already finished

SBC_ILLEGAL_TASK_TYPE 

Illegal

Definition at line 121 of file sbc.h.

◆ SBC_STATE_REQUEST

State requests for the SYS statemachine

Enumerator
SBC_STATE_INIT_REQUEST 

request to begin SBC initialization

SBC_STATE_ERROR_REQUEST 

request to switch SBC into error state

SBC_STATE_NO_REQUEST 

enum to clarify that currently no new request needs to be processed

Definition at line 108 of file sbc.h.

◆ SBC_STATEMACHINE

States of the SBC state machine

Enumerator
SBC_STATEMACHINE_UNINITIALIZED 

statemachien start value

SBC_STATEMACHINE_INITIALIZATION 

SBC startup initialization process

SBC_STATEMACHINE_RUNNING 

error detected communicating with SBC

SBC_STATEMACHINE_ERROR 

default initialization value

SBC_STATEMACHINE_UNDEFINED 

Definition at line 131 of file sbc.h.

◆ SBC_STATEMACHINE_SUB

Substates of the SBC state machine

Enumerator
SBC_ENTRY 

Substate entry state

SBC_INIT_RESET_FAULT_ERROR_COUNTER_PART1 

Substate during initialization to reset fault-error counter

SBC_INIT_RESET_FAULT_ERROR_COUNTER_PART2 

Substate during initialization to reset fault-error counter

SBC_INITIALIZE_SAFETY_PATH_CHECK 

Substate to initialize SBC

SBC_INITIALIZE_VOLTAGE_SUPERVISOR_PART3 

Substate to initialize SBC

SBC_INITIALIZE_VOLTAGE_SUPERVISOR_PART4 

Substate to initialize SBC

Definition at line 141 of file sbc.h.

Function Documentation

◆ 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_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_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
extern

state of the SBC module

Definition at line 75 of file sbc.c.