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