ISSDK  1.8
IoT Sensing Software Development Kit
Data Structures | Macros | Functions
fxls8974_drv.h File Reference

The fxls8974_drv.h file describes the FXLS8974CF driver interface and structures. More...

#include <stdint.h>
#include "fxls8974.h"
#include "sensor_io_i2c.h"
#include "sensor_io_spi.h"
#include "register_io_i2c.h"
#include "register_io_spi.h"
Include dependency graph for fxls8974_drv.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  fxls8974_spi_sensorhandle_t
 This defines the sensor specific information for SPI. More...
 
struct  fxls8974_i2c_sensorhandle_t
 This defines the sensor specific information for I2C. More...
 
struct  fxls8974_acceldata_t
 This structure defines the fxls8974 raw data buffer. More...
 

Macros

#define FXLS8974_SPI_MAX_MSG_SIZE   (64)
 
#define FXLS8974_SPI_CMD_LEN   (2)
 The size of the Sensor specific SPI Header. More...
 
#define FXLS8974_SS_ACTIVE_VALUE   SPI_SS_ACTIVE_LOW
 Is the Slave Select Pin Active Low or High. More...
 

Functions

int32_t FXLS8974_I2C_Initialize (fxls8974_i2c_sensorhandle_t *pSensorHandle, ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress, uint8_t *whoAmi)
 The interface function to initialize the sensor. More...
 
void FXLS8974_I2C_SetIdleTask (fxls8974_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
 : The interface function to set the I2C Idle Task. More...
 
int32_t FXLS8974_I2C_Configure (fxls8974_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
 The interface function to configure he sensor. More...
 
int32_t FXLS8974_I2C_ReadData (fxls8974_i2c_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer)
 The interface function to read the sensor data. More...
 
int32_t FXLS8974_I2C_DeInit (fxls8974_i2c_sensorhandle_t *pSensorHandle)
 The interface function to De Initialize sensor.. More...
 
int32_t FXLS8974_SPI_Initialize (fxls8974_spi_sensorhandle_t *pSensorHandle, ARM_DRIVER_SPI *pBus, uint8_t index, void *pSlaveSelect, uint8_t *whoAmi)
 The interface function to initialize the sensor. More...
 
void FXLS8974_SPI_SetIdleTask (fxls8974_spi_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
 : The interface function to set the SPI Idle Task. More...
 
int32_t FXLS8974_SPI_Configure (fxls8974_spi_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
 The interface function to configure he sensor. More...
 
int32_t FXLS8974_SPI_ReadData (fxls8974_spi_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer)
 The interface function to read the sensor data. More...
 
int32_t FXLS8974_SPI_Deinit (fxls8974_spi_sensorhandle_t *pSensorHandle)
 The interface function to De Initialize sensor.. More...
 
void FXLS8974_SPI_ReadPreprocess (void *pCmdOut, uint32_t offset, uint32_t size)
 The SPI Read Pre-Process function to generate Sensor specific SPI Message Header. More...
 
void FXLS8974_SPI_WritePreprocess (void *pCmdOut, uint32_t offset, uint32_t size, void *pWritebuffer)
 The SPI Write Pre-Process function to generate Sensor specific SPI Message Header. More...
 

Detailed Description

The fxls8974_drv.h file describes the FXLS8974CF driver interface and structures.

Definition in file fxls8974_drv.h.

Macro Definition Documentation

◆ FXLS8974_SPI_CMD_LEN

#define FXLS8974_SPI_CMD_LEN   (2)

The size of the Sensor specific SPI Header.

Definition at line 64 of file fxls8974_drv.h.

Referenced by FXLS8974_SPI_Initialize(), FXLS8974_SPI_ReadPreprocess(), and FXLS8974_SPI_WritePreprocess().

◆ FXLS8974_SPI_MAX_MSG_SIZE

#define FXLS8974_SPI_MAX_MSG_SIZE   (64)

Definition at line 60 of file fxls8974_drv.h.

◆ FXLS8974_SS_ACTIVE_VALUE

#define FXLS8974_SS_ACTIVE_VALUE   SPI_SS_ACTIVE_LOW

Is the Slave Select Pin Active Low or High.

Definition at line 68 of file fxls8974_drv.h.

Referenced by FXLS8974_SPI_Initialize().

Function Documentation

◆ FXLS8974_I2C_Configure()

int32_t FXLS8974_I2C_Configure ( fxls8974_i2c_sensorhandle_t pSensorHandle,
const registerwritelist_t pRegWriteList 
)

The interface function to configure he sensor.

This function configure the sensor with requested ODR, Range and registers in the regsiter pair array.

Parameters
[in]pSensorHandlehandle to the sensor.
[in]pRegWriteListpointer to the register list.
Constraints:
This can be called any number of times only after FXLS8974_I2C_Initialize(). Application has to ensure that previous instances of these APIs have exited before invocation. No
Returns
FXLS8974_I2C_Configure() returns the status .

Validate for the correct handle and register write list.

Check whether sensor handle is initialized before applying configuration.

Put the device into standby mode so that configuration can be applied.

Apply the Sensor Configuration based on the Register Write List

Put the device into active mode and ready for reading data.

Definition at line 285 of file fxls8974_drv.c.

References fxls8974_i2c_sensorhandle_t::deviceInfo, FXLS8974_SENS_CONFIG1, FXLS8974_SENS_CONFIG1_ACTIVE_ACTIVE, FXLS8974_SENS_CONFIG1_ACTIVE_MASK, FXLS8974_SENS_CONFIG1_ACTIVE_STANDBY, int32_t(), fxls8974_i2c_sensorhandle_t::isInitialized, fxls8974_i2c_sensorhandle_t::pCommDrv, Register_I2C_Write(), SENSOR_ERROR_INIT, SENSOR_ERROR_INVALID_PARAM, SENSOR_ERROR_NONE, SENSOR_ERROR_WRITE, Sensor_I2C_Write(), fxls8974_i2c_sensorhandle_t::slaveAddress, and status.

Referenced by apply_register_write(), main(), and perform_selftest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FXLS8974_I2C_DeInit()

int32_t FXLS8974_I2C_DeInit ( fxls8974_i2c_sensorhandle_t pSensorHandle)

The interface function to De Initialize sensor..

This function made sensor in a power safe state and de initialize its handle.

Parameters
[in]pSensorHandlehandle to the sensor.
Constraints:
This can be called only after FXLS8974_I2C_Initialize(). Application has to ensure that previous instances of these APIs have exited before invocation. No
Returns
FXLS8974_I2C_DeInit() returns the status .

Check whether sensor handle is initialized before triggering sensor reset.

Trigger sensor device reset.

De-initialize sensor handle.

Definition at line 359 of file fxls8974_drv.c.

References BOARD_DELAY_ms(), fxls8974_i2c_sensorhandle_t::deviceInfo, FXLS8974_SENS_CONFIG1, FXLS8974_SENS_CONFIG1_RST_MASK, FXLS8974_SENS_CONFIG1_RST_RST, FXLS8974_TBOOT_MAX, int32_t(), fxls8974_i2c_sensorhandle_t::isInitialized, fxls8974_i2c_sensorhandle_t::pCommDrv, Register_I2C_Write(), SENSOR_ERROR_INIT, SENSOR_ERROR_INVALID_PARAM, SENSOR_ERROR_NONE, SENSOR_ERROR_WRITE, fxls8974_i2c_sensorhandle_t::slaveAddress, and status.

Here is the call graph for this function:

◆ FXLS8974_I2C_Initialize()

int32_t FXLS8974_I2C_Initialize ( fxls8974_i2c_sensorhandle_t pSensorHandle,
ARM_DRIVER_I2C *  pBus,
uint8_t  index,
uint16_t  sAddress,
uint8_t *  whoAmi 
)

The interface function to initialize the sensor.

This function initialize the sensor and sensor handle.

Parameters
[in]pSensorHandlehandle to the sensor.
[in]pBuspointer to the CMSIS API compatible I2C bus object.
[in]indexthe I2C device number.
[in]sAddressslave address of the device on the bus.
[in]whoamiWHO_AM_I value of the device.
Constraints:
This should be the first API to be called. Application has to ensure that previous instances of these APIs have exited before invocation. No
Returns
FXLS8974_I2C_Initialize() returns the status .

Check the input parameters.

Read and store the device's WHO_AM_I.

Initialize the sensor handle.

Definition at line 239 of file fxls8974_drv.c.

References fxls8974_i2c_sensorhandle_t::deviceInfo, registerDeviceInfo_t::deviceInstance, registerDeviceInfo_t::functionParam, FXLS8962_WHOAMI_VALUE, FXLS8964_WHOAMI_VALUE, FXLS8967_WHOAMI_VALUE, FXLS8968_WHOAMI_VALUE, FXLS8974_WHO_AM_I, FXLS8974_WHOAMI_VALUE, registerDeviceInfo_t::idleFunction, int32_t(), fxls8974_i2c_sensorhandle_t::isInitialized, fxls8974_i2c_sensorhandle_t::pCommDrv, Register_I2C_Read(), SENSOR_ERROR_BAD_ADDRESS, SENSOR_ERROR_INIT, SENSOR_ERROR_INVALID_PARAM, SENSOR_ERROR_NONE, fxls8974_i2c_sensorhandle_t::slaveAddress, and status.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FXLS8974_I2C_ReadData()

int32_t FXLS8974_I2C_ReadData ( fxls8974_i2c_sensorhandle_t pSensorHandle,
const registerreadlist_t pReadList,
uint8_t *  pBuffer 
)

The interface function to read the sensor data.

This function read the sensor data out from the device and returns raw data in a byte stream.

Parameters
[in]pSensorHandlehandle to the sensor.
[in]pReadListpointer to the list of device registers and values to read.
[out]pBufferbuffer which holds raw sensor data.This buffer may be back to back databuffer based command read in the list.
Constraints:
This can be called any number of times only after FXLS8974_I2C_Initialize(). Application has to ensure that previous instances of these APIs have exited before invocation. No
Returns
FXLS8974_I2C_ReadData() returns the status .

Validate for the correct handle and register read list.

Check whether sensor handle is initialized before reading sensor data.

Parse through the read list and read the data one by one.

Definition at line 330 of file fxls8974_drv.c.

References fxls8974_i2c_sensorhandle_t::deviceInfo, int32_t(), fxls8974_i2c_sensorhandle_t::isInitialized, fxls8974_i2c_sensorhandle_t::pCommDrv, SENSOR_ERROR_INIT, SENSOR_ERROR_INVALID_PARAM, SENSOR_ERROR_NONE, SENSOR_ERROR_READ, Sensor_I2C_Read(), fxls8974_i2c_sensorhandle_t::slaveAddress, and status.

Referenced by apply_register_read(), apply_register_readall(), main(), and perform_selftest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FXLS8974_I2C_SetIdleTask()

void FXLS8974_I2C_SetIdleTask ( fxls8974_i2c_sensorhandle_t pSensorHandle,
registeridlefunction_t  idleTask,
void *  userParam 
)

: The interface function to set the I2C Idle Task.

Parameters
[in]fxls8974_i2c_sensorhandle_t *pSensorHandle, handle to the sensor handle.
[in]registeridlefunction_t idleTask, function pointer to the function to execute on I2C Idle Time.
[in]void *userParam, the pointer to the user idle ftask parameters.
Returns
void.
Constraints:
This can be called any number of times only after FXLS8974_I2C_Initialize(). Application has to ensure that previous instances of these APIs have exited before invocation. No

Definition at line 277 of file fxls8974_drv.c.

References fxls8974_i2c_sensorhandle_t::deviceInfo, registerDeviceInfo_t::functionParam, and registerDeviceInfo_t::idleFunction.

Referenced by main().

Here is the caller graph for this function:

◆ FXLS8974_SPI_Configure()

int32_t FXLS8974_SPI_Configure ( fxls8974_spi_sensorhandle_t pSensorHandle,
const registerwritelist_t pRegWriteList 
)

The interface function to configure he sensor.

This function configure the sensor with requested ODR, Range and registers in the regsiter pair array.

Parameters
[in]pSensorHandlehandle to the sensor.
[in]pRegWriteListpointer to the register list.
Constraints:
This can be called any number of times only after FXLS8974_SPI_Initialize(). Application has to ensure that previous instances of these APIs have exited before invocation. No
Returns
FXLS8974_SPI_Configure() returns the status .

Validate for the correct handle and register write list.

Check whether sensor handle is initialized before applying configuration.

Put the device into standby mode so that configuration can be applied.

Apply the Sensor Configuration based on the Register Write List

Put the device into active mode and ready for reading data.

Definition at line 130 of file fxls8974_drv.c.

References fxls8974_spi_sensorhandle_t::deviceInfo, FXLS8974_SENS_CONFIG1, FXLS8974_SENS_CONFIG1_ACTIVE_ACTIVE, FXLS8974_SENS_CONFIG1_ACTIVE_MASK, FXLS8974_SENS_CONFIG1_ACTIVE_STANDBY, int32_t(), fxls8974_spi_sensorhandle_t::isInitialized, fxls8974_spi_sensorhandle_t::pCommDrv, Register_SPI_Write(), SENSOR_ERROR_INIT, SENSOR_ERROR_INVALID_PARAM, SENSOR_ERROR_NONE, SENSOR_ERROR_WRITE, Sensor_SPI_Write(), fxls8974_spi_sensorhandle_t::slaveParams, and status.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FXLS8974_SPI_Deinit()

int32_t FXLS8974_SPI_Deinit ( fxls8974_spi_sensorhandle_t pSensorHandle)

The interface function to De Initialize sensor..

This function made sensor in a power safe state and de initialize its handle.

Parameters
[in]pSensorHandlehandle to the sensor.
Constraints:
This can be called only after after FXLS8974_SPI_Initialize(). Application has to ensure that previous instances of these APIs have exited before invocation. No
Returns
FXLS8974_SPI_Deinit() returns the status .

Check whether sensor handle is initialized before triggering sensor reset.

Trigger sensor device reset.

De-initialize sensor handle.

Definition at line 204 of file fxls8974_drv.c.

References BOARD_DELAY_ms(), fxls8974_spi_sensorhandle_t::deviceInfo, FXLS8974_SENS_CONFIG1, FXLS8974_SENS_CONFIG1_RST_MASK, FXLS8974_SENS_CONFIG1_RST_RST, FXLS8974_TBOOT_MAX, int32_t(), fxls8974_spi_sensorhandle_t::isInitialized, fxls8974_spi_sensorhandle_t::pCommDrv, Register_SPI_Write(), SENSOR_ERROR_INIT, SENSOR_ERROR_INVALID_PARAM, SENSOR_ERROR_NONE, SENSOR_ERROR_WRITE, fxls8974_spi_sensorhandle_t::slaveParams, and status.

Here is the call graph for this function:

◆ FXLS8974_SPI_Initialize()

int32_t FXLS8974_SPI_Initialize ( fxls8974_spi_sensorhandle_t pSensorHandle,
ARM_DRIVER_SPI *  pBus,
uint8_t  index,
void *  pSlaveSelect,
uint8_t *  whoAmi 
)

The interface function to initialize the sensor.

This function initializes the sensor and sensor handle.

Parameters
[in]pSensorHandlehandle to the sensor.
[in]pBuspointer to the CMSIS API compatible SPI bus object.
[in]indexthe I2C device number.
[in]pSlaveSelectslave select hndle of the device on the bus.
[in]whoamiWHO_AM_I value of the device.
Constraints:
This should be the first API to be called. Application has to ensure that previous instances of these APIs have exited before invocation. No
Returns
FXLS8974_SPI_Initialize() returns the status .

Check the input parameters.

Initialize the sensor handle.

Read and store the device's WHO_AM_I.

Definition at line 67 of file fxls8974_drv.c.

References GENERIC_DRIVER_GPIO::clr_pin, fxls8974_spi_sensorhandle_t::deviceInfo, registerDeviceInfo_t::deviceInstance, Driver_GPIO_KSDK, registerDeviceInfo_t::functionParam, FXLS8962_WHOAMI_VALUE, FXLS8964_WHOAMI_VALUE, FXLS8967_WHOAMI_VALUE, FXLS8968_WHOAMI_VALUE, FXLS8974_SPI_CMD_LEN, FXLS8974_SPI_ReadPreprocess(), FXLS8974_SPI_WritePreprocess(), FXLS8974_SS_ACTIVE_VALUE, FXLS8974_WHO_AM_I, FXLS8974_WHOAMI_VALUE, GPIO_DIRECTION_OUT, registerDeviceInfo_t::idleFunction, int32_t(), fxls8974_spi_sensorhandle_t::isInitialized, fxls8974_spi_sensorhandle_t::pCommDrv, pGPIODriver, GENERIC_DRIVER_GPIO::pin_init, spiSlaveSpecificParams_t::pReadPreprocessFN, spiSlaveSpecificParams_t::pTargetSlavePinID, spiSlaveSpecificParams_t::pWritePreprocessFN, Register_SPI_Read(), SENSOR_ERROR_BAD_ADDRESS, SENSOR_ERROR_INIT, SENSOR_ERROR_INVALID_PARAM, SENSOR_ERROR_NONE, GENERIC_DRIVER_GPIO::set_pin, fxls8974_spi_sensorhandle_t::slaveParams, SPI_SS_ACTIVE_LOW, spiSlaveSpecificParams_t::spiCmdLen, spiSlaveSpecificParams_t::ssActiveValue, and status.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FXLS8974_SPI_ReadData()

int32_t FXLS8974_SPI_ReadData ( fxls8974_spi_sensorhandle_t pSensorHandle,
const registerreadlist_t pReadList,
uint8_t *  pBuffer 
)

The interface function to read the sensor data.

This function read the sensor data out from the device and returns raw data in a byte stream.

Parameters
[in]pSensorHandlehandle to the sensor.
[in]pReadListpointer to the list of device registers and values to read.
[out]pBufferbuffer which holds raw sensor data.This buffer may be back to back databuffer based command read in the list.
Constraints:
This can be called any number of times only after FXLS8974_SPI_Initialize(). Application has to ensure that previous instances of these APIs have exited before invocation. No
Returns
FXLS8974_SPI_ReadData() returns the status .

Validate for the correct handle and register read list.

Check whether sensor handle is initialized before reading sensor data.

Parse through the read list and read the data one by one.

Definition at line 175 of file fxls8974_drv.c.

References fxls8974_spi_sensorhandle_t::deviceInfo, int32_t(), fxls8974_spi_sensorhandle_t::isInitialized, fxls8974_spi_sensorhandle_t::pCommDrv, SENSOR_ERROR_INIT, SENSOR_ERROR_INVALID_PARAM, SENSOR_ERROR_NONE, SENSOR_ERROR_READ, Sensor_SPI_Read(), fxls8974_spi_sensorhandle_t::slaveParams, and status.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FXLS8974_SPI_ReadPreprocess()

void FXLS8974_SPI_ReadPreprocess ( void *  pCmdOut,
uint32_t  offset,
uint32_t  size 
)

The SPI Read Pre-Process function to generate Sensor specific SPI Message Header.

This function prepares the SPI Read Command Header with register address and R/W bit encoded as the Sensor.

Parameters
[out]pCmdOuthandle to the output buffer.
[in]offsetthe address of the register to start reading from.
[in]sizenumber of bytes to read.
Constraints:
None Application has to ensure that previous instances of these APIs have exited before invocation. No
Returns
:: None.

Definition at line 30 of file fxls8974_drv.c.

References FXLS8974_SPI_CMD_LEN, fxls8974_spiRead_CmdBuffer, fxls8974_spiRead_DataBuffer, spi_mater_SlaveCmd::pReadBuffer, spi_mater_SlaveCmd::pWriteBuffer, and spi_mater_SlaveCmd::size.

Referenced by FXLS8974_SPI_Initialize().

Here is the caller graph for this function:

◆ FXLS8974_SPI_SetIdleTask()

void FXLS8974_SPI_SetIdleTask ( fxls8974_spi_sensorhandle_t pSensorHandle,
registeridlefunction_t  idleTask,
void *  userParam 
)

: The interface function to set the SPI Idle Task.

Parameters
[in]fxls8974_spi_sensorhandle_t *pSensorHandle, handle to the sensor handle.
[in]registeridlefunction_t idleTask, function pointer to the function to execute on SPI Idle Time.
[in]void *userParam, the pointer to the user idle ftask parameters.
Returns
void.
Constraints:
This can be called any number of times only after FXLS8974_SPI_Initialize(). Application has to ensure that previous instances of these APIs have exited before invocation. No

Definition at line 122 of file fxls8974_drv.c.

References fxls8974_spi_sensorhandle_t::deviceInfo, registerDeviceInfo_t::functionParam, and registerDeviceInfo_t::idleFunction.

Referenced by main().

Here is the caller graph for this function:

◆ FXLS8974_SPI_WritePreprocess()

void FXLS8974_SPI_WritePreprocess ( void *  pCmdOut,
uint32_t  offset,
uint32_t  size,
void *  pWritebuffer 
)

The SPI Write Pre-Process function to generate Sensor specific SPI Message Header.

This function prepares the SPI Write Command Header with register address and R/W bit encoded as the Sensor.

Parameters
[out]pCmdOuthandle to the output buffer.
[in]offsetthe address of the register to start writing from.
[in]sizenumber of bytes to write.
Constraints:
None Application has to ensure that previous instances of these APIs have exited before invocation. No
Returns
:: None.

Definition at line 47 of file fxls8974_drv.c.

References FXLS8974_SPI_CMD_LEN, fxls8974_spiWrite_CmdDataBuffer, spi_mater_SlaveCmd::pReadBuffer, spi_mater_SlaveCmd::pWriteBuffer, and spi_mater_SlaveCmd::size.

Referenced by FXLS8974_SPI_Initialize().

Here is the caller graph for this function: