foxBMS  1.1.0
The foxBMS Battery Management System API Documentation
n775_cfg.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 n775_cfg.h
44  * @author foxBMS Team
45  * @date 2020-05-08 (date of creation)
46  * @updated 2021-03-24 (date of last update)
47  * @ingroup DRIVERS_CONFIGURATION
48  * @prefix N775
49  *
50  * @brief Header for the configuration for the MC33775A monitoring chip.
51  *
52  */
53 
54 #ifndef FOXBMS__N775_CFG_H_
55 #define FOXBMS__N775_CFG_H_
56 
57 /*========== Includes =======================================================*/
58 #include "battery_system_cfg.h"
59 
60 #include "n775_defs.h"
61 #include "nxp_mic_dma.h"
62 #include "spi.h"
63 
64 /*========== Macros and Definitions =========================================*/
65 
66 /**
67  * Number of used N775-ICs
68  */
69 #define N775_N_N775 (BS_NR_OF_MODULES)
70 
71 /**
72  * Number of N775-ICs per battery module
73  */
74 #define N775_NUMBER_OF_N775_PER_MODULE (1u)
75 
76 /**
77  * 775A Tx message length in bytes.
78  */
79 #define N775_TX_MESSAGE_LENGTH (7u)
80 
81 /**
82  * 775A Rx message length in bytes.
83  */
84 #define N775_RX_MESSAGE_LENGTH (4u)
85 
86 /**
87  * 775A maximum number of cell voltages that can be measured.
88  */
89 #define N775_MAX_NUMBER_OF_VOLTAGES (14u)
90 
91 /**
92  * Timeout in milliseconds added to the transmission time for interrupt-based
93  * SPI transmission.
94  */
95 #define N775_TRANSMISSION_TIMEOUT (10u)
96 
97 /**
98  * SPI1 is used for communication with N775
99  * @{
100  */
101 #define N775_SPI_HANDLE &spi_devices[0]
102 
103 #define N775_SPI_INSTANCE *N775_SPI_HANDLE.Instance
104 
105 #define N775_SPI_PRESCALER *N775_SPI_HANDLE.Init.BaudRatePrescaler
106 /**@}*/
107 
108 /**
109  * N775 statemachine short time definition in ms
110  */
111 #define N775_STATEMACH_SHORTTIME (1u)
112 
113 /**
114  * N775 Maximum time from wakeup event to possible communication in ms
115  * 2.4ms in datasheet
116  */
117 #define N775_TWAKECOM_MS (3u)
118 
119 /**
120  * N775 Time between two consecutive wake-up messages in ms
121  * 4ms in datasheet
122  */
123 #define N775_TDWAKE_MS (4u)
124 
125 /**
126  * N775 time for daisy-chain to wake-up in ms
127  */
128 #define N775_TIME_DAISYCHAIN_WAKEUP_MS (N775_N_N775 * (N775_TWAKECOM_MS + N775_TDWAKE_MS))
129 
130 /**
131  * N775 time between two wake up commands in ms
132  */
133 #define N775_TIME_BETWEEN_WAKEUP_MS (4u)
134 
135 /**
136  * N775 time after enumeraiton in ms
137  */
138 #define N775_TIME_AFTER_ENUMERATION_MS (1u)
139 
140 /**
141  * Maximum number of re-tries in case of SPI error during the communication with daisy chain
142  * before going into error state
143  */
144 #define N775_TRANSMIT_SPIERRLIMIT (3u)
145 
146 /**
147  * Max number of Bytes to be received from daisy-chain
148  * This limit is not due to the hardware.
149  * It is only to set the length of the receive buffer for DMA.
150  */
151 #define N775_MAX_N_BYTES_FOR_DATA_RECEPTION (N775_TX_MESSAGE_LENGTH * N775_MAX_NUMBER_OF_VOLTAGES)
152 
153 /**
154  * Transmit functions
155  */
156 #define N775_SendData(txbuf, rxbuf, length) SPI_TransmitReceiveDataDma(&spi_nxp775Interface, txbuf, rxbuf, length)
157 
158 /*========== Extern Constant and Variable Declarations ======================*/
159 
160 /**
161  * Lookup table to indicate which voltage inpus are used
162  */
163 extern const uint8_t n775_voltage_input_used[BS_MAX_SUPPORTED_CELLS];
164 
165 /*========== Extern Function Prototypes =====================================*/
166 
167 /**
168  * @brief converts a raw voltage from multiplexer to a temperature value in Celsius.
169  *
170  * The temperatures are read from NTC elements via voltage dividers.
171  * This function implements the look-up table between voltage and temperature,
172  * taking into account the NTC characteristics and the voltage divider.
173  *
174  * @param v_adc_V voltage read from the multiplexer in V
175  *
176  * @return temperature temperature value in deci °C
177  */
178 extern float N775_Convert_MuxVoltages_to_Temperatures(float v_adc_V);
179 
180 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
181 
182 #endif /* FOXBMS__N775_CFG_H_ */
Configuration of the battery system (e.g., number of battery modules, battery cells,...
#define BS_MAX_SUPPORTED_CELLS
Defines the maximal number of supported cells per module.
float N775_Convert_MuxVoltages_to_Temperatures(float v_adc_V)
converts a raw voltage from multiplexer to a temperature value in Celsius.
Definition: n775_cfg.c:84
const uint8_t n775_voltage_input_used[BS_MAX_SUPPORTED_CELLS]
Definition: n775_cfg.c:62
Definitions for the driver for the MC33775A monitoring chip.
Headers for the driver for the DMA module.
Headers for the driver for the SPI module.