25 #include "clock_config.h"    30 #include "Driver_I2C.h"    31 #include "Driver_USART.h"    36 #include "issdk_hal.h"    37 #include "gpio_driver.h"    43 #include "auto_detection_service.h"    48 #define STREAMING_PKT_TIMESTAMP_LEN (4)    49 #define FXOS8700_ACCEL_DATA_SIZE (6)    50 #define FXOS8700_MAG_DATA_SIZE (6)    51 #define MPL3115_PADDING_SIZE (1)    52 #define MPL3115_PRESSURE_DATA_SIZE (3)    53 #define MPL3115_TEMPERATURE_DATA_SIZE (2)    55 #define FXOS8700_DATA_SIZE (FXOS8700_ACCEL_DATA_SIZE + FXOS8700_MAG_DATA_SIZE)    56 #define FXAS21002_DATA_SIZE (FXAS21002_GYRO_DATA_SIZE)    57 #define MPL3115_DATA_SIZE (MPL3115_PRESSURE_DATA_SIZE + MPL3115_TEMPERATURE_DATA_SIZE)    60 #define LED_TOGGLE_RATE (100)    61 #define STREAMING_PAYLOAD_LEN \    62     (STREAMING_PKT_TIMESTAMP_LEN + FXOS8700_DATA_SIZE + FXAS21002_DATA_SIZE + MPL3115_DATA_SIZE + MPL3115_PADDING_SIZE)    63 #define STREAMING_PAYLOAD_SHORT_LEN (STREAMING_PKT_TIMESTAMP_LEN + FXOS8700_DATA_SIZE + FXAS21002_DATA_SIZE)    66 #define nmi_handler NMI_Handler    69 #define APPLICATION_NAME "Generic Data Logger Demo"    71 #define APPLICATION_VERSION "2.5"   145     uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse, 
size_t *hostMsgSize, 
size_t respBufferSize)
   147     bool success = 
false;
   162         if (respBufferSize >= boardNameLen + shieldNameLen + appNameLen + 3)
   171         hostResponse[*hostMsgSize] = appNameLen;
   174         memcpy(hostResponse + *hostMsgSize, 
embAppName, appNameLen);
   175         *hostMsgSize += appNameLen;
   177         hostResponse[*hostMsgSize] = boardNameLen;
   180         memcpy(hostResponse + *hostMsgSize, 
boardString, boardNameLen);
   181         *hostMsgSize += boardNameLen;
   183         hostResponse[*hostMsgSize] = shieldNameLen;
   186         memcpy(hostResponse + *hostMsgSize, 
shieldString, shieldNameLen);
   187         *hostMsgSize += shieldNameLen;
   197         switch (hostCommand[0]) 
   231     uint8_t secondaryStreamID1, secondaryStreamID2, 
   232         dataReady_3115, toggle_pin = 0,             
   269     if (ARM_DRIVER_OK != status)
   275     status = pI2cDriver->PowerControl(ARM_POWER_FULL);
   276     if (ARM_DRIVER_OK != status)
   282     status = pI2cDriver->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
   283     if (ARM_DRIVER_OK != status)
   290     if (ARM_DRIVER_OK != status)
   296     status = pUartDriver->PowerControl(ARM_POWER_FULL);
   297     if (ARM_DRIVER_OK != status)
   304     if (ARM_DRIVER_OK != status)
   368     if (0 == secondaryStreamID1)
   376     if (0 == secondaryStreamID2)
   409         if (ARM_DRIVER_OK != status)
   415         rawData_fxos8700.
accel[0] = ((int16_t)
data[0] << 8) | 
data[1];
   416         rawData_fxos8700.
accel[0] /= 4;
   417         rawData_fxos8700.
accel[1] = ((int16_t)
data[2] << 8) | 
data[3];
   418         rawData_fxos8700.
accel[1] /= 4;
   419         rawData_fxos8700.
accel[2] = ((int16_t)
data[4] << 8) | 
data[5];
   420         rawData_fxos8700.
accel[2] /= 4;
   421         rawData_fxos8700.
mag[0] = ((int16_t)
data[6] << 8) | 
data[7];
   422         rawData_fxos8700.
mag[1] = ((int16_t)
data[8] << 8) | 
data[9];
   423         rawData_fxos8700.
mag[2] = ((int16_t)
data[10] << 8) | 
data[11];
   427                sizeof(rawData_fxos8700.
accel));
   429                &rawData_fxos8700.
mag, 
sizeof(rawData_fxos8700.
mag));
   433         if (ARM_DRIVER_OK != status)
   439         rawData_fxas21002.
gyro[0] = ((int16_t)
data[12] << 8) | 
data[13];
   440         rawData_fxas21002.
gyro[1] = ((int16_t)
data[14] << 8) | 
data[15];
   441         rawData_fxas21002.
gyro[2] = ((int16_t)
data[16] << 8) | 
data[17];
   445                &rawData_fxas21002.
gyro, 
sizeof(rawData_fxas21002.
gyro));
   449         if (ARM_DRIVER_OK != status)
   458             if (ARM_DRIVER_OK != status)
   480             if (ARM_DRIVER_OK != status)
 void(* set_pin)(pinID_t aPinId)
 
#define FXAS21002_WHO_AM_I_WHOAMI_PROD_VALUE
 
int32_t FXOS8700_I2C_Initialize(fxos8700_i2c_sensorhandle_t *pSensorHandle, ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress, uint8_t whoAmi)
The interface function to initialize the sensor. 
 
#define FXAS21002_CTRL_REG2_INT_EN_DRDY_ENABLE
 
This structure defines the fxos8700 raw data buffer. 
 
uint8_t Host_IO_Init(ARM_DRIVER_USART *pDrv, void *pBus, void *pDevInfo, void *spiSlaveParams, uint16_t slaveAddress)
 
void Host_IO_Receive(host_cmd_proc_fn_t process_host_command, uint8_t encoding)
 
#define MPL3115_DATA_SIZE
 
This structure defines the Write command List. 
 
volatile bool bFxas21002DataReady
 
#define FXOS8700_M_CTRL_REG2_M_AUTOINC_MASK
 
ARM_DRIVER_I2C * pCommDrv
 
#define FXAS21002_CTRL_REG2_INT_CFG_DRDY_INT1
 
void MPL3115_I2C_SetIdleTask(mpl3115_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task. 
 
int32_t FXAS21002_I2C_Initialize(fxas21002_i2c_sensorhandle_t *pSensorHandle, ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress, uint8_t whoAmi)
The interface function to initialize the sensor. 
 
status_t SMC_SetPowerModeVlpr(void *arg)
Configures the system to VLPR power mode. API name used from Kinetis family to maintain compatibility...
 
The host_io_uart.h file contains the Host Protocol interface definitions and configuration. 
 
#define FXOS8700_M_CTRL_REG1_M_HMS_MASK
 
#define FXOS8700_WHO_AM_I_PROD_VALUE
 
void FXAS21002_I2C_SetIdleTask(fxas21002_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task. 
 
char shieldString[ADS_MAX_STRING_LENGTH]
 
#define FXOS8700_CTRL_REG1_DR_MASK
 
const registerwritelist_t cMpl3115SetOST[]
Register settings for Triggring One-Shot Sampling. 
 
int32_t MPL3115_I2C_ReadData(mpl3115_i2c_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer)
The interface function to read the sensor data. 
 
The mpl3115_drv.h file describes the MPL3115 driver interface and structures. 
 
#define HOST_PRO_CMD_W_CFG_TAG
 
This structure defines the fxas21002 raw data buffer. 
 
Access structure of the GPIO Driver. 
 
#define FXOS8700_M_CTRL_REG1_M_HMS_HYBRID_MODE
 
registerDeviceInfo_t deviceInfo
 
const registerreadlist_t fxos8700_Output_values[]
 
GENERIC_DRIVER_GPIO * pGpioDriver
 
#define __END_WRITE_DATA__
 
#define STREAMING_PKT_TIMESTAMP_LEN
 
#define FXOS8700_M_CTRL_REG2_M_AUTOINC_HYBRID_MODE
 
void(* clr_pin)(pinID_t aPinId)
 
typedef int32_t(DATA_FORMAT_Append_t))(void *pData
The interface function to append the data on the formated stream. 
 
#define HOST_S_SIGNAL_EVENT
 
#define FXAS21002_CTRL_REG2_INT_EN_DRDY_MASK
 
const registerreadlist_t cMpl3115GetOST[]
Address of Register containing OST Bit. 
 
#define I2C_S_SIGNAL_EVENT
 
const registerwritelist_t fxos8700_Config_Hybrid[]
 
bool process_host_command(uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse, size_t *hostMsgSize, size_t respBufferSize)
 
This defines the sensor specific information for I2C. 
 
int32_t FXAS21002_I2C_Configure(fxas21002_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor. 
 
int32_t FXOS8700_I2C_Configure(fxos8700_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor. 
 
This defines the sensor specific information for I2C. 
 
#define APPLICATION_NAME
Unique Name for this application which should match the target GUI pkg name. 
 
void Host_IO_Add_ISO_Header(uint8_t streamID, uint8_t *pStreamingPacket, size_t sizePayload)
 
#define FXAS21002_CTRL_REG2_IPOL_MASK
 
#define BOARD_DEBUG_UART_BAUDRATE
 
int32_t FXOS8700_I2C_ReadData(fxos8700_i2c_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer)
The interface function to read the sensor data. 
 
int32_t Sensor_I2C_Write(ARM_DRIVER_I2C *pCommDrv, registerDeviceInfo_t *devInfo, uint16_t slaveAddress, const registerwritelist_t *pRegWriteList)
Write register data to a sensor. 
 
#define BOARD_BootClockRUN
 
#define FXAS21002_CTRL_REG2_IPOL_ACTIVE_HIGH
 
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type. 
 
#define STREAMING_PAYLOAD_LEN
 
volatile bool bStreamingEnabled
 
uint8_t streamingPacket[STREAMING_HEADER_LEN+FXLS8962_STREAM_DATA_SIZE]
 
GENERIC_DRIVER_GPIO Driver_GPIO_KSDK
 
#define FXAS21002_I2C_ADDR
 
#define FXOS8700_M_CTRL_REG1_M_ACAL_EN
 
void Host_IO_Send(uint8_t *pMsg, size_t size, uint8_t encoding)
 
void BOARD_SystickStart(int32_t *pStart)
Function to Record the Start systick. 
 
#define FXOS8700_M_CTRL_REG1_M_ACAL_MASK
 
This structure defines the mpl3115 data buffer in Pressure Mode. 
 
uint32_t BOARD_SystickElapsedTime_us(int32_t *pStart)
Function to compute the Elapsed Time. 
 
uint8_t data[FXLS8962_DATA_SIZE]
 
#define FXOS8700_CTRL_REG1_DR_HYBRID_200_HZ
 
#define __END_READ_DATA__
 
#define HOST_PRO_INT_DEV_TAG
 
void BOARD_RunADS(const char *appName, char *boardString, char *shieldString, size_t bufferLength)
The function to register Application Name and initialte ADS. 
 
#define MPL3115_PRESSURE_DATA_SIZE
 
#define MPL3115_CTRL_REG1_OST_RESET
 
#define MPL3115_CTRL_REG1_OST_MASK
 
The fxas21002_drv.h file describes the fxas21002 driver interface and structures. ...
 
#define FXAS21002_DATA_SIZE
 
This defines the sensor specific information. 
 
int32_t FXAS21002_I2C_ReadData(fxas21002_i2c_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer)
The interface function to read the sensor data. 
 
#define FXOS8700_DATA_SIZE
 
char embAppName[ADS_MAX_STRING_LENGTH]
 
volatile bool bDataLoggerReady
 
const registerreadlist_t mpl3115_Output_Values[]
Address and size of Raw Pressure+Temperature Data in Normal Mode. 
 
int32_t MPL3115_I2C_Initialize(mpl3115_i2c_sensorhandle_t *pSensorHandle, ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress, uint8_t whoAmi)
The interface function to initialize the sensor. 
 
#define FXOS8700_M_CTRL_REG2_M_RST_CNT_DISABLE
 
#define FXOS8700_M_CTRL_REG2_M_RST_CNT_MASK
 
void fxas21002_isr(void *pUserData)
 
#define FXOS8700_ACCEL_DATA_SIZE
 
void(* toggle_pin)(pinID_t aPinId)
 
#define ADS_MAX_STRING_LENGTH
 
ARM_DRIVER_I2C * pCommDrv
 
The fxos8700_drv.h file describes the fxos8700 driver interface and structures. 
 
#define STREAMING_PAYLOAD_SHORT_LEN
 
#define APPLICATION_VERSION
Version to distinguish between instances the same application based on target Shield and updates...
 
#define FXAS21002_CTRL_REG1_DR_MASK
 
void BOARD_SystickEnable(void)
Function to enable systicks framework. 
 
#define MPL3115_WHOAMI_VALUE
 
#define STREAMING_HEADER_LEN
 
char boardString[ADS_MAX_STRING_LENGTH]
 
status_t SMC_SetPowerModeWait(void *arg)
Configures the system to WAIT power mode. API name used from Kinetis family to maintain compatibility...
 
void(* pin_init)(pinID_t aPinId, gpio_direction_t dir, void *apPinConfig, gpio_isr_handler_t aIsrHandler, void *apUserData)
 
int main(void)
Main function. 
 
ARM_DRIVER_I2C * pCommDrv
 
#define FXAS21002_CTRL_REG1_DR_200HZ
 
This structure defines the Read command List. 
 
#define FXAS21002_CTRL_REG2_INT_CFG_DRDY_MASK
 
#define MPL3115_CTRL_REG1_OST_SET
 
#define I2C_S_DEVICE_INDEX
 
void FXOS8700_I2C_SetIdleTask(fxos8700_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task. 
 
#define HOST_PRO_INT_CMD_TAG
Bit aligned values for Host Protocol Interface IDs (Bits 5-6). 
 
#define FXOS8700_I2C_ADDR
 
#define MPL3115_PADDING_SIZE
 
registerDeviceInfo_t deviceInfo
 
const registerreadlist_t fxas21002_Output_Values[]
 
const registerwritelist_t fxas21002_Config_Isr[]
 
registerDeviceInfo_t deviceInfo