ISSDK  1.7
IoT Sensing Software Development Kit
Macros | Functions | Variables
auto_detection_service.c File Reference
#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"
Include dependency graph for auto_detection_service.c:

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_GPIOpGPIODriver = &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}
 

Macro Definition Documentation

◆ ADS_NUM_BOARDS

#define ADS_NUM_BOARDS   (sizeof(gADS_QueryMap) / ADS_QUERY_NUM)

Definition at line 96 of file auto_detection_service.c.

Referenced by ADS_DetectShield().

◆ ADS_QUERY_NUM

#define ADS_QUERY_NUM   (sizeof(ADS_SensorQueryList) / sizeof(sensorAccess_t))

Definition at line 95 of file auto_detection_service.c.

Referenced by ADS_DetectShield().

◆ DIFF_P_SPI_CMD_LEN

#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().

◆ DIFF_P_SS_ACTIVE_VALUE

#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().

◆ FXLS8471Q_SPI_CMD_LEN

#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().

◆ FXLS8471Q_SS_ACTIVE_VALUE

#define FXLS8471Q_SS_ACTIVE_VALUE   SPI_SS_ACTIVE_LOW

Definition at line 74 of file auto_detection_service.c.

Referenced by ADS_InitSPI_FXLS8471().

◆ FXLS8962_SPI_CMD_LEN

#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().

◆ FXLS8962_SS_ACTIVE_VALUE

#define FXLS8962_SS_ACTIVE_VALUE   SPI_SS_ACTIVE_LOW

Definition at line 80 of file auto_detection_service.c.

Referenced by ADS_InitSPI_FXLS8962().

◆ MMA8491Q_WHO_AM_I

#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.

◆ MMA8491Q_WHO_AM_I_VALUE

#define MMA8491Q_WHO_AM_I_VALUE
Value:
MMA8491Q_STATUS_ZYXDR_DRDY)
#define MMA8491Q_STATUS_ZDR_DRDY
Definition: mma8491q.h:83
#define MMA8491Q_STATUS_YDR_DRDY
Definition: mma8491q.h:80
#define MMA8491Q_STATUS_XDR_DRDY
Definition: mma8491q.h:77
#define MMA8491Q_STATUS_RESERVED_ZERO
Definition: mma8491q.h:90

Definition at line 92 of file auto_detection_service.c.

◆ SPI_MAX_MSG_SIZE

#define SPI_MAX_MSG_SIZE   (64)

Definition at line 97 of file auto_detection_service.c.

Function Documentation

◆ ADS_DeInitI2CBuses()

int ADS_DeInitI2CBuses ( )

De-Initialize the Internal I2C driver.

De-Initialize the External I2C driver.

Definition at line 721 of file auto_detection_service.c.

References I2CextDrv, I2CintDrv, int32_t(), and status.

Here is the call graph for this function:

◆ ADS_DeInitSPIBus()

int ADS_DeInitSPIBus ( )

De-Initialize the SPI0 driver.

Definition at line 742 of file auto_detection_service.c.

References int32_t(), SPIdrv, and status.

Here is the call graph for this function:

◆ ADS_DetectQN()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ADS_DetectShield()

int ADS_DetectShield ( char *  pShieldString,
size_t  bufferLength 
)

◆ ADS_DIFF_P_SPI_ReadPreprocess()

void ADS_DIFF_P_SPI_ReadPreprocess ( void *  pCmdOut,
uint32_t  offset,
uint32_t  size 
)

◆ ADS_DIFF_P_SPI_WritePreprocess()

void ADS_DIFF_P_SPI_WritePreprocess ( void *  pCmdOut,
uint32_t  offset,
uint32_t  size,
void *  pWritebuffer 
)

◆ ADS_DIFF_PQuery()

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.

Here is the call graph for this function:

◆ ADS_FlashCompare()

ADS_FlashStatus_t ADS_FlashCompare ( char *  pResultString)

◆ ADS_FlashUpdate()

ADS_Status_t ADS_FlashUpdate ( char *  pResultString)

◆ ADS_FXLC95000Query()

ADS_Status_t ADS_FXLC95000Query ( )

◆ ADS_FXLS8471Q_SPI_ReadPreprocess()

void ADS_FXLS8471Q_SPI_ReadPreprocess ( void *  pCmdOut,
uint32_t  offset,
uint32_t  size 
)

◆ ADS_FXLS8471Q_SPI_WritePreprocess()

void ADS_FXLS8471Q_SPI_WritePreprocess ( void *  pCmdOut,
uint32_t  offset,
uint32_t  size,
void *  pWritebuffer 
)

◆ ADS_FXLS8471Query()

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.

Here is the call graph for this function:

◆ ADS_FXLS8962_SPI_ReadPreprocess()

void ADS_FXLS8962_SPI_ReadPreprocess ( void *  pCmdOut,
uint32_t  offset,
uint32_t  size 
)

◆ ADS_FXLS8962_SPI_WritePreprocess()

void ADS_FXLS8962_SPI_WritePreprocess ( void *  pCmdOut,
uint32_t  offset,
uint32_t  size,
void *  pWritebuffer 
)

◆ ADS_FXLS8962Query()

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.

Here is the call graph for this function:

◆ ADS_InitI2CBuses()

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.

Here is the call graph for this function:

◆ ADS_InitSPI_DIFF_P()

void ADS_InitSPI_DIFF_P ( )

◆ ADS_InitSPI_FXLS8471()

void ADS_InitSPI_FXLS8471 ( )

◆ ADS_InitSPI_FXLS8962()

void ADS_InitSPI_FXLS8962 ( )

◆ ADS_InitSPIBus()

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.

Here is the call graph for this function:

◆ ADS_MMA9553Query()

ADS_Status_t ADS_MMA9553Query ( )

◆ BOARD_RunADS()

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.

Parameters
[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.

Here is the call graph for this function:

Variable Documentation

◆ ADS_SensorQueryList

const sensorAccess_t ADS_SensorQueryList[]
Initial value:
= {
}
#define MMA8491_I2C_ADDR
#define DIFF_P_I2C_ADDR
#define FXPQ3115_I2C_ADDR
#define FXLS8471Q_WHO_AM_I_WHOAMI_VALUE
Definition: fxls8471q.h:538
#define FXPQ3115_WHOAMI_VALUE
Definition: fxpq3115.h:65
#define MMA8491Q_WHO_AM_I_VALUE
#define MPL3115_WHOAMI_VALUE
Definition: mpl3115.h:65
#define MMA8652_I2C_ADDR
#define FXOS8700_WHO_AM_I_PROD_VALUE
Definition: fxos8700.h:172
#define MMA8652_WHOAMI_VALUE
Definition: mma865x.h:65
#define FXLS8962_I2C_ADDR
#define ADS_NO_WHO_AM_I
#define FXAS21002_WHO_AM_I_WHOAMI_PROD_VALUE
Definition: fxas21002.h:428
#define DIFF_P_NPS3000VV_WHOAMI_VALUE
Definition: diff_p.h:96
#define FXAS21002_I2C_ADDR
#define FXLS8962_WHOAMI_VALUE
Definition: fxls8962.h:113
#define MPL3115_I2C_ADDR
#define MMA8491Q_WHO_AM_I
These variables are specific to MMA8491Q which does not have a Who Am I register. ...
#define MAG3110_WHOAMI_VALUE
Definition: mag3110.h:37
#define FXOS8700_I2C_ADDR
#define MAG3110_I2C_ADDR

This constant data structure contains the expected valid comm/sensor/who_am_i combinations.

Definition at line 117 of file auto_detection_service.c.

◆ ADS_ShieldList

char ADS_ShieldList[][ADS_MAX_STRING_LENGTH]
Initial value:
= {
"FRDM-STBC-AGM01", "FRDM-STBC-SA9500", "FRDMSTBC-A8471", "FRDMSTBC-A8491",
"FRDMSTBC-P3115", "FRDMSTBI-DP300x", "FRDMSTBI-DP300x", "FRDMSTBC-B3115",
"FRDM-STBC-AGMP03", "FRDM-STBC-AGMP03", "OnBoard",
}

Definition at line 335 of file auto_detection_service.c.

◆ ADS_ValidDEVIDValues

const mcuDEVID_t ADS_ValidDEVIDValues[]
Initial value:

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.

◆ gADS_QueryMap

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.

◆ gADS_QueryResults

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.

◆ I2CextDrv

ARM_DRIVER_I2C* I2CextDrv = &I2C_S1_DRIVER

Definition at line 345 of file auto_detection_service.c.

◆ I2CintDrv

ARM_DRIVER_I2C* I2CintDrv = &I2C_BB_DRIVER

Definition at line 346 of file auto_detection_service.c.

◆ pGPIODriver

Definition at line 347 of file auto_detection_service.c.

◆ ReadVersionInfo_MMA9553

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.

◆ SPIdrv

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.

◆ spiParams_8471

spiSlaveSpecificParams_t spiParams_8471

Definition at line 349 of file auto_detection_service.c.

◆ spiParams_8962

spiSlaveSpecificParams_t spiParams_8962

Definition at line 350 of file auto_detection_service.c.

◆ spiParams_diff_p

spiSlaveSpecificParams_t spiParams_diff_p

Definition at line 351 of file auto_detection_service.c.

◆ spiRead_CmdBuffer

uint8_t spiRead_CmdBuffer[SPI_MAX_MSG_SIZE] = {0}

Definition at line 352 of file auto_detection_service.c.

◆ spiRead_DataBuffer

uint8_t spiRead_DataBuffer[SPI_MAX_MSG_SIZE] = {0}

Definition at line 353 of file auto_detection_service.c.

◆ spiWrite_CmdDataBuffer

uint8_t spiWrite_CmdDataBuffer[SPI_MAX_MSG_SIZE] = {0}

Definition at line 354 of file auto_detection_service.c.