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