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