20 #include "clock_config.h" 25 #include "Driver_I2C.h" 26 #include "Driver_USART.h" 31 #include "issdk_hal.h" 32 #include "gpio_driver.h" 39 #include "auto_detection_service.h" 44 #define MPL3115_PADDING_SIZE (1) 45 #define MPL3115_PRESSURE_DATA_SIZE (3) 46 #define MPL3115_TEMPERATURE_DATA_SIZE (2) 48 #define STREAMING_PKT_TIMESTAMP_LEN (4) 49 #define MMA865x_DATA_SIZE (6) 50 #define MAG3110_DATA_SIZE (6) 51 #define FXAS21002_DATA_SIZE (FXAS21002_GYRO_DATA_SIZE) 52 #define MPL3115_DATA_SIZE (MPL3115_PRESSURE_DATA_SIZE + MPL3115_TEMPERATURE_DATA_SIZE) 54 #define STREAMING_PAYLOAD_LEN \ 55 (STREAMING_PKT_TIMESTAMP_LEN + MMA865x_DATA_SIZE + MAG3110_DATA_SIZE + FXAS21002_DATA_SIZE + MPL3115_DATA_SIZE + \ 59 #define APPLICATION_NAME "11 Axis Sensor Demo" 61 #define APPLICATION_VERSION "2.5" 67 #define FF_MT_WT_DBCNT 0x32 68 #define FF_MT_THS_VALUE 0x03 70 #define SDCD_FF_EVT_ID (0x01) 71 #define P_THS_EVENT_ID (0x02) 72 #define EVENT_PAYLOAD_LEN (1) 188 uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse,
size_t *hostMsgSize,
size_t respBufferSize)
190 bool success =
false;
205 if (respBufferSize >= boardNameLen + shieldNameLen + appNameLen + 3)
214 hostResponse[*hostMsgSize] = appNameLen;
217 memcpy(hostResponse + *hostMsgSize,
embAppName, appNameLen);
218 *hostMsgSize += appNameLen;
220 hostResponse[*hostMsgSize] = boardNameLen;
223 memcpy(hostResponse + *hostMsgSize,
boardString, boardNameLen);
224 *hostMsgSize += boardNameLen;
226 hostResponse[*hostMsgSize] = shieldNameLen;
229 memcpy(hostResponse + *hostMsgSize,
shieldString, shieldNameLen);
230 *hostMsgSize += shieldNameLen;
240 switch (hostCommand[0])
274 secondaryStreamID2, secondaryStreamID3,
320 if (ARM_DRIVER_OK != status)
326 status = pI2cDriver->PowerControl(ARM_POWER_FULL);
327 if (ARM_DRIVER_OK != status)
333 status = pI2cDriver->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
334 if (ARM_DRIVER_OK != status)
341 if (ARM_DRIVER_OK != status)
347 status = pUartDriver->PowerControl(ARM_POWER_FULL);
348 if (ARM_DRIVER_OK != status)
355 if (ARM_DRIVER_OK != status)
430 if (0 == secondaryStreamID1)
438 if (0 == secondaryStreamID2)
445 if (0 == secondaryStreamID3)
508 if (ARM_DRIVER_OK != status)
514 rawData_mma865x.
accel[0] = ((int16_t)data[0] << 8) | data[1];
515 rawData_mma865x.
accel[0] /= 16;
516 rawData_mma865x.
accel[1] = ((int16_t)data[2] << 8) | data[3];
517 rawData_mma865x.
accel[1] /= 16;
518 rawData_mma865x.
accel[2] = ((int16_t)data[4] << 8) | data[5];
519 rawData_mma865x.
accel[2] /= 16;
523 sizeof(rawData_mma865x.
accel));
527 if (ARM_DRIVER_OK != status)
533 rawData_mag3110.
mag[0] = ((int16_t)data[6] << 8) | data[7];
534 rawData_mag3110.
mag[1] = ((int16_t)data[8] << 8) | data[9];
535 rawData_mag3110.
mag[2] = ((int16_t)data[10] << 8) | data[11];
541 &rawData_mag3110.
mag,
sizeof(rawData_mag3110.
mag));
546 if (ARM_DRIVER_OK != status)
552 rawData_fxas21002.
gyro[0] = ((int16_t)data[12] << 8) | data[13];
553 rawData_fxas21002.
gyro[1] = ((int16_t)data[14] << 8) | data[15];
554 rawData_fxas21002.
gyro[2] = ((int16_t)data[16] << 8) | data[17];
559 &rawData_fxas21002.
gyro,
sizeof(rawData_fxas21002.
gyro));
564 if (ARM_DRIVER_OK != status)
570 rawData_mpl3115.
pressure = (uint32_t)((data[18]) << 16) | ((data[19]) << 8) | ((data[20]));
572 rawData_mpl3115.
temperature = (int16_t)((data[21]) << 8) | (data[22]);
bool process_host_command(uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse, size_t *hostMsgSize, size_t respBufferSize)
#define MMA865x_CTRL_REG1_DR_MASK
#define FXAS21002_WHO_AM_I_WHOAMI_PROD_VALUE
ARM_DRIVER_I2C * pCommDrv
#define MAG3110_DATA_SIZE
#define MMA865x_FF_MT_CFG_YEFE_MASK
#define FXAS21002_CTRL_REG2_INT_EN_DRDY_ENABLE
#define MMA865x_FF_MT_SRC_EA_MASK
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)
This structure defines the Write command List.
This defines the sensor specific information.
#define MMA865x_CTRL_REG5_INT_CFG_FF_MT_INT1
int32_t MAG3110_I2C_Initialize(mag3110_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 MAG3110_CTRL_REG1_OS_OSR_16
#define APPLICATION_NAME
Unique Name for this application which should match the target GUI pkg name.
#define MMA865x_XYZ_DATA_CFG_FS_MASK
#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.
#define FXAS21002_CTRL_REG1_DR_25HZ
status_t SMC_SetPowerModeVlpr(void *arg)
Configures the system to VLPR power mode. API name used from Kinetis family to maintain compatibility...
#define MAG3110_CTRL_REG2_MAG_RST_EN
#define MMA865x_CTRL_REG1_DR_50HZ
The host_io_uart.h file contains the Host Protocol interface definitions and configuration.
#define MMA865x_FF_MT_CFG_XEFE_EN
const registerreadlist_t cMma865xOutputValues[]
void FXAS21002_I2C_SetIdleTask(fxas21002_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
This structure defines the mag3110 data buffer.
#define HOST_B_SIGNAL_EVENT
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.
volatile bool bStreamingEnabled
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.
volatile bool bMpl3115EventReady
#define STREAMING_PKT_TIMESTAMP_LEN
#define MAG3110_CTRL_REG2_MAG_RST_MASK
const registerreadlist_t cMag3110OutputNormal[]
Address and size of Raw Magnetic Data in Normal Mode.
#define MMA865x_FF_MT_THS_THS_MASK
registerDeviceInfo_t deviceInfo
#define __END_WRITE_DATA__
#define MMA865x_CTRL_REG3_IPOL_MASK
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.
const registerreadlist_t cMma865xFreeFallEvent[]
Address of Freefall Status Register.
#define MPL3115_DATA_SIZE
#define FXAS21002_CTRL_REG2_INT_EN_DRDY_MASK
#define MMA865x_FF_MT_THS_DBCNTM_INC_CLR
int32_t MMA865x_I2C_ReadData(mma865x_i2c_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer)
The interface function to read the sensor data.
#define MMA865x_FF_MT_SRC_EA_DETECTED
#define MMA865x_CTRL_REG3_IPOL_ACTIVE_HIGH
#define I2C_S_SIGNAL_EVENT
#define MMA865x_FF_MT_CFG_ZEFE_EN
int32_t FXAS21002_I2C_Configure(fxas21002_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
#define MAG3110_CTRL_REG1_DR_ODR_1
This defines the sensor specific information for I2C.
int32_t MAG3110_I2C_Configure(mag3110_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
void Host_IO_Add_ISO_Header(uint8_t streamID, uint8_t *pStreamingPacket, size_t sizePayload)
#define MMA865x_CTRL_REG4_INT_EN_FF_MT_EN
#define FXAS21002_CTRL_REG2_IPOL_MASK
#define BOARD_DEBUG_UART_BAUDRATE
#define MMA865x_CTRL_REG4_INT_EN_FF_MT_MASK
#define MMA865x_CTRL_REG2_MODS_MASK
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
ARM_DRIVER_I2C * pCommDrv
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
char shieldString[ADS_MAX_STRING_LENGTH]
registerDeviceInfo_t deviceInfo
#define FXAS21002_DATA_SIZE
#define MPL3115_CTRL_REG3_IPOL1_HIGH
uint8_t streamingPacket[STREAMING_HEADER_LEN+FXLS8962_STREAM_DATA_SIZE]
GENERIC_DRIVER_GPIO Driver_GPIO_KSDK
#define FXAS21002_I2C_ADDR
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 MPL3115_CTRL_REG5_INT_CFG_PTH_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.
#define MPL3115_CTRL_REG3_IPOL1_MASK
void mpl3115_int_event_ready_callback(void *pUserData)
uint8_t data[FXLS8962_DATA_SIZE]
int32_t MMA865x_I2C_Configure(mma865x_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
#define MMA865x_DATA_SIZE
#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_CTRL_REG4_INT_EN_PTH_INTENABLED
#define MPL3115_CTRL_REG1_OST_MASK
The mma865x_drv.h file describes the MMA865x driver interface and structures.
#define MPL3115_CTRL_REG4_INT_EN_PTH_MASK
int32_t MAG3110_I2C_ReadData(mag3110_i2c_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer)
The interface function to read the sensor data.
const registerreadlist_t mpl3115_Output_Values[]
Address and size of Raw Pressure+Temperature Data in Normal Mode.
The fxas21002_drv.h file describes the fxas21002 driver interface and structures. ...
#define MPL3115_PRESSURE_DATA_SIZE
char boardString[ADS_MAX_STRING_LENGTH]
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 MMA865x_CTRL_REG5_INT_CFG_FF_MT_MASK
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 MMA865x_FF_MT_CFG_XEFE_MASK
#define STREAMING_PAYLOAD_LEN
#define MAG3110_CTRL_REG1_DR_MASK
volatile bool bMma865xEventReady
#define MPL3115_PADDING_SIZE
char embAppName[ADS_MAX_STRING_LENGTH]
registerDeviceInfo_t deviceInfo
void(* toggle_pin)(pinID_t aPinId)
#define ADS_MAX_STRING_LENGTH
#define MAG3110_CTRL_REG1_OS_MASK
#define MMA865x_CTRL_REG2_MODS_HR
ARM_DRIVER_I2C * pCommDrv
#define MAG3110_CTRL_REG2_AUTO_MSRT_EN_MASK
#define FXAS21002_CTRL_REG1_DR_MASK
void BOARD_SystickEnable(void)
Function to enable systicks framework.
#define MAG3110_CTRL_REG2_RAW_RAW
#define MPL3115_WHOAMI_VALUE
#define STREAMING_HEADER_LEN
#define MAG3110_CTRL_REG2_AUTO_MSRT_EN_EN
status_t SMC_SetPowerModeWait(void *arg)
Configures the system to WAIT power mode. API name used from Kinetis family to maintain compatibility...
#define MMA865x_XYZ_DATA_CFG_FS_2G
#define MMA865x_FF_MT_CFG_ZEFE_MASK
void(* pin_init)(pinID_t aPinId, gpio_direction_t dir, void *apPinConfig, gpio_isr_handler_t aIsrHandler, void *apUserData)
This defines the sensor specific information.
ARM_DRIVER_I2C * pCommDrv
This structure defines the Read command List.
This structure defines the mma865x raw data buffer.
#define FXAS21002_CTRL_REG2_INT_CFG_DRDY_MASK
#define MAG3110_WHOAMI_VALUE
void MAG3110_CalibrateHardIronOffset(int16_t *xValue, int16_t *yValue, int16_t *zValue)
Calibrates the magnetometer reading by determining the current hard iron offset.
gpioHandleKSDK_t GREEN_LED
#define MPL3115_CTRL_REG1_OST_SET
int main(void)
Main function.
const registerwritelist_t fxas21002_Config_Normal[]
void mma865x_int_event_ready_callback(void *pUserData)
This is the Sensor WT Event Ready ISR implementation.
#define I2C_S_DEVICE_INDEX
void MMA865x_I2C_SetIdleTask(mma865x_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
volatile bool bFxas21002DataReady
#define MMA865x_FF_MT_CFG_ELE_MASK
#define MPL3115_CTRL_REG5_INT_CFG_PTH_INT1
const registerreadlist_t fxas21002_Output_Values[]
#define APPLICATION_VERSION
Version to distinguish between instances the same application based on target Shield and updates...
volatile bool bMult2bReady
void fxas21002_int_data_ready_callback(void *pUserData)
#define HOST_PRO_INT_CMD_TAG
Bit aligned values for Host Protocol Interface IDs (Bits 5-6).
#define MMA8652_WHOAMI_VALUE
#define MMA865x_FF_MT_CFG_OAE_MASK
#define MMA865x_FF_MT_THS_DBCNTM_MASK
const registerwritelist_t cMma865xConfigFreeFall[]
Register settings for freefall detection and poll mode.
int32_t MMA865x_I2C_Initialize(mma865x_i2c_sensorhandle_t *pSensorHandle, ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress, uint8_t whoAmi)
The interface function to initialize the sensor.
void MAG3110_I2C_SetIdleTask(mag3110_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
#define MMA865x_FF_MT_CFG_OAE_FREEFALL
#define MAG3110_CTRL_REG2_RAW_MASK
registerDeviceInfo_t deviceInfo
GENERIC_DRIVER_GPIO * pGpioDriver
const registerwritelist_t cMpl3115SetOST[]
Register settings for Triggring One-Shot Sampling.
The mag3110_drv.h file describes the MAG3110 driver interface and structures.
const registerwritelist_t cMag3110ConfigNormal[]
Register settings for Normal (non buffered) mode.
#define MMA865x_FF_MT_CFG_ELE_EN
#define EVENT_PAYLOAD_LEN
#define MMA865x_FF_MT_CFG_YEFE_EN