foxBMS  1.6.0
The foxBMS Battery Management System API Documentation
nxp_mc33775a-ll.h
Go to the documentation of this file.
1 /* Copyright 2019 NXP
2 *
3 * Redistribution and use in source and binary forms, with or without modification, are permitted
4 * provided that the following terms are met:
5 * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
6 * and the following disclaimer.
7 * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions,
8 * and the following disclaimer in the documentation and/or other materials provided with the distribution.
9 * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse
10 * or promote products derived from this software without specific prior written permission.
11 *
12 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ?AS IS? AND ANY
13 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
15 * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
16 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
17 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA; OR PROFITS; OR BUSINESS INTERRUPTION)
18 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
19 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
20 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21 */
22 
23 /**
24  * @file nxp_mc33775a-ll.h
25  * @author NXP
26  * @date 2022-07-29 (date of creation)
27  * @updated 2023-09-05 (date of last update)
28  * @version v1.6.0
29  * @ingroup DRIVERS
30  * @prefix N775
31  *
32  * @brief Header for the low level driver for the MC33775A
33  *
34  */
35 
36 #ifndef FOXBMS__NXP_MC33775A_LL_H_
37 #define FOXBMS__NXP_MC33775A_LL_H_
38 
39 /*========== Includes =======================================================*/
40 #include "nxp_mc33775a_cfg.h"
41 
42 #include "spi.h"
43 #include "uc_msg_t.h"
44 
45 #include <stdint.h>
46 
47 /*========== Macros and Definitions =========================================*/
48 
49 /** defines for addresses */
50 #define N775_ALL_CHAINS (0x1C0u)
51 #define N775_ALL_DEVICES (0x03Fu)
52 
53 /** Error register address */
54 #define N775_ERROR_REGISTER_ADDRESS 0x3FFF
55 
67 
68 /*========== Extern Constant and Variable Declarations ======================*/
69 
70 /*========== Extern Function Prototypes =====================================*/
71 /**
72  * @brief Write a value into a specific register in a specific device
73  * @param deviceAddress
74  * @param registerAddress
75  * @param value
76  * @param pSpiInterface
77  */
79  uint16_t deviceAddress,
80  uint16_t registerAddress,
81  uint16_t value,
82  SPI_INTERFACE_CONFIG_s *pSpiInterface);
83 
84 /**
85  * @brief Read a value from a specific register in a specific device
86  * @param deviceAddress
87  * @param registerAddress
88  * @param pValue
89  * @param pState
90  * @return returns 0 on success and >=1 in error case
91  */
93  uint16_t deviceAddress,
94  uint16_t registerAddress,
95  uint16_t *pValue,
96  N775_STATE_s *pState);
97 
98 /**
99  * @brief Read multiple values from specific registers in a specific device
100  * @param deviceAddress
101  * @param numberOfItems
102  * @param responseLength
103  * @param registerAddress
104  * @param pValues
105  * @param pState
106  * @return returns 0 on success and >=1 in error case
107  */
109  uint16_t deviceAddress,
110  uint16_t numberOfItems,
111  uint16_t responseLength,
112  uint16_t registerAddress,
113  uint16_t *pValues,
114  N775_STATE_s *pState);
115 
116 /**
117  * @brief Reset the message counter for one or all devices
118  * @param deviceAddress
119  * @param string
120  */
121 void N775_ResetMessageCounter(uint16_t deviceAddress, uint8_t string);
122 
123 /**
124  * @brief Composes a message
125  * @param cmd
126  * @param masterAddress
127  * @param deviceAddress
128  * @param registerAddress
129  * @param length
130  * @param pValue
131  * @param pMessage
132  */
134  uint16_t cmd,
135  uint16_t masterAddress,
136  uint16_t deviceAddress,
137  uint16_t registerAddress,
138  uint16_t length,
139  uint16_t *pValue,
140  uc_msg_t *pMessage);
141 
142 /**
143  * @brief Decomposes and analysis a message
144  * @param pMessage
145  * @param pCommand
146  * @param pMasterAddress
147  * @param pDeviceAddress
148  * @param pRegisterAddress
149  * @param pLength
150  * @param pValue
151  * @param string
152  */
154  uc_msg_t *pMessage,
155  uint16_t *pCommand,
156  uint16_t *pMasterAddress,
157  uint16_t *pDeviceAddress,
158  uint16_t *pRegisterAddress,
159  uint16_t *pLength,
160  uint16_t *pValue,
161  uint8_t string);
162 
163 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
164 #ifdef UNITY_UNIT_TEST
165 #endif
166 
167 #endif /* FOXBMS__NXP_MC33775A_LL_H_ */
N775_COMMUNICATION_STATUS_e N775_CommunicationDecomposeMessage(uc_msg_t *pMessage, uint16_t *pCommand, uint16_t *pMasterAddress, uint16_t *pDeviceAddress, uint16_t *pRegisterAddress, uint16_t *pLength, uint16_t *pValue, uint8_t string)
Decomposes and analysis a message.
N775_COMMUNICATION_STATUS_e N775_CommunicationRead(uint16_t deviceAddress, uint16_t registerAddress, uint16_t *pValue, N775_STATE_s *pState)
Read a value from a specific register in a specific device.
N775_COMMUNICATION_STATUS_e N775_CommunicationReadMultiple(uint16_t deviceAddress, uint16_t numberOfItems, uint16_t responseLength, uint16_t registerAddress, uint16_t *pValues, N775_STATE_s *pState)
Read multiple values from specific registers in a specific device.
enum N775_COMMUNICATION_STATUS N775_COMMUNICATION_STATUS_e
void N775_ResetMessageCounter(uint16_t deviceAddress, uint8_t string)
Reset the message counter for one or all devices.
void N775_CommunicationWrite(uint16_t deviceAddress, uint16_t registerAddress, uint16_t value, SPI_INTERFACE_CONFIG_s *pSpiInterface)
Write a value into a specific register in a specific device.
N775_COMMUNICATION_STATUS
@ N775_COMMUNICATION_ERROR_NOT_MATCHING_REGISTER_ADDRESS
@ N775_COMMUNICATION_ERROR_NO_ACCESS
@ N775_COMMUNICATION_ERROR_WRONG_MESSAGE_COUNT
@ N775_COMMUNICATION_OK
@ N775_COMMUNICATION_ERROR_WRONG_CRC
@ N775_COMMUNICATION_ERROR_TIMEOUT
@ N775_COMMUNICATION_ERROR_SHORT_MESSAGE
@ N775_COMMUNICATION_ERROR_NO_RESPONSE
@ N775_COMMUNICATION_ERROR_NOT_MATCHING_DEVICE_ADDRESS
void N775_CommunicationComposeMessage(uint16_t cmd, uint16_t masterAddress, uint16_t deviceAddress, uint16_t registerAddress, uint16_t length, uint16_t *pValue, uc_msg_t *pMessage)
Composes a message.
Header for the configuration for the MC33775A analog front-end.
Headers for the driver for the SPI module.