![]() |
ISSDK
1.8
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 "mma845x.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_DetectFRDM (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 mcuSDID_t | ADS_ValidSDIDValues [] |
This constant data structure contains the expected valid MCU SDID combinations. 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 72 of file auto_detection_service.c.
Referenced by ADS_DetectShield().
#define ADS_QUERY_NUM (sizeof(ADS_SensorQueryList) / sizeof(sensorAccess_t)) |
Definition at line 71 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 60 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 61 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 48 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 49 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 54 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 55 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 66 of file auto_detection_service.c.
#define MMA8491Q_WHO_AM_I_VALUE |
Definition at line 67 of file auto_detection_service.c.
#define SPI_MAX_MSG_SIZE (64) |
Definition at line 73 of file auto_detection_service.c.
int ADS_DeInitI2CBuses | ( | ) |
int ADS_DeInitSPIBus | ( | ) |
De-Initialize the SPI0 driver.
Definition at line 790 of file auto_detection_service.c.
References int32_t(), SPIdrv, and status.
int ADS_DetectFRDM | ( | char * | pBoardString, |
size_t | bufferLength | ||
) |
Definition at line 951 of file auto_detection_service.c.
References ADS_FRDM_K22F, ADS_FRDM_K64F, ADS_FRDM_KE15Z, ADS_FRDM_KL25Z, ADS_FRDM_KL27Z, ADS_FRDM_KW41Z, ADS_NO_BOARD_DETECTED, ADS_RD_KL25_AGMP01, ADS_ValidSDIDValues, mcuSDID_t::board, int32_t(), mcuSDID_t::mcuFamId, mcuSDID_t::mcuFamilyId, mcuSDID_t::mcuPinId, mcuSDID_t::mcuSeriesId, mcuSDID_t::mcuSubfamilyId, and status.
Referenced by BOARD_RunADS().
int ADS_DetectShield | ( | char * | pShieldString, |
size_t | bufferLength | ||
) |
Definition at line 805 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(), 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 561 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 577 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 616 of file auto_detection_service.c.
References ADS_FAIL, ADS_OK, 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 1035 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 1060 of file auto_detection_service.c.
References ADS_COOKIE_VALUE, ADS_FAIL, ADS_NVM_ADDR, ADS_OK, ADSFlashRecord_t::ADSString, ADSFlashRecord_t::cookie, FLASH_SECTOR_SIZE_PROPERTY, and ADSFlashRecord_t::length.
ADS_Status_t ADS_FXLC95000Query | ( | ) |
Definition at line 636 of file auto_detection_service.c.
References 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 407 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 424 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 464 of file auto_detection_service.c.
References ADS_FAIL, ADS_OK, 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 484 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 501 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 541 of file auto_detection_service.c.
References ADS_FAIL, ADS_OK, 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 692 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 596 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 444 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 521 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 741 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 665 of file auto_detection_service.c.
References ADS_FAIL, ADS_OK, BOARD_DELAY_ms(), 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 1101 of file auto_detection_service.c.
References ADS_DetectFRDM(), 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 98 of file auto_detection_service.c.
char ADS_ShieldList[][ADS_MAX_STRING_LENGTH] |
Definition at line 382 of file auto_detection_service.c.
const mcuSDID_t ADS_ValidSDIDValues[] |
This constant data structure contains the expected valid MCU SDID combinations.
Definition at line 84 of file auto_detection_service.c.
Referenced by ADS_DetectFRDM().
const ADS_Status_t gADS_QueryMap[][ADS_QUERY_NUM] |
These are the expected query signatures for the shield boards.
Definition at line 119 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 380 of file auto_detection_service.c.
ARM_DRIVER_I2C* I2CextDrv = &I2C_S1_DRIVER |
Definition at line 393 of file auto_detection_service.c.
ARM_DRIVER_I2C* I2CintDrv = &I2C_BB_DRIVER |
Definition at line 394 of file auto_detection_service.c.
Referenced by ADS_DeInitI2CBuses(), ADS_DetectShield(), and ADS_InitI2CBuses().
GENERIC_DRIVER_GPIO* pGPIODriver = &Driver_GPIO_KSDK |
Definition at line 395 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 79 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 392 of file auto_detection_service.c.
spiSlaveSpecificParams_t spiParams_8471 |
Definition at line 397 of file auto_detection_service.c.
spiSlaveSpecificParams_t spiParams_8962 |
Definition at line 398 of file auto_detection_service.c.
spiSlaveSpecificParams_t spiParams_diff_p |
Definition at line 399 of file auto_detection_service.c.
uint8_t spiRead_CmdBuffer[SPI_MAX_MSG_SIZE] = {0} |
Definition at line 400 of file auto_detection_service.c.
uint8_t spiRead_DataBuffer[SPI_MAX_MSG_SIZE] = {0} |
Definition at line 401 of file auto_detection_service.c.
uint8_t spiWrite_CmdDataBuffer[SPI_MAX_MSG_SIZE] = {0} |
Definition at line 402 of file auto_detection_service.c.