foxBMS  1.2.1
The foxBMS Battery Management System API Documentation
sbc_fs8x_common.h File Reference

Driver common structures, enums, macros and configuration values. More...

#include "spi.h"
#include <stdint.h>
#include <stdbool.h>
Include dependency graph for sbc_fs8x_common.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  fs8x_tx_frame_t
 Structure representing transmit data frame. More...
 
struct  fs8x_rx_frame_t
 Structure representing received data frame. More...
 
struct  fs8x_drv_data_t
 This data structure is used by the FS8x driver (this is the first parameter of most the FS8x functions). It contains a configuration of the FS8x device. More...
 

Macros

#define FS8x_WD_DISABLE   0
 
#define FS8x_WD_SIMPLE   1
 
#define FS8x_WD_CHALLENGER   2
 
#define FS8x_WD_TYPE   FS8x_WD_SIMPLE
 Define Watchdog type (see Watchdog types). More...
 
#define FS8x_COMM_SPI   0
 
#define FS8x_COMM_I2C   1
 
#define FS8x_COMM_BOTH   2
 
#define FS8x_COMM_TYPE   FS8x_COMM_SPI
 Define communication type (see Allowed communication types). More...
 
Bitwise operations used by this driver.
#define FS8x_BO_SETVAL(data, val, mask)   (((data) & ~(mask)) | (val))
 This macro updates value of bits specified by the mask. It is assumed that value is already shifted. More...
 
#define FS8x_BO_SETVAL_EXT(data, value, mask, shift)    (((data) & ~(mask << shift)) | (((value) & (mask)) << (shift)))
 This macro updates value of bits specified by the mask. Additionally range check on the value is performed. It is assumed that value is not shifted. More...
 
#define FS8x_BO_GETVAL(data, mask, shift)   ((data) & (mask) << (shift))
 This macro returns value specified by the mask. More...
 
#define FS8x_BO_GET_REG_VALUE(value, mask, shift)   (((value) & (mask)) >> (shift))
 Macro for getting value from register. More...
 

Enumerations

enum  fs8x_status_t { fs8xStatusOk = 0U , fs8xStatusError = 1U }
 Status return codes. More...
 
enum  fs8x_commType_t { fs8xSPI = 0 , fs8xI2C = 1 }
 Actually selected communication type (SPI or I2C). More...
 
enum  fs8x_command_type_t { fs8xRegRead , fs8xRegWrite }
 Command type. More...
 

Detailed Description

Driver common structures, enums, macros and configuration values.

This header file contains settings for following driver functionalities:

  • Watchdog type selection.
  • Communication type selection (SPI/I2C).
Author
nxf44615
Version
1.1
Date
9-Oct-2018
Updated
2020-03-18 (date of last update) Adapted driver to pass interface configuration as parameter into the functions to enable the usage of multiple ICs in the system.

Definition in file sbc_fs8x_common.h.

Macro Definition Documentation

◆ FS8x_BO_GET_REG_VALUE

#define FS8x_BO_GET_REG_VALUE (   value,
  mask,
  shift 
)    (((value) & (mask)) >> (shift))

Macro for getting value from register.

Parameters
valueValue read from register.
maskBit selection.
shiftBit shift.
Returns
Masked and r-shifted value.

Definition at line 188 of file sbc_fs8x_common.h.

◆ FS8x_BO_GETVAL

#define FS8x_BO_GETVAL (   data,
  mask,
  shift 
)    ((data) & (mask) << (shift))

This macro returns value specified by the mask.

Definition at line 180 of file sbc_fs8x_common.h.

◆ FS8x_BO_SETVAL

#define FS8x_BO_SETVAL (   data,
  val,
  mask 
)    (((data) & ~(mask)) | (val))

This macro updates value of bits specified by the mask. It is assumed that value is already shifted.

Definition at line 172 of file sbc_fs8x_common.h.

◆ FS8x_BO_SETVAL_EXT

#define FS8x_BO_SETVAL_EXT (   data,
  value,
  mask,
  shift 
)     (((data) & ~(mask << shift)) | (((value) & (mask)) << (shift)))

This macro updates value of bits specified by the mask. Additionally range check on the value is performed. It is assumed that value is not shifted.

Definition at line 176 of file sbc_fs8x_common.h.

◆ FS8x_COMM_TYPE

#define FS8x_COMM_TYPE   FS8x_COMM_SPI

Define communication type (see Allowed communication types).

Definition at line 86 of file sbc_fs8x_common.h.

◆ FS8x_WD_TYPE

#define FS8x_WD_TYPE   FS8x_WD_SIMPLE

Define Watchdog type (see Watchdog types).

Definition at line 73 of file sbc_fs8x_common.h.