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