![]() |
ISSDK
1.8
IoT Sensing Software Development Kit
|
The mma9553_drv.h file describes the MMA9553L driver interface and structures. More...
#include <stdint.h>
#include "mma9553.h"
#include "sensor_io_i2c.h"
#include "sensor_io_spi.h"
#include "register_io_i2c.h"
#include "register_io_spi.h"
Go to the source code of this file.
Data Structures | |
struct | mma9553_spi_sensorhandle_t |
This defines the sensor specific information for SPI. More... | |
struct | mma9553_i2c_sensorhandle_t |
This defines the sensor specific information for I2C. More... | |
struct | mma9553_acceldata_t |
This structure defines the mma9553 pedometer data buffer. More... | |
struct | mma9553_pedometerdata_t |
This structure defines the Size of response for pedometer data read command. More... | |
Macros | |
#define | MMA9553_COCO_ERROR_MASK (0x7F) |
The Error Bit Mask in COCO Byte. More... | |
#define | MMA9553_SPI_MAX_MSG_SIZE (64) |
The MAX size of SPI message. More... | |
#define | MMA9553_SPI_CMD_LEN (1) |
The size of the Sensor specific SPI Header. More... | |
#define | MMA9553_SS_ACTIVE_VALUE SPI_SS_ACTIVE_LOW |
Is the Slave Select Pin Active Low or High. More... | |
Functions | |
int32_t | MMA9553_I2C_Initialize (mma9553_i2c_sensorhandle_t *pSensorHandle, ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress) |
The interface function to initialize the sensor. More... | |
void | MMA9553_I2C_SetIdleTask (mma9553_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam) |
: The interface function to set the I2C Idle Task. More... | |
int32_t | MMA9553_I2C_Configure (mma9553_i2c_sensorhandle_t *pSensorHandle, const registercommandlist_t *pCommandList) |
The interface function to configure he sensor. More... | |
int32_t | MMA9553_I2C_CommandResponse (mma9553_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 | MMA9553_I2C_DeInit (mma9553_i2c_sensorhandle_t *pSensorHandle) |
The interface function to De Initialize sensor.. More... | |
int32_t | MMA9553_SPI_Initialize (mma9553_spi_sensorhandle_t *pSensorHandle, ARM_DRIVER_SPI *pBus, uint8_t index, void *pSlaveSelect, void *pReset) |
The interface function to initialize the sensor. More... | |
void | MMA9553_SPI_SetIdleTask (mma9553_spi_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam) |
: The interface function to set the SPI Idle Task. More... | |
int32_t | MMA9553_SPI_Configure (mma9553_spi_sensorhandle_t *pSensorHandle, const registercommandlist_t *pCommandList) |
The interface function to configure he sensor. More... | |
int32_t | MMA9553_SPI_CommandResponse (mma9553_spi_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 | MMA9553_SPI_DeInit (mma9553_spi_sensorhandle_t *pSensorHandle) |
The interface function to De Initialize sensor.. More... | |
void | MMA9553_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 | MMA9553_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... | |
The mma9553_drv.h file describes the MMA9553L driver interface and structures.
Definition in file mma9553_drv.h.
#define MMA9553_COCO_ERROR_MASK (0x7F) |
The Error Bit Mask in COCO Byte.
Definition at line 73 of file mma9553_drv.h.
Referenced by MMA9553_I2C_CommandResponse(), MMA9553_I2C_Configure(), MMA9553_I2C_DeInit(), MMA9553_I2C_Initialize(), MMA9553_SPI_CommandResponse(), MMA9553_SPI_Configure(), MMA9553_SPI_DeInit(), and MMA9553_SPI_Initialize().
#define MMA9553_SPI_CMD_LEN (1) |
The size of the Sensor specific SPI Header.
Definition at line 81 of file mma9553_drv.h.
Referenced by MMA9553_SPI_Initialize(), MMA9553_SPI_ReadPreprocess(), and MMA9553_SPI_WritePreprocess().
#define MMA9553_SPI_MAX_MSG_SIZE (64) |
The MAX size of SPI message.
Definition at line 77 of file mma9553_drv.h.
#define MMA9553_SS_ACTIVE_VALUE SPI_SS_ACTIVE_LOW |
Is the Slave Select Pin Active Low or High.
Definition at line 85 of file mma9553_drv.h.
Referenced by MMA9553_SPI_Initialize().
int32_t MMA9553_I2C_CommandResponse | ( | mma9553_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.
[in] | pSensorHandle | handle to the sensor. |
[in] | pCommandList | pointer to the command read list. |
[in] | pReadList | pointer to the list of device registers and values to read. |
[out] | pBuffer | buffer which holds raw sensor data.This buffer may be back to back databuffer based command read in the list. |
Validate for the correct handle and register read list.
Check whether sensor handle is initialized before reading sensor data.
Definition at line 487 of file mma9553_drv.c.
References mma9553_i2c_sensorhandle_t::deviceInfo, int32_t(), mma9553_i2c_sensorhandle_t::isInitialized, MMA9553_COCO_ERROR_MASK, mma9553_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(), mma9553_i2c_sensorhandle_t::slaveAddress, and status.
Referenced by main().
int32_t MMA9553_I2C_Configure | ( | mma9553_i2c_sensorhandle_t * | pSensorHandle, |
const registercommandlist_t * | pCommandList | ||
) |
The interface function to configure he sensor.
This function configure the sensor with requested ODR, Range and registers in the regsiter pair array.
[in] | pSensorHandle | handle to the sensor. |
[in] | pCommandList | pointer to the command write list. |
Check whether sensor handle is initialized before applying configuration.
Definition at line 422 of file mma9553_drv.c.
References mma9553_i2c_sensorhandle_t::deviceInfo, int32_t(), mma9553_i2c_sensorhandle_t::isInitialized, MMA9553_COCO_ERROR_MASK, MMA9553_HDR_SIZE, mma9553_i2c_sensorhandle_t::pCommDrv, Register_I2C_Read(), SENSOR_ERROR_INIT, SENSOR_ERROR_INVALID_PARAM, SENSOR_ERROR_READ, SENSOR_ERROR_WRITE, Sensor_I2C_BlockWrite(), mma9553_i2c_sensorhandle_t::slaveAddress, STANDBY_REG_SIZE, and status.
Referenced by main().
int32_t MMA9553_I2C_DeInit | ( | mma9553_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.
[in] | pSensorHandle | handle to the sensor. |
Check whether sensor handle is initialized before triggering sensor reset.
De-initialize sensor handle.
Definition at line 529 of file mma9553_drv.c.
References mma9553_i2c_sensorhandle_t::deviceInfo, int32_t(), mma9553_i2c_sensorhandle_t::isInitialized, MMA9553_COCO_ERROR_MASK, mma9553_i2c_sensorhandle_t::pCommDrv, SENSOR_ERROR_INIT, SENSOR_ERROR_INVALID_PARAM, SENSOR_ERROR_NONE, SENSOR_ERROR_WRITE, Sensor_I2C_BlockWrite(), mma9553_i2c_sensorhandle_t::slaveAddress, and status.
int32_t MMA9553_I2C_Initialize | ( | mma9553_i2c_sensorhandle_t * | pSensorHandle, |
ARM_DRIVER_I2C * | pBus, | ||
uint8_t | index, | ||
uint16_t | sAddress | ||
) |
The interface function to initialize the sensor.
This function initialize the sensor and sensor handle.
[in] | pSensorHandle | handle to the sensor. |
[in] | pBus | pointer to the CMSIS API compatible I2C bus object. |
[in] | index | the I2C device number. |
[in] | sAddress | slave address of the device on the bus. |
Check the input parameters.
Definition at line 369 of file mma9553_drv.c.
References BOARD_DELAY_ms(), mma9553_i2c_sensorhandle_t::deviceInfo, registerDeviceInfo_t::deviceInstance, registerDeviceInfo_t::functionParam, registerDeviceInfo_t::idleFunction, int32_t(), mma9553_i2c_sensorhandle_t::isInitialized, MMA9553_COCO_ERROR_MASK, MMA9553_HDR_SIZE, mma9553_i2c_sensorhandle_t::pCommDrv, ReadVersionInfo, Register_I2C_BlockWrite(), Register_I2C_Read(), SENSOR_ERROR_INIT, SENSOR_ERROR_INVALID_PARAM, SENSOR_ERROR_NONE, SENSOR_ERROR_WRITE, Sensor_I2C_BlockWrite(), mma9553_i2c_sensorhandle_t::slaveAddress, and status.
Referenced by main().
void MMA9553_I2C_SetIdleTask | ( | mma9553_i2c_sensorhandle_t * | pSensorHandle, |
registeridlefunction_t | idleTask, | ||
void * | userParam | ||
) |
: The interface function to set the I2C Idle Task.
[in] | mma9553_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. |
Definition at line 414 of file mma9553_drv.c.
References mma9553_i2c_sensorhandle_t::deviceInfo, registerDeviceInfo_t::functionParam, and registerDeviceInfo_t::idleFunction.
Referenced by main().
int32_t MMA9553_SPI_CommandResponse | ( | mma9553_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.
[in] | pSensorHandle | handle to the sensor. |
[in] | pCommandList | pointer to the command read list. |
[in] | pReadList | pointer to the list of device registers and values to read. |
[out] | pBuffer | buffer which holds raw sensor data.This buffer may be back to back databuffer based command read in the list. |
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 295 of file mma9553_drv.c.
References mma9553_spi_sensorhandle_t::deviceInfo, int32_t(), mma9553_spi_sensorhandle_t::isInitialized, MMA9553_COCO_ERROR_MASK, mma9553_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(), mma9553_spi_sensorhandle_t::slaveParams, and status.
Referenced by main().
int32_t MMA9553_SPI_Configure | ( | mma9553_spi_sensorhandle_t * | pSensorHandle, |
const registercommandlist_t * | pCommandList | ||
) |
The interface function to configure he sensor.
This function configure the sensor with requested ODR, Range and registers in the regsiter pair array.
[in] | pSensorHandle | handle to the sensor. |
[in] | pCommandList | pointer to the command list. |
Validate for the correct handle and register write list.
Check whether sensor handle is initialized before applying configuration.
Definition at line 230 of file mma9553_drv.c.
References mma9553_spi_sensorhandle_t::deviceInfo, int32_t(), mma9553_spi_sensorhandle_t::isInitialized, MMA9553_COCO_ERROR_MASK, MMA9553_HDR_SIZE, mma9553_spi_sensorhandle_t::pCommDrv, Register_SPI_Read(), SENSOR_ERROR_INIT, SENSOR_ERROR_INVALID_PARAM, SENSOR_ERROR_READ, SENSOR_ERROR_WRITE, Sensor_SPI_BlockWrite(), mma9553_spi_sensorhandle_t::slaveParams, STANDBY_REG_SIZE, and status.
Referenced by main().
int32_t MMA9553_SPI_DeInit | ( | mma9553_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.
[in] | pSensorHandle | handle to the sensor. |
Check whether sensor handle is initialized before triggering sensor reset.
Trigger sensor device reset.
De-initialize sensor handle.
Definition at line 338 of file mma9553_drv.c.
References mma9553_spi_sensorhandle_t::deviceInfo, int32_t(), mma9553_spi_sensorhandle_t::isInitialized, MMA9553_COCO_ERROR_MASK, mma9553_spi_sensorhandle_t::pCommDrv, SENSOR_ERROR_INIT, SENSOR_ERROR_INVALID_PARAM, SENSOR_ERROR_NONE, SENSOR_ERROR_WRITE, Sensor_SPI_BlockWrite(), mma9553_spi_sensorhandle_t::slaveParams, and status.
int32_t MMA9553_SPI_Initialize | ( | mma9553_spi_sensorhandle_t * | pSensorHandle, |
ARM_DRIVER_SPI * | pBus, | ||
uint8_t | index, | ||
void * | pSlaveSelect, | ||
void * | pReset | ||
) |
The interface function to initialize the sensor.
This function initializes the sensor and sensor handle.
[in] | pSensorHandle | handle to the sensor. |
[in] | pBus | pointer to the CMSIS API compatible SPI bus object. |
[in] | index | the I2C device number. |
[in] | pSlaveSelect | slave select hndle of the device on the bus. |
[in] | pReset | reset handle of the device on the bus. |
Check the input parameters.
Initialize the sensor handle.
Definition at line 157 of file mma9553_drv.c.
References BOARD_DELAY_ms(), GENERIC_DRIVER_GPIO::clr_pin, mma9553_spi_sensorhandle_t::deviceInfo, registerDeviceInfo_t::deviceInstance, Driver_GPIO_KSDK, registerDeviceInfo_t::functionParam, GPIO_DIRECTION_OUT, registerDeviceInfo_t::idleFunction, int32_t(), mma9553_spi_sensorhandle_t::isInitialized, MMA9553_COCO_ERROR_MASK, MMA9553_HDR_SIZE, MMA9553_SPI_CMD_LEN, MMA9553_SPI_ReadPreprocess(), MMA9553_SPI_WritePreprocess(), MMA9553_SS_ACTIVE_VALUE, mma9553_spi_sensorhandle_t::pCommDrv, pGPIODriver, GENERIC_DRIVER_GPIO::pin_init, spiSlaveSpecificParams_t::pReadPreprocessFN, spiSlaveSpecificParams_t::pTargetSlavePinID, spiSlaveSpecificParams_t::pWritePreprocessFN, ReadVersionInfo, Register_SPI_BlockWrite(), Register_SPI_Read(), SENSOR_ERROR_INIT, SENSOR_ERROR_INVALID_PARAM, SENSOR_ERROR_NONE, SENSOR_ERROR_WRITE, Sensor_SPI_BlockWrite(), GENERIC_DRIVER_GPIO::set_pin, mma9553_spi_sensorhandle_t::slaveParams, spiSlaveSpecificParams_t::spiCmdLen, spiSlaveSpecificParams_t::ssActiveValue, and status.
Referenced by main().
void MMA9553_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.
[out] | pCmdOut | handle to the output buffer. |
[in] | offset | the address of the register to start reading from. |
[in] | size | number of bytes to read. |
Definition at line 120 of file mma9553_drv.c.
References MMA9553_SPI_CMD_LEN, mma9553_spiRead_CmdBuffer, mma9553_spiRead_DataBuffer, spi_mater_SlaveCmd::pReadBuffer, spi_mater_SlaveCmd::pWriteBuffer, and spi_mater_SlaveCmd::size.
Referenced by MMA9553_SPI_Initialize().
void MMA9553_SPI_SetIdleTask | ( | mma9553_spi_sensorhandle_t * | pSensorHandle, |
registeridlefunction_t | idleTask, | ||
void * | userParam | ||
) |
: The interface function to set the SPI Idle Task.
[in] | mma9553_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. |
Definition at line 222 of file mma9553_drv.c.
References mma9553_spi_sensorhandle_t::deviceInfo, registerDeviceInfo_t::functionParam, and registerDeviceInfo_t::idleFunction.
Referenced by main().
void MMA9553_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.
[out] | pCmdOut | handle to the output buffer. |
[in] | offset | the address of the register to start writing from. |
[in] | size | number of bytes to write. |
Definition at line 137 of file mma9553_drv.c.
References MMA9553_SPI_CMD_LEN, mma9553_spiWrite_CmdDataBuffer, spi_mater_SlaveCmd::pReadBuffer, spi_mater_SlaveCmd::pWriteBuffer, and spi_mater_SlaveCmd::size.
Referenced by MMA9553_SPI_Initialize().