foxBMS-UnitTests  1.0.0
The foxBMS Unit Tests API Documentation
n775_cfg.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 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_ */
spi.h
Headers for the driver for the SPI module.
battery_system_cfg.h
Configuration of the battery system (e.g., number of battery modules, battery cells,...
nxp_mic_dma.h
Headers for the driver for the DMA module.
N775_Convert_MuxVoltages_to_Temperatures
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
n775_voltage_input_used
const uint8_t n775_voltage_input_used[BS_MAX_SUPPORTED_CELLS]
Definition: n775_cfg.c:62
BS_MAX_SUPPORTED_CELLS
#define BS_MAX_SUPPORTED_CELLS
Defines the maximal number of supported cells per module.
n775_defs.h
Definitions for the driver for the MC33775A monitoring chip.