foxBMS  1.6.0
The foxBMS Battery Management System API Documentation
nxp_mc33775a_cfg.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 nxp_mc33775a_cfg.h
44  * @author foxBMS Team
45  * @date 2020-05-08 (date of creation)
46  * @updated 2023-10-12 (date of last update)
47  * @version v1.6.0
48  * @ingroup DRIVERS_CONFIGURATION
49  * @prefix N775
50  *
51  * @brief Header for the configuration for the MC33775A analog front-end.
52  *
53  */
54 
55 #ifndef FOXBMS__NXP_MC33775A_CFG_H_
56 #define FOXBMS__NXP_MC33775A_CFG_H_
57 
58 /*========== Includes =======================================================*/
59 #include "battery_system_cfg.h"
60 
61 #include "nxp_afe_dma.h"
62 #include "nxp_mc33775a_defs.h"
63 #include "spi.h"
64 
65 #include <stdint.h>
66 
67 /*========== Macros and Definitions =========================================*/
68 #define N775_MAXIMUM_NUMBER_OF_SUPPORTED_CELL_MEASUREMENTS (14u)
69 
70 #if BS_NR_OF_CELL_BLOCKS_PER_MODULE > N775_MAXIMUM_NUMBER_OF_SUPPORTED_CELL_MEASUREMENTS
71 #error "Number of cell blocks per module cannot be higher than maximum number of supported cells per IC"
72 #endif
73 
74 /** Number of bytes to be sent over I2C to write and read I2C mux register in order to choose channel */
75 #define N775_I2C_NR_BYTES_FOR_MUX_WRITE (4u)
76 
77 /** Number of bytes in I2C transaction after which the I2C bus should change to read*/
78 #define N775_I2C_NR_BYTES_TO_SWITCH_TO_READ_FOR_UX_READ (2u)
79 
80 /**
81  * Index used for FreeRTOS notification sent when TX DMA interrupt comes
82  */
83 #define N775_NOTIFICATION_TX_INDEX (1u)
84 /**
85  * Index used for FreeRTOS notification sent when RX DMA interrupt comes
86  */
87 #define N775_NOTIFICATION_RX_INDEX (2u)
88 /**
89  * Default notification value, signals that no notification was received
90  */
91 #define N775_NO_NOTIFIED_VALUE (0x0u)
92 /**
93  * Notification value sent when TX DMA interrupt comes
94  */
95 #define N775_TX_NOTIFIED_VALUE (0x50u)
96 /**
97  * Notification value sent when RX DMA interrupt comes
98  */
99 #define N775_RX_NOTIFIED_VALUE (0x60u)
100 /**
101  * Time in ms to wait for DMA TX notification, after this delay the transaction
102  * is considered to have failed
103  */
104 #define N775_NOTIFICATION_TX_TIMEOUT_ms (1u)
105 /**
106  * Time in ms to wait for DMA RX notification, after this delay the transaction
107  * is considered to have failed
108  */
109 #define N775_NOTIFICATION_RX_TIMEOUT_ms (2u)
110 
111 /**
112  * Number of used N775-ICs
113  */
114 #define N775_N_N775 (BS_NR_OF_MODULES_PER_STRING)
115 
116 /**
117  * Number of N775-ICs per battery module
118  */
119 #define N775_NUMBER_OF_N775_PER_MODULE (1u)
120 
121 /**
122  * 775A Tx message length in bytes.
123  */
124 #define N775_TX_MESSAGE_LENGTH (7u)
125 
126 /**
127  * 775A Rx message length in bytes.
128  */
129 #define N775_RX_MESSAGE_LENGTH (4u)
130 
131 /**
132  * Timeout in milliseconds added to the transmission time for interrupt-based
133  * SPI transmission.
134  */
135 #define N775_TRANSMISSION_TIMEOUT (10u)
136 
137 /**
138  * N775 Maximum time from wakeup event to possible communication in ms
139  * 2.4ms in data sheet
140  */
141 #define N775_TWAKECOM_MS (3u)
142 
143 /**
144  * N775 Time between two consecutive wake-up messages in ms
145  * 4ms in data sheet
146  */
147 #define N775_TDWAKE_MS (4u)
148 
149 /**
150  * N775 time for daisy-chain to wake-up in ms
151  */
152 #define N775_TIME_DAISYCHAIN_WAKEUP_MS (N775_N_N775 * (N775_TWAKECOM_MS + N775_TDWAKE_MS))
153 
154 /**
155  * N775 time between two wake up commands in ms
156  */
157 #define N775_TIME_BETWEEN_WAKEUP_MS (4u)
158 
159 /**
160  * N775 time after enumeraiton in ms
161  */
162 #define N775_TIME_AFTER_ENUMERATION_MS (1u)
163 
164 /**
165  * Maximum number of re-tries in case of SPI error during the communication with daisy chain
166  * before going into error state
167  */
168 #define N775_TRANSMIT_SPIERRLIMIT (3u)
169 
170 /**
171  * Max number of Bytes to be received from daisy-chain
172  * This limit is not due to the hardware.
173  * It is only to set the length of the receive buffer for DMA.
174  */
175 #define N775_MAX_N_BYTES_FOR_DATA_RECEPTION (N775_TX_MESSAGE_LENGTH * N775_MAX_NUMBER_OF_VOLTAGES)
176 
177 /*========== Extern Constant and Variable Declarations ======================*/
178 
179 /** Multiplexer measurement sequence */
181 
182 /*========== Extern Function Prototypes =====================================*/
183 
184 /**
185  * @brief converts a raw voltage from multiplexer to a temperature value in
186  * deci &deg;C.
187  * @details The temperatures are read from NTC elements via voltage dividers.
188  * This function implements the look-up table between voltage and
189  * temperature, taking into account the NTC characteristics and the
190  * voltage divider.
191  * @param adcVoltage_mV voltage read from the multiplexer in mV
192  * @return temperature value in deci &deg;C
193  */
194 extern int16_t N775_ConvertVoltagesToTemperatures(uint16_t adcVoltage_mV);
195 
196 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
197 #ifdef UNITY_UNIT_TEST
198 #endif
199 
200 #endif /* FOXBMS__NXP_MC33775A_CFG_H_ */
Configuration of the battery system (e.g., number of battery modules, battery cells,...
Headers for the driver for the DMA module.
N775_MUX_CH_CFG_s n775_muxSequence[N775_MUX_SEQUENCE_LENGTH]
int16_t N775_ConvertVoltagesToTemperatures(uint16_t adcVoltage_mV)
converts a raw voltage from multiplexer to a temperature value in deci °C.
Definitions for the driver for the MC33775A analog front-end.
#define N775_MUX_SEQUENCE_LENGTH
Headers for the driver for the SPI module.