foxBMS
1.4.1
The foxBMS Battery Management System API Documentation
|
Go to the source code of this file.
Macros | |
#define | N775_ALL_CHAINS (0x1C0u) |
#define | N775_ALL_DEVICES (0x03Fu) |
#define | N775_ERROR_REGISTER_ADDRESS 0x3FFF |
Typedefs | |
typedef enum N775_COMMUNICATION_STATUS | N775_COMMUNICATION_STATUS_e |
Functions | |
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. More... | |
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. More... | |
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. More... | |
void | N775_ResetMessageCounter (uint16_t deviceAddress, uint8_t string) |
Reset the message counter for one or all devices. More... | |
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. More... | |
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. More... | |
#define N775_ALL_CHAINS (0x1C0u) |
defines for addresses
Definition at line 35 of file nxp_mc33775a-ll.h.
#define N775_ALL_DEVICES (0x03Fu) |
Definition at line 36 of file nxp_mc33775a-ll.h.
#define N775_ERROR_REGISTER_ADDRESS 0x3FFF |
Error register address
Definition at line 39 of file nxp_mc33775a-ll.h.
typedef enum N775_COMMUNICATION_STATUS N775_COMMUNICATION_STATUS_e |
Definition at line 41 of file nxp_mc33775a-ll.h.
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.
cmd | |
masterAddress | |
deviceAddress | |
registerAddress | |
length | |
pValue | |
pMessage |
Definition at line 436 of file nxp_mc33775a-ll.c.
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.
pMessage | |
pCommand | |
pMasterAddress | |
pDeviceAddress | |
pRegisterAddress | |
pLength | |
pValue | |
string |
Definition at line 464 of file nxp_mc33775a-ll.c.
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.
deviceAddress | |
registerAddress | |
pValue | |
n775_state |
Definition at line 239 of file nxp_mc33775a-ll.c.
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.
deviceAddress | |
numberOfItems | |
responseLength | |
registerAddress | |
pValues | |
n775_state |
numberOfItems = 0 --> corresponds to one frame (max_frames - 1): because first frame is for the mirroring of Tx So (numberOfItems - 1u) is used in the following
The function gets the device address The pack_msg function adds the chain address. Chain address = 1 used so (deviceAddress | (1u << 6u)) is used in the following
After transmission to daisy-chain, daisy-chain will normally answer Already prepare SPI slave for reception
Compute the number of answer frames needed by the MC33775A. Padding is used: always same number of registers in each answer frame (1,2,3 or 4 registers).
Additional answer frame if number of registers to read and number of registers per answer frame are not multiples Example: 22 registers to read, 4 registers per answer frame. Answer: (5*4 register) + (2 registers + 2 words padded with 0)
N775_WRITE_SPI_BUFFER_SIZE (4u): because of Tx mirroring, the command is received, too N775_READ_HEADER_SPI_BUFFER_SIZE + (responseLength - 1u) + 1u: size of one answer frame (responseLength - 1u) 0 --> 1 register --> (responseLength - 1u) +1u = 1 (responseLength - 1u) 1 --> 2 registers --> (responseLength - 1u) +1u = 2 (responseLength - 1u) 2 --> 3 registers --> (responseLength - 1u) +1u = 3 (responseLength - 1u) 3 --> 4 registers --> (responseLength - 1u) +1u = 4
Definition at line 251 of file nxp_mc33775a-ll.c.
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.
deviceAddress | |
registerAddress | |
value | |
pSpiInterface |
The function gets the device address The N775_CommunicationComposeMessage function adds the chain address. Chain address = 1 used so (deviceAddress | (1u << 6u)) is used
Definition at line 204 of file nxp_mc33775a-ll.c.
void N775_ResetMessageCounter | ( | uint16_t | deviceAddress, |
uint8_t | string | ||
) |
Reset the message counter for one or all devices.
deviceAddress | |
string |
Definition at line 429 of file nxp_mc33775a-ll.c.