foxBMS  1.6.0
The foxBMS Battery Management System API Documentation
adi_ades183x.c File Reference

Driver for the ADI analog front-end. More...

#include "adi_ades183x.h"
#include "adi_ades183x_balancing.h"
#include "adi_ades183x_buffers.h"
#include "adi_ades183x_commands.h"
#include "adi_ades183x_diagnostic.h"
#include "adi_ades183x_gpio_voltages.h"
#include "adi_ades183x_helpers.h"
#include "adi_ades183x_initialization.h"
#include "adi_ades183x_pec.h"
#include "adi_ades183x_temperatures.h"
#include "adi_ades183x_voltages.h"
#include "database.h"
#include "ftask.h"
#include "infinite-loop-helper.h"
#include "os.h"
#include "pex.h"
#include <stdbool.h>
#include <stdint.h>
Include dependency graph for adi_ades183x.c:

Go to the source code of this file.

Functions

static void ADI_AccessToDatabase (ADI_STATE_s *adiState)
 Read local variables from database and write local variables to database. More...
 
static void ADI_BalanceControl (ADI_STATE_s *adiState)
 Sets the balancing according to the control values read in the database. More...
 
static STD_RETURN_TYPE_e ADI_GetRequest (AFE_REQUEST_e *request)
 Checks the requests made to the ades183x driver. More...
 
static bool ADI_ProcessMeasurementNotStartedState (ADI_STATE_s *adiState, AFE_REQUEST_e *request)
 Runs the initialization sequence of the driver. More...
 
static void ADI_SetFirstMeasurementCycleFinished (ADI_STATE_s *adiState)
 sets the measurement initialization status. More...
 
static void ADI_RunCurrentStringMeasurement (ADI_STATE_s *adiState)
 
void ADI_ActivateInterfaceBoard (void)
 Sets the pins to activate the interface board. More...
 
STD_RETURN_TYPE_e ADI_MakeRequest (AFE_REQUEST_e request)
 Makes a request to the ADI driver. More...
 
bool ADI_IsFirstMeasurementCycleFinished (ADI_STATE_s *adiState)
 Gets the measurement initialization status. More...
 
void ADI_MeasurementCycle (ADI_STATE_s *adiState)
 Implements the actual measurement sequence for the ADI driver. More...
 

Variables

ADI_STATE_s adi_stateBase
 
static uint16_t adi_bufferRxPec [ADI_N_BYTES_FOR_DATA_TRANSMISSION] = {0}
 
static uint16_t adi_bufferTxPec [ADI_N_BYTES_FOR_DATA_TRANSMISSION] = {0}
 
static DATA_BLOCK_CELL_VOLTAGE_s adi_cellVoltage = {.header.uniqueId = DATA_BLOCK_ID_CELL_VOLTAGE_BASE}
 
static DATA_BLOCK_CELL_VOLTAGE_s adi_cellVoltageAverage = {.header.uniqueId = DATA_BLOCK_ID_CELL_VOLTAGE_BASE}
 
static DATA_BLOCK_CELL_VOLTAGE_s adi_cellVoltageFiltered = {.header.uniqueId = DATA_BLOCK_ID_CELL_VOLTAGE_BASE}
 
static DATA_BLOCK_CELL_VOLTAGE_s adi_cellVoltageRedundant = {.header.uniqueId = DATA_BLOCK_ID_CELL_VOLTAGE_BASE}
 
static DATA_BLOCK_CELL_TEMPERATURE_s adi_cellTemperature = {.header.uniqueId = DATA_BLOCK_ID_CELL_TEMPERATURE_BASE}
 
static DATA_BLOCK_BALANCING_CONTROL_s adi_balancingControl = {.header.uniqueId = DATA_BLOCK_ID_BALANCING_CONTROL}
 
static DATA_BLOCK_ALL_GPIO_VOLTAGES_s adi_allGpioVoltage = {.header.uniqueId = DATA_BLOCK_ID_ALL_GPIO_VOLTAGES_BASE}
 
static DATA_BLOCK_ALL_GPIO_VOLTAGES_s adi_allGpioVoltageRedundant
 
static DATA_BLOCK_CELL_VOLTAGE_s adi_cellVoltageOpenWireEven = {.header.uniqueId = DATA_BLOCK_ID_CELL_VOLTAGE_BASE}
 
static DATA_BLOCK_CELL_VOLTAGE_s adi_cellVoltageOpenWireOdd = {.header.uniqueId = DATA_BLOCK_ID_CELL_VOLTAGE_BASE}
 
static DATA_BLOCK_CELL_VOLTAGE_s adi_cellVoltageAverageOpenWire = {.header.uniqueId = DATA_BLOCK_ID_CELL_VOLTAGE_BASE}
 
static DATA_BLOCK_CELL_VOLTAGE_s adi_cellVoltageRedundantOpenWire
 
static DATA_BLOCK_ALL_GPIO_VOLTAGES_s adi_allGpioVoltageOpenWire
 
static DATA_BLOCK_OPEN_WIRE_s adi_openWire = {.header.uniqueId = DATA_BLOCK_ID_OPEN_WIRE_BASE}
 
static ADI_ERROR_TABLE_s adi_errorTable = {0}
 

Detailed Description

Driver for the ADI analog front-end.

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-12-09 (date of creation)
Updated
2023-10-12 (date of last update)
Version
v1.6.0
Prefix
ADI

Definition in file adi_ades183x.c.

Function Documentation

◆ ADI_AccessToDatabase()

static void ADI_AccessToDatabase ( ADI_STATE_s adiState)
static

Read local variables from database and write local variables to database.

Parameters
adiStatestate of the ADI driver

Definition at line 185 of file adi_ades183x.c.

Here is the call graph for this function:

◆ ADI_ActivateInterfaceBoard()

void ADI_ActivateInterfaceBoard ( void  )

Sets the pins to activate the interface board.

Definition at line 322 of file adi_ades183x.c.

Here is the call graph for this function:

◆ ADI_BalanceControl()

static void ADI_BalanceControl ( ADI_STATE_s adiState)
static

Sets the balancing according to the control values read in the database.

To set balancing for the cells, the corresponding bits have to be written in the configuration register. The ades183x driver only executes the balancing orders written by the BMS in the database.

Parameters
adiStatestate of the ADI driver

Definition at line 200 of file adi_ades183x.c.

Here is the call graph for this function:

◆ ADI_GetRequest()

static STD_RETURN_TYPE_e ADI_GetRequest ( AFE_REQUEST_e request)
static

Checks the requests made to the ades183x driver.

Parameters
requestrequest to be made with string addressed
Returns
STD_OK if request queue was full, STD_NOT_OK otherwise

Definition at line 219 of file adi_ades183x.c.

Here is the call graph for this function:

◆ ADI_IsFirstMeasurementCycleFinished()

bool ADI_IsFirstMeasurementCycleFinished ( ADI_STATE_s adiState)

Gets the measurement initialization status.

Parameters
adiStatestate of the adi driver
Returns
true if a first measurement cycle was made, false otherwise

Definition at line 354 of file adi_ades183x.c.

◆ ADI_MakeRequest()

STD_RETURN_TYPE_e ADI_MakeRequest ( AFE_REQUEST_e  request)

Makes a request to the ADI driver.

Parameters
requestrequest to be made with string addressed
Returns
STD_OK if request queue was empty, STD_NOT_OK otherwise

Definition at line 342 of file adi_ades183x.c.

Here is the call graph for this function:

◆ ADI_MeasurementCycle()

void ADI_MeasurementCycle ( ADI_STATE_s adiState)

Implements the actual measurement sequence for the ADI driver.

This function contains the sequence of events

Parameters
adiStatestate of the adi driver

Definition at line 364 of file adi_ades183x.c.

Here is the call graph for this function:

◆ ADI_ProcessMeasurementNotStartedState()

static bool ADI_ProcessMeasurementNotStartedState ( ADI_STATE_s adiState,
AFE_REQUEST_e request 
)
static

Runs the initialization sequence of the driver.

Parameters
adiStatestate of the ADI driver
requestrequest to be made with string addressed
Returns
true if measurement has been started, false otherwise

Definition at line 231 of file adi_ades183x.c.

Here is the call graph for this function:

◆ ADI_RunCurrentStringMeasurement()

static void ADI_RunCurrentStringMeasurement ( ADI_STATE_s adiState)
static

Definition at line 250 of file adi_ades183x.c.

Here is the call graph for this function:

◆ ADI_SetFirstMeasurementCycleFinished()

static void ADI_SetFirstMeasurementCycleFinished ( ADI_STATE_s adiState)
static

sets the measurement initialization status.

Definition at line 311 of file adi_ades183x.c.

Here is the call graph for this function:

Variable Documentation

◆ adi_allGpioVoltage

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

local copies of database tables

Definition at line 100 of file adi_ades183x.c.

◆ adi_allGpioVoltageOpenWire

DATA_BLOCK_ALL_GPIO_VOLTAGES_s adi_allGpioVoltageOpenWire
static
Initial value:
= {
@ DATA_BLOCK_ID_ALL_GPIO_VOLTAGES_BASE
Definition: database_cfg.h:81

local copies of database tables

Definition at line 108 of file adi_ades183x.c.

◆ adi_allGpioVoltageRedundant

DATA_BLOCK_ALL_GPIO_VOLTAGES_s adi_allGpioVoltageRedundant
static
Initial value:
= {

local copies of database tables

Definition at line 101 of file adi_ades183x.c.

◆ adi_balancingControl

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

local copies of database tables

Definition at line 99 of file adi_ades183x.c.

◆ adi_bufferRxPec

uint16_t adi_bufferRxPec[ADI_N_BYTES_FOR_DATA_TRANSMISSION] = {0}
static

PEC buffer for RX and TX

Definition at line 87 of file adi_ades183x.c.

◆ adi_bufferTxPec

uint16_t adi_bufferTxPec[ADI_N_BYTES_FOR_DATA_TRANSMISSION] = {0}
static

PEC buffer for RX and TX

Definition at line 88 of file adi_ades183x.c.

◆ adi_cellTemperature

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

local copies of database tables

Definition at line 98 of file adi_ades183x.c.

◆ adi_cellVoltage

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

local copies of database tables

Definition at line 94 of file adi_ades183x.c.

◆ adi_cellVoltageAverage

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

local copies of database tables

Definition at line 95 of file adi_ades183x.c.

◆ adi_cellVoltageAverageOpenWire

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

local copies of database tables

Definition at line 105 of file adi_ades183x.c.

◆ adi_cellVoltageFiltered

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

local copies of database tables

Definition at line 96 of file adi_ades183x.c.

◆ adi_cellVoltageOpenWireEven

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

local copies of database tables

Definition at line 103 of file adi_ades183x.c.

◆ adi_cellVoltageOpenWireOdd

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

local copies of database tables

Definition at line 104 of file adi_ades183x.c.

◆ adi_cellVoltageRedundant

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

local copies of database tables

Definition at line 97 of file adi_ades183x.c.

◆ adi_cellVoltageRedundantOpenWire

DATA_BLOCK_CELL_VOLTAGE_s adi_cellVoltageRedundantOpenWire
static
Initial value:
= {
.header.uniqueId = DATA_BLOCK_ID_CELL_VOLTAGE_BASE}
@ DATA_BLOCK_ID_CELL_VOLTAGE_BASE
Definition: database_cfg.h:90

local copies of database tables

Definition at line 106 of file adi_ades183x.c.

◆ adi_errorTable

ADI_ERROR_TABLE_s adi_errorTable = {0}
static

init in ADI_ResetErrorTable-function

Definition at line 111 of file adi_ades183x.c.

◆ adi_openWire

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

local copies of database tables

Definition at line 110 of file adi_ades183x.c.

◆ adi_stateBase

ADI_STATE_s adi_stateBase
Initial value:
= {
.measurementStarted = false,
.firstMeasurementMade = false,
.firstDiagnosticMade = false,
.currentString = 0u,
.redundantAuxiliaryChannel = {0u},
.data.txBuffer = adi_bufferTxPec,
.data.rxBuffer = adi_bufferRxPec,
.data.cellVoltage = &adi_cellVoltage,
.data.cellVoltageAverage = &adi_cellVoltageAverage,
.data.cellVoltageFiltered = &adi_cellVoltageFiltered,
.data.cellVoltageRedundant = &adi_cellVoltageRedundant,
.data.cellTemperature = &adi_cellTemperature,
.data.balancingControl = &adi_balancingControl,
.data.errorTable = &adi_errorTable,
.data.allGpioVoltages = &adi_allGpioVoltage,
.data.allGpioVoltagesRedundant = &adi_allGpioVoltageRedundant,
.data.cellVoltageOpenWireEven = &adi_cellVoltageOpenWireEven,
.data.cellVoltageOpenWireOdd = &adi_cellVoltageOpenWireOdd,
.data.cellVoltageAverageOpenWire = &adi_cellVoltageAverageOpenWire,
.data.cellVoltageRedundantOpenWire = &adi_cellVoltageRedundantOpenWire,
.data.allGpioVoltageOpenWire = &adi_allGpioVoltageOpenWire,
.data.openWire = &adi_openWire,
}
static DATA_BLOCK_OPEN_WIRE_s adi_openWire
Definition: adi_ades183x.c:110
static DATA_BLOCK_ALL_GPIO_VOLTAGES_s adi_allGpioVoltageOpenWire
Definition: adi_ades183x.c:108
static DATA_BLOCK_CELL_VOLTAGE_s adi_cellVoltageFiltered
Definition: adi_ades183x.c:96
static DATA_BLOCK_CELL_VOLTAGE_s adi_cellVoltageRedundant
Definition: adi_ades183x.c:97
static DATA_BLOCK_BALANCING_CONTROL_s adi_balancingControl
Definition: adi_ades183x.c:99
static DATA_BLOCK_CELL_VOLTAGE_s adi_cellVoltage
Definition: adi_ades183x.c:94
static DATA_BLOCK_CELL_VOLTAGE_s adi_cellVoltageAverage
Definition: adi_ades183x.c:95
static DATA_BLOCK_CELL_VOLTAGE_s adi_cellVoltageAverageOpenWire
Definition: adi_ades183x.c:105
static DATA_BLOCK_ALL_GPIO_VOLTAGES_s adi_allGpioVoltage
Definition: adi_ades183x.c:100
static DATA_BLOCK_CELL_TEMPERATURE_s adi_cellTemperature
Definition: adi_ades183x.c:98
static DATA_BLOCK_CELL_VOLTAGE_s adi_cellVoltageRedundantOpenWire
Definition: adi_ades183x.c:106
static ADI_ERROR_TABLE_s adi_errorTable
Definition: adi_ades183x.c:111
static DATA_BLOCK_ALL_GPIO_VOLTAGES_s adi_allGpioVoltageRedundant
Definition: adi_ades183x.c:101
static DATA_BLOCK_CELL_VOLTAGE_s adi_cellVoltageOpenWireOdd
Definition: adi_ades183x.c:104
static uint16_t adi_bufferRxPec[ADI_N_BYTES_FOR_DATA_TRANSMISSION]
Definition: adi_ades183x.c:87
static DATA_BLOCK_CELL_VOLTAGE_s adi_cellVoltageOpenWireEven
Definition: adi_ades183x.c:103
static uint16_t adi_bufferTxPec[ADI_N_BYTES_FOR_DATA_TRANSMISSION]
Definition: adi_ades183x.c:88

Contains the internal state of the adi driver.

Definition at line 116 of file adi_ades183x.c.