foxBMS  1.1.0
The foxBMS Battery Management System API Documentation
debug_default.c File Reference

Driver implementation for the fake measurement IC. More...

#include "general.h"
#include "debug_default.h"
#include "battery_cell_cfg.h"
#include "battery_system_cfg.h"
#include "database.h"
#include "diag.h"
#include "os.h"
Include dependency graph for debug_default.c:

Go to the source code of this file.

Macros

#define FAKE_CELL_VOLTAGE_mV   (BC_VOLTAGE_NOMINAL_mV)
 
#define FAKE_CELL_TEMPERATURE_ddegC   ((BC_TEMPERATURE_MAX_CHARGE_MOL_ddegC + BC_TEMPERATURE_MIN_CHARGE_MOL_ddegC) / 2u)
 
#define FAKE_FSM_SHORT_TIME   (1u)
 
#define FAKE_FSM_MEDIUM_TIME   (5u)
 
#define FAKE_FSM_LONG_TIME   (10u)
 

Typedefs

typedef enum FAKE_CHECK_MULTIPLE_CALLS FAKE_CHECK_MULTIPLE_CALLS_e
 

Enumerations

enum  FAKE_CHECK_MULTIPLE_CALLS { FAKE_MULTIPLE_CALLS_NO , FAKE_MULTIPLE_CALLS_YES }
 

Functions

static bool FAKE_CheckMultipleCalls (FAKE_STATE_s *pFakeState)
 check for multiple calls of state machine trigger function More...
 
static void FAKE_SetState (FAKE_STATE_s *pFakeState, FAKE_FSM_STATES_e nextState, FAKE_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 FAKE_SetSubstate (FAKE_STATE_s *pFakeState, FAKE_FSM_SUBSTATES_e nextSubstate, uint16_t idleTime)
 Sets the next substate and the timer value of the state variable. More...
 
static void FAKE_SetFirstMeasurementCycleFinished (FAKE_STATE_s *pFakeState)
 Sets the indicator that one full measurement cycles was successful. More...
 
static STD_RETURN_TYPE_e FAKE_SaveFakeVoltageMeasurementData (FAKE_STATE_s *pFakeState)
 Write voltage measurement data. More...
 
static STD_RETURN_TYPE_e FAKE_SaveFakeTemperatureMeasurementData (FAKE_STATE_s *pFakeState)
 Write temperature measurement data. More...
 
static FAKE_FSM_STATES_e FAKE_ProcessInitializationState (FAKE_STATE_s *pFakeState)
 Processes the initialization state. More...
 
static FAKE_FSM_STATES_e FAKE_ProcessRunningState (FAKE_STATE_s *pFakeState)
 Processes the running state. More...
 
static STD_RETURN_TYPE_e FAKE_RunStateMachine (FAKE_STATE_s *pFakeState)
 Defines the state transitions. More...
 
STD_RETURN_TYPE_e FAKE_Initialize (void)
 initialize driver More...
 
bool FAKE_IsFirstMeasurementCycleFinished (FAKE_STATE_s *pFakeState)
 return whether the first measurement cycle is finished More...
 
STD_RETURN_TYPE_e FAKE_TriggerMeasurementIc (FAKE_STATE_s *pFakeState)
 Trigger function for the driver, called to advance the state machine. More...
 

Variables

FAKE_STATE_s fake_state
 
static DATA_BLOCK_CELL_VOLTAGE_s fake_cellVoltage = {.header.uniqueId = DATA_BLOCK_ID_CELL_VOLTAGE_BASE}
 
static DATA_BLOCK_CELL_TEMPERATURE_s fake_cellTemperature = {.header.uniqueId = DATA_BLOCK_ID_CELL_TEMPERATURE_BASE}
 
static DATA_BLOCK_BALANCING_FEEDBACK_s fake_balancingFeedback
 
static DATA_BLOCK_BALANCING_CONTROL_s fake_balancingControl = {.header.uniqueId = DATA_BLOCK_ID_BALANCING_CONTROL}
 
static DATA_BLOCK_SLAVE_CONTROL_s fake_slaveControl = {.header.uniqueId = DATA_BLOCK_ID_SLAVE_CONTROL}
 
static DATA_BLOCK_ALL_GPIO_VOLTAGES_s fake_allGpioVoltage = {.header.uniqueId = DATA_BLOCK_ID_ALL_GPIO_VOLTAGES_BASE}
 
static DATA_BLOCK_OPEN_WIRE_s fake_openWire = {.header.uniqueId = DATA_BLOCK_ID_OPEN_WIRE_BASE}
 

Detailed Description

Driver implementation for the fake measurement IC.

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-09-17 (date of creation)
Updated
2021-06-09 (date of last update)
Prefix
FAKE

Definition in file debug_default.c.

Macro Definition Documentation

◆ FAKE_CELL_TEMPERATURE_ddegC

#define FAKE_CELL_TEMPERATURE_ddegC   ((BC_TEMPERATURE_MAX_CHARGE_MOL_ddegC + BC_TEMPERATURE_MIN_CHARGE_MOL_ddegC) / 2u)

faked cell temperature for all cell temperatures in deci °C

Definition at line 71 of file debug_default.c.

◆ FAKE_CELL_VOLTAGE_mV

#define FAKE_CELL_VOLTAGE_mV   (BC_VOLTAGE_NOMINAL_mV)

faked cell voltage value for all cell voltages in mV

Definition at line 68 of file debug_default.c.

◆ FAKE_FSM_LONG_TIME

#define FAKE_FSM_LONG_TIME   (10u)

statemachine long time definition in FAKE_TriggerMeasurementIc calls until next state/substate is processed

Definition at line 89 of file debug_default.c.

◆ FAKE_FSM_MEDIUM_TIME

#define FAKE_FSM_MEDIUM_TIME   (5u)

statemachine medium time definition in FAKE_TriggerMeasurementIc calls until next state/substate is processed

Definition at line 83 of file debug_default.c.

◆ FAKE_FSM_SHORT_TIME

#define FAKE_FSM_SHORT_TIME   (1u)

statemachine short time definition in FAKE_TriggerMeasurementIc calls until next state is processed

Definition at line 77 of file debug_default.c.

Typedef Documentation

◆ FAKE_CHECK_MULTIPLE_CALLS_e

Symbolic names to check for multiple calls of FAKE_TriggerMeasurementIc

Enumeration Type Documentation

◆ FAKE_CHECK_MULTIPLE_CALLS

Symbolic names to check for multiple calls of FAKE_TriggerMeasurementIc

Enumerator
FAKE_MULTIPLE_CALLS_NO 

no multiple calls, OK

FAKE_MULTIPLE_CALLS_YES 

multiple calls, not OK

Definition at line 92 of file debug_default.c.

Function Documentation

◆ FAKE_CheckMultipleCalls()

static bool FAKE_CheckMultipleCalls ( FAKE_STATE_s pFakeState)
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.

Parameters
pFakeStatestate of the fake state machine
Returns
true if there were multiple calls, false otherwise

Definition at line 220 of file debug_default.c.

Here is the call graph for this function:

◆ FAKE_Initialize()

STD_RETURN_TYPE_e FAKE_Initialize ( void  )

initialize driver

Definition at line 515 of file debug_default.c.

◆ FAKE_IsFirstMeasurementCycleFinished()

bool FAKE_IsFirstMeasurementCycleFinished ( FAKE_STATE_s pFakeState)

return whether the first measurement cycle is finished

Parameters
pFakeStatecurrent state of the fake driver
Returns
true if the first measurement cycle was successfully finished, false otherwise

Definition at line 519 of file debug_default.c.

Here is the call graph for this function:

◆ FAKE_ProcessInitializationState()

static FAKE_FSM_STATES_e FAKE_ProcessInitializationState ( FAKE_STATE_s pFakeState)
static

Processes the initialization state.

Parameters
pFakeStatestate of the fake state machine
Returns
Always STD_OK

Definition at line 367 of file debug_default.c.

Here is the call graph for this function:

◆ FAKE_ProcessRunningState()

static FAKE_FSM_STATES_e FAKE_ProcessRunningState ( FAKE_STATE_s pFakeState)
static

Processes the running state.

Parameters
pFakeStatestate of the fake state machine
Returns
Always STD_OK

Definition at line 421 of file debug_default.c.

Here is the call graph for this function:

◆ FAKE_RunStateMachine()

static STD_RETURN_TYPE_e FAKE_RunStateMachine ( FAKE_STATE_s pFakeState)
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.

Parameters
pFakeStatestate of the example state machine
Returns
Always STD_OK

Definition at line 456 of file debug_default.c.

Here is the call graph for this function:

◆ FAKE_SaveFakeTemperatureMeasurementData()

static STD_RETURN_TYPE_e FAKE_SaveFakeTemperatureMeasurementData ( FAKE_STATE_s pFakeState)
static

Write temperature measurement data.

Parameters
pFakeStatestate of the fake state machine
Returns
STD_OK if successful, STD_NOT_OK otherwise

Definition at line 352 of file debug_default.c.

◆ FAKE_SaveFakeVoltageMeasurementData()

static STD_RETURN_TYPE_e FAKE_SaveFakeVoltageMeasurementData ( FAKE_STATE_s pFakeState)
static

Write voltage measurement data.

Parameters
pFakeStatestate of the fake state machine
Returns
STD_OK if successful, STD_NOT_OK otherwise

Definition at line 337 of file debug_default.c.

◆ FAKE_SetFirstMeasurementCycleFinished()

static void FAKE_SetFirstMeasurementCycleFinished ( FAKE_STATE_s pFakeState)
static

Sets the indicator that one full measurement cycles was successful.

Parameters
pFakeStatestate of the fake state machine
Returns
true if it is a reentrance, false otherwise

Definition at line 276 of file debug_default.c.

Here is the call graph for this function:

◆ FAKE_SetState()

static void FAKE_SetState ( FAKE_STATE_s pFakeState,
FAKE_FSM_STATES_e  nextState,
FAKE_FSM_SUBSTATES_e  nextSubstate,
uint16_t  idleTime 
)
static

Sets the next state, the next substate and the timer value of the state variable.

Parameters
pFakeStatestate of the example state machine
nextStatestate to be transferred into
nextSubstatesubstate to be transferred into
idleTimewait time for the state machine

Definition at line 233 of file debug_default.c.

Here is the call graph for this function:

◆ FAKE_SetSubstate()

static void FAKE_SetSubstate ( FAKE_STATE_s pFakeState,
FAKE_FSM_SUBSTATES_e  nextSubstate,
uint16_t  idleTime 
)
static

Sets the next substate and the timer value of the state variable.

Parameters
pFakeStatestate of the example state machine
nextSubstatesubstate to be transferred into
idleTimewait time for the state machine

Definition at line 268 of file debug_default.c.

◆ FAKE_TriggerMeasurementIc()

STD_RETURN_TYPE_e FAKE_TriggerMeasurementIc ( FAKE_STATE_s pFakeState)

Trigger function for the driver, called to advance the state machine.

Parameters
pFakeStatecurrent state of the fake driver
Returns
returns always STD_OK

Definition at line 528 of file debug_default.c.

Here is the call graph for this function:

Variable Documentation

◆ fake_allGpioVoltage

DATA_BLOCK_ALL_GPIO_VOLTAGES_s fake_allGpioVoltage = {.header.uniqueId = DATA_BLOCK_ID_ALL_GPIO_VOLTAGES_BASE}
static

local copies of database tables

Definition at line 107 of file debug_default.c.

◆ fake_balancingControl

DATA_BLOCK_BALANCING_CONTROL_s fake_balancingControl = {.header.uniqueId = DATA_BLOCK_ID_BALANCING_CONTROL}
static

local copies of database tables

Definition at line 105 of file debug_default.c.

◆ fake_balancingFeedback

DATA_BLOCK_BALANCING_FEEDBACK_s fake_balancingFeedback
static
Initial value:
= {
@ DATA_BLOCK_ID_BALANCING_FEEDBACK_BASE
Definition: database_cfg.h:79

local copies of database tables

Definition at line 103 of file debug_default.c.

◆ fake_cellTemperature

DATA_BLOCK_CELL_TEMPERATURE_s fake_cellTemperature = {.header.uniqueId = DATA_BLOCK_ID_CELL_TEMPERATURE_BASE}
static

local copies of database tables

Definition at line 102 of file debug_default.c.

◆ fake_cellVoltage

DATA_BLOCK_CELL_VOLTAGE_s fake_cellVoltage = {.header.uniqueId = DATA_BLOCK_ID_CELL_VOLTAGE_BASE}
static

local copies of database tables

Definition at line 101 of file debug_default.c.

◆ fake_openWire

DATA_BLOCK_OPEN_WIRE_s fake_openWire = {.header.uniqueId = DATA_BLOCK_ID_OPEN_WIRE_BASE}
static

local copies of database tables

Definition at line 108 of file debug_default.c.

◆ fake_slaveControl

DATA_BLOCK_SLAVE_CONTROL_s fake_slaveControl = {.header.uniqueId = DATA_BLOCK_ID_SLAVE_CONTROL}
static

local copies of database tables

Definition at line 106 of file debug_default.c.

◆ fake_state

FAKE_STATE_s fake_state
Initial value:
= {
.timer = 0,
.triggerEntry = 0,
.previousState = FAKE_FSM_STATE_HAS_NEVER_RUN,
.nextSubstate = FAKE_FSM_SUBSTATE_DUMMY,
.currentSubstate = FAKE_FSM_SUBSTATE_DUMMY,
.previousSubstate = FAKE_FSM_SUBSTATE_DUMMY,
.firstMeasurementFinished = false,
.data.allGpioVoltages = &fake_allGpioVoltage,
.data.balancingControl = &fake_balancingControl,
.data.balancingFeedback = &fake_balancingFeedback,
.data.cellTemperature = &fake_cellTemperature,
.data.cellVoltage = &fake_cellVoltage,
.data.openWire = &fake_openWire,
.data.slaveControl = &fake_slaveControl,
}
static DATA_BLOCK_ALL_GPIO_VOLTAGES_s fake_allGpioVoltage
static DATA_BLOCK_BALANCING_CONTROL_s fake_balancingControl
static DATA_BLOCK_CELL_TEMPERATURE_s fake_cellTemperature
static DATA_BLOCK_SLAVE_CONTROL_s fake_slaveControl
static DATA_BLOCK_BALANCING_FEEDBACK_s fake_balancingFeedback
static DATA_BLOCK_CELL_VOLTAGE_s fake_cellVoltage
static DATA_BLOCK_OPEN_WIRE_s fake_openWire
@ FAKE_FSM_SUBSTATE_DUMMY
Definition: debug_default.h:76
@ FAKE_FSM_STATE_HAS_NEVER_RUN
Definition: debug_default.h:67

local instance of the driver-state

Definition at line 114 of file debug_default.c.