foxBMS - Unit Tests  1.3.0
The foxBMS Unit Tests API Documentation
mxm_basic_defines.h
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2022, 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 mxm_basic_defines.h
44  * @author foxBMS Team
45  * @date 2020-02-11 (date of creation)
46  * @updated 2022-05-30 (date of last update)
47  * @version v1.3.0
48  * @ingroup DRIVERS
49  * @prefix MXM
50  *
51  * @brief Basic defines for the complete Maxim driver
52  *
53  * @details def
54  *
55  */
56 
57 #ifndef FOXBMS__MXM_BASIC_DEFINES_H_
58 #define FOXBMS__MXM_BASIC_DEFINES_H_
59 
60 /*========== Includes =======================================================*/
61 #include "general.h"
62 
63 #include "battery_system_cfg.h"
64 
65 /*========== Macros and Definitions =========================================*/
66 
67 /**
68  * @brief Maximum number of modules
69  *
70  * Maximum number of modules that can be connected to one UART daisy-chain.
71  * This value is defined in the Maxim Battery Management Protocol and cannot be
72  * changed.
73  */
74 #define MXM_MAXIMUM_NR_OF_MODULES (32u)
75 
76 /**
77  * @brief Maximum number of cells per module
78  *
79  * Maximum number of cells that can be connected to one module. This value
80  * is given by the hardware and cannot be changed.
81  */
82 #define MXM_MAXIMUM_NR_OF_CELLS_PER_MODULE (14u)
83 
84 /**
85  * @brief Maximum number of AUX ports per module
86  *
87  * Maximum number of AUX ports that can be on one module. This value is given
88  * by the hardware and cannot be changed.
89  */
90 #define MXM_MAXIMUM_NR_OF_AUX_PER_MODULE (6u)
91 
92 /**
93  * @brief Type of monitoring device.
94  *
95  * This enum describes the available types of monitoring devices.
96  * These values also align with the register values on the corresponding
97  * devices and should therefore not be altered.
98  */
99 typedef enum {
100  MXM_MODEL_ID_NONE = 0u, /*!< init value for registry */
101  MXM_MODEL_ID_MAX17852 = 0x852u, /*!< monitoring IC MAX17852 */
102  MXM_MODEL_ID_MAX17853 = 0x853u, /*!< monitoring IC MAX17853 */
103  MXM_MODEL_ID_MAX17854 = 0x854u, /*!< monitoring IC MAX17854 */
104  MXM_MODEL_ID_invalid = 0x1000u, /*!< invalid version ID (cannot be encoded in register or unknown value) */
106 
107 /** values that the datacheck byte can assume */
108 typedef enum {
109  MXM_DC_PEC_ERROR = (1u << 7u), /*!< PEC Error */
110  MXM_DC_ALRTFMEA = (1u << 6u), /*!< FMEA alert */
111  MXM_DC_ALRTSTATUS = (1u << 5u), /*!< alert from status register */
112  MXM_DC_AUXOV = (1u << 4u), /*!< OV or UT on AUX */
113  MXM_DC_AUXUV = (1u << 3u), /*!< UV or OT on AUX */
114  MXM_DC_CELLOV = (1u << 2u), /*!< OV on CELLs */
115  MXM_DC_CELLUV = (1u << 1u), /*!< UV on CELLs */
116  MXM_DC_RESERVED = 1u, /*!< reserved */
117  MXM_DC_EMPTY = 0u, /*!< empty data-check-byte */
118 } MXM_DC_BYTE_e;
119 
120 /** valid values for the silicon version of connected monitoring ICs */
121 typedef enum {
122  MXM_SILICON_VERSION_0 = 0x0u, /*!< initialization value */
123  MXM_SILICON_VERSION_1 = 0x1u, /*!< silicon version 1 (known from data-sheet) */
124  MXM_SILICON_VERSION_2 = 0x2u, /*!< silicon version 2 */
125  MXM_SILICON_VERSION_3 = 0x3u, /*!< silicon version 3 */
126  MXM_SILICON_VERSION_4 = 0x4u, /*!< silicon version 4 (located on old EV kit 2018) */
127  MXM_SILICON_VERSION_5 = 0x5u, /*!< silicon version 5 (located on new EV kit 04.2019) */
128  MXM_SILICON_VERSION_6 = 0x6u, /*!< silicon version 6 */
129  MXM_SILICON_VERSION_7 = 0x7u, /*!< silicon version 7 (most recent as of 2021-11-21) */
130  MXM_SILICON_VERSION_8 = 0x8u, /*!< unknown silicon version */
131  MXM_SILICON_VERSION_9 = 0x9u, /*!< unknown silicon version */
132  MXM_SILICON_VERSION_10 = 0xAu, /*!< unknown silicon version */
133  MXM_SILICON_VERSION_11 = 0xBu, /*!< unknown silicon version */
134  MXM_SILICON_VERSION_12 = 0xCu, /*!< unknown silicon version */
135  MXM_SILICON_VERSION_13 = 0xDu, /*!< unknown silicon version */
136  MXM_SILICON_VERSION_14 = 0xEu, /*!< unknown silicon version */
137  MXM_SILICON_VERSION_15 = 0xFu, /*!< unknown silicon version */
138  MXM_SILICON_VERSION_INVALID = 0x10u, /*!< due to the register size, no version number can take this value */
140 
141 /** Conversion Type */
142 typedef enum {
143  MXM_CONVERSION_UNIPOLAR, /*!< unipolar measurement */
144  MXM_CONVERSION_BIPOLAR, /*!< bipolar measurement */
145  MXM_CONVERSION_BLOCK_VOLTAGE, /*!< measurement of block voltage */
147 
148 /** Type of measurement */
149 typedef enum {
150  MXM_MEASURE_CELL_VOLTAGE, /*!< cell voltage measurement */
151  MXM_MEASURE_TEMP, /*!< temperature measurement */
152  MXM_MEASURE_BLOCK_VOLTAGE, /*!< block voltage measurement */
154 
155 /**
156  * struct that summarizes all types of measurement values of the monitoring IC
157  */
158 typedef struct {
159  /** array of all cell voltages measured by the driver */
161  /** array of all voltages measured by the driver on the AUX inputs */
163  /** array of all measured block voltages */
164  uint16_t blockVoltages[MXM_MAXIMUM_NR_OF_MODULES];
166 
167 /*========== Extern Constant and Variable Declarations ======================*/
168 
169 /*========== Extern Function Prototypes =====================================*/
170 
171 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
172 
173 #endif /* FOXBMS__MXM_BASIC_DEFINES_H_ */
Configuration of the battery system (e.g., number of battery modules, battery cells,...
General macros and definitions for the whole platform.
MXM_SILICON_VERSION_e
@ MXM_SILICON_VERSION_3
@ MXM_SILICON_VERSION_5
@ MXM_SILICON_VERSION_4
@ MXM_SILICON_VERSION_8
@ MXM_SILICON_VERSION_1
@ MXM_SILICON_VERSION_2
@ MXM_SILICON_VERSION_INVALID
@ MXM_SILICON_VERSION_10
@ MXM_SILICON_VERSION_0
@ MXM_SILICON_VERSION_11
@ MXM_SILICON_VERSION_9
@ MXM_SILICON_VERSION_14
@ MXM_SILICON_VERSION_6
@ MXM_SILICON_VERSION_12
@ MXM_SILICON_VERSION_7
@ MXM_SILICON_VERSION_13
@ MXM_SILICON_VERSION_15
MXM_MODEL_ID_e
Type of monitoring device.
@ MXM_MODEL_ID_MAX17853
@ MXM_MODEL_ID_MAX17852
@ MXM_MODEL_ID_MAX17854
@ MXM_MODEL_ID_NONE
@ MXM_MODEL_ID_invalid
#define MXM_MAXIMUM_NR_OF_CELLS_PER_MODULE
Maximum number of cells per module.
#define MXM_MAXIMUM_NR_OF_AUX_PER_MODULE
Maximum number of AUX ports per module.
MXM_DC_BYTE_e
@ MXM_DC_ALRTSTATUS
@ MXM_DC_RESERVED
@ MXM_DC_EMPTY
@ MXM_DC_AUXOV
@ MXM_DC_ALRTFMEA
@ MXM_DC_CELLUV
@ MXM_DC_AUXUV
@ MXM_DC_CELLOV
@ MXM_DC_PEC_ERROR
MXM_MEASURE_TYPE_e
@ MXM_MEASURE_CELL_VOLTAGE
@ MXM_MEASURE_BLOCK_VOLTAGE
@ MXM_MEASURE_TEMP
MXM_CONVERSION_TYPE_e
@ MXM_CONVERSION_BIPOLAR
@ MXM_CONVERSION_UNIPOLAR
@ MXM_CONVERSION_BLOCK_VOLTAGE
#define MXM_MAXIMUM_NR_OF_MODULES
Maximum number of modules.