46 #include "clock_config.h" 51 #include "Driver_I2C.h" 52 #include "Driver_USART.h" 57 #include "issdk_hal.h" 58 #include "gpio_driver.h" 65 #include "auto_detection_service.h" 70 #define MPL3115_PADDING_SIZE (1) 71 #define MPL3115_PRESSURE_DATA_SIZE (3) 72 #define MPL3115_TEMPERATURE_DATA_SIZE (2) 74 #define STREAMING_PKT_TIMESTAMP_LEN (4) 75 #define MMA865x_DATA_SIZE (6) 76 #define MAG3110_DATA_SIZE (6) 77 #define FXAS21002_DATA_SIZE (FXAS21002_GYRO_DATA_SIZE) 78 #define MPL3115_DATA_SIZE (MPL3115_PRESSURE_DATA_SIZE + MPL3115_TEMPERATURE_DATA_SIZE) 80 #define STREAMING_PAYLOAD_LEN \ 81 (STREAMING_PKT_TIMESTAMP_LEN + MMA865x_DATA_SIZE + MAG3110_DATA_SIZE + FXAS21002_DATA_SIZE + MPL3115_DATA_SIZE + \ 85 #define APPLICATION_NAME "11 Axis Sensor Demo" 87 #define APPLICATION_VERSION "2.5" 93 #define FF_MT_WT_DBCNT 0x32 94 #define FF_MT_THS_VALUE 0x03 96 #define SDCD_FF_EVT_ID (0x01) 97 #define P_THS_EVENT_ID (0x02) 98 #define EVENT_PAYLOAD_LEN (1) 214 uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse,
size_t *hostMsgSize,
size_t respBufferSize)
216 bool success =
false;
231 if (respBufferSize >= boardNameLen + shieldNameLen + appNameLen + 3)
240 hostResponse[*hostMsgSize] = appNameLen;
243 memcpy(hostResponse + *hostMsgSize,
embAppName, appNameLen);
244 *hostMsgSize += appNameLen;
246 hostResponse[*hostMsgSize] = boardNameLen;
249 memcpy(hostResponse + *hostMsgSize,
boardString, boardNameLen);
250 *hostMsgSize += boardNameLen;
252 hostResponse[*hostMsgSize] = shieldNameLen;
255 memcpy(hostResponse + *hostMsgSize,
shieldString, shieldNameLen);
256 *hostMsgSize += shieldNameLen;
266 switch (hostCommand[0])
300 secondaryStreamID2, secondaryStreamID3,
346 if (ARM_DRIVER_OK != status)
352 status = pI2cDriver->PowerControl(ARM_POWER_FULL);
353 if (ARM_DRIVER_OK != status)
359 status = pI2cDriver->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
360 if (ARM_DRIVER_OK != status)
367 if (ARM_DRIVER_OK != status)
373 status = pUartDriver->PowerControl(ARM_POWER_FULL);
374 if (ARM_DRIVER_OK != status)
381 if (ARM_DRIVER_OK != status)
456 if (0 == secondaryStreamID1)
464 if (0 == secondaryStreamID2)
471 if (0 == secondaryStreamID3)
534 if (ARM_DRIVER_OK != status)
540 rawData_mma865x.
accel[0] = ((int16_t)data[0] << 8) | data[1];
541 rawData_mma865x.
accel[0] /= 16;
542 rawData_mma865x.
accel[1] = ((int16_t)data[2] << 8) | data[3];
543 rawData_mma865x.
accel[1] /= 16;
544 rawData_mma865x.
accel[2] = ((int16_t)data[4] << 8) | data[5];
545 rawData_mma865x.
accel[2] /= 16;
549 sizeof(rawData_mma865x.
accel));
553 if (ARM_DRIVER_OK != status)
559 rawData_mag3110.
mag[0] = ((int16_t)data[6] << 8) | data[7];
560 rawData_mag3110.
mag[1] = ((int16_t)data[8] << 8) | data[9];
561 rawData_mag3110.
mag[2] = ((int16_t)data[10] << 8) | data[11];
567 &rawData_mag3110.
mag,
sizeof(rawData_mag3110.
mag));
572 if (ARM_DRIVER_OK != status)
578 rawData_fxas21002.
gyro[0] = ((int16_t)data[12] << 8) | data[13];
579 rawData_fxas21002.
gyro[1] = ((int16_t)data[14] << 8) | data[15];
580 rawData_fxas21002.
gyro[2] = ((int16_t)data[16] << 8) | data[17];
585 &rawData_fxas21002.
gyro,
sizeof(rawData_fxas21002.
gyro));
590 if (ARM_DRIVER_OK != status)
596 rawData_mpl3115.
pressure = (uint32_t)((data[18]) << 16) | ((data[19]) << 8) | ((data[20]));
598 rawData_mpl3115.
temperature = (int16_t)((data[21]) << 8) | (data[22]);
registerDeviceInfo_t deviceInfo
#define MAG3110_CTRL_REG1_OS_OSR_16
uint32_t BOARD_SystickElapsedTime_us(int32_t *pStart)
Function to compute the Elapsed Time.
#define MMA865x_CTRL_REG3_IPOL_MASK
#define FXAS21002_CTRL_REG2_INT_EN_DRDY_MASK
#define FXAS21002_CTRL_REG2_INT_CFG_DRDY_INT1
#define MMA865x_XYZ_DATA_CFG_FS_MASK
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 FXAS21002_CTRL_REG2_IPOL_MASK
ARM_DRIVER_I2C * pCommDrv
#define __END_WRITE_DATA__
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.
#define HOST_PRO_CMD_W_CFG_TAG
char embAppName[ADS_MAX_STRING_LENGTH]
volatile bool bMult2bReady
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.
This structure defines the mma865x raw data buffer.
#define MAG3110_CTRL_REG2_MAG_RST_EN
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 MMA865x_DATA_SIZE
#define BOARD_BootClockRUN
#define FXAS21002_CTRL_REG1_DR_MASK
int32_t MAG3110_I2C_Configure(mag3110_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
#define MMA865x_CTRL_REG5_INT_CFG_FF_MT_MASK
volatile bool bMpl3115EventReady
#define MMA865x_FF_MT_SRC_EA_DETECTED
#define MMA865x_CTRL_REG3_IPOL_ACTIVE_HIGH
const registerreadlist_t cMma865xOutputValues[]
#define MPL3115_CTRL_REG3_IPOL1_MASK
The mag3110_drv.h file describes the MAG3110 driver interface and structures.
const registerreadlist_t cMag3110OutputNormal[]
Address and size of Raw Magnetic Data in Normal Mode.
volatile bool bStreamingEnabled
#define FXAS21002_DATA_SIZE
#define MMA865x_FF_MT_THS_THS_MASK
This defines the sensor specific information.
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.
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 MAG3110_CTRL_REG1_DR_ODR_1
#define MPL3115_CTRL_REG5_INT_CFG_PTH_MASK
#define MPL3115_CTRL_REG1_OST_SET
#define FXAS21002_CTRL_REG2_INT_EN_DRDY_ENABLE
void(* toggle_pin)(pinID_t aPinId)
const registerreadlist_t mpl3115_Output_Values[]
Address and size of Raw Pressure+Temperature Data in Normal Mode.
#define APPLICATION_NAME
Unique Name for this application which should match the target GUI pkg name.
#define MMA865x_FF_MT_CFG_ELE_EN
ARM_DRIVER_I2C * pCommDrv
#define HOST_B_SIGNAL_EVENT
#define ADS_MAX_STRING_LENGTH
#define MPL3115_CTRL_REG4_INT_EN_PTH_INTENABLED
#define MPL3115_CTRL_REG1_OST_MASK
This defines the sensor specific information.
registerDeviceInfo_t deviceInfo
#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.
GENERIC_DRIVER_GPIO * pGpioDriver
#define MAG3110_CTRL_REG1_OS_MASK
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).
#define MMA865x_CTRL_REG1_DR_MASK
#define MPL3115_CTRL_REG4_INT_EN_PTH_MASK
#define MAG3110_CTRL_REG2_RAW_RAW
#define __END_READ_DATA__
#define MMA865x_CTRL_REG1_DR_50HZ
void MPL3115_I2C_SetIdleTask(mpl3115_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
void mma865x_int_event_ready_callback(void *pUserData)
This is the Sensor WT Event Ready ISR implementation.
#define MMA865x_FF_MT_CFG_YEFE_MASK
#define MPL3115_CTRL_REG5_INT_CFG_PTH_INT1
#define MPL3115_WHOAMI_VALUE
#define FXAS21002_CTRL_REG2_INT_CFG_DRDY_MASK
void MAG3110_I2C_SetIdleTask(mag3110_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
const registerwritelist_t cMma865xConfigFreeFall[]
Register settings for freefall detection and poll mode.
void MMA865x_I2C_SetIdleTask(mma865x_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
#define MMA8652_WHOAMI_VALUE
#define MPL3115_DATA_SIZE
This structure defines the mag3110 data buffer.
#define MMA865x_CTRL_REG4_INT_EN_FF_MT_EN
gpioHandleKSDK_t GREEN_LED
This defines the sensor specific information.
This structure defines the fxas21002 raw data buffer.
This defines the sensor specific information for I2C.
void MAG3110_CalibrateHardIronOffset(int16_t *xValue, int16_t *yValue, int16_t *zValue)
Calibrates the magnetometer reading by determining the current hard iron offset.
const registerreadlist_t fxas21002_Output_Values[]
const registerwritelist_t cMag3110ConfigNormal[]
Register settings for Normal (non buffered) mode.
#define MMA865x_FF_MT_CFG_OAE_FREEFALL
#define MAG3110_CTRL_REG1_DR_MASK
#define MAG3110_CTRL_REG2_MAG_RST_MASK
#define MAG3110_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_FF_MT_CFG_XEFE_EN
#define MAG3110_CTRL_REG2_RAW_MASK
#define MMA865x_XYZ_DATA_CFG_FS_2G
void Host_IO_Add_ISO_Header(uint8_t streamID, uint8_t *pStreamingPacket, size_t sizePayload)
#define MMA865x_CTRL_REG4_INT_EN_FF_MT_MASK
#define APPLICATION_VERSION
Version to distinguish between instances the same application based on target Shield and updates...
void Host_IO_Send(uint8_t *pMsg, size_t size, uint8_t encoding)
void(* clr_pin)(pinID_t aPinId)
#define MMA865x_CTRL_REG2_MODS_MASK
#define MMA865x_FF_MT_CFG_ZEFE_EN
#define MPL3115_PRESSURE_DATA_SIZE
char boardString[ADS_MAX_STRING_LENGTH]
#define STREAMING_PKT_TIMESTAMP_LEN
#define EVENT_PAYLOAD_LEN
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.
#define MMA865x_FF_MT_CFG_ZEFE_MASK
#define MMA865x_CTRL_REG5_INT_CFG_FF_MT_INT1
#define MAG3110_CTRL_REG2_AUTO_MSRT_EN_EN
char shieldString[ADS_MAX_STRING_LENGTH]
int main(void)
Main function.
#define I2C_S_DEVICE_INDEX
#define MMA865x_FF_MT_CFG_XEFE_MASK
#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.
The mma865x_drv.h file describes the MMA865x driver interface and structures.
void fxas21002_int_data_ready_callback(void *pUserData)
GENERIC_DRIVER_GPIO Driver_GPIO_KSDK
#define MMA865x_FF_MT_THS_DBCNTM_INC_CLR
volatile bool bFxas21002DataReady
#define STREAMING_PAYLOAD_LEN
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
#define MMA865x_FF_MT_CFG_ELE_MASK
The mpl3115_drv.h file describes the MPL3115 driver interface and structures.
const registerwritelist_t cMpl3115SetOST[]
Register settings for Triggring One-Shot Sampling.
registerDeviceInfo_t deviceInfo
Access structure of the GPIO Driver.
void BOARD_SystickStart(int32_t *pStart)
Function to Record the Start systick.
volatile bool bMma865xEventReady
void BOARD_RunADS(const char *appName, char *boardString, char *shieldString, size_t bufferLength)
The function to register Application Name and initialte ADS.
#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)
#define MMA865x_CTRL_REG2_MODS_HR
This structure defines the Write command List.
const registerreadlist_t cMma865xFreeFallEvent[]
Address of Freefall Status Register.
This structure defines the Read command List.
#define MAG3110_WHOAMI_VALUE
#define MMA865x_FF_MT_CFG_YEFE_EN
The host_io_uart.h file contains the Host Protocol interface definitions and configuration.
#define STREAMING_HEADER_LEN
#define MPL3115_PADDING_SIZE
status_t SMC_SetPowerModeWait(void *arg)
Configures the system to WAIT power mode. API name used from Kinetis family to maintain compatibility...
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 registerwritelist_t fxas21002_Config_Normal[]
#define FXAS21002_CTRL_REG2_IPOL_ACTIVE_HIGH
#define MAG3110_CTRL_REG2_AUTO_MSRT_EN_MASK
void mpl3115_int_event_ready_callback(void *pUserData)
This structure defines the mpl3115 data buffer in Pressure Mode.
#define FXAS21002_CTRL_REG1_DR_25HZ
bool process_host_command(uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse, size_t *hostMsgSize, size_t respBufferSize)
#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.
#define MMA865x_FF_MT_THS_DBCNTM_MASK
ARM_DRIVER_I2C * pCommDrv
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.
#define MPL3115_CTRL_REG3_IPOL1_HIGH
#define MMA865x_FF_MT_CFG_OAE_MASK
registerDeviceInfo_t deviceInfo