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 "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_flashiap.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 ADS_NVM_SECTOR_NUM   (ADS_NVM_ADDR / FSL_FEATURE_SYSCON_FLASH_SECTOR_SIZE_BYTES)
 
#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_DetectLPC (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 Device ID combinations. Refer : LPC5411x User manual - UM10914, Section: 33.5.12. 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
 
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 89 of file auto_detection_service.c.

Referenced by ADS_DetectShield().

◆ ADS_NVM_SECTOR_NUM

#define ADS_NVM_SECTOR_NUM   (ADS_NVM_ADDR / FSL_FEATURE_SYSCON_FLASH_SECTOR_SIZE_BYTES)

Definition at line 86 of file auto_detection_service.c.

Referenced by ADS_FlashUpdate().

◆ ADS_QUERY_NUM

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

Definition at line 88 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 84 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 85 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 72 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 73 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 78 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 79 of file auto_detection_service.c.

Referenced by ADS_InitSPI_FXLS8962().

◆ SPI_MAX_MSG_SIZE

#define SPI_MAX_MSG_SIZE   (64)

Definition at line 90 of file auto_detection_service.c.

Function Documentation

◆ ADS_DeInitI2CBuses()

int ADS_DeInitI2CBuses ( )

De-Initialize the External I2C driver.

Definition at line 681 of file auto_detection_service.c.

References I2CextDrv, int32_t(), and status.

Referenced by ADS_DetectShield().

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

◆ ADS_DeInitSPIBus()

int ADS_DeInitSPIBus ( )

De-Initialize the SPI0 driver.

Definition at line 695 of file auto_detection_service.c.

References int32_t(), SPIdrv, and status.

Referenced by ADS_DetectShield().

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

◆ ADS_DetectLPC()

int ADS_DetectLPC ( char *  pBoardString,
size_t  bufferLength 
)

Definition at line 828 of file auto_detection_service.c.

References ADS_LPC_54113J128, ADS_LPC_54113J256, ADS_LPC_54114J256, ADS_NO_BOARD_DETECTED, ADS_ValidDEVIDValues, mcuDEVID_t::board, int32_t(), mcuDEVID_t::mcuDeviceId, 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 
)

Definition at line 510 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.

Referenced by ADS_InitSPI_DIFF_P().

Here is the caller graph for this function:

◆ 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 549 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.

Referenced by ADS_DetectShield().

Here is the call graph for this function:
Here is the caller 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 ( )

Definition at line 569 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.

Referenced by ADS_DetectShield().

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

◆ 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 397 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.

Referenced by ADS_DetectShield().

Here is the call graph for this function:
Here is the caller 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 474 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.

Referenced by ADS_DetectShield().

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

◆ ADS_InitI2CBuses()

int ADS_InitI2CBuses ( )

Initialize the External I2C driver.

Set the External I2C Power mode.

Set the External I2C bus speed.

Definition at line 625 of file auto_detection_service.c.

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

Referenced by ADS_DetectShield().

Here is the call graph for this function:
Here is the caller 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 653 of file auto_detection_service.c.

References int32_t(), SPI_S_BAUDRATE, SPI_S_SIGNAL_EVENT, SPIdrv, and status.

Referenced by ADS_DetectShield().

Here is the call graph for this function:
Here is the caller 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 943 of file auto_detection_service.c.

Referenced by main().

Here is the caller graph for this function:

Variable Documentation

◆ ADS_SensorQueryList

const sensorAccess_t ADS_SensorQueryList[]
Initial value:
= {
}
#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 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 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 111 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-P3115", "FRDMSTBI-DP300x", "FRDMSTBI-DP300x", "FRDMSTBC-B3115",
"FRDM-FXS-MULT2-B", "FRDM-STBC-AGMP03", "FRDM-STBC-AGMP03", "FRDM-STBC-AGM04",
}

Definition at line 317 of file auto_detection_service.c.

Referenced by ADS_DetectShield().

◆ ADS_ValidDEVIDValues

const mcuDEVID_t ADS_ValidDEVIDValues[]
Initial value:

This constant data structure contains the expected valid MCU Device ID combinations. Refer : LPC5411x User manual - UM10914, Section: 33.5.12.

Definition at line 102 of file auto_detection_service.c.

Referenced by ADS_DetectLPC(), and ADS_DetectQN().

◆ gADS_QueryMap

const ADS_Status_t gADS_QueryMap[][ADS_QUERY_NUM]

These are the expected query signatures for the shield boards.

Definition at line 130 of file auto_detection_service.c.

Referenced by ADS_DetectShield().

◆ gADS_QueryResults

ADS_Status_t gADS_QueryResults[ADS_QUERY_NUM]

This global contains the results from the sensor query.

Definition at line 315 of file auto_detection_service.c.

Referenced by ADS_DetectShield().

◆ I2CextDrv

ARM_DRIVER_I2C* I2CextDrv = &I2C_S1_DRIVER

◆ pGPIODriver

◆ ReadVersionInfo_MMA9553

const uint8_t ReadVersionInfo_MMA9553[4] = {0x00, 0x00, 0x00, 0x0C}

The Read Version Info Command for FXLC95000.

Definition at line 96 of file auto_detection_service.c.

Referenced by ADS_MMA9553Query().

◆ SPIdrv

ARM_DRIVER_SPI* SPIdrv = &SPI_S_DRIVER

These values hold the ARM CMSIS Driver interface pointers.

Definition at line 326 of file auto_detection_service.c.

Referenced by ADS_DeInitSPIBus(), ADS_DIFF_PQuery(), ADS_FXLS8471Query(), ADS_FXLS8962Query(), ADS_InitSPIBus(), and main().

◆ spiParams_8471

spiSlaveSpecificParams_t spiParams_8471

Definition at line 330 of file auto_detection_service.c.

◆ spiParams_8962

spiSlaveSpecificParams_t spiParams_8962

Definition at line 331 of file auto_detection_service.c.

◆ spiParams_diff_p

spiSlaveSpecificParams_t spiParams_diff_p

Definition at line 332 of file auto_detection_service.c.

◆ spiRead_CmdBuffer

uint8_t spiRead_CmdBuffer[SPI_MAX_MSG_SIZE] = {0}

◆ spiRead_DataBuffer

uint8_t spiRead_DataBuffer[SPI_MAX_MSG_SIZE] = {0}

◆ spiWrite_CmdDataBuffer

uint8_t spiWrite_CmdDataBuffer[SPI_MAX_MSG_SIZE] = {0}