foxBMS - Unit Tests  1.4.0
The foxBMS Unit Tests API Documentation
nxp_mc33775a-ll.h File Reference
#include "nxp_mc33775a_cfg.h"
#include "spi.h"
#include "uc_msg_t.h"
Include dependency graph for nxp_mc33775a-ll.h:
This graph shows which files directly or indirectly include this file:

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
 

Enumerations

enum  N775_COMMUNICATION_STATUS {
  N775_COMMUNICATION_OK , N775_COMMUNICATION_ERROR_SHORT_MESSAGE , N775_COMMUNICATION_ERROR_WRONG_CRC , N775_COMMUNICATION_ERROR_WRONG_MESSAGE_COUNT ,
  N775_COMMUNICATION_ERROR_TIMEOUT , N775_COMMUNICATION_ERROR_NO_ACCESS , N775_COMMUNICATION_ERROR_NO_RESPONSE , N775_COMMUNICATION_ERROR_NOT_MATCHING_DEVICE_ADDRESS ,
  N775_COMMUNICATION_ERROR_NOT_MATCHING_REGISTER_ADDRESS
}
 

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...
 

Macro Definition Documentation

◆ N775_ALL_CHAINS

#define N775_ALL_CHAINS   (0x1C0u)

defines for addresses

Definition at line 35 of file nxp_mc33775a-ll.h.

◆ N775_ALL_DEVICES

#define N775_ALL_DEVICES   (0x03Fu)

Definition at line 36 of file nxp_mc33775a-ll.h.

◆ N775_ERROR_REGISTER_ADDRESS

#define N775_ERROR_REGISTER_ADDRESS   0x3FFF

Error register address

Definition at line 39 of file nxp_mc33775a-ll.h.

Typedef Documentation

◆ N775_COMMUNICATION_STATUS_e

Enumeration Type Documentation

◆ N775_COMMUNICATION_STATUS

Enumerator
N775_COMMUNICATION_OK 
N775_COMMUNICATION_ERROR_SHORT_MESSAGE 
N775_COMMUNICATION_ERROR_WRONG_CRC 
N775_COMMUNICATION_ERROR_WRONG_MESSAGE_COUNT 
N775_COMMUNICATION_ERROR_TIMEOUT 
N775_COMMUNICATION_ERROR_NO_ACCESS 
N775_COMMUNICATION_ERROR_NO_RESPONSE 
N775_COMMUNICATION_ERROR_NOT_MATCHING_DEVICE_ADDRESS 
N775_COMMUNICATION_ERROR_NOT_MATCHING_REGISTER_ADDRESS 

Definition at line 41 of file nxp_mc33775a-ll.h.

Function Documentation

◆ N775_CommunicationComposeMessage()

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.

Parameters
cmd
masterAddress
deviceAddress
registerAddress
length
pValue
pMessage

Definition at line 436 of file nxp_mc33775a-ll.c.

◆ N775_CommunicationDecomposeMessage()

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.

Parameters
pMessage
pCommand
pMasterAddress
pDeviceAddress
pRegisterAddress
pLength
pValue
string

Definition at line 464 of file nxp_mc33775a-ll.c.

◆ N775_CommunicationRead()

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.

Parameters
deviceAddress
registerAddress
pValue
n775_state
Returns
returns 0 on success and >=1 in error case

Definition at line 239 of file nxp_mc33775a-ll.c.

Here is the call graph for this function:

◆ N775_CommunicationReadMultiple()

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.

Parameters
deviceAddress
numberOfItems
responseLength
registerAddress
pValues
n775_state
Returns
returns 0 on success and >=1 in error case

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.

Here is the call graph for this function:

◆ N775_CommunicationWrite()

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.

Parameters
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.

Here is the call graph for this function:

◆ N775_ResetMessageCounter()

void N775_ResetMessageCounter ( uint16_t  deviceAddress,
uint8_t  string 
)

Reset the message counter for one or all devices.

Parameters
deviceAddress
string

Definition at line 429 of file nxp_mc33775a-ll.c.