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