foxBMS - Unit Tests
1.3.0
The foxBMS Unit Tests API Documentation
|
Implementation of communication logic for NXP SBC FS8x. More...
#include <stdint.h>
#include <stddef.h>
#include "sbc_fs8x_map.h"
#include "sbc_fs8x_assert.h"
#include "sbc_fs8x_common.h"
#include "sbc_fs8x_communication.h"
Go to the source code of this file.
Macros | |
#define | FS8x_REG_ADDR_MASK 0x3FU |
#define | FS8x_REG_ADDR_SHIFT 0x01U |
#define | FS8x_I2C_READ_FRAME_LENGTH 1U |
#define | FS8x_I2C_ADDRESS_BASE 0x20U |
#define | FS8x_I2C_FRAME_SIZE 0x05U |
#define | FS8x_I2C_RX_SIZE 0x03U |
#define | FS8x_CRC_TBL_SIZE 256U |
#define | FS8x_COM_CRC_POLYNOM 0x1DU |
#define | FS8x_COM_CRC_INIT 0xFFU |
Functions | |
static uint8_t | FS8x_CalcCRC (const uint8_t *data, uint8_t dataLen) |
This function calculates CRC value of passed data array. Takes bytes in inverted order due to frame format. More... | |
static fs8x_status_t | FS8x_CheckCRC (const uint8_t *data, uint8_t dataLen) |
Performs CRC check of the data array. More... | |
static fs8x_status_t | FS8x_SPI_TransferData (SPI_INTERFACE_CONFIG_s *pSpiInterface, fs8x_tx_frame_t *txData, fs8x_rx_frame_t *rxData) |
Performs SPI transfer of the txData. Received frame is saved into rxData structure. More... | |
static void | FS8x_SPI_CreateSendFrame (fs8x_tx_frame_t *txData, uint8_t *txFrame) |
Creates a raw frame for SPI transfer. More... | |
fs8x_status_t | FS8x_ReadRegister (SPI_INTERFACE_CONFIG_s *pSpiInterface, fs8x_drv_data_t *drvData, bool isFailSafe, uint8_t address, fs8x_rx_frame_t *rxData) |
Performs a read from a single FS8x register. More... | |
fs8x_status_t | FS8x_WriteRegister (SPI_INTERFACE_CONFIG_s *pSpiInterface, fs8x_drv_data_t *drvData, bool isFailSafe, uint8_t address, uint16_t writeData) |
Sends write command to the FS8x. More... | |
fs8x_status_t | FS8x_WriteRegisterInit (SPI_INTERFACE_CONFIG_s *pSpiInterface, fs8x_drv_data_t *drvData, uint8_t address, uint16_t writeData) |
Performs a write to a single FS8x FS init register (during the INIT_FS phase only). More... | |
fs8x_status_t | FS8x_UpdateRegister (SPI_INTERFACE_CONFIG_s *pSpiInterface, fs8x_drv_data_t *drvData, bool isFailSafe, uint8_t address, int16_t mask, uint16_t writeData) |
Performs update of a single register. It affects bits specified by a bit mask. More... | |
Variables | |
static const uint8_t | FS8x_CRC_TABLE [FS8x_CRC_TBL_SIZE] |
CRC lookup table. More... | |
Implementation of communication logic for NXP SBC FS8x.
Definition in file sbc_fs8x_communication.c.
#define FS8x_COM_CRC_INIT 0xFFU |
CRC initial value.
Definition at line 73 of file sbc_fs8x_communication.c.
#define FS8x_COM_CRC_POLYNOM 0x1DU |
CRC polynom.
Definition at line 72 of file sbc_fs8x_communication.c.
#define FS8x_CRC_TBL_SIZE 256U |
Size of CRC table.
Definition at line 71 of file sbc_fs8x_communication.c.
#define FS8x_I2C_ADDRESS_BASE 0x20U |
I2C device base address
Definition at line 66 of file sbc_fs8x_communication.c.
#define FS8x_I2C_FRAME_SIZE 0x05U |
Length of the complete I2C frame
Definition at line 67 of file sbc_fs8x_communication.c.
#define FS8x_I2C_READ_FRAME_LENGTH 1U |
Length of the data frame for I2C read command.
Definition at line 65 of file sbc_fs8x_communication.c.
#define FS8x_I2C_RX_SIZE 0x03U |
Length of the received I2C data frame
Definition at line 68 of file sbc_fs8x_communication.c.
#define FS8x_REG_ADDR_MASK 0x3FU |
< Length of the communication frame Register address mask
Definition at line 61 of file sbc_fs8x_communication.c.
#define FS8x_REG_ADDR_SHIFT 0x01U |
SPI register address shift
Definition at line 62 of file sbc_fs8x_communication.c.
|
static |
This function calculates CRC value of passed data array. Takes bytes in inverted order due to frame format.
[in] | data | Data array. |
[in] | dataLen | Length of the data array. |
Definition at line 344 of file sbc_fs8x_communication.c.
|
static |
Performs CRC check of the data array.
CRC is expected in the first array item (index 0).
[in] | data | Data array. |
[in] | dataLen | Length of the data array. |
Definition at line 365 of file sbc_fs8x_communication.c.
|
static |
Creates a raw frame for SPI transfer.
[in] | txData | TX data. |
[out] | txFrame | TX frame for SPI transfer. |
Definition at line 211 of file sbc_fs8x_communication.c.
|
static |
Performs SPI transfer of the txData. Received frame is saved into rxData structure.
[in,out] | pSpiInterface | SPI communication interface config |
[in] | txData | TX data. |
[out] | rxData | RX data. Can be NULL in case of write-only command. |
Definition at line 180 of file sbc_fs8x_communication.c.
|
static |
CRC lookup table.
Definition at line 80 of file sbc_fs8x_communication.c.