![]() |
ISSDK
1.7
IoT Sensing Software Development Kit
|
The diff_p_drv.c file implements the diff_p functional interface. More...
Go to the source code of this file.
Functions | |
void | DIFF_P_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 | DIFF_P_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... | |
int32_t | DIFF_P_SPI_Initialize (diff_p_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 | DIFF_P_SPI_SetIdleTask (diff_p_spi_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam) |
: The interface function to set the SPI Idle Task. More... | |
int32_t | DIFF_P_SPI_Configure (diff_p_spi_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList) |
The interface function to configure he sensor. More... | |
int32_t | DIFF_P_SPI_ReadData (diff_p_spi_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer) |
The interface function to read the sensor data. More... | |
int32_t | DIFF_P_SPI_DeInit (diff_p_spi_sensorhandle_t *pSensorHandle) |
The interface function to De Initialize sensor.. More... | |
int32_t | DIFF_P_I2C_Initialize (diff_p_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 | DIFF_P_I2C_SetIdleTask (diff_p_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam) |
: The interface function to set the I2C Idle Task. More... | |
int32_t | DIFF_P_I2C_Configure (diff_p_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList) |
The interface function to configure he sensor. More... | |
int32_t | DIFF_P_I2C_ReadData (diff_p_i2c_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer) |
The interface function to read the sensor data. More... | |
int32_t | DIFF_P_I2C_DeInit (diff_p_i2c_sensorhandle_t *pSensorHandle) |
The interface function to De Initialize sensor.. More... | |
Variables | |
uint8_t | diff_p_spiRead_CmdBuffer [DIFF_P_SPI_MAX_MSG_SIZE] = {0} |
uint8_t | diff_p_spiRead_DataBuffer [DIFF_P_SPI_MAX_MSG_SIZE] = {0} |
uint8_t | diff_p_spiWrite_CmdDataBuffer [DIFF_P_SPI_MAX_MSG_SIZE] = {0} |
The diff_p_drv.c file implements the diff_p functional interface.
Definition in file diff_p_drv.c.
int32_t DIFF_P_I2C_Configure | ( | diff_p_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.
[in] | pSensorHandle | handle to the sensor. |
[in] | pRegWriteList | pointer to the register list. |
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 372 of file diff_p_drv.c.
References diff_p_i2c_sensorhandle_t::deviceInfo, DIFF_P_CTRL_REG1, DIFF_P_CTRL_REG1_SBYB_ACTIVE, DIFF_P_CTRL_REG1_SBYB_MASK, DIFF_P_CTRL_REG1_SBYB_STANDBY, int32_t(), diff_p_i2c_sensorhandle_t::isInitialized, diff_p_i2c_sensorhandle_t::pCommDrv, Register_I2C_Write(), SENSOR_ERROR_INIT, SENSOR_ERROR_INVALID_PARAM, SENSOR_ERROR_NONE, SENSOR_ERROR_WRITE, Sensor_I2C_Write(), diff_p_i2c_sensorhandle_t::slaveAddress, and status.
Referenced by main().
int32_t DIFF_P_I2C_DeInit | ( | diff_p_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.
Trigger sensor device reset.
De-initialize sensor handle.
Definition at line 444 of file diff_p_drv.c.
References diff_p_i2c_sensorhandle_t::deviceInfo, DIFF_P_CTRL_REG1, DIFF_P_CTRL_REG1_RST_MASK, DIFF_P_CTRL_REG1_RST_RESET, int32_t(), diff_p_i2c_sensorhandle_t::isInitialized, diff_p_i2c_sensorhandle_t::pCommDrv, Register_I2C_Write(), SENSOR_ERROR_INIT, SENSOR_ERROR_INVALID_PARAM, SENSOR_ERROR_NONE, SENSOR_ERROR_WRITE, diff_p_i2c_sensorhandle_t::slaveAddress, and status.
int32_t DIFF_P_I2C_Initialize | ( | diff_p_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.
[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. |
[in] | whoami | WHO_AM_I value of the device. |
Check the input parameters.
Read and store the device's WHO_AM_I.
Initialize the sensor handle.
Put the device into standby mode so that we can run calibration can be done.
Run Calibration algorithm.
Wait for calibration to finish.
Definition at line 292 of file diff_p_drv.c.
References BOARD_DELAY_ms(), diff_p_i2c_sensorhandle_t::deviceInfo, registerDeviceInfo_t::deviceInstance, DIFF_P_CTRL_REG1, DIFF_P_CTRL_REG1_SBYB_MASK, DIFF_P_CTRL_REG1_SBYB_STANDBY, DIFF_P_CTRL_REG2, DIFF_P_CTRL_REG2_CTRL_AC_CALRUN, DIFF_P_CTRL_REG2_CTRL_AC_MASK, DIFF_P_STATUS, DIFF_P_STATUS_STAT_EP_MASK, DIFF_P_WHO_AM_I, registerDeviceInfo_t::functionParam, registerDeviceInfo_t::idleFunction, int32_t(), diff_p_i2c_sensorhandle_t::isInitialized, diff_p_i2c_sensorhandle_t::pCommDrv, Register_I2C_Read(), Register_I2C_Write(), SENSOR_ERROR_INIT, SENSOR_ERROR_INVALID_PARAM, SENSOR_ERROR_NONE, diff_p_i2c_sensorhandle_t::slaveAddress, and status.
Referenced by main().
int32_t DIFF_P_I2C_ReadData | ( | diff_p_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.
[in] | pSensorHandle | handle to the sensor. |
[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.
Parse through the read list and read the data one by one.
Definition at line 415 of file diff_p_drv.c.
References diff_p_i2c_sensorhandle_t::deviceInfo, int32_t(), diff_p_i2c_sensorhandle_t::isInitialized, diff_p_i2c_sensorhandle_t::pCommDrv, SENSOR_ERROR_INIT, SENSOR_ERROR_INVALID_PARAM, SENSOR_ERROR_NONE, SENSOR_ERROR_READ, Sensor_I2C_Read(), diff_p_i2c_sensorhandle_t::slaveAddress, and status.
Referenced by main().
void DIFF_P_I2C_SetIdleTask | ( | diff_p_i2c_sensorhandle_t * | pSensorHandle, |
registeridlefunction_t | idleTask, | ||
void * | userParam | ||
) |
: The interface function to set the I2C Idle Task.
[in] | diff_p_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 366 of file diff_p_drv.c.
References diff_p_i2c_sensorhandle_t::deviceInfo, registerDeviceInfo_t::functionParam, and registerDeviceInfo_t::idleFunction.
Referenced by main().
int32_t DIFF_P_SPI_Configure | ( | diff_p_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.
[in] | pSensorHandle | handle to the sensor. |
[in] | pRegWriteList | pointer to the register list. |
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 189 of file diff_p_drv.c.
References diff_p_spi_sensorhandle_t::deviceInfo, DIFF_P_CTRL_REG1, DIFF_P_CTRL_REG1_SBYB_ACTIVE, DIFF_P_CTRL_REG1_SBYB_MASK, DIFF_P_CTRL_REG1_SBYB_STANDBY, int32_t(), diff_p_spi_sensorhandle_t::isInitialized, diff_p_spi_sensorhandle_t::pCommDrv, Register_SPI_Write(), SENSOR_ERROR_INIT, SENSOR_ERROR_INVALID_PARAM, SENSOR_ERROR_NONE, SENSOR_ERROR_WRITE, Sensor_SPI_Write(), diff_p_spi_sensorhandle_t::slaveParams, and status.
Referenced by main().
int32_t DIFF_P_SPI_DeInit | ( | diff_p_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 261 of file diff_p_drv.c.
References diff_p_spi_sensorhandle_t::deviceInfo, DIFF_P_CTRL_REG1, DIFF_P_CTRL_REG1_RST_MASK, DIFF_P_CTRL_REG1_RST_RESET, int32_t(), diff_p_spi_sensorhandle_t::isInitialized, diff_p_spi_sensorhandle_t::pCommDrv, Register_SPI_Write(), SENSOR_ERROR_INIT, SENSOR_ERROR_INVALID_PARAM, SENSOR_ERROR_NONE, SENSOR_ERROR_WRITE, diff_p_spi_sensorhandle_t::slaveParams, and status.
int32_t DIFF_P_SPI_Initialize | ( | diff_p_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.
[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] | whoami | WHO_AM_I value of the device. |
Check the input parameters.
Initialize the sensor handle.
Read and store the device's WHO_AM_I.
Put the device into standby mode so that we can run calibration can be done.
Run Calibration algorithm.
Wait for calibration to finish.
Definition at line 92 of file diff_p_drv.c.
References BOARD_DELAY_ms(), GENERIC_DRIVER_GPIO::clr_pin, diff_p_spi_sensorhandle_t::deviceInfo, registerDeviceInfo_t::deviceInstance, DIFF_P_CTRL_REG1, DIFF_P_CTRL_REG1_SBYB_MASK, DIFF_P_CTRL_REG1_SBYB_STANDBY, DIFF_P_CTRL_REG2, DIFF_P_CTRL_REG2_CTRL_AC_CALRUN, DIFF_P_CTRL_REG2_CTRL_AC_MASK, DIFF_P_SPI_CMD_LEN, DIFF_P_SPI_ReadPreprocess(), DIFF_P_SPI_WritePreprocess(), DIFF_P_SS_ACTIVE_VALUE, DIFF_P_STATUS, DIFF_P_STATUS_STAT_EP_MASK, DIFF_P_WHO_AM_I, Driver_GPIO_KSDK, registerDeviceInfo_t::functionParam, GPIO_DIRECTION_OUT, registerDeviceInfo_t::idleFunction, int32_t(), diff_p_spi_sensorhandle_t::isInitialized, diff_p_spi_sensorhandle_t::pCommDrv, pGPIODriver, GENERIC_DRIVER_GPIO::pin_init, spiSlaveSpecificParams_t::pReadPreprocessFN, spiSlaveSpecificParams_t::pTargetSlavePinID, spiSlaveSpecificParams_t::pWritePreprocessFN, Register_SPI_Read(), Register_SPI_Write(), SENSOR_ERROR_INIT, SENSOR_ERROR_INVALID_PARAM, SENSOR_ERROR_NONE, GENERIC_DRIVER_GPIO::set_pin, diff_p_spi_sensorhandle_t::slaveParams, SPI_SS_ACTIVE_LOW, spiSlaveSpecificParams_t::spiCmdLen, spiSlaveSpecificParams_t::ssActiveValue, and status.
Referenced by main().
int32_t DIFF_P_SPI_ReadData | ( | diff_p_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.
[in] | pSensorHandle | handle to the sensor. |
[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.
Parse through the read list and read the data one by one.
Definition at line 232 of file diff_p_drv.c.
References diff_p_spi_sensorhandle_t::deviceInfo, int32_t(), diff_p_spi_sensorhandle_t::isInitialized, diff_p_spi_sensorhandle_t::pCommDrv, SENSOR_ERROR_INIT, SENSOR_ERROR_INVALID_PARAM, SENSOR_ERROR_NONE, SENSOR_ERROR_READ, Sensor_SPI_Read(), diff_p_spi_sensorhandle_t::slaveParams, and status.
Referenced by main().
void DIFF_P_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 57 of file diff_p_drv.c.
References DIFF_P_SPI_CMD_LEN, diff_p_spiRead_CmdBuffer, diff_p_spiRead_DataBuffer, spi_mater_SlaveCmd::pReadBuffer, spi_mater_SlaveCmd::pWriteBuffer, and spi_mater_SlaveCmd::size.
Referenced by DIFF_P_SPI_Initialize().
void DIFF_P_SPI_SetIdleTask | ( | diff_p_spi_sensorhandle_t * | pSensorHandle, |
registeridlefunction_t | idleTask, | ||
void * | userParam | ||
) |
: The interface function to set the SPI Idle Task.
[in] | diff_p_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 183 of file diff_p_drv.c.
References diff_p_spi_sensorhandle_t::deviceInfo, registerDeviceInfo_t::functionParam, and registerDeviceInfo_t::idleFunction.
Referenced by main().
void DIFF_P_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 73 of file diff_p_drv.c.
References DIFF_P_SPI_CMD_LEN, diff_p_spiWrite_CmdDataBuffer, spi_mater_SlaveCmd::pReadBuffer, spi_mater_SlaveCmd::pWriteBuffer, and spi_mater_SlaveCmd::size.
Referenced by DIFF_P_SPI_Initialize().
uint8_t diff_p_spiRead_CmdBuffer[DIFF_P_SPI_MAX_MSG_SIZE] = {0} |
Definition at line 50 of file diff_p_drv.c.
Referenced by DIFF_P_SPI_ReadPreprocess().
uint8_t diff_p_spiRead_DataBuffer[DIFF_P_SPI_MAX_MSG_SIZE] = {0} |
Definition at line 51 of file diff_p_drv.c.
Referenced by DIFF_P_SPI_ReadPreprocess().
uint8_t diff_p_spiWrite_CmdDataBuffer[DIFF_P_SPI_MAX_MSG_SIZE] = {0} |
Definition at line 52 of file diff_p_drv.c.
Referenced by DIFF_P_SPI_WritePreprocess().