foxBMS - Unit Tests  1.4.1
The foxBMS Unit Tests 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 #ifndef FOXBMS__NXP_MC33775A_LL_H_
24 #define FOXBMS__NXP_MC33775A_LL_H_
25 
26 /*========== Includes =======================================================*/
27 #include "nxp_mc33775a_cfg.h"
28 
29 #include "spi.h"
30 #include "uc_msg_t.h"
31 
32 /*========== Macros and Definitions =========================================*/
33 
34 /** defines for addresses */
35 #define N775_ALL_CHAINS (0x1C0u)
36 #define N775_ALL_DEVICES (0x03Fu)
37 
38 /** Error register address */
39 #define N775_ERROR_REGISTER_ADDRESS 0x3FFF
40 
52 
53 /*========== Extern Constant and Variable Declarations ======================*/
54 
55 /*========== Extern Function Prototypes =====================================*/
56 /**
57  * @brief Write a value into a specific register in a specific device
58  * @param deviceAddress
59  * @param registerAddress
60  * @param value
61  * @param pSpiInterface
62  */
64  uint16_t deviceAddress,
65  uint16_t registerAddress,
66  uint16_t value,
67  SPI_INTERFACE_CONFIG_s *pSpiInterface);
68 
69 /**
70  * @brief Read a value from a specific register in a specific device
71  * @param deviceAddress
72  * @param registerAddress
73  * @param pValue
74  * @param n775_state
75  * @return returns 0 on success and >=1 in error case
76  */
78  uint16_t deviceAddress,
79  uint16_t registerAddress,
80  uint16_t *pValue,
81  N775_STATE_s *n775_state);
82 
83 /**
84  * @brief Read multiple values from specific registers in a specific device
85  * @param deviceAddress
86  * @param numberOfItems
87  * @param responseLength
88  * @param registerAddress
89  * @param pValues
90  * @param n775_state
91  * @return returns 0 on success and >=1 in error case
92  */
94  uint16_t deviceAddress,
95  uint16_t numberOfItems,
96  uint16_t responseLength,
97  uint16_t registerAddress,
98  uint16_t *pValues,
99  N775_STATE_s *n775_state);
100 
101 /**
102  * @brief Reset the message counter for one or all devices
103  * @param deviceAddress
104  * @param string
105  */
106 void N775_ResetMessageCounter(uint16_t deviceAddress, uint8_t string);
107 
108 /**
109  * @brief Composes a message
110  * @param cmd
111  * @param masterAddress
112  * @param deviceAddress
113  * @param registerAddress
114  * @param length
115  * @param pValue
116  * @param pMessage
117  */
119  uint16_t cmd,
120  uint16_t masterAddress,
121  uint16_t deviceAddress,
122  uint16_t registerAddress,
123  uint16_t length,
124  uint16_t *pValue,
125  uc_msg_t *pMessage);
126 
127 /**
128  * @brief Decomposes and analysis a message
129  * @param pMessage
130  * @param pCommand
131  * @param pMasterAddress
132  * @param pDeviceAddress
133  * @param pRegisterAddress
134  * @param pLength
135  * @param pValue
136  * @param string
137  */
139  uc_msg_t *pMessage,
140  uint16_t *pCommand,
141  uint16_t *pMasterAddress,
142  uint16_t *pDeviceAddress,
143  uint16_t *pRegisterAddress,
144  uint16_t *pLength,
145  uint16_t *pValue,
146  uint8_t string);
147 
148 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
149 
150 #endif /* FOXBMS__NXP_MC33775A_LL_H_ */
N775_COMMUNICATION_STATUS_e N775_CommunicationReadMultiple(uint16_t deviceAddress, uint16_t numberOfItems, uint16_t responseLength, uint16_t registerAddress, uint16_t *pValues, N775_STATE_s *n775_state)
Read multiple values from specific registers in a specific device.
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.
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_e N775_CommunicationRead(uint16_t deviceAddress, uint16_t registerAddress, uint16_t *pValue, N775_STATE_s *n775_state)
Read a value from 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 monitoring chip.
Headers for the driver for the SPI module.