ISSDK  1.8
IoT Sensing Software Development Kit
fxls8471q_drv.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 - 2016, Freescale Semiconductor, Inc.
3  * Copyright 2016-2017 NXP
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 /**
10  * @file fxls8471q_drv.h
11  * @brief The fxls8471q_drv.h file describes the fxls8471q driver interface and structures.
12  */
13 
14 #ifndef FXLS8471Q_DRV_H_
15 #define FXLS8471Q_DRV_H_
16 
17 /* Standard C Includes */
18 #include <stdint.h>
19 
20 /* ISSDK Includes */
21 #include "fxls8471q.h"
22 #include "sensor_io_spi.h"
23 #include "register_io_spi.h"
24 
25 /*******************************************************************************
26  * Definitions
27  ******************************************************************************/
28 /*!
29  * @brief This defines the sensor specific information for SPI.
30  */
31 typedef struct
32 {
33  registerDeviceInfo_t deviceInfo; /*!< SPI device context. */
34  ARM_DRIVER_SPI *pCommDrv; /*!< Pointer to the spi driver. */
35  bool isInitialized; /*!< Whether sensor is intialized or not.*/
36  spiSlaveSpecificParams_t slaveParams; /*!< Slave Specific Params.*/
38 
39 /*! @brief This structure defines the fxls8471q raw data buffer.*/
40 typedef struct
41 {
42  uint32_t timestamp; /*! The time, this sample was recorded. */
43  int16_t accel[3]; /*!< The accel data */
45 
46 /*! @def FXLS8471Q_ACCEL_DATA_SIZE
47  * @brief The size of the FXLS8471Q accel data. */
48 #define FXLS8471Q_ACCEL_DATA_SIZE (0x06) /* Size of the accel data*/
49 
50 /*! @def FXLS8471Q_SPI_MAX_MSG_SIZE
51  * @brief The MAX size of SPI message. */
52 #define FXLS8471Q_SPI_MAX_MSG_SIZE (64)
53 
54 /*! @def FXLS8471Q_SPI_CMD_LEN
55  * @brief The size of the Sensor specific SPI Header. */
56 #define FXLS8471Q_SPI_CMD_LEN (2)
57 
58 /*! @def FXLS8471Q_SS_ACTIVE_VALUE
59  * @brief Is the Slave Select Pin Active Low or High. */
60 #define FXLS8471Q_SS_ACTIVE_VALUE SPI_SS_ACTIVE_LOW
61 
62 /*******************************************************************************
63  * APIs
64  ******************************************************************************/
65 /*! @brief The interface function to initialize the sensor for I2C.
66  * @details This function initializes the sensor and sensor handle.
67  * @param[in] pSensorHandle handle to the sensor.
68  * @param[in] pBus pointer to the CMSIS API compatible SPI bus object.
69  * @param[in] index the I2C device number.
70  * @param[in] pSlaveSelect slave select hndle of the device on the bus.
71  * @param[in] whoami WHO_AM_I value of the device.
72  * @constraints This should be the first API to be called.
73  * Application has to ensure that previous instances of these APIs have exited before invocation.
74  * @reeentrant No
75  * @return ::FXLS8471Q_SPI_Initialize() returns the status .
76 */
78  ARM_DRIVER_SPI *pBus,
79  uint8_t index,
80  void *pSlaveSelect,
81  uint8_t whoAmi);
82 
83 /*! @brief : The interface function to set the SPI Idle Task.
84  * @param[in] : fxls8471q_spi_sensorhandle_t *pSensorHandle, handle to the sensor handle.
85  * @param[in] : registeridlefunction_t idleTask, function pointer to the function to execute on SPI Idle Time.
86  * @param[in] : void *userParam, the pointer to the user idle ftask parameters.
87  * @return void.
88  * @constraints This can be called any number of times only after FXLS8471Q_SPI_Initialize().
89  * Application has to ensure that previous instances of these APIs have exited before invocation.
90  * @reeentrant No
91  */
93  registeridlefunction_t idleTask,
94  void *userParam);
95 
96 /*! @brief The interface function to configure he sensor.
97  * @details This function configure the sensor with requested ODR, Range and registers in the regsiter pair array.
98  * @param[in] pSensorHandle handle to the sensor.
99  * @param[in] pRegWriteList pointer to the register list.
100  * @constraints This can be called any number of times only after FXLS8471Q_SPI_Initialize().
101  * Application has to ensure that previous instances of these APIs have exited before invocation.
102  * @reeentrant No
103  * @return ::FXLS8471Q_SPI_Configure() returns the status .
104  */
106 
107 /*! @brief The interface function to read the sensor data.
108  * @details This function read the sensor data out from the device and returns raw data in a byte stream.
109  * @param[in] pSensorHandle handle to the sensor.
110  * @param[in] pReadList pointer to the list of device registers and values to read.
111  * @param[out] pBuffer buffer which holds raw sensor data.This buffer may be back to back databuffer based
112  * command read in the list.
113  * @constraints This can be called any number of times only after FXLS8471Q_SPI_Initialize().
114  * Application has to ensure that previous instances of these APIs have exited before invocation.
115  * @reeentrant No
116  * @return ::FXLS8471Q_SPI_ReadData() returns the status .
117  */
119  const registerreadlist_t *pReadList,
120  uint8_t *pBuffer);
121 
122 /*! @brief The interface function to De Initialize sensor..
123  * @details This function made sensor in a power safe state and de initialize its handle.
124  * @param[in] pSensorHandle handle to the sensor.
125  * @constraints This can be called only after after FXLS8471Q_SPI_Initialize().
126  * Application has to ensure that previous instances of these APIs have exited before invocation.
127  * @reeentrant No
128  * @return ::FXLS8471Q_SPI_Deinit() returns the status .
129  */
131 
132 /*! @brief The SPI Read Pre-Process function to generate Sensor specific SPI Message Header.
133  * @details This function prepares the SPI Read Command Header with register address and
134  * R/W bit encoded as the Sensor.
135  * @param[out] pCmdOut handle to the output buffer.
136  * @param[in] offset the address of the register to start reading from.
137  * @param[in] size number of bytes to read.
138  * @constraints None
139  * Application has to ensure that previous instances of these APIs have exited before invocation.
140  * @reeentrant No
141  * @return :: None.
142  */
143 void FXLS8471Q_SPI_ReadPreprocess(void *pCmdOut, uint32_t offset, uint32_t size);
144 
145 /*! @brief The SPI Write Pre-Process function to generate Sensor specific SPI Message Header.
146  * @details This function prepares the SPI Write Command Header with register address and
147  * R/W bit encoded as the Sensor.
148  * @param[out] pCmdOut handle to the output buffer.
149  * @param[in] offset the address of the register to start writing from.
150  * @param[in] size number of bytes to write.
151  * @constraints None
152  * Application has to ensure that previous instances of these APIs have exited before invocation.
153  * @reeentrant No
154  * @return :: None.
155  */
156 void FXLS8471Q_SPI_WritePreprocess(void *pCmdOut, uint32_t offset, uint32_t size, void *pWritebuffer);
157 
158 #endif // FXLS8471Q_DRV_H_
uint32_t size
This defines the sensor specific information for SPI.
Definition: fxls8471q_drv.h:31
int32_t FXLS8471Q_SPI_Initialize(fxls8471q_spi_sensorhandle_t *pSensorHandle, ARM_DRIVER_SPI *pBus, uint8_t index, void *pSlaveSelect, uint8_t whoAmi)
The interface function to initialize the sensor for I2C.
Definition: fxls8471q_drv.c:67
This structure defines the device specific info required by register I/O.
Definition: sensor_drv.h:102
registerDeviceInfo_t deviceInfo
Definition: fxls8471q_drv.h:33
This structure defines the Write command List.
Definition: sensor_drv.h:68
The sensor_io_spi.h file declares low-level interface functions for reading and writing sensor regist...
The fxls8471q.h file contains the register definitions for fxls8471q sensor driver.
The register_io_spi.h file declares low-level interface functions for reading and writing sensor regi...
This structure defines the spi slave command format.
int32_t FXLS8471Q_SPI_Deinit(fxls8471q_spi_sensorhandle_t *pSensorHandle)
The interface function to De Initialize sensor..
typedef int32_t(DATA_FORMAT_Append_t))(void *pData
The interface function to append the data on the formated stream.
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
Definition: sensor_drv.h:97
This structure defines the fxls8471q raw data buffer.
Definition: fxls8471q_drv.h:40
spiSlaveSpecificParams_t slaveParams
Definition: fxls8471q_drv.h:36
void FXLS8471Q_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.
Definition: fxls8471q_drv.c:47
int32_t FXLS8471Q_SPI_ReadData(fxls8471q_spi_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer)
The interface function to read the sensor data.
int32_t FXLS8471Q_SPI_Configure(fxls8471q_spi_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
void FXLS8471Q_SPI_SetIdleTask(fxls8471q_spi_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the SPI Idle Task.
This structure defines the Read command List.
Definition: sensor_drv.h:78
void FXLS8471Q_SPI_ReadPreprocess(void *pCmdOut, uint32_t offset, uint32_t size)
The SPI Read Pre-Process function to generate Sensor specific SPI Message Header. ...
Definition: fxls8471q_drv.c:30