foxBMS - Unit Tests  1.1.0
The foxBMS Unit Tests API Documentation
sys.h File Reference

Sys driver header. More...

#include "sys_cfg.h"
Include dependency graph for sys.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SYS_STATE
 

Typedefs

typedef enum SYS_CHECK SYS_CHECK_e
 
typedef enum SYS_FSM_STATES SYS_FSM_STATES_e
 
typedef enum SYS_FSM_SUBSTATES SYS_FSM_SUBSTATES_e
 
typedef enum SYS_STATEMACH SYS_STATEMACH_e
 
typedef enum SYS_STATEMACH_SUB SYS_STATEMACH_SUB_e
 
typedef enum SYS_STATE_REQUEST SYS_STATE_REQUEST_e
 
typedef enum SYS_RETURN_TYPE SYS_RETURN_TYPE_e
 
typedef struct SYS_STATE SYS_STATE_s
 

Enumerations

enum  SYS_CHECK { SYS_CHECK_OK , SYS_CHECK_BUSY , SYS_CHECK_NOT_OK }
 
enum  SYS_FSM_STATES {
  SYS_FSM_STATE_DUMMY , SYS_FSM_STATE_HAS_NEVER_RUN , SYS_FSM_STATE_UNINITIALIZED , SYS_FSM_STATE_INITIALIZATION ,
  SYS_FSM_STATE_RUNNING , SYS_FSM_STATE_ERROR
}
 
enum  SYS_FSM_SUBSTATES {
  SYS_FSM_SUBSTATE_DUMMY , SYS_FSM_SUBSTATE_ENTRY , SYS_FSM_SUBSTATE_INITIALIZATION_SBC , SYS_FSM_SUBSTATE_INITIALIZATION_BOOT_MESSAGE ,
  SYS_FSM_SUBSTATE_INITIALIZATION_INTERLOCK , SYS_FSM_SUBSTATE_INITIALIZATION_CONTACTORS , SYS_FSM_SUBSTATE_INITIALIZATION_BALANCING , SYS_FSM_SUBSTATE_INITIALIZATION_INSULATION_GUARD ,
  SYS_FSM_SUBSTATE_INITIALIZATION_FIRST_MEASUREMENT_CYCLE , SYS_FSM_SUBSTATE_INITIALIZATION_CHECK_CURRENT_SENSOR , SYS_FSM_SUBSTATE_INITIALIZATION_MISC , SYS_FSM_SUBSTATE_INITIALIZATION_BMS ,
  SYS_FSM_SUBSTATE_RUNNING
}
 
enum  SYS_STATEMACH {
  SYS_STATEMACH_UNINITIALIZED , SYS_STATEMACH_INITIALIZATION , SYS_STATEMACH_SYSTEM_BIST , SYS_STATEMACH_INITIALIZED ,
  SYS_STATEMACH_INITIALIZE_SBC , SYS_STATEMACH_INITIALIZE_INTERLOCK , SYS_STATEMACH_INITIALIZE_CONTACTORS , SYS_STATEMACH_INITIALIZE_BALANCING ,
  SYS_STATEMACH_INITIALIZE_BMS , SYS_STATEMACH_RUNNING , SYS_STATEMACH_FIRST_MEASUREMENT_CYCLE , SYS_STATEMACH_INITIALIZE_MISC ,
  SYS_STATEMACH_CHECK_CURRENT_SENSOR_PRESENCE , SYS_STATEMACH_INITIALIZE_ISOGUARD , SYS_STATEMACH_ERROR
}
 
enum  SYS_STATEMACH_SUB {
  SYS_ENTRY , SYS_CHECK_ERROR_FLAGS , SYS_CHECK_STATE_REQUESTS , SYS_WAIT_INITIALIZATION_SBC ,
  SYS_WAIT_INITIALIZATION_INTERLOCK , SYS_WAIT_INITIALIZATION_CONT , SYS_WAIT_INITIALIZATION_BAL , SYS_WAIT_INITIALIZATION_BAL_GLOBAL_ENABLE ,
  SYS_WAIT_INITIALIZATION_BMS , SYS_WAIT_FIRST_MEASUREMENT_CYCLE , SYS_WAIT_CURRENT_SENSOR_PRESENCE , SYS_SBC_INIT_ERROR ,
  SYS_CONT_INIT_ERROR , SYS_BAL_INIT_ERROR , SYS_ILCK_INIT_ERROR , SYS_BMS_INIT_ERROR ,
  SYS_MEAS_INIT_ERROR , SYS_CURRENT_SENSOR_PRESENCE_ERROR
}
 
enum  SYS_STATE_REQUEST { SYS_STATE_INIT_REQUEST , SYS_STATE_ERROR_REQUEST , SYS_STATE_NO_REQUEST }
 
enum  SYS_RETURN_TYPE {
  SYS_OK , SYS_BUSY_OK , SYS_REQUEST_PENDING , SYS_ILLEGAL_REQUEST ,
  SYS_ALREADY_INITIALIZED , SYS_ILLEGAL_TASK_TYPE
}
 

Functions

SYS_RETURN_TYPE_e SYS_SetStateRequest (SYS_STATE_REQUEST_e stateRequest)
 sets the current state request of the state variable sys_state. More...
 
STD_RETURN_TYPE_e SYS_Trigger (SYS_STATE_s *pSystemState)
 tick function, call this to advance the state machine More...
 
void SYS_GeneralMacroBist (void)
 

Variables

SYS_STATE_s sys_state
 

Detailed Description

Sys driver header.

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
2021-05-19 (date of last update)
Prefix
SYS

Definition in file sys.h.

Typedef Documentation

◆ SYS_CHECK_e

typedef enum SYS_CHECK SYS_CHECK_e

Symbolic names for busyness of the system

◆ SYS_FSM_STATES_e

States of the state machine

◆ SYS_FSM_SUBSTATES_e

Substates of the state machine

◆ SYS_RETURN_TYPE_e

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

◆ SYS_STATE_REQUEST_e

State requests for the SYS statemachine

◆ SYS_STATE_s

typedef struct SYS_STATE SYS_STATE_s

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

◆ SYS_STATEMACH_e

States of the SYS state machine

◆ SYS_STATEMACH_SUB_e

Substates of the SYS state machine

Enumeration Type Documentation

◆ SYS_CHECK

enum SYS_CHECK

Symbolic names for busyness of the system

Enumerator
SYS_CHECK_OK 

system ok

SYS_CHECK_BUSY 

system busy

SYS_CHECK_NOT_OK 

system not ok

Definition at line 64 of file sys.h.

◆ SYS_FSM_STATES

States of the state machine

Enumerator
SYS_FSM_STATE_DUMMY 

dummy state - always the first state

SYS_FSM_STATE_HAS_NEVER_RUN 

never run state - always the second state

SYS_FSM_STATE_UNINITIALIZED 

uninitialized state

SYS_FSM_STATE_INITIALIZATION 

initializing the state machine

SYS_FSM_STATE_RUNNING 

operational mode of the state machine

SYS_FSM_STATE_ERROR 

state for error processing

Definition at line 71 of file sys.h.

◆ SYS_FSM_SUBSTATES

Substates of the state machine

Enumerator
SYS_FSM_SUBSTATE_DUMMY 

dummy state - always the first substate

SYS_FSM_SUBSTATE_ENTRY 

entry state - always the second substate

SYS_FSM_SUBSTATE_INITIALIZATION_SBC 

TODO

SYS_FSM_SUBSTATE_INITIALIZATION_BOOT_MESSAGE 

TODO

SYS_FSM_SUBSTATE_INITIALIZATION_INTERLOCK 

TODO

SYS_FSM_SUBSTATE_INITIALIZATION_CONTACTORS 

TODO

SYS_FSM_SUBSTATE_INITIALIZATION_BALANCING 

TODO

SYS_FSM_SUBSTATE_INITIALIZATION_INSULATION_GUARD 

TODO

SYS_FSM_SUBSTATE_INITIALIZATION_FIRST_MEASUREMENT_CYCLE 

TODO

SYS_FSM_SUBSTATE_INITIALIZATION_CHECK_CURRENT_SENSOR 

TODO

SYS_FSM_SUBSTATE_INITIALIZATION_MISC 

TODO

SYS_FSM_SUBSTATE_INITIALIZATION_BMS 

TODO

SYS_FSM_SUBSTATE_RUNNING 

fist running substate

Definition at line 81 of file sys.h.

◆ SYS_RETURN_TYPE

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

Enumerator
SYS_OK 

sys --> ok

SYS_BUSY_OK 

sys busy --> ok

SYS_REQUEST_PENDING 

requested to be executed

SYS_ILLEGAL_REQUEST 

Request can not be executed

SYS_ALREADY_INITIALIZED 

Initialization of LTC already finished

SYS_ILLEGAL_TASK_TYPE 

Illegal

Definition at line 149 of file sys.h.

◆ SYS_STATE_REQUEST

State requests for the SYS statemachine

Enumerator
SYS_STATE_INIT_REQUEST 

initialization request

SYS_STATE_ERROR_REQUEST 

error state requested

SYS_STATE_NO_REQUEST 

no request

Definition at line 142 of file sys.h.

◆ SYS_STATEMACH

States of the SYS state machine

Enumerator
SYS_STATEMACH_UNINITIALIZED 
SYS_STATEMACH_INITIALIZATION 
SYS_STATEMACH_SYSTEM_BIST 

run a built-in self-test

SYS_STATEMACH_INITIALIZED 
SYS_STATEMACH_INITIALIZE_SBC 
SYS_STATEMACH_INITIALIZE_INTERLOCK 
SYS_STATEMACH_INITIALIZE_CONTACTORS 
SYS_STATEMACH_INITIALIZE_BALANCING 
SYS_STATEMACH_INITIALIZE_BMS 
SYS_STATEMACH_RUNNING 
SYS_STATEMACH_FIRST_MEASUREMENT_CYCLE 
SYS_STATEMACH_INITIALIZE_MISC 
SYS_STATEMACH_CHECK_CURRENT_SENSOR_PRESENCE 
SYS_STATEMACH_INITIALIZE_ISOGUARD 
SYS_STATEMACH_ERROR 

Error-State

Definition at line 100 of file sys.h.

◆ SYS_STATEMACH_SUB

Substates of the SYS state machine

Enumerator
SYS_ENTRY 

Substate entry state

SYS_CHECK_ERROR_FLAGS 

Substate check if any error flag set

SYS_CHECK_STATE_REQUESTS 

Substate check if there is a state request

SYS_WAIT_INITIALIZATION_SBC 

Substate to wait for initialization of the sbc state machine

SYS_WAIT_INITIALIZATION_INTERLOCK 

Substate to wait for initialization of the interlock state machine

SYS_WAIT_INITIALIZATION_CONT 

Substate to wait for initialization of the contactor state machine

SYS_WAIT_INITIALIZATION_BAL 

Substate to wait for initialization of the balancing state machine

SYS_WAIT_INITIALIZATION_BAL_GLOBAL_ENABLE 

Substate to enable/disable balancing globally

SYS_WAIT_INITIALIZATION_BMS 

Substate to wait for initialization of the bms state machine

SYS_WAIT_FIRST_MEASUREMENT_CYCLE 

Substate to wait for first measurement cycle to complete

SYS_WAIT_CURRENT_SENSOR_PRESENCE 

Substate to wait for first measurement cycle to complete

SYS_SBC_INIT_ERROR 

Substate error of SBC initialization

SYS_CONT_INIT_ERROR 

Substate error of contactor state machine initialization

SYS_BAL_INIT_ERROR 

Substate error of balancing state machine initialization

SYS_ILCK_INIT_ERROR 

Substate error of contactor state machine initialization

SYS_BMS_INIT_ERROR 

Substate error of bms state machine initialization

SYS_MEAS_INIT_ERROR 

Substate error if first measurement cycle does not complete

SYS_CURRENT_SENSOR_PRESENCE_ERROR 

Substate error if first measurement cycle does not complete

Definition at line 120 of file sys.h.

Function Documentation

◆ SYS_GeneralMacroBist()

void SYS_GeneralMacroBist ( void  )

built-in self-test for the macros in general.h

Definition at line 614 of file sys.c.

◆ SYS_SetStateRequest()

SYS_RETURN_TYPE_e SYS_SetStateRequest ( SYS_STATE_REQUEST_e  stateRequest)

sets the current state request of the state variable sys_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 SYS_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
stateRequeststate requested to set
Returns
If the request was successfully set, it returns the SYS_OK, else the current state of requests (type SYS_STATE_REQUEST_e)

Definition at line 565 of file sys.c.

Here is the call graph for this function:

◆ SYS_Trigger()

STD_RETURN_TYPE_e SYS_Trigger ( SYS_STATE_s pSystemState)

tick function, call this to advance the state machine

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

Definition at line 622 of file sys.c.

Here is the call graph for this function:

Variable Documentation

◆ sys_state

SYS_STATE_s sys_state
extern

contains the state of the contactor state machine

Definition at line 92 of file sys.c.