foxBMS
1.3.0
The foxBMS Battery Management System API Documentation
|
Implementation of some driver that needs a state machine. More...
#include "state-machine.h"
Go to the source code of this file.
Macros | |
#define | EG_FSM_SHORT_TIME (1u) |
#define | EG_FSM_MEDIUM_TIME (5u) |
#define | EG_FSM_LONG_TIME (10u) |
Enumerations | |
enum | EG_CHECK_MULTIPLE_CALLS_e { EG_MULTIPLE_CALLS_NO , EG_MULTIPLE_CALLS_YES } |
Functions | |
static EG_CHECK_MULTIPLE_CALLS_e | EG_CheckMultipleCalls (EG_STATE_s *pEgState) |
check for multiple calls of state machine trigger function More... | |
static void | EG_SetState (EG_STATE_s *pEgState, EG_FSM_STATES_e nextState, EG_FSM_SUBSTATES_e nextSubstate, uint16_t idleTime) |
Sets the next state, the next substate and the timer value of the state variable. More... | |
static void | EG_SetSubstate (EG_STATE_s *pEgState, EG_FSM_SUBSTATES_e nextSubstate, uint16_t idleTime) |
Sets the next substate and the timer value of the state variable. More... | |
static bool | EG_SomeInitializationFunction0 (void) |
dummy function for initialization substate EG_FSM_SUBSTATE_INITIALIZATION_0 More... | |
static bool | EG_SomeInitializationFunction1 (void) |
dummy function for initialization substate EG_FSM_SUBSTATE_INITIALIZATION_1 More... | |
static bool | EG_SomeInitializationFunctionExit (void) |
dummy function to check if the initialization step of the state machine was successful (EG_FSM_SUBSTATE_INITIALIZATION_1) More... | |
static bool | EG_SomeRunningFunction0 (void) |
dummy function making a test to determine the outcome of substate EG_FSM_SUBSTATE_RUNNING_0 More... | |
static bool | EG_SomeRunningFunction1 (void) |
dummy function making a test to determine the outcome of substate EG_FSM_SUBSTATE_RUNNING_1 More... | |
static bool | EG_SomeRunningFunction2 (void) |
dummy function making a test to determine the outcome of substate EG_FSM_SUBSTATE_RUNNING_2 More... | |
static EG_FSM_STATES_e | EG_ProcessInitializationState (EG_STATE_s *pEgState) |
Processes the initialization state. More... | |
static EG_FSM_STATES_e | EG_ProcessRunningState (EG_STATE_s *pEgState) |
Processes the running state. More... | |
static STD_RETURN_TYPE_e | EG_RunStateMachine (EG_STATE_s *pEgState) |
Defines the state transitions. More... | |
STD_RETURN_TYPE_e | EG_Trigger (EG_STATE_s *pEgState) |
tick function, call this to advance the state machine More... | |
Variables | |
EG_STATE_s | eg_state |
Implementation of some driver that needs a state machine.
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:
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:
Definition in file state-machine.c.
#define EG_FSM_LONG_TIME (10u) |
statemachine long time definition in EG_Trigger calls until next state/substate is processed
Definition at line 75 of file state-machine.c.
#define EG_FSM_MEDIUM_TIME (5u) |
statemachine medium time definition in EG_Trigger calls until next state/substate is processed
Definition at line 69 of file state-machine.c.
#define EG_FSM_SHORT_TIME (1u) |
statemachine short time definition in EG_Trigger calls until next state is processed
Definition at line 63 of file state-machine.c.
Symbolic names to check for multiple calls of EG_Trigger
Enumerator | |
---|---|
EG_MULTIPLE_CALLS_NO | no multiple calls, OK |
EG_MULTIPLE_CALLS_YES | multiple calls, not OK |
Definition at line 78 of file state-machine.c.
|
static |
check for multiple calls of state machine trigger function
The trigger function is not reentrant, which means it cannot be called multiple times. This functions increments the triggerEntry counter once and must be called each time the trigger function is called. If triggerEntry is greater than one, there were multiple calls. For this function to work, triggerEntry must be decremented each time the trigger function is called, even if no processing do because the timer is non-zero.
pEgState | state of the fake state machine |
Definition at line 212 of file state-machine.c.
|
static |
Processes the initialization state.
pEgState | state of the example state machine |
Definition at line 292 of file state-machine.c.
|
static |
Processes the running state.
pEgState | state of the example state machine |
Definition at line 335 of file state-machine.c.
|
static |
Defines the state transitions.
This function contains the implementation of the state machine, i.e., the sequence of states and substates. It is called by the trigger function every time the state machine timer has a non-zero value.
pEgState | state of the example state machine |
Definition at line 378 of file state-machine.c.
|
static |
Sets the next state, the next substate and the timer value of the state variable.
pEgState | state of the example state machine |
nextState | state to be transferred into |
nextSubstate | substate to be transferred into |
idleTime | wait time for the state machine |
Definition at line 225 of file state-machine.c.
|
static |
Sets the next substate and the timer value of the state variable.
pEgState | state of the example state machine |
nextSubstate | substate to be transferred into |
idleTime | wait time for the state machine |
Definition at line 260 of file state-machine.c.
|
static |
dummy function for initialization substate EG_FSM_SUBSTATE_INITIALIZATION_0
Definition at line 268 of file state-machine.c.
|
static |
dummy function for initialization substate EG_FSM_SUBSTATE_INITIALIZATION_1
Definition at line 272 of file state-machine.c.
|
static |
dummy function to check if the initialization step of the state machine was successful (EG_FSM_SUBSTATE_INITIALIZATION_1)
Definition at line 276 of file state-machine.c.
|
static |
dummy function making a test to determine the outcome of substate EG_FSM_SUBSTATE_RUNNING_0
Definition at line 280 of file state-machine.c.
|
static |
dummy function making a test to determine the outcome of substate EG_FSM_SUBSTATE_RUNNING_1
Definition at line 284 of file state-machine.c.
|
static |
dummy function making a test to determine the outcome of substate EG_FSM_SUBSTATE_RUNNING_2
Definition at line 288 of file state-machine.c.
STD_RETURN_TYPE_e EG_Trigger | ( | EG_STATE_s * | pEgState | ) |
tick function, call this to advance the state machine
pEgState | current state of the state machine |
Definition at line 436 of file state-machine.c.
EG_STATE_s eg_state |
local instance of the driver-state
Definition at line 88 of file state-machine.c.