51 #include "clock_config.h" 56 #include "Driver_I2C.h" 57 #include "Driver_USART.h" 62 #include "issdk_hal.h" 63 #include "gpio_driver.h" 69 #include "auto_detection_service.h" 74 #define STREAMING_PKT_TIMESTAMP_LEN (4) 75 #define FXOS8700_ACCEL_DATA_SIZE (6) 76 #define FXOS8700_MAG_DATA_SIZE (6) 77 #define MPL3115_PADDING_SIZE (1) 78 #define MPL3115_PRESSURE_DATA_SIZE (3) 79 #define MPL3115_TEMPERATURE_DATA_SIZE (2) 81 #define FXOS8700_DATA_SIZE (FXOS8700_ACCEL_DATA_SIZE + FXOS8700_MAG_DATA_SIZE) 82 #define FXAS21002_DATA_SIZE (FXAS21002_GYRO_DATA_SIZE) 83 #define MPL3115_DATA_SIZE (MPL3115_PRESSURE_DATA_SIZE + MPL3115_TEMPERATURE_DATA_SIZE) 86 #define LED_TOGGLE_RATE (100) 87 #define STREAMING_PAYLOAD_LEN \ 88 (STREAMING_PKT_TIMESTAMP_LEN + FXOS8700_DATA_SIZE + FXAS21002_DATA_SIZE + MPL3115_DATA_SIZE + MPL3115_PADDING_SIZE) 89 #define STREAMING_PAYLOAD_SHORT_LEN (STREAMING_PKT_TIMESTAMP_LEN + FXOS8700_DATA_SIZE + FXAS21002_DATA_SIZE) 92 #define nmi_handler NMI_Handler 95 #define APPLICATION_NAME "Generic Data Logger Demo" 97 #define APPLICATION_VERSION "2.5" 171 uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse,
size_t *hostMsgSize,
size_t respBufferSize)
173 bool success =
false;
188 if (respBufferSize >= boardNameLen + shieldNameLen + appNameLen + 3)
197 hostResponse[*hostMsgSize] = appNameLen;
200 memcpy(hostResponse + *hostMsgSize,
embAppName, appNameLen);
201 *hostMsgSize += appNameLen;
203 hostResponse[*hostMsgSize] = boardNameLen;
206 memcpy(hostResponse + *hostMsgSize,
boardString, boardNameLen);
207 *hostMsgSize += boardNameLen;
209 hostResponse[*hostMsgSize] = shieldNameLen;
212 memcpy(hostResponse + *hostMsgSize,
shieldString, shieldNameLen);
213 *hostMsgSize += shieldNameLen;
223 switch (hostCommand[0])
257 uint8_t secondaryStreamID1, secondaryStreamID2,
258 dataReady_3115, toggle_pin = 0,
295 if (ARM_DRIVER_OK != status)
301 status = pI2cDriver->PowerControl(ARM_POWER_FULL);
302 if (ARM_DRIVER_OK != status)
308 status = pI2cDriver->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
309 if (ARM_DRIVER_OK != status)
316 if (ARM_DRIVER_OK != status)
322 status = pUartDriver->PowerControl(ARM_POWER_FULL);
323 if (ARM_DRIVER_OK != status)
330 if (ARM_DRIVER_OK != status)
394 if (0 == secondaryStreamID1)
402 if (0 == secondaryStreamID2)
435 if (ARM_DRIVER_OK != status)
441 rawData_fxos8700.
accel[0] = ((int16_t)
data[0] << 8) |
data[1];
442 rawData_fxos8700.
accel[0] /= 4;
443 rawData_fxos8700.
accel[1] = ((int16_t)
data[2] << 8) |
data[3];
444 rawData_fxos8700.
accel[1] /= 4;
445 rawData_fxos8700.
accel[2] = ((int16_t)
data[4] << 8) |
data[5];
446 rawData_fxos8700.
accel[2] /= 4;
447 rawData_fxos8700.
mag[0] = ((int16_t)
data[6] << 8) |
data[7];
448 rawData_fxos8700.
mag[1] = ((int16_t)
data[8] << 8) |
data[9];
449 rawData_fxos8700.
mag[2] = ((int16_t)
data[10] << 8) |
data[11];
453 sizeof(rawData_fxos8700.
accel));
455 &rawData_fxos8700.
mag,
sizeof(rawData_fxos8700.
mag));
459 if (ARM_DRIVER_OK != status)
465 rawData_fxas21002.
gyro[0] = ((int16_t)
data[12] << 8) |
data[13];
466 rawData_fxas21002.
gyro[1] = ((int16_t)
data[14] << 8) |
data[15];
467 rawData_fxas21002.
gyro[2] = ((int16_t)
data[16] << 8) |
data[17];
471 &rawData_fxas21002.
gyro,
sizeof(rawData_fxas21002.
gyro));
475 if (ARM_DRIVER_OK != status)
484 if (ARM_DRIVER_OK != status)
506 if (ARM_DRIVER_OK != status)
#define FXOS8700_M_CTRL_REG1_M_HMS_MASK
registerDeviceInfo_t deviceInfo
uint32_t BOARD_SystickElapsedTime_us(int32_t *pStart)
Function to compute the Elapsed Time.
#define STREAMING_PAYLOAD_SHORT_LEN
#define FXAS21002_CTRL_REG2_INT_EN_DRDY_MASK
#define FXAS21002_CTRL_REG2_INT_CFG_DRDY_INT1
#define FXOS8700_M_CTRL_REG1_M_ACAL_EN
const registerwritelist_t cMpl3115SetOST[]
Register settings for Triggring One-Shot Sampling.
#define FXAS21002_CTRL_REG2_IPOL_MASK
ARM_DRIVER_I2C * pCommDrv
#define __END_WRITE_DATA__
int main(void)
Main function.
The fxos8700_drv.h file describes the fxos8700 driver interface and structures.
#define HOST_PRO_CMD_W_CFG_TAG
This structure defines the fxos8700 raw data buffer.
volatile bool bDataLoggerReady
void FXOS8700_I2C_SetIdleTask(fxos8700_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
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 HOST_S_SIGNAL_EVENT
char shieldString[ADS_MAX_STRING_LENGTH]
void Host_IO_Receive(host_cmd_proc_fn_t process_host_command, uint8_t encoding)
void(* pin_init)(pinID_t aPinId, gpio_direction_t dir, void *apPinConfig, gpio_isr_handler_t aIsrHandler, void *apUserData)
#define BOARD_BootClockRUN
#define FXAS21002_CTRL_REG1_DR_MASK
volatile bool bStreamingEnabled
const registerwritelist_t fxas21002_Config_Isr[]
#define MPL3115_PADDING_SIZE
uint8_t data[FXLS8962_DATA_SIZE]
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.
#define MPL3115_CTRL_REG1_OST_SET
#define FXAS21002_CTRL_REG2_INT_EN_DRDY_ENABLE
void(* toggle_pin)(pinID_t aPinId)
ARM_DRIVER_I2C * pCommDrv
#define ADS_MAX_STRING_LENGTH
#define MPL3115_CTRL_REG1_OST_MASK
#define HOST_PRO_INT_DEV_TAG
uint8_t streamingPacket[STREAMING_HEADER_LEN+FXLS8962_STREAM_DATA_SIZE]
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
This defines the sensor specific information for I2C.
const registerreadlist_t fxas21002_Output_Values[]
The fxas21002_drv.h file describes the fxas21002 driver interface and structures. ...
#define HOST_PRO_INT_CMD_TAG
Bit aligned values for Host Protocol Interface IDs (Bits 5-6).
char boardString[ADS_MAX_STRING_LENGTH]
#define FXOS8700_M_CTRL_REG2_M_RST_CNT_DISABLE
bool process_host_command(uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse, size_t *hostMsgSize, size_t respBufferSize)
#define __END_READ_DATA__
void MPL3115_I2C_SetIdleTask(mpl3115_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
#define MPL3115_WHOAMI_VALUE
const registerwritelist_t fxos8700_Config_Hybrid[]
#define FXAS21002_CTRL_REG2_INT_CFG_DRDY_MASK
#define FXOS8700_WHO_AM_I_PROD_VALUE
#define MPL3115_DATA_SIZE
This defines the sensor specific information.
This structure defines the fxas21002 raw data buffer.
This defines the sensor specific information for I2C.
#define FXOS8700_M_CTRL_REG2_M_AUTOINC_MASK
#define FXOS8700_M_CTRL_REG1_M_ACAL_MASK
#define FXOS8700_ACCEL_DATA_SIZE
#define APPLICATION_NAME
Unique Name for this application which should match the target GUI pkg name.
const registerreadlist_t fxos8700_Output_values[]
void Host_IO_Add_ISO_Header(uint8_t streamID, uint8_t *pStreamingPacket, size_t sizePayload)
void Host_IO_Send(uint8_t *pMsg, size_t size, uint8_t encoding)
void(* set_pin)(pinID_t aPinId)
void(* clr_pin)(pinID_t aPinId)
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 MPL3115_PRESSURE_DATA_SIZE
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.
void BOARD_SystickEnable(void)
Function to enable systicks framework.
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.
registerDeviceInfo_t deviceInfo
#define FXOS8700_M_CTRL_REG2_M_AUTOINC_HYBRID_MODE
#define I2C_S_DEVICE_INDEX
#define APPLICATION_VERSION
Version to distinguish between instances the same application based on target Shield and updates...
#define FXAS21002_WHO_AM_I_WHOAMI_PROD_VALUE
#define FXAS21002_I2C_ADDR
int32_t FXAS21002_I2C_Configure(fxas21002_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
void fxas21002_isr(void *pUserData)
#define FXOS8700_M_CTRL_REG2_M_RST_CNT_MASK
GENERIC_DRIVER_GPIO Driver_GPIO_KSDK
const registerreadlist_t mpl3115_Output_Values[]
Address and size of Raw Pressure+Temperature Data in Normal Mode.
int32_t FXOS8700_I2C_Configure(fxos8700_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
void FXAS21002_I2C_SetIdleTask(fxas21002_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
#define BOARD_DEBUG_UART_BAUDRATE
The mpl3115_drv.h file describes the MPL3115 driver interface and structures.
#define FXOS8700_CTRL_REG1_DR_MASK
Access structure of the GPIO Driver.
void BOARD_SystickStart(int32_t *pStart)
Function to Record the Start systick.
const registerreadlist_t cMpl3115GetOST[]
Address of Register containing OST Bit.
void BOARD_RunADS(const char *appName, char *boardString, char *shieldString, size_t bufferLength)
The function to register Application Name and initialte ADS.
uint8_t Host_IO_Init(ARM_DRIVER_USART *pDrv, void *pBus, void *pDevInfo, void *spiSlaveParams, uint16_t slaveAddress)
This structure defines the Write command List.
This structure defines the Read command List.
volatile bool bFxas21002DataReady
#define FXOS8700_DATA_SIZE
The host_io_uart.h file contains the Host Protocol interface definitions and configuration.
#define FXAS21002_CTRL_REG1_DR_200HZ
#define STREAMING_HEADER_LEN
status_t SMC_SetPowerModeWait(void *arg)
Configures the system to WAIT power mode. API name used from Kinetis family to maintain compatibility...
#define FXAS21002_DATA_SIZE
#define STREAMING_PKT_TIMESTAMP_LEN
char embAppName[ADS_MAX_STRING_LENGTH]
#define FXAS21002_CTRL_REG2_IPOL_ACTIVE_HIGH
#define FXOS8700_I2C_ADDR
#define FXOS8700_CTRL_REG1_DR_HYBRID_200_HZ
#define FXOS8700_M_CTRL_REG1_M_HMS_HYBRID_MODE
#define STREAMING_PAYLOAD_LEN
This structure defines the mpl3115 data buffer in Pressure Mode.
#define MPL3115_CTRL_REG1_OST_RESET
GENERIC_DRIVER_GPIO * pGpioDriver
#define I2C_S_SIGNAL_EVENT
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.
ARM_DRIVER_I2C * pCommDrv
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.
registerDeviceInfo_t deviceInfo