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

The fxlc95000_drv.h file describes the FXLC95000L driver interface and structures. More...

#include <stdint.h>
#include "fxlc95000.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 fxlc95000_drv.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  fxlc95000_spi_sensorhandle_t
 This defines the sensor specific information for SPI. More...
 
struct  fxlc95000_i2c_sensorhandle_t
 This defines the sensor specific information for I2C. More...
 
struct  fxlc95000_acceldata_t
 This structure defines the fxlc95000 pedometer data buffer. More...
 

Macros

#define FXLC95000_COCO_ERROR_MASK   (0x7F)
 The Error Bit Mask in COCO Byte. More...
 
#define FXLC95000_SPI_MAX_MSG_SIZE   (64)
 The MAX size of SPI message. More...
 
#define FXLC95000_SPI_CMD_LEN   (1)
 The size of the Sensor specific SPI Header. More...
 
#define FXLC95000_SS_ACTIVE_VALUE   SPI_SS_ACTIVE_LOW
 Is the Slave Select Pin Active Low or High. More...
 
#define FXLC95000_ROM_CI_WRITE_MIN_LEN   4
 The MIN Length of ROM CI_WRITE Data. More...
 
#define FXLC95000_ROM_CI_WRITE_MAX_LEN   24
 The MAX Length of ROM CI_WRITE Data. More...
 
#define FXLC95000_ROM_CI_READ_WRITE_MAX_LEN   32
 The MAX Length of ROM CI_READ_WRITE Command. More...
 
#define FXLC95000_ROM_CI_READ_WRITE_HDR_LEN   6
 The Length of ROM CI_READ_WRITE Command Header. More...
 
#define FXLC95000_ROM_CI_READ_WRITE_ADDR_LEN   2
 The Length of Address field in ROM CI_READ_WRITE Command Header. More...
 
#define FXLC95000_FLASH_PAYLOAD_ADDR_LEN   4
 The Length of Address field in FLASH Payload form Host. More...
 

Functions

int32_t FXLC95000_I2C_CheckRomMode (ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress)
 The interface function to check if the sensor is in ROM CI Mode. More...
 
int32_t FXLC95000_I2C_FlashCommands (ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress, const registercommandlist_t *pCommandList)
 The interface function to write ROM CI Commands. More...
 
int32_t FXLC95000_I2C_FlashPayload (ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress, uint8_t *pFlashBytes, uint8_t numBytes)
 The interface function to write ROM CI Data Payload. More...
 
int32_t FXLC95000_I2C_Initialize (fxlc95000_i2c_sensorhandle_t *pSensorHandle, ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress, uint16_t buildId)
 The interface function to initialize the sensor. More...
 
void FXLC95000_I2C_SetIdleTask (fxlc95000_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
 : The interface function to set the I2C Idle Task. More...
 
int32_t FXLC95000_I2C_CommandResponse (fxlc95000_i2c_sensorhandle_t *pSensorHandle, const registercommandlist_t *pCommandList, const registerreadlist_t *pReadList, uint8_t *pBuffer)
 The interface function to read the sensor data. More...
 
int32_t FXLC95000_SPI_Initialize (fxlc95000_spi_sensorhandle_t *pSensorHandle, ARM_DRIVER_SPI *pBus, uint8_t index, void *pSpiSelect, void *pSlaveSelect, void *pReset, uint16_t buildId)
 The interface function to initialize the sensor. More...
 
void FXLC95000_SPI_SetIdleTask (fxlc95000_spi_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
 : The interface function to set the SPI Idle Task. More...
 
int32_t FXLC95000_SPI_CommandResponse (fxlc95000_spi_sensorhandle_t *pSensorHandle, const registercommandlist_t *pCommandList, const registerreadlist_t *pReadList, uint8_t *pBuffer)
 The interface function to read the sensor data. More...
 
void FXLC95000_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 FXLC95000_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 fxlc95000_drv.h file describes the FXLC95000L driver interface and structures.

Definition in file fxlc95000_drv.h.

Macro Definition Documentation

◆ FXLC95000_COCO_ERROR_MASK

#define FXLC95000_COCO_ERROR_MASK   (0x7F)

The Error Bit Mask in COCO Byte.

Definition at line 61 of file fxlc95000_drv.h.

Referenced by FXLC95000_I2C_CommandResponse(), FXLC95000_I2C_FlashCommands(), and FXLC95000_SPI_CommandResponse().

◆ FXLC95000_FLASH_PAYLOAD_ADDR_LEN

#define FXLC95000_FLASH_PAYLOAD_ADDR_LEN   4

The Length of Address field in FLASH Payload form Host.

Definition at line 97 of file fxlc95000_drv.h.

Referenced by FXLC95000_I2C_FlashPayload().

◆ FXLC95000_ROM_CI_READ_WRITE_ADDR_LEN

#define FXLC95000_ROM_CI_READ_WRITE_ADDR_LEN   2

The Length of Address field in ROM CI_READ_WRITE Command Header.

Definition at line 93 of file fxlc95000_drv.h.

Referenced by FXLC95000_I2C_FlashPayload().

◆ FXLC95000_ROM_CI_READ_WRITE_HDR_LEN

#define FXLC95000_ROM_CI_READ_WRITE_HDR_LEN   6

The Length of ROM CI_READ_WRITE Command Header.

Definition at line 89 of file fxlc95000_drv.h.

Referenced by FXLC95000_I2C_FlashPayload().

◆ FXLC95000_ROM_CI_READ_WRITE_MAX_LEN

#define FXLC95000_ROM_CI_READ_WRITE_MAX_LEN   32

The MAX Length of ROM CI_READ_WRITE Command.

Definition at line 85 of file fxlc95000_drv.h.

Referenced by FXLC95000_I2C_FlashPayload().

◆ FXLC95000_ROM_CI_WRITE_MAX_LEN

#define FXLC95000_ROM_CI_WRITE_MAX_LEN   24

The MAX Length of ROM CI_WRITE Data.

Definition at line 81 of file fxlc95000_drv.h.

Referenced by FXLC95000_I2C_FlashPayload().

◆ FXLC95000_ROM_CI_WRITE_MIN_LEN

#define FXLC95000_ROM_CI_WRITE_MIN_LEN   4

The MIN Length of ROM CI_WRITE Data.

Definition at line 77 of file fxlc95000_drv.h.

Referenced by FXLC95000_I2C_FlashPayload().

◆ FXLC95000_SPI_CMD_LEN

#define FXLC95000_SPI_CMD_LEN   (1)

The size of the Sensor specific SPI Header.

Definition at line 69 of file fxlc95000_drv.h.

Referenced by FXLC95000_SPI_Initialize(), FXLC95000_SPI_ReadPreprocess(), and FXLC95000_SPI_WritePreprocess().

◆ FXLC95000_SPI_MAX_MSG_SIZE

#define FXLC95000_SPI_MAX_MSG_SIZE   (64)

The MAX size of SPI message.

Definition at line 65 of file fxlc95000_drv.h.

◆ FXLC95000_SS_ACTIVE_VALUE

#define FXLC95000_SS_ACTIVE_VALUE   SPI_SS_ACTIVE_LOW

Is the Slave Select Pin Active Low or High.

Definition at line 73 of file fxlc95000_drv.h.

Referenced by FXLC95000_SPI_Initialize().

Function Documentation

◆ FXLC95000_I2C_CheckRomMode()

int32_t FXLC95000_I2C_CheckRomMode ( ARM_DRIVER_I2C *  pBus,
uint8_t  index,
uint16_t  sAddress 
)

The interface function to check if the sensor is in ROM CI Mode.

This function checks the Response of Version Info command to determine if Sensor is in ROM CI Mode.

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

Definition at line 190 of file fxlc95000_drv.c.

References registerDeviceInfo_t::deviceInstance, int32_t(), Register_I2C_BlockWrite(), and status.

Referenced by process_host_command().

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

◆ FXLC95000_I2C_CommandResponse()

int32_t FXLC95000_I2C_CommandResponse ( fxlc95000_i2c_sensorhandle_t pSensorHandle,
const registercommandlist_t pCommandList,
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]pCommandListpointer to the command read list.
[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 FXLC95000_I2C_Initialize(). Application has to ensure that previous instances of these APIs have exited before invocation. No
Returns
FXLC95000_I2C_CommandResponse() returns the status .

Validate for the correct handle and register read list.

Check whether sensor handle is initialized before reading sensor data.

Definition at line 389 of file fxlc95000_drv.c.

References fxlc95000_i2c_sensorhandle_t::deviceInfo, FXLC95000_COCO_ERROR_MASK, int32_t(), fxlc95000_i2c_sensorhandle_t::isInitialized, fxlc95000_i2c_sensorhandle_t::pCommDrv, SENSOR_ERROR_INIT, SENSOR_ERROR_INVALID_PARAM, SENSOR_ERROR_NONE, SENSOR_ERROR_READ, SENSOR_ERROR_WRITE, Sensor_I2C_BlockWrite(), Sensor_I2C_Read(), fxlc95000_i2c_sensorhandle_t::slaveAddress, and status.

Referenced by fxlc95000_enSensor(), and main().

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

◆ FXLC95000_I2C_FlashCommands()

int32_t FXLC95000_I2C_FlashCommands ( ARM_DRIVER_I2C *  pBus,
uint8_t  index,
uint16_t  sAddress,
const registercommandlist_t pCommandList 
)

The interface function to write ROM CI Commands.

This function Writes ROM CI commands over I2C to the Sensor.

Parameters
[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]pCommandListpointer to the command read list.
Constraints:
This can be called only if Sensor is in ROM CI Mode. Application has to ensure that previous instances of these APIs have exited before invocation. No
Returns
FXLC95000_I2C_FlashCommands() returns the status.

Validate for the correct handle and register write list.

Definition at line 211 of file fxlc95000_drv.c.

References registerDeviceInfo_t::deviceInstance, FXLC95000_COCO_ERROR_MASK, int32_t(), SENSOR_ERROR_INVALID_PARAM, SENSOR_ERROR_NONE, SENSOR_ERROR_WRITE, Sensor_I2C_BlockWrite(), and status.

Referenced by FXLC95000_I2C_FlashPayload(), and process_host_command().

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

◆ FXLC95000_I2C_FlashPayload()

int32_t FXLC95000_I2C_FlashPayload ( ARM_DRIVER_I2C *  pBus,
uint8_t  index,
uint16_t  sAddress,
uint8_t *  pFlashBytes,
uint8_t  numBytes 
)

The interface function to write ROM CI Data Payload.

This function Writes ROM CI Payload Bytes by creating formatted Commands and writing over I2C to the Sensor.

Parameters
[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]pFlashBytespointer to payload bytes of flash data.
[in]numBytesthe number of bytes of flash data to be written.
Constraints:
This can be called only if Sensor is in ROM CI Mode. Application has to ensure that previous instances of these APIs have exited before invocation. No
Returns
FXLC95000_I2C_FlashPayload() returns the status.

Definition at line 235 of file fxlc95000_drv.c.

References __END_WRITE_CMD__, FXLC95000_FLASH_PAYLOAD_ADDR_LEN, FXLC95000_I2C_FlashCommands(), FXLC95000_ROM_CI_READ_WRITE_ADDR_LEN, FXLC95000_ROM_CI_READ_WRITE_HDR_LEN, FXLC95000_ROM_CI_READ_WRITE_MAX_LEN, FXLC95000_ROM_CI_WRITE_MAX_LEN, FXLC95000_ROM_CI_WRITE_MIN_LEN, int32_t(), SENSOR_ERROR_INVALID_PARAM, SENSOR_ERROR_NONE, SENSOR_ERROR_WRITE, and status.

Referenced by process_host_command().

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

◆ FXLC95000_I2C_Initialize()

int32_t FXLC95000_I2C_Initialize ( fxlc95000_i2c_sensorhandle_t pSensorHandle,
ARM_DRIVER_I2C *  pBus,
uint8_t  index,
uint16_t  sAddress,
uint16_t  buildId 
)

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]buildIdFXLC95000 firmware buid number.
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
FXLC95000_I2C_Initialize() returns the status .

Check the input parameters.

Definition at line 338 of file fxlc95000_drv.c.

References fxlc95000_i2c_sensorhandle_t::deviceInfo, registerDeviceInfo_t::deviceInstance, registerDeviceInfo_t::functionParam, registerDeviceInfo_t::idleFunction, int32_t(), Register_I2C_BlockWrite(), SENSOR_ERROR_INVALID_PARAM, and status.

Referenced by fxlc95000_enSensor(), and main().

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

◆ FXLC95000_I2C_SetIdleTask()

void FXLC95000_I2C_SetIdleTask ( fxlc95000_i2c_sensorhandle_t pSensorHandle,
registeridlefunction_t  idleTask,
void *  userParam 
)

: The interface function to set the I2C Idle Task.

Parameters
[in]fxlc95000_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 FXLC95000_I2C_Initialize(). Application has to ensure that previous instances of these APIs have exited before invocation. No

Definition at line 381 of file fxlc95000_drv.c.

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

Referenced by fxlc95000_enSensor(), and main().

Here is the caller graph for this function:

◆ FXLC95000_SPI_CommandResponse()

int32_t FXLC95000_SPI_CommandResponse ( fxlc95000_spi_sensorhandle_t pSensorHandle,
const registercommandlist_t pCommandList,
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]pCommandListpointer to the command read list.
[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 FXLC95000_SPI_Initialize(). Application has to ensure that previous instances of these APIs have exited before invocation. No
Returns
FXLC95000_SPI_CommandResponse() returns the status .

Validate for the correct handle and command 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 147 of file fxlc95000_drv.c.

References fxlc95000_spi_sensorhandle_t::deviceInfo, FXLC95000_COCO_ERROR_MASK, int32_t(), fxlc95000_spi_sensorhandle_t::isInitialized, fxlc95000_spi_sensorhandle_t::pCommDrv, SENSOR_ERROR_INIT, SENSOR_ERROR_INVALID_PARAM, SENSOR_ERROR_NONE, SENSOR_ERROR_READ, SENSOR_ERROR_WRITE, Sensor_SPI_BlockWrite(), Sensor_SPI_Read(), fxlc95000_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:

◆ FXLC95000_SPI_Initialize()

int32_t FXLC95000_SPI_Initialize ( fxlc95000_spi_sensorhandle_t pSensorHandle,
ARM_DRIVER_SPI *  pBus,
uint8_t  index,
void *  pSpiSelect,
void *  pSlaveSelect,
void *  pReset,
uint16_t  buildId 
)

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]pResetreset handle of the device on the bus.
[in]buildIdFXLC95000 firmware buid number.
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
FXLC95000_SPI_Initialize() returns the status .

Check the input parameters.

Initialize the sensor handle.

Definition at line 68 of file fxlc95000_drv.c.

References BOARD_DELAY_ms(), GENERIC_DRIVER_GPIO::clr_pin, fxlc95000_spi_sensorhandle_t::deviceInfo, registerDeviceInfo_t::deviceInstance, Driver_GPIO_KSDK, registerDeviceInfo_t::functionParam, FXLC95000_SPI_CMD_LEN, FXLC95000_SPI_ReadPreprocess(), FXLC95000_SPI_WritePreprocess(), FXLC95000_SS_ACTIVE_VALUE, GPIO_DIRECTION_OUT, registerDeviceInfo_t::idleFunction, int32_t(), fxlc95000_spi_sensorhandle_t::pCommDrv, pGPIODriver, GENERIC_DRIVER_GPIO::pin_init, spiSlaveSpecificParams_t::pReadPreprocessFN, spiSlaveSpecificParams_t::pTargetSlavePinID, spiSlaveSpecificParams_t::pWritePreprocessFN, Register_SPI_BlockWrite(), SENSOR_ERROR_INVALID_PARAM, GENERIC_DRIVER_GPIO::set_pin, fxlc95000_spi_sensorhandle_t::slaveParams, 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:

◆ FXLC95000_SPI_ReadPreprocess()

void FXLC95000_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 31 of file fxlc95000_drv.c.

References FXLC95000_SPI_CMD_LEN, fxlc95000_spiRead_CmdBuffer, fxlc95000_spiRead_DataBuffer, spi_mater_SlaveCmd::pReadBuffer, spi_mater_SlaveCmd::pWriteBuffer, and spi_mater_SlaveCmd::size.

Referenced by FXLC95000_SPI_Initialize().

Here is the caller graph for this function:

◆ FXLC95000_SPI_SetIdleTask()

void FXLC95000_SPI_SetIdleTask ( fxlc95000_spi_sensorhandle_t pSensorHandle,
registeridlefunction_t  idleTask,
void *  userParam 
)

: The interface function to set the SPI Idle Task.

Parameters
[in]fxlc95000_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 FXLC95000_SPI_Initialize(). Application has to ensure that previous instances of these APIs have exited before invocation. No

Definition at line 139 of file fxlc95000_drv.c.

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

Referenced by main().

Here is the caller graph for this function:

◆ FXLC95000_SPI_WritePreprocess()

void FXLC95000_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 48 of file fxlc95000_drv.c.

References FXLC95000_SPI_CMD_LEN, fxlc95000_spiWrite_CmdDataBuffer, spi_mater_SlaveCmd::pReadBuffer, spi_mater_SlaveCmd::pWriteBuffer, and spi_mater_SlaveCmd::size.

Referenced by FXLC95000_SPI_Initialize().

Here is the caller graph for this function: