![]() |
ISSDK
1.7
IoT Sensing Software Development Kit
|
#include <stdio.h>
#include <stdint.h>
#include "diff_p.h"
#include "mma9553.h"
#include "mpl3115.h"
#include "mag3110.h"
#include "mma865x.h"
#include "fxls8962.h"
#include "fxpq3115.h"
#include "fxos8700.h"
#include "mma8491q.h"
#include "fxas21002.h"
#include "fxlc95000.h"
#include "fxls8471q.h"
#include "issdk_hal.h"
#include "gpio_driver.h"
#include "systick_utils.h"
#include "register_io_spi.h"
#include "register_io_i2c.h"
#include "auto_detection_shield.h"
#include "auto_detection_service.h"
#include "fsl_flash.h"
Go to the source code of this file.
Macros | |
#define | FXLS8471Q_SPI_CMD_LEN (2) |
These variables are specific to SPI access to the FXLS8471 for ADS. More... | |
#define | FXLS8471Q_SS_ACTIVE_VALUE SPI_SS_ACTIVE_LOW |
#define | FXLS8962_SPI_CMD_LEN (2) |
These variables are specific to SPI access to the FXLS8962 for ADS. More... | |
#define | FXLS8962_SS_ACTIVE_VALUE SPI_SS_ACTIVE_LOW |
#define | DIFF_P_SPI_CMD_LEN (1) |
These variables are specific to SPI access to the DIFF_P for ADS. More... | |
#define | DIFF_P_SS_ACTIVE_VALUE SPI_SS_ACTIVE_LOW |
#define | MMA8491Q_WHO_AM_I (MMA8491Q_STATUS) |
These variables are specific to MMA8491Q which does not have a Who Am I register. More... | |
#define | MMA8491Q_WHO_AM_I_VALUE |
#define | ADS_QUERY_NUM (sizeof(ADS_SensorQueryList) / sizeof(sensorAccess_t)) |
#define | ADS_NUM_BOARDS (sizeof(gADS_QueryMap) / ADS_QUERY_NUM) |
#define | SPI_MAX_MSG_SIZE (64) |
Functions | |
void | ADS_FXLS8471Q_SPI_ReadPreprocess (void *pCmdOut, uint32_t offset, uint32_t size) |
void | ADS_FXLS8471Q_SPI_WritePreprocess (void *pCmdOut, uint32_t offset, uint32_t size, void *pWritebuffer) |
void | ADS_InitSPI_FXLS8471 () |
ADS_Status_t | ADS_FXLS8471Query (uint8_t whoAmiAddr, uint8_t whoAmi) |
void | ADS_FXLS8962_SPI_ReadPreprocess (void *pCmdOut, uint32_t offset, uint32_t size) |
void | ADS_FXLS8962_SPI_WritePreprocess (void *pCmdOut, uint32_t offset, uint32_t size, void *pWritebuffer) |
void | ADS_InitSPI_FXLS8962 () |
ADS_Status_t | ADS_FXLS8962Query (uint8_t whoAmiAddr, uint8_t whoAmi) |
void | ADS_DIFF_P_SPI_ReadPreprocess (void *pCmdOut, uint32_t offset, uint32_t size) |
void | ADS_DIFF_P_SPI_WritePreprocess (void *pCmdOut, uint32_t offset, uint32_t size, void *pWritebuffer) |
void | ADS_InitSPI_DIFF_P () |
ADS_Status_t | ADS_DIFF_PQuery (uint8_t whoAmiAddr, uint8_t whoAmi) |
ADS_Status_t | ADS_FXLC95000Query () |
ADS_Status_t | ADS_MMA9553Query () |
int | ADS_InitI2CBuses () |
int | ADS_InitSPIBus () |
int | ADS_DeInitI2CBuses () |
int | ADS_DeInitSPIBus () |
int | ADS_DetectShield (char *pShieldString, size_t bufferLength) |
int | ADS_DetectQN (char *pBoardString, size_t bufferLength) |
ADS_FlashStatus_t | ADS_FlashCompare (char *pResultString) |
ADS_Status_t | ADS_FlashUpdate (char *pResultString) |
void | BOARD_RunADS (const char *appName, char *boardString, char *shieldString, size_t bufferLength) |
The function to register Application Name and initialte ADS. More... | |
Variables | |
const uint8_t | ReadVersionInfo_MMA9553 [4] = {0x00, 0x00, 0x00, 0x0C} |
The Read Version Info Command for FXLC95000. More... | |
const mcuDEVID_t | ADS_ValidDEVIDValues [] |
This constant data structure contains the expected valid MCU Chip ID combinations. Refer : QN908x user manual - UM11023, Section: 2.5.10. More... | |
const sensorAccess_t | ADS_SensorQueryList [] |
This constant data structure contains the expected valid comm/sensor/who_am_i combinations. More... | |
const ADS_Status_t | gADS_QueryMap [][ADS_QUERY_NUM] |
These are the expected query signatures for the shield boards. More... | |
ADS_Status_t | gADS_QueryResults [ADS_QUERY_NUM] |
This global contains the results from the sensor query. More... | |
char | ADS_ShieldList [][ADS_MAX_STRING_LENGTH] |
ARM_DRIVER_SPI * | SPIdrv = &SPI_S_DRIVER |
These values hold the ARM CMSIS Driver interface pointers. More... | |
ARM_DRIVER_I2C * | I2CextDrv = &I2C_S1_DRIVER |
ARM_DRIVER_I2C * | I2CintDrv = &I2C_BB_DRIVER |
GENERIC_DRIVER_GPIO * | pGPIODriver = &Driver_GPIO_KSDK |
spiSlaveSpecificParams_t | spiParams_8471 |
spiSlaveSpecificParams_t | spiParams_8962 |
spiSlaveSpecificParams_t | spiParams_diff_p |
uint8_t | spiRead_CmdBuffer [SPI_MAX_MSG_SIZE] = {0} |
uint8_t | spiRead_DataBuffer [SPI_MAX_MSG_SIZE] = {0} |
uint8_t | spiWrite_CmdDataBuffer [SPI_MAX_MSG_SIZE] = {0} |
#define ADS_NUM_BOARDS (sizeof(gADS_QueryMap) / ADS_QUERY_NUM) |
Definition at line 96 of file auto_detection_service.c.
Referenced by ADS_DetectShield().
#define ADS_QUERY_NUM (sizeof(ADS_SensorQueryList) / sizeof(sensorAccess_t)) |
Definition at line 95 of file auto_detection_service.c.
Referenced by ADS_DetectShield().
#define DIFF_P_SPI_CMD_LEN (1) |
These variables are specific to SPI access to the DIFF_P for ADS.
Definition at line 85 of file auto_detection_service.c.
Referenced by ADS_DIFF_P_SPI_ReadPreprocess(), ADS_DIFF_P_SPI_WritePreprocess(), and ADS_InitSPI_DIFF_P().
#define DIFF_P_SS_ACTIVE_VALUE SPI_SS_ACTIVE_LOW |
Definition at line 86 of file auto_detection_service.c.
Referenced by ADS_InitSPI_DIFF_P().
#define FXLS8471Q_SPI_CMD_LEN (2) |
These variables are specific to SPI access to the FXLS8471 for ADS.
Definition at line 73 of file auto_detection_service.c.
Referenced by ADS_FXLS8471Q_SPI_ReadPreprocess(), ADS_FXLS8471Q_SPI_WritePreprocess(), and ADS_InitSPI_FXLS8471().
#define FXLS8471Q_SS_ACTIVE_VALUE SPI_SS_ACTIVE_LOW |
Definition at line 74 of file auto_detection_service.c.
Referenced by ADS_InitSPI_FXLS8471().
#define FXLS8962_SPI_CMD_LEN (2) |
These variables are specific to SPI access to the FXLS8962 for ADS.
Definition at line 79 of file auto_detection_service.c.
Referenced by ADS_FXLS8962_SPI_ReadPreprocess(), ADS_FXLS8962_SPI_WritePreprocess(), and ADS_InitSPI_FXLS8962().
#define FXLS8962_SS_ACTIVE_VALUE SPI_SS_ACTIVE_LOW |
Definition at line 80 of file auto_detection_service.c.
Referenced by ADS_InitSPI_FXLS8962().
#define MMA8491Q_WHO_AM_I (MMA8491Q_STATUS) |
These variables are specific to MMA8491Q which does not have a Who Am I register.
Definition at line 91 of file auto_detection_service.c.
#define MMA8491Q_WHO_AM_I_VALUE |
Definition at line 92 of file auto_detection_service.c.
#define SPI_MAX_MSG_SIZE (64) |
Definition at line 97 of file auto_detection_service.c.
int ADS_DeInitI2CBuses | ( | ) |
int ADS_DeInitSPIBus | ( | ) |
De-Initialize the SPI0 driver.
Definition at line 742 of file auto_detection_service.c.
References int32_t(), SPIdrv, and status.
int ADS_DetectQN | ( | char * | pBoardString, |
size_t | bufferLength | ||
) |
Definition at line 903 of file auto_detection_service.c.
References ADS_NO_BOARD_DETECTED, ADS_QN_9020, ADS_QN_9080, ADS_ValidDEVIDValues, mcuDEVID_t::board, int32_t(), mcuDEVID_t::mcuChipId, mcuDEVID_t::mcuChipIdMask, and status.
Referenced by BOARD_RunADS().
int ADS_DetectShield | ( | char * | pShieldString, |
size_t | bufferLength | ||
) |
Definition at line 757 of file auto_detection_service.c.
References ADS_DeInitI2CBuses(), ADS_DeInitSPIBus(), ADS_DIFF_PQuery(), ADS_FAIL, ADS_FXLC95000Query(), ADS_FXLS8471Query(), ADS_FXLS8962Query(), ADS_I2C_EXT, ADS_I2C_INT, ADS_InitI2CBuses(), ADS_InitSPI_DIFF_P(), ADS_InitSPI_FXLS8471(), ADS_InitSPI_FXLS8962(), ADS_InitSPIBus(), ADS_MMA9553Query(), ADS_NO_SHIELD_DETECTED, ADS_NULL, ADS_NUM_BOARDS, ADS_OK, ADS_QUERY_NUM, ADS_ShieldList, ADS_SPI_DEV, BOARD_DELAY_ms(), PhysicalSensor::deviceInfo, registerDeviceInfo_t::deviceInstance, DIFF_P, FXLC95000, FXLS8471, FXLS8962, gADS_QueryMap, gADS_QueryResults, GPIO_DIRECTION_OUT, I2C_BB_DEVICE_INDEX, I2C_S1_DEVICE_INDEX, I2CextDrv, I2CintDrv, int32_t(), MMA8491_EN, MMA8491Q_I2C_ADDRESS, MMA8491Q_STATUS_RESERVED_MASK, MMA8491Q_T_ON_TYPICAL, MMA9553, GENERIC_DRIVER_GPIO::pin_init, Register_I2C_Read(), GENERIC_DRIVER_GPIO::set_pin, and status.
void ADS_DIFF_P_SPI_ReadPreprocess | ( | void * | pCmdOut, |
uint32_t | offset, | ||
uint32_t | size | ||
) |
Definition at line 513 of file auto_detection_service.c.
References DIFF_P_SPI_CMD_LEN, spi_mater_SlaveCmd::pReadBuffer, spi_mater_SlaveCmd::pWriteBuffer, spi_mater_SlaveCmd::size, spiRead_CmdBuffer, and spiRead_DataBuffer.
void ADS_DIFF_P_SPI_WritePreprocess | ( | void * | pCmdOut, |
uint32_t | offset, | ||
uint32_t | size, | ||
void * | pWritebuffer | ||
) |
Definition at line 529 of file auto_detection_service.c.
References DIFF_P_SPI_CMD_LEN, spi_mater_SlaveCmd::pReadBuffer, spi_mater_SlaveCmd::pWriteBuffer, spi_mater_SlaveCmd::size, and spiWrite_CmdDataBuffer.
ADS_Status_t ADS_DIFF_PQuery | ( | uint8_t | whoAmiAddr, |
uint8_t | whoAmi | ||
) |
Read and store the device's WHO_AM_I.
Definition at line 568 of file auto_detection_service.c.
References ADS_FAIL, ADS_OK, PhysicalSensor::deviceInfo, registerDeviceInfo_t::deviceInstance, int32_t(), Register_SPI_Read(), SPI_S_DEVICE_INDEX, SPIdrv, and status.
ADS_FlashStatus_t ADS_FlashCompare | ( | char * | pResultString | ) |
Definition at line 948 of file auto_detection_service.c.
References ADS_COOKIE_VALUE, ADS_FLASH_RECORD_CHANGE, ADS_FLASH_RECORD_NO_CHANGE, ADS_NO_FLASH_RECORD, ADS_NVM_ADDR, ADSFlashRecord_t::ADSString, ADSFlashRecord_t::cookie, ADSFlashRecord_t::length, and status.
ADS_Status_t ADS_FlashUpdate | ( | char * | pResultString | ) |
Definition at line 973 of file auto_detection_service.c.
References ADS_COOKIE_VALUE, ADS_FAIL, ADS_NVM_ADDR, ADS_OK, ADSFlashRecord_t::ADSString, ADSFlashRecord_t::cookie, and ADSFlashRecord_t::length.
ADS_Status_t ADS_FXLC95000Query | ( | ) |
Definition at line 588 of file auto_detection_service.c.
References PhysicalSensor::deviceInfo, registerDeviceInfo_t::deviceInstance, FXLC95000_I2C_ADDR, I2C_S1_DEVICE_INDEX, I2CextDrv, int32_t(), Register_I2C_BlockWrite(), and status.
void ADS_FXLS8471Q_SPI_ReadPreprocess | ( | void * | pCmdOut, |
uint32_t | offset, | ||
uint32_t | size | ||
) |
Definition at line 359 of file auto_detection_service.c.
References FXLS8471Q_SPI_CMD_LEN, spi_mater_SlaveCmd::pReadBuffer, spi_mater_SlaveCmd::pWriteBuffer, spi_mater_SlaveCmd::size, spiRead_CmdBuffer, and spiRead_DataBuffer.
void ADS_FXLS8471Q_SPI_WritePreprocess | ( | void * | pCmdOut, |
uint32_t | offset, | ||
uint32_t | size, | ||
void * | pWritebuffer | ||
) |
Definition at line 376 of file auto_detection_service.c.
References FXLS8471Q_SPI_CMD_LEN, spi_mater_SlaveCmd::pReadBuffer, spi_mater_SlaveCmd::pWriteBuffer, spi_mater_SlaveCmd::size, and spiWrite_CmdDataBuffer.
ADS_Status_t ADS_FXLS8471Query | ( | uint8_t | whoAmiAddr, |
uint8_t | whoAmi | ||
) |
Read and store the device's WHO_AM_I.
Definition at line 416 of file auto_detection_service.c.
References ADS_FAIL, ADS_OK, PhysicalSensor::deviceInfo, registerDeviceInfo_t::deviceInstance, int32_t(), Register_SPI_Read(), SPI_S_DEVICE_INDEX, SPIdrv, and status.
void ADS_FXLS8962_SPI_ReadPreprocess | ( | void * | pCmdOut, |
uint32_t | offset, | ||
uint32_t | size | ||
) |
Definition at line 436 of file auto_detection_service.c.
References FXLS8962_SPI_CMD_LEN, spi_mater_SlaveCmd::pReadBuffer, spi_mater_SlaveCmd::pWriteBuffer, spi_mater_SlaveCmd::size, spiRead_CmdBuffer, and spiRead_DataBuffer.
void ADS_FXLS8962_SPI_WritePreprocess | ( | void * | pCmdOut, |
uint32_t | offset, | ||
uint32_t | size, | ||
void * | pWritebuffer | ||
) |
Definition at line 453 of file auto_detection_service.c.
References FXLS8962_SPI_CMD_LEN, spi_mater_SlaveCmd::pReadBuffer, spi_mater_SlaveCmd::pWriteBuffer, spi_mater_SlaveCmd::size, and spiWrite_CmdDataBuffer.
ADS_Status_t ADS_FXLS8962Query | ( | uint8_t | whoAmiAddr, |
uint8_t | whoAmi | ||
) |
Read and store the device's WHO_AM_I.
Definition at line 493 of file auto_detection_service.c.
References ADS_FAIL, ADS_OK, PhysicalSensor::deviceInfo, registerDeviceInfo_t::deviceInstance, int32_t(), Register_SPI_Read(), SPI_S_DEVICE_INDEX, SPIdrv, and status.
int ADS_InitI2CBuses | ( | ) |
Initialize the Internal I2C driver.
Set the Internal I2C Power mode.
Set the Internal I2C bus speed.
Initialize the External I2C driver.
Set the External I2C Power mode.
Set the External I2C bus speed.
Definition at line 644 of file auto_detection_service.c.
References I2C_BB_SIGNAL_EVENT, I2C_S1_SIGNAL_EVENT, I2CextDrv, I2CintDrv, int32_t(), and status.
void ADS_InitSPI_DIFF_P | ( | ) |
Definition at line 548 of file auto_detection_service.c.
References ADS_DIFF_P_SPI_ReadPreprocess(), ADS_DIFF_P_SPI_WritePreprocess(), GENERIC_DRIVER_GPIO::clr_pin, DIFF_P_SPI_CMD_LEN, DIFF_P_SPI_CS, DIFF_P_SS_ACTIVE_VALUE, GPIO_DIRECTION_OUT, GENERIC_DRIVER_GPIO::pin_init, spiSlaveSpecificParams_t::pReadPreprocessFN, spiSlaveSpecificParams_t::pTargetSlavePinID, spiSlaveSpecificParams_t::pWritePreprocessFN, GENERIC_DRIVER_GPIO::set_pin, SPI_SS_ACTIVE_LOW, spiSlaveSpecificParams_t::spiCmdLen, and spiSlaveSpecificParams_t::ssActiveValue.
void ADS_InitSPI_FXLS8471 | ( | ) |
Definition at line 396 of file auto_detection_service.c.
References ADS_FXLS8471Q_SPI_ReadPreprocess(), ADS_FXLS8471Q_SPI_WritePreprocess(), GENERIC_DRIVER_GPIO::clr_pin, FXLS8471_SPI_CS, FXLS8471Q_SPI_CMD_LEN, FXLS8471Q_SS_ACTIVE_VALUE, GPIO_DIRECTION_OUT, GENERIC_DRIVER_GPIO::pin_init, spiSlaveSpecificParams_t::pReadPreprocessFN, spiSlaveSpecificParams_t::pTargetSlavePinID, spiSlaveSpecificParams_t::pWritePreprocessFN, GENERIC_DRIVER_GPIO::set_pin, SPI_SS_ACTIVE_LOW, spiSlaveSpecificParams_t::spiCmdLen, and spiSlaveSpecificParams_t::ssActiveValue.
void ADS_InitSPI_FXLS8962 | ( | ) |
Initialize the sensor handle.
Definition at line 473 of file auto_detection_service.c.
References ADS_FXLS8962_SPI_ReadPreprocess(), ADS_FXLS8962_SPI_WritePreprocess(), GENERIC_DRIVER_GPIO::clr_pin, FXLS8962_CS, FXLS8962_SPI_CMD_LEN, FXLS8962_SS_ACTIVE_VALUE, GPIO_DIRECTION_OUT, GENERIC_DRIVER_GPIO::pin_init, spiSlaveSpecificParams_t::pReadPreprocessFN, spiSlaveSpecificParams_t::pTargetSlavePinID, spiSlaveSpecificParams_t::pWritePreprocessFN, GENERIC_DRIVER_GPIO::set_pin, SPI_SS_ACTIVE_LOW, spiSlaveSpecificParams_t::spiCmdLen, and spiSlaveSpecificParams_t::ssActiveValue.
int ADS_InitSPIBus | ( | ) |
Initialize the SPI driver.
Set the SPI Power mode.
Set the SPI Slave speed.
Definition at line 693 of file auto_detection_service.c.
References int32_t(), SPI_S_BAUDRATE, SPI_S_SIGNAL_EVENT, SPIdrv, and status.
ADS_Status_t ADS_MMA9553Query | ( | ) |
Definition at line 617 of file auto_detection_service.c.
References ADS_FAIL, ADS_OK, BOARD_DELAY_ms(), PhysicalSensor::deviceInfo, registerDeviceInfo_t::deviceInstance, I2C_S1_DEVICE_INDEX, I2CextDrv, int32_t(), MMA9553_HDR_SIZE, MMA9553_I2C_ADDR, ReadVersionInfo_MMA9553, Register_I2C_BlockWrite(), Register_I2C_Read(), and status.
void BOARD_RunADS | ( | const char * | appName, |
char * | boardString, | ||
char * | shieldString, | ||
size_t | bufferLength | ||
) |
The function to register Application Name and initialte ADS.
The API will read the Application Name from the user and return the result string with the ADS detection results. It will also update the FLASH with the new results.
[in] | pAppName | - pointer to a buffer where the application name is placed. |
Definition at line 1009 of file auto_detection_service.c.
References ADS_DetectLPC(), ADS_DetectQN(), ADS_DetectShield(), ADS_FAIL, ADS_FLASH_RECORD_NO_CHANGE, ADS_FLASH_STRING_LENGTH, ADS_FlashCompare(), ADS_FlashUpdate(), ADS_OK, int32_t(), and status.
const sensorAccess_t ADS_SensorQueryList[] |
This constant data structure contains the expected valid comm/sensor/who_am_i combinations.
Definition at line 117 of file auto_detection_service.c.
char ADS_ShieldList[][ADS_MAX_STRING_LENGTH] |
Definition at line 335 of file auto_detection_service.c.
const mcuDEVID_t ADS_ValidDEVIDValues[] |
This constant data structure contains the expected valid MCU Chip ID combinations. Refer : QN908x user manual - UM11023, Section: 2.5.10.
Definition at line 109 of file auto_detection_service.c.
const ADS_Status_t gADS_QueryMap[][ADS_QUERY_NUM] |
These are the expected query signatures for the shield boards.
Definition at line 137 of file auto_detection_service.c.
ADS_Status_t gADS_QueryResults[ADS_QUERY_NUM] |
This global contains the results from the sensor query.
Definition at line 333 of file auto_detection_service.c.
ARM_DRIVER_I2C* I2CextDrv = &I2C_S1_DRIVER |
Definition at line 345 of file auto_detection_service.c.
ARM_DRIVER_I2C* I2CintDrv = &I2C_BB_DRIVER |
Definition at line 346 of file auto_detection_service.c.
GENERIC_DRIVER_GPIO* pGPIODriver = &Driver_GPIO_KSDK |
Definition at line 347 of file auto_detection_service.c.
const uint8_t ReadVersionInfo_MMA9553[4] = {0x00, 0x00, 0x00, 0x0C} |
The Read Version Info Command for FXLC95000.
Definition at line 103 of file auto_detection_service.c.
ARM_DRIVER_SPI* SPIdrv = &SPI_S_DRIVER |
These values hold the ARM CMSIS Driver interface pointers.
Definition at line 344 of file auto_detection_service.c.
spiSlaveSpecificParams_t spiParams_8471 |
Definition at line 349 of file auto_detection_service.c.
spiSlaveSpecificParams_t spiParams_8962 |
Definition at line 350 of file auto_detection_service.c.
spiSlaveSpecificParams_t spiParams_diff_p |
Definition at line 351 of file auto_detection_service.c.
uint8_t spiRead_CmdBuffer[SPI_MAX_MSG_SIZE] = {0} |
Definition at line 352 of file auto_detection_service.c.
uint8_t spiRead_DataBuffer[SPI_MAX_MSG_SIZE] = {0} |
Definition at line 353 of file auto_detection_service.c.
uint8_t spiWrite_CmdDataBuffer[SPI_MAX_MSG_SIZE] = {0} |
Definition at line 354 of file auto_detection_service.c.