foxBMS-UnitTests  1.0.0
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
4  * angewandten Forschung e.V. All rights reserved.
5  *
6  * BSD 3-Clause License
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  * 1. Redistributions of source code must retain the above copyright notice,
10  * this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * 3. Neither the name of the copyright holder nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  *
30  * We kindly request you to use one or more of the following phrases to refer
31  * to foxBMS in your hardware, software, documentation or advertising
32  * materials:
33  *
34  * ″This product uses parts of foxBMS®″
35  *
36  * ″This product includes parts of foxBMS®″
37  *
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 2020-06-22 (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 MXM_MODEL_ID {
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 */
104 
105 /** values that the datacheck byte can assume */
106 typedef enum MXM_DC_BYTE {
107  MXM_DC_PEC_ERROR = (1u << 7u), /*!< PEC Error */
108  MXM_DC_ALRTFMEA = (1u << 6u), /*!< FMEA alert */
109  MXM_DC_ALRTSTATUS = (1u << 5u), /*!< alert from status register */
110  MXM_DC_AUXOV = (1u << 4u), /*!< OV or UT on AUX */
111  MXM_DC_AUXUV = (1u << 3u), /*!< UV or OT on AUX */
112  MXM_DC_CELLOV = (1u << 2u), /*!< OV on CELLs */
113  MXM_DC_CELLUV = (1u << 1u), /*!< UV on CELLs */
114  MXM_DC_RESERVED = 1u, /*!< reserved */
115  MXM_DC_EMPTY = 0u, /*!< empty data-check-byte */
117 
118 /** valid values for the silicon version of connected monitoring ICs */
119 typedef enum MXM_siliconVersion {
120  MXM_siliconVersion_0 = 0x0u, /*!< initialization value */
121  MXM_siliconVersion_1 = 0x1u, /*!< silicon version 1 (known from datasheet) */
122  MXM_siliconVersion_2 = 0x2u, /*!< silicon version 2 */
123  MXM_siliconVersion_3 = 0x3u, /*!< silicon version 3 */
124  MXM_siliconVersion_4 = 0x4u, /*!< silicon version 4 (located on old EV kit 2018) */
125  MXM_siliconVersion_5 = 0x5u, /*!< silicon version 5 (located on new EV kit 04.2019) */
126  MXM_siliconVersion_7 = 0x7u, /*!< silicon version 7 (located as Sample on 4-Cell-Boards) */
128 
129 /** Conversion Type */
130 typedef enum MXM_CONVERSION_TYPE {
131  MXM_CONVERSION_UNIPOLAR, /*!< unipolar measurement */
132  MXM_CONVERSION_BIPOLAR, /*!< bipolar measurement */
133  MXM_CONVERSION_BLOCK_VOLTAGE, /*!< measurement of block voltage */
135 
136 /** Type of measurement */
137 typedef enum MXM_MEASURE_TYPE {
138  MXM_MEASURE_CELL_VOLTAGE, /*!< cell voltage measurement */
139  MXM_MEASURE_TEMP, /*!< temperature measurement */
140  MXM_MEASURE_BLOCK_VOLTAGE, /*!< block voltage measurement */
142 
143 /**
144  * struct that summarizes all types of measurement values of the monitoring IC
145  */
146 typedef struct MXM_DATA_STORAGE {
147  /** array of all cell voltages measured by the driver */
149  /** array of all voltages measured by the driver on the AUX inputs */
151  /** array of all measured block voltages */
154 
155 /*========== Extern Constant and Variable Declarations ======================*/
156 
157 /*========== Extern Function Prototypes =====================================*/
158 
159 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
160 
161 #endif /* FOXBMS__MXM_BASIC_DEFINES_H_ */
MXM_CONVERSION_BLOCK_VOLTAGE
@ MXM_CONVERSION_BLOCK_VOLTAGE
Definition: mxm_basic_defines.h:133
MXM_MAXIMUM_NR_OF_CELLS_PER_MODULE
#define MXM_MAXIMUM_NR_OF_CELLS_PER_MODULE
Maximum number of cells per module.
Definition: mxm_basic_defines.h:81
MXM_DC_AUXUV
@ MXM_DC_AUXUV
Definition: mxm_basic_defines.h:111
MXM_DATA_STORAGE
Definition: mxm_basic_defines.h:146
general.h
TODO.
MXM_CONVERSION_TYPE_e
enum MXM_CONVERSION_TYPE MXM_CONVERSION_TYPE_e
MXM_MODEL_ID_e
enum MXM_MODEL_ID MXM_MODEL_ID_e
Type of monitoring device.
MXM_siliconVersion_0
@ MXM_siliconVersion_0
Definition: mxm_basic_defines.h:120
MXM_MODEL_ID
MXM_MODEL_ID
Type of monitoring device.
Definition: mxm_basic_defines.h:98
MXM_DC_RESERVED
@ MXM_DC_RESERVED
Definition: mxm_basic_defines.h:114
MXM_DC_ALRTFMEA
@ MXM_DC_ALRTFMEA
Definition: mxm_basic_defines.h:108
MXM_DC_EMPTY
@ MXM_DC_EMPTY
Definition: mxm_basic_defines.h:115
MXM_DC_CELLOV
@ MXM_DC_CELLOV
Definition: mxm_basic_defines.h:112
MXM_DC_BYTE_e
enum MXM_DC_BYTE MXM_DC_BYTE_e
MXM_MEASURE_TYPE
MXM_MEASURE_TYPE
Definition: mxm_basic_defines.h:137
battery_system_cfg.h
Configuration of the battery system (e.g., number of battery modules, battery cells,...
MXM_MAXIMUM_NR_OF_AUX_PER_MODULE
#define MXM_MAXIMUM_NR_OF_AUX_PER_MODULE
Maximum number of AUX ports per module.
Definition: mxm_basic_defines.h:89
MXM_siliconVersion_1
@ MXM_siliconVersion_1
Definition: mxm_basic_defines.h:121
MXM_MAXIMUM_NR_OF_MODULES
#define MXM_MAXIMUM_NR_OF_MODULES
Maximum number of modules.
Definition: mxm_basic_defines.h:73
MXM_MEASURE_CELL_VOLTAGE
@ MXM_MEASURE_CELL_VOLTAGE
Definition: mxm_basic_defines.h:138
MXM_CONVERSION_UNIPOLAR
@ MXM_CONVERSION_UNIPOLAR
Definition: mxm_basic_defines.h:131
MXM_MEASURE_BLOCK_VOLTAGE
@ MXM_MEASURE_BLOCK_VOLTAGE
Definition: mxm_basic_defines.h:140
MXM_CONVERSION_BIPOLAR
@ MXM_CONVERSION_BIPOLAR
Definition: mxm_basic_defines.h:132
MXM_siliconVersion_4
@ MXM_siliconVersion_4
Definition: mxm_basic_defines.h:124
MXM_DC_CELLUV
@ MXM_DC_CELLUV
Definition: mxm_basic_defines.h:113
MXM_CONVERSION_TYPE
MXM_CONVERSION_TYPE
Definition: mxm_basic_defines.h:130
MXM_siliconVersion_5
@ MXM_siliconVersion_5
Definition: mxm_basic_defines.h:125
MXM_siliconVersion_e
enum MXM_siliconVersion MXM_siliconVersion_e
MXM_MODEL_ID_MAX17854
@ MXM_MODEL_ID_MAX17854
Definition: mxm_basic_defines.h:102
MXM_DC_AUXOV
@ MXM_DC_AUXOV
Definition: mxm_basic_defines.h:110
MXM_DC_BYTE
MXM_DC_BYTE
Definition: mxm_basic_defines.h:106
MXM_DATA_STORAGE::cellVoltages
uint16_t cellVoltages[MXM_MAXIMUM_NR_OF_MODULES *MXM_MAXIMUM_NR_OF_CELLS_PER_MODULE]
Definition: mxm_basic_defines.h:148
MXM_DC_ALRTSTATUS
@ MXM_DC_ALRTSTATUS
Definition: mxm_basic_defines.h:109
MXM_DATA_STORAGE_s
struct MXM_DATA_STORAGE MXM_DATA_STORAGE_s
MXM_siliconVersion_7
@ MXM_siliconVersion_7
Definition: mxm_basic_defines.h:126
MXM_siliconVersion_2
@ MXM_siliconVersion_2
Definition: mxm_basic_defines.h:122
MXM_DATA_STORAGE::auxVoltages
uint16_t auxVoltages[MXM_MAXIMUM_NR_OF_MODULES *MXM_MAXIMUM_NR_OF_AUX_PER_MODULE]
Definition: mxm_basic_defines.h:150
MXM_MODEL_ID_MAX17853
@ MXM_MODEL_ID_MAX17853
Definition: mxm_basic_defines.h:101
MXM_MEASURE_TEMP
@ MXM_MEASURE_TEMP
Definition: mxm_basic_defines.h:139
MXM_siliconVersion
MXM_siliconVersion
Definition: mxm_basic_defines.h:119
MXM_MEASURE_TYPE_e
enum MXM_MEASURE_TYPE MXM_MEASURE_TYPE_e
MXM_DATA_STORAGE::blockVoltages
uint16_t blockVoltages[MXM_MAXIMUM_NR_OF_MODULES]
Definition: mxm_basic_defines.h:152
MXM_siliconVersion_3
@ MXM_siliconVersion_3
Definition: mxm_basic_defines.h:123
MXM_DC_PEC_ERROR
@ MXM_DC_PEC_ERROR
Definition: mxm_basic_defines.h:107
MXM_MODEL_ID_MAX17852
@ MXM_MODEL_ID_MAX17852
Definition: mxm_basic_defines.h:100
MXM_MODEL_ID_NONE
@ MXM_MODEL_ID_NONE
Definition: mxm_basic_defines.h:99