foxBMS  1.6.0
The foxBMS Battery Management System API Documentation
adi_ades183x_voltages.h
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2023, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V.
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright notice, this
12  * list of conditions and the following disclaimer.
13  *
14  * 2. Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  *
18  * 3. Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from
20  * this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *
33  * We kindly request you to use one or more of the following phrases to refer to
34  * foxBMS in your hardware, software, documentation or advertising materials:
35  *
36  * - ″This product uses parts of foxBMS®″
37  * - ″This product includes parts of foxBMS®″
38  * - ″This product is derived from foxBMS®″
39  *
40  */
41 
42 /**
43  * @file adi_ades183x_voltages.h
44  * @author foxBMS Team
45  * @date 2022-12-07 (date of creation)
46  * @updated 2023-10-12 (date of last update)
47  * @version v1.6.0
48  * @ingroup DRIVERS
49  * @prefix ADI
50  *
51  * @brief Header file of some software
52  *
53  */
54 
55 #ifndef FOXBMS__ADI_ADES183X_VOLTAGES_H_
56 #define FOXBMS__ADI_ADES183X_VOLTAGES_H_
57 
58 /*========== Includes =======================================================*/
59 
60 #include "adi_ades183x_defs.h"
61 
62 #include <stdint.h>
63 
64 /*========== Macros and Definitions =========================================*/
65 /** Struct to group the commands to read the registers A to F */
66 typedef struct {
67  uint16_t registerA[ADI_COMMAND_DEFINITION_LENGTH];
68  uint16_t registerB[ADI_COMMAND_DEFINITION_LENGTH];
69  uint16_t registerC[ADI_COMMAND_DEFINITION_LENGTH];
70  uint16_t registerD[ADI_COMMAND_DEFINITION_LENGTH];
71  uint16_t registerE[ADI_COMMAND_DEFINITION_LENGTH];
72  uint16_t registerF[ADI_COMMAND_DEFINITION_LENGTH];
74 
75 /*========== Extern Constant and Variable Declarations ======================*/
76 
77 /*========== Extern Function Prototypes =====================================*/
78 
79 /**
80  * @brief Converts index of read voltages.
81  * @details This function translates the indexes of read voltages so that
82  * if some inputs are unused, they do not appear in the final
83  * cell voltage table
84  * @param registerVoltageIndex index of the read voltage ion the ades183x
85  * register
86  * @return index where the voltage must be stored if it is used
87  */
88 extern uint16_t ADI_GetStoredVoltageIndex(uint16_t registerVoltageIndex);
89 
90 /**
91  * @brief Reads and stores cell voltages.
92  * @details This function, reads the raw values from the registers, and
93  * calls ADI_SaveRxToCellVoltageBuffer() which convert them into
94  * voltages and stores them.
95  * @param adiState state of the ADI driver
96  * @param registerType type of voltage register to read
97  * @param storeLocation location where read data has to be stored
98  */
99 extern void ADI_GetVoltages(
100  ADI_STATE_s *adiState,
101  ADI_VOLTAGE_REGISTER_TYPE_e registerType,
102  ADI_VOLTAGE_STORE_LOCATION_e storeLocation);
103 
104 /**
105  * @brief Stop cell voltage measurement.
106  * @details This function should be called before activation of balancing
107  * @param adiState state of the driver
108  */
110 
111 /**
112  * @brief Restart cell voltage measurement.
113  * @details This function should be called after deactivation of balancing
114  * @param adiState state of the driver
115  */
117 
118 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
119 #ifdef UNITY_UNIT_TEST
120 extern void TEST_ADI_CopyCommandBytesCellVoltageRegister(
121  ADI_COMMAND_READ_REGISTERS_s *commandBytesToReadVoltageRegisters);
122 extern void TEST_ADI_CopyCommandBytesAverageCellVoltageRegisters(
123  ADI_COMMAND_READ_REGISTERS_s *commandBytesToReadVoltageRegisters);
124 extern void TEST_ADI_CopyCommandBytesFilteredCellVoltageRegisters(
125  ADI_COMMAND_READ_REGISTERS_s *commandBytesToReadVoltageRegisters);
126 extern void TEST_ADI_CopyCommandBytesRedundantCellVoltageRegisters(
127  ADI_COMMAND_READ_REGISTERS_s *commandBytesToReadVoltageRegisters);
128 extern void TEST_ADI_ReadAndStoreVoltages(
129  ADI_STATE_s *adiState,
130  ADI_COMMAND_READ_REGISTERS_s *commandBytesToReadVoltageRegisters,
131  ADI_VOLTAGE_STORE_LOCATION_e storeLocation);
132 extern void TEST_ADI_SaveRxToCellVoltageBuffer(
133  ADI_STATE_s *adiState,
134  uint8_t *data,
135  uint8_t registerSet,
136  ADI_VOLTAGE_STORE_LOCATION_e storeLocation);
137 #endif
138 
139 #endif /* FOXBMS__ADI_ADES183X_VOLTAGES_H_ */
Headers for the driver for the ades183x analog front-end.
ADI_VOLTAGE_REGISTER_TYPE_e
ADI_VOLTAGE_STORE_LOCATION_e
#define ADI_COMMAND_DEFINITION_LENGTH
void ADI_StopContinuousCellVoltageMeasurements(ADI_STATE_s *adiState)
Stop cell voltage measurement.
void ADI_GetVoltages(ADI_STATE_s *adiState, ADI_VOLTAGE_REGISTER_TYPE_e registerType, ADI_VOLTAGE_STORE_LOCATION_e storeLocation)
Reads and stores cell voltages.
uint16_t ADI_GetStoredVoltageIndex(uint16_t registerVoltageIndex)
Converts index of read voltages.
void ADI_RestartContinuousCellVoltageMeasurements(ADI_STATE_s *adiState)
Restart cell voltage measurement.