ISSDK  1.8
IoT Sensing Software Development Kit
demo_11_axis_mult2b.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, Freescale Semiconductor, Inc.
3  * Copyright 2016-2017 NXP
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 /**
10  * @file demo_11_axis_mult2b.c
11  * @brief The demo_11_axis_mult2b.c file implements the ISSDK MMA8652, MAG3110, FXAS21002 and MPL3115 sensors
12  * 11-Axis demo example demonstration using Bluetooth.
13  */
14 
15 //-----------------------------------------------------------------------
16 // SDK Includes
17 //-----------------------------------------------------------------------
18 #include "board.h"
19 #include "pin_mux.h"
20 #include "clock_config.h"
21 
22 //-----------------------------------------------------------------------
23 // CMSIS Includes
24 //-----------------------------------------------------------------------
25 #include "Driver_I2C.h"
26 #include "Driver_USART.h"
27 
28 //-----------------------------------------------------------------------
29 // ISSDK Includes
30 //-----------------------------------------------------------------------
31 #include "issdk_hal.h"
32 #include "gpio_driver.h"
33 #include "mag3110_drv.h"
34 #include "mpl3115_drv.h"
35 #include "mma865x_drv.h"
36 #include "fxas21002_drv.h"
37 #include "host_io_uart.h"
38 #include "systick_utils.h"
39 #include "auto_detection_service.h"
40 
41 //-----------------------------------------------------------------------
42 // Macros
43 //-----------------------------------------------------------------------
44 #define MPL3115_PADDING_SIZE (1)
45 #define MPL3115_PRESSURE_DATA_SIZE (3)
46 #define MPL3115_TEMPERATURE_DATA_SIZE (2)
47 
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)
53 
54 #define STREAMING_PAYLOAD_LEN \
55  (STREAMING_PKT_TIMESTAMP_LEN + MMA865x_DATA_SIZE + MAG3110_DATA_SIZE + FXAS21002_DATA_SIZE + MPL3115_DATA_SIZE + \
56  MPL3115_PADDING_SIZE)
57 
58 /*! @brief Unique Name for this application which should match the target GUI pkg name. */
59 #define APPLICATION_NAME "11 Axis Sensor Demo"
60 /*! @brief Version to distinguish between instances the same application based on target Shield and updates. */
61 #define APPLICATION_VERSION "2.5"
62 
63 /* FF_MT freefall counter register values for High resolution Mode and ODR = 100Hz.
64  * These values have been derived based on the MMA865x DataSheet and Application Note AN4070 for MMA8451 (the same is
65  * applicable to MMA865x too).
66  * http://cache.freescale.com/files/sensors/doc/app_note/AN4070.pdf */
67 #define FF_MT_WT_DBCNT 0x32 /* Debounce count value. */
68 #define FF_MT_THS_VALUE 0x03 /* Threshold Value. */
69 
70 #define SDCD_FF_EVT_ID (0x01)
71 #define P_THS_EVENT_ID (0x02)
72 #define EVENT_PAYLOAD_LEN (1)
73 
74 //-----------------------------------------------------------------------
75 // Constants
76 //-----------------------------------------------------------------------
77 /*! @brief Register settings for freefall detection and poll mode. */
79  {/*! Configure the MMA865x to set FS Range as 2g. */
81  /*! Configure the MMA865x to set ODR to 50Hz. */
83  /*! Configure the MMA865x to set High Resolution mode. */
85  /*! Configure the MMA865x to set interrupt polarity as Active High. */
87  /*! Configure the MMA865x to enable Interrupts for Data Ready. */
89  /*! Configure the MMA865x to route Data Ready Interrupts to INT1. */
91  /*! Configure the MMA865x to set freefall Mode and enable all XYZ axis events and event latching. */
96  /*! Configure the MMA865x to set Debounce counter to be cleared on favourable events and the thresholds . */
99  /*! Configure the MMA865x to set Debounce counter value. */
102 
103 /*! Prepare the register read list to read the raw Accel data from MMA865x. */
106 
107 /*! @brief Address of Freefall Status Register. */
109 
110 /*! @brief Register settings for Normal (non buffered) mode. */
112  /* Set Ouput Rate @40HZ (ODR = 1 and OSR = 16). */
115  /* Set Auto Magnetic Sensor Reset. */
119 
120 /*! @brief Address and size of Raw Magnetic Data in Normal Mode. */
123 
124 /*! Prepare the register write list to configure FXAS21002 in non-FIFO mode. */
126  /*! Configure CTRL_REG1 register to put FXAS21002 to 25Hz sampling rate. */
128  /*! Configure CTRL_REG2 register to set interrupt configuration settings. */
133 
134 /*! Prepare the register read list to read the raw gyro data from the FXAS21002. */
137 
138 /*! @brief Register settings for Triggring One-Shot Sampling. */
140  /* Route Interrupt to INT1. */
142  /* Enable Interrupts for Pressure Threshold Events. */
144  /* Set INT Active High. */
146  /* Set the One ShoT Bit. */
149 
150 /*! @brief Address and size of Raw Pressure+Temperature Data in Normal Mode. */
153 
154 //-----------------------------------------------------------------------
155 // Global Variables
156 //-----------------------------------------------------------------------
159 volatile bool bStreamingEnabled = false, bFxas21002DataReady = false, bMult2bReady = false, bMma865xEventReady = false,
161 uint8_t gStreamID; /* The auto assigned Stream ID. */
164 
165 //-----------------------------------------------------------------------
166 // Functions
167 //-----------------------------------------------------------------------
168 /* This is the Sensor Data Ready ISR implementation.*/
170 { /*! @brief Set flag to indicate Sensor has signalled data ready. */
171  bFxas21002DataReady = true;
172 }
173 
174 /*! @brief This is the Sensor WT Event Ready ISR implementation. */
175 void mma865x_int_event_ready_callback(void *pUserData)
176 { /*! @brief Set flag to indicate Sensor has signalled event ready. */
177  bMma865xEventReady = true;
178 }
179 
180 /* This is the Sensor PTH Event Ready ISR implementation.*/
181 void mpl3115_int_event_ready_callback(void *pUserData)
182 { /*! @brief Set flag to indicate Sensor has signalled data ready. */
183  bMpl3115EventReady = true;
184 }
185 
186 /* Handler for Device Info and Streaming Control Commands. */
188  uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse, size_t *hostMsgSize, size_t respBufferSize)
189 {
190  bool success = false;
191 
192  /* If it is Host requesting Device Info, send Board Name and Shield Name. */
193  if (tag == HOST_PRO_INT_DEV_TAG)
194  { /* Byte 1 : Payload - Length of APPLICATION_NAME (b)
195  * Bytes=b : Payload Application Name
196  * Byte b+1 : Payload - Length of BOARD_NAME (s)
197  * Bytes=s : Payload Board Name
198  * Byte b+s+2 : Payload - Length of SHIELD_NAME (v)
199  * Bytes=v : Payload Shield Name */
200 
201  size_t appNameLen = strlen(embAppName);
202  size_t boardNameLen = strlen(boardString);
203  size_t shieldNameLen = strlen(shieldString);
204 
205  if (respBufferSize >= boardNameLen + shieldNameLen + appNameLen + 3)
206  { /* We have sufficient buffer. */
207  *hostMsgSize = 0;
208  }
209  else
210  {
211  return false;
212  }
213 
214  hostResponse[*hostMsgSize] = appNameLen;
215  *hostMsgSize += 1;
216 
217  memcpy(hostResponse + *hostMsgSize, embAppName, appNameLen);
218  *hostMsgSize += appNameLen;
219 
220  hostResponse[*hostMsgSize] = boardNameLen;
221  *hostMsgSize += 1;
222 
223  memcpy(hostResponse + *hostMsgSize, boardString, boardNameLen);
224  *hostMsgSize += boardNameLen;
225 
226  hostResponse[*hostMsgSize] = shieldNameLen;
227  *hostMsgSize += 1;
228 
229  memcpy(hostResponse + *hostMsgSize, shieldString, shieldNameLen);
230  *hostMsgSize += shieldNameLen;
231 
232  return true;
233  }
234 
235  /* If it is Host sending Streaming Commands, take necessary actions. */
236  if ((tag == (HOST_PRO_INT_CMD_TAG | HOST_PRO_CMD_W_CFG_TAG)) &&
238  { /* Byte 1 : Payload - Operation Code (Start/Stop Operation Code)
239  * Byte 2 : Payload - Stream ID (Target Stream for carrying out operation) */
240  switch (hostCommand[0]) /* Execute desired operation (Start/Stop) on the requested Stream. */
241  {
242  case HOST_CMD_START:
243  if (hostCommand[1] == gStreamID && bMult2bReady && bStreamingEnabled == false)
244  {
246  bStreamingEnabled = true;
247  success = true;
248  }
249  break;
250  case HOST_CMD_STOP:
251  if (hostCommand[1] == gStreamID && bMult2bReady && bStreamingEnabled == true)
252  {
253  pGpioDriver->clr_pin(&GREEN_LED);
254  bStreamingEnabled = false;
255  success = true;
256  }
257  break;
258  default:
259  break;
260  }
261  *hostMsgSize = 0; /* Zero payload in response. */
262  }
263 
264  return success;
265 }
266 
267 /*!
268  * @brief Main function
269  */
270 int main(void)
271 {
272  int32_t status;
273  uint8_t eventReady = 0, eventPacket[STREAMING_HEADER_LEN + EVENT_PAYLOAD_LEN], secondaryStreamID1,
274  secondaryStreamID2, secondaryStreamID3, /* Auto assigned StreamIDs not to be used for streaming. */
277 
278  mma865x_i2c_sensorhandle_t mma865xDriver;
279  mag3110_i2c_sensorhandle_t mag3110Driver;
280  fxas21002_i2c_sensorhandle_t fxas21002Driver;
281  mpl3115_i2c_sensorhandle_t mpl3115Driver;
282 
283  mma865x_acceldata_t rawData_mma865x;
284  mag3110_magdata_t rawData_mag3110;
285  fxas21002_gyrodata_t rawData_fxas21002;
286  mpl3115_pressuredata_t rawData_mpl3115;
287 
288  ARM_DRIVER_I2C *pI2cDriver = &I2C_S_DRIVER;
289  ARM_DRIVER_USART *pUartDriver = &HOST_B_DRIVER;
290 
291  /*! Initialize the MCU hardware. */
294 
295  /* Create the Short Application Name String for ADS. */
296  sprintf(embAppName, "%s:%s", APPLICATION_NAME, APPLICATION_VERSION);
297 
298  /* Run ADS. */
300 
301  /* Create the Full Application Name String for Device Info Response. */
303 
304  /*! Initialize FXAS21002 INT1 pin used by FRDM board */
306 
307  /*! Initialize MMA865x INT1 pin used by FRDM board */
309 
310  /*! Initialize INT1 MAG3110 used on FRDM board.
311  * NOTE: INT1 of MPL3115 pin on MULT2B maps to PTA0 of K64F which is used as OpenSDA CLK.
312  * Hence, we will wire connect INT1_MPL3115 to INT_MAG (J5_Pin3 to J3_Pin2) and use INT1_MAG3110 handle instead. */
314 
315  /*! Initialize RGB LED pin used by FRDM board */
316  pGpioDriver->pin_init(&GREEN_LED, GPIO_DIRECTION_OUT, NULL, NULL, NULL);
317 
318  /*! Initialize the I2C driver. */
319  status = pI2cDriver->Initialize(I2C_S_SIGNAL_EVENT);
320  if (ARM_DRIVER_OK != status)
321  {
322  return -1;
323  }
324 
325  /*! Set the I2C Power mode. */
326  status = pI2cDriver->PowerControl(ARM_POWER_FULL);
327  if (ARM_DRIVER_OK != status)
328  {
329  return -1;
330  }
331 
332  /*! Set the I2C bus speed. */
333  status = pI2cDriver->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
334  if (ARM_DRIVER_OK != status)
335  {
336  return -1;
337  }
338 
339  /*! Initialize the UART driver. */
340  status = pUartDriver->Initialize(HOST_B_SIGNAL_EVENT);
341  if (ARM_DRIVER_OK != status)
342  {
343  return -1;
344  }
345 
346  /*! Set the UART Power mode. */
347  status = pUartDriver->PowerControl(ARM_POWER_FULL);
348  if (ARM_DRIVER_OK != status)
349  {
350  return -1;
351  }
352 
353  /*! Set UART Baud Rate. */
354  status = pUartDriver->Control(ARM_USART_MODE_ASYNCHRONOUS, BOARD_DEBUG_UART_BAUDRATE);
355  if (ARM_DRIVER_OK != status)
356  {
357  return -1;
358  }
359 
360  do
361  { /*! Initialize the MMA865x sensor driver. */
364  if (SENSOR_ERROR_NONE != status)
365  {
366  break;
367  }
368  /*! Initialize MAG3110 sensor driver. */
371  if (SENSOR_ERROR_NONE != status)
372  {
373  break;
374  }
375  /*! Initialize the FXAS21002 sensor driver. */
378  if (SENSOR_ERROR_NONE != status)
379  {
380  break;
381  }
382  /*! Initialize the MPL3115 sensor driver. */
385  if (SENSOR_ERROR_NONE != status)
386  {
387  break;
388  }
389 
390  /*! Set the task to be executed while waiting for SPI transactions to complete. */
392  MAG3110_I2C_SetIdleTask(&mag3110Driver, (registeridlefunction_t)SMC_SetPowerModeVlpr, SMC);
393  FXAS21002_I2C_SetIdleTask(&fxas21002Driver, (registeridlefunction_t)SMC_SetPowerModeVlpr, SMC);
394  MPL3115_I2C_SetIdleTask(&mpl3115Driver, (registeridlefunction_t)SMC_SetPowerModeVlpr, SMC);
395 
396  /*! Configure the FXLS8962 sensor. */
397  status = MMA865x_I2C_Configure(&mma865xDriver, cMma865xConfigFreeFall);
398  if (SENSOR_ERROR_NONE != status)
399  {
400  break;
401  }
402  /*! Configure the MAG3110 sensor driver. */
403  status = MAG3110_I2C_Configure(&mag3110Driver, cMag3110ConfigNormal);
404  if (SENSOR_ERROR_NONE != status)
405  {
406  break;
407  }
408  /*! Configure the FXAS21002 sensor driver. */
409  status = FXAS21002_I2C_Configure(&fxas21002Driver, fxas21002_Config_Normal);
410  if (SENSOR_ERROR_NONE != status)
411  {
412  break;
413  }
414  /*! In One-Shot Mode we do not need to Configure MPL3115, instead we will set OST bit directly. */
415 
416  bMult2bReady = true;
417  } while (false);
418 
419  /*! Initialize streaming and assign a Stream ID. */
420  gStreamID =
421  Host_IO_Init(pUartDriver, (void *)mma865xDriver.pCommDrv, &mma865xDriver.deviceInfo, NULL, MMA8652_I2C_ADDR);
422  /* Confirm if a valid Stream ID has been allocated for this stream. */
423  if (0 == gStreamID)
424  {
425  bMult2bReady = false;
426  }
427  secondaryStreamID1 = /* This is required for registering the slave address with Host I/O for Register Read/Write. */
428  Host_IO_Init(pUartDriver, (void *)mag3110Driver.pCommDrv, &mag3110Driver.deviceInfo, NULL, MAG3110_I2C_ADDR);
429  /* Confirm if a valid Stream ID has been allocated for this stream. */
430  if (0 == secondaryStreamID1)
431  {
432  bMult2bReady = false;
433  }
434  secondaryStreamID2 = /* This is required for registering the slave address with Host I/O for Register Read/Write. */
435  Host_IO_Init(pUartDriver, (void *)fxas21002Driver.pCommDrv, &fxas21002Driver.deviceInfo, NULL,
437  /* Confirm if a valid Stream ID has been allocated for this stream. */
438  if (0 == secondaryStreamID2)
439  {
440  bMult2bReady = false;
441  }
442  secondaryStreamID3 = /* This is required for registering the slave address with Host I/O for Register Read/Write. */
443  Host_IO_Init(pUartDriver, (void *)mpl3115Driver.pCommDrv, &mpl3115Driver.deviceInfo, NULL, MPL3115_I2C_ADDR);
444  /* Confirm if a valid Stream ID has been allocated for this stream. */
445  if (0 == secondaryStreamID3)
446  {
447  bMult2bReady = false;
448  }
449 
450  if (true == bMult2bReady)
451  {
452  *((uint32_t *)&streamingPacket[STREAMING_HEADER_LEN]) = 0; /* Initialize time stamp field. */
453  pGpioDriver->clr_pin(&GREEN_LED); /* Set LED to indicate application is ready. */
454  /*! Populate streaming header. */
456  /*! Populate event header. */
458  }
459 
460  for (;;) /* Forever loop */
461  { /* Call UART Non-Blocking Receive. */
463 
464  if (bMma865xEventReady)
465  { /*! Read the Freefall event FLAGs from FXLS8962 to clear INT2. */
466  status = MMA865x_I2C_ReadData(&mma865xDriver, cMma865xFreeFallEvent, &eventReady);
467  if (SENSOR_ERROR_NONE != status)
468  {
469  return -1;
470  }
471 
473  { /* Update Event ID with Freefall event and send message to Host. */
474  eventPacket[STREAMING_HEADER_LEN] = SDCD_FF_EVT_ID;
475  Host_IO_Send(eventPacket, sizeof(eventPacket), HOST_FORMAT_HDLC);
476  }
477 
478  eventReady = 0;
479  bMma865xEventReady = false;
480  }
481 
482  if (bMpl3115EventReady)
483  { /* Send Pressure Threshold event message to Host. */
484  eventPacket[STREAMING_HEADER_LEN] = P_THS_EVENT_ID;
485  Host_IO_Send(eventPacket, sizeof(eventPacket), HOST_FORMAT_HDLC);
486  bMpl3115EventReady = false;
487  }
488 
489  /* Process packets only if streaming has been enabled by Host and ISR is available.
490  * In ISR Mode we do not need to check Data Ready Register.
491  * The receipt of interrupt will indicate data is ready. */
492  if (false == bStreamingEnabled || false == bFxas21002DataReady)
493  {
494  SMC_SetPowerModeWait(SMC); /* Power save, wait if nothing to do. */
495  continue;
496  }
497  else
498  { /*! Clear the data ready flag, it will be set again by the ISR. */
499  bFxas21002DataReady = false;
500  pGpioDriver->toggle_pin(&GREEN_LED);
501  }
502 
503  /* Read timestamp from Systick framework. */
504  *((uint32_t *)&streamingPacket[STREAMING_HEADER_LEN]) += BOARD_SystickElapsedTime_us(&gSystick);
505 
506  /*! Read new raw sensor data from the MMA865x. */
507  status = MMA865x_I2C_ReadData(&mma865xDriver, cMma865xOutputValues, data);
508  if (ARM_DRIVER_OK != status)
509  {
510  return -1;
511  }
512 
513  /* Convert to Little Endian, Right Justified, Even Padded Signed integer counts. */
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;
520 
521  /* Copy Raw samples to Streaming Buffer. */
522  memcpy(streamingPacket + STREAMING_HEADER_LEN + STREAMING_PKT_TIMESTAMP_LEN, &rawData_mma865x.accel,
523  sizeof(rawData_mma865x.accel));
524 
525  /*! Read raw sensor data from the MAG3110. */
526  status = MAG3110_I2C_ReadData(&mag3110Driver, cMag3110OutputNormal, data + MMA865x_DATA_SIZE);
527  if (ARM_DRIVER_OK != status)
528  {
529  return -1;
530  }
531 
532  /* Convert to Little Endian, Right Justified, Even Padded Signed integer counts. */
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];
536 
537  MAG3110_CalibrateHardIronOffset(&rawData_mag3110.mag[0], &rawData_mag3110.mag[1], &rawData_mag3110.mag[2]);
538 
539  /* Copy Raw samples to Streaming Buffer. */
540  memcpy(streamingPacket + STREAMING_HEADER_LEN + STREAMING_PKT_TIMESTAMP_LEN + MMA865x_DATA_SIZE,
541  &rawData_mag3110.mag, sizeof(rawData_mag3110.mag));
542 
543  /*! Read the raw sensor data from the FXAS21002. */
544  status = FXAS21002_I2C_ReadData(&fxas21002Driver, fxas21002_Output_Values,
546  if (ARM_DRIVER_OK != status)
547  {
548  return -1;
549  }
550 
551  /* Convert to Little Endian, Right Justified, Even Padded Signed integer counts. */
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];
555 
556  /* Copy the converted sample to the streaming buffer. */
557  memcpy(streamingPacket + STREAMING_HEADER_LEN + STREAMING_PKT_TIMESTAMP_LEN + MMA865x_DATA_SIZE +
559  &rawData_fxas21002.gyro, sizeof(rawData_fxas21002.gyro));
560 
561  /*! Read raw sensor data from the MPL3115. */
562  status = MPL3115_I2C_ReadData(&mpl3115Driver, mpl3115_Output_Values,
564  if (ARM_DRIVER_OK != status)
565  {
566  return -1;
567  }
568 
569  /* Convert to Little Endian, Right Justified, Even Padded Signed integer counts. */
570  rawData_mpl3115.pressure = (uint32_t)((data[18]) << 16) | ((data[19]) << 8) | ((data[20]));
571  rawData_mpl3115.pressure /= 16;
572  rawData_mpl3115.temperature = (int16_t)((data[21]) << 8) | (data[22]);
573  rawData_mpl3115.temperature /= 16;
574 
575  /* Copy the converted sample to the streaming buffer. */
576  memcpy(streamingPacket + STREAMING_HEADER_LEN + STREAMING_PKT_TIMESTAMP_LEN + MMA865x_DATA_SIZE +
578  &rawData_mpl3115.pressure, sizeof(rawData_mpl3115.pressure));
579  memcpy(streamingPacket + STREAMING_HEADER_LEN + STREAMING_PKT_TIMESTAMP_LEN + MMA865x_DATA_SIZE +
581  &rawData_mpl3115.temperature, sizeof(rawData_mpl3115.temperature));
582 
583  /* Trigger acquisition of New Sample. */
584  status = Sensor_I2C_Write(mpl3115Driver.pCommDrv, &mpl3115Driver.deviceInfo, mpl3115Driver.slaveAddress,
585  cMpl3115SetOST);
586 
587  /* Send streaming packet to Host. */
588  Host_IO_Send(streamingPacket, sizeof(streamingPacket), HOST_FORMAT_HDLC);
589  }
590 }
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
Definition: mma865x.h:1534
#define FXAS21002_WHO_AM_I_WHOAMI_PROD_VALUE
Definition: fxas21002.h:402
ARM_DRIVER_I2C * pCommDrv
Definition: mma865x_drv.h:32
#define MAG3110_DATA_SIZE
#define MMA865x_FF_MT_CFG_YEFE_MASK
Definition: mma865x.h:854
#define FXAS21002_INT1
#define FXAS21002_CTRL_REG2_INT_EN_DRDY_ENABLE
Definition: fxas21002.h:783
#define MMA865x_FF_MT_SRC_EA_MASK
Definition: mma865x.h:937
uint8_t Host_IO_Init(ARM_DRIVER_USART *pDrv, void *pBus, void *pDevInfo, void *spiSlaveParams, uint16_t slaveAddress)
Definition: host_io_uart.c:100
void Host_IO_Receive(host_cmd_proc_fn_t process_host_command, uint8_t encoding)
Definition: host_io_uart.c:207
This structure defines the Write command List.
Definition: sensor_drv.h:68
This defines the sensor specific information.
Definition: mma865x_drv.h:29
#define MMA865x_CTRL_REG5_INT_CFG_FF_MT_INT1
Definition: mma865x.h:1851
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.
Definition: mag3110_drv.c:22
int32_t status
#define MAG3110_CTRL_REG1_OS_OSR_16
Definition: mag3110.h:417
#define APPLICATION_NAME
Unique Name for this application which should match the target GUI pkg name.
#define MMA865x_XYZ_DATA_CFG_FS_MASK
Definition: mma865x.h:530
#define FXAS21002_CTRL_REG2_INT_CFG_DRDY_INT1
Definition: fxas21002.h:786
void MPL3115_I2C_SetIdleTask(mpl3115_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
Definition: mpl3115_drv.c:53
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
Definition: fxas21002.h:709
status_t SMC_SetPowerModeVlpr(void *arg)
Configures the system to VLPR power mode. API name used from Kinetis family to maintain compatibility...
Definition: lpc54114.c:169
#define MAG3110_CTRL_REG2_MAG_RST_EN
Definition: mag3110.h:471
#define MMA865x_CTRL_REG1_DR_50HZ
Definition: mma865x.h:1552
The host_io_uart.h file contains the Host Protocol interface definitions and configuration.
#define MMA865x_FF_MT_CFG_XEFE_EN
Definition: mma865x.h:881
#define MAG3110_I2C_ADDR
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.
Definition: mag3110_drv.h:38
#define MAG3110_INT1
#define HOST_B_SIGNAL_EVENT
Definition: frdm_k64f.h:98
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.
Definition: mpl3115_drv.c:104
volatile bool bStreamingEnabled
#define MMA8652_INT1
The mpl3115_drv.h file describes the MPL3115 driver interface and structures.
#define HOST_PRO_CMD_W_CFG_TAG
Definition: host_io_uart.h:63
This structure defines the fxas21002 raw data buffer.
Definition: fxas21002_drv.h:53
Access structure of the GPIO Driver.
Definition: Driver_GPIO.h:38
volatile bool bMpl3115EventReady
#define SMC
Definition: lpc54114.h:118
#define STREAMING_PKT_TIMESTAMP_LEN
#define MAG3110_CTRL_REG2_MAG_RST_MASK
Definition: mag3110.h:458
const registerreadlist_t cMag3110OutputNormal[]
Address and size of Raw Magnetic Data in Normal Mode.
#define MMA865x_FF_MT_THS_THS_MASK
Definition: mma865x.h:983
registerDeviceInfo_t deviceInfo
Definition: fxas21002_drv.h:46
#define __END_WRITE_DATA__
Definition: sensor_drv.h:45
#define MMA865x_CTRL_REG3_IPOL_MASK
Definition: mma865x.h:1664
void(* clr_pin)(pinID_t aPinId)
Definition: Driver_GPIO.h:47
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
Definition: fxas21002.h:757
#define MMA865x_FF_MT_THS_DBCNTM_INC_CLR
Definition: mma865x.h:994
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.
Definition: mma865x_drv.c:106
#define MMA865x_FF_MT_SRC_EA_DETECTED
Definition: mma865x.h:945
#define MMA865x_CTRL_REG3_IPOL_ACTIVE_HIGH
Definition: mma865x.h:1701
#define I2C_S_SIGNAL_EVENT
Definition: issdk_hal.h:34
#define MMA865x_FF_MT_CFG_ZEFE_EN
Definition: mma865x.h:875
int32_t FXAS21002_I2C_Configure(fxas21002_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
#define I2C_S_DRIVER
Definition: issdk_hal.h:33
#define MAG3110_CTRL_REG1_DR_ODR_1
Definition: mag3110.h:422
This defines the sensor specific information for I2C.
Definition: fxas21002_drv.h:44
int32_t MAG3110_I2C_Configure(mag3110_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
Definition: mag3110_drv.c:61
void Host_IO_Add_ISO_Header(uint8_t streamID, uint8_t *pStreamingPacket, size_t sizePayload)
Definition: host_io_uart.c:86
#define MMA865x_CTRL_REG4_INT_EN_FF_MT_EN
Definition: mma865x.h:1776
#define FXAS21002_CTRL_REG2_IPOL_MASK
Definition: fxas21002.h:754
#define BOARD_DEBUG_UART_BAUDRATE
Definition: board.h:31
#define MMA865x_CTRL_REG4_INT_EN_FF_MT_MASK
Definition: mma865x.h:1743
#define MMA865x_CTRL_REG2_MODS_MASK
Definition: mma865x.h:1592
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.
Definition: sensor_io_i2c.c:71
#define BOARD_BootClockRUN
Definition: clock_config.h:19
#define FXAS21002_CTRL_REG2_IPOL_ACTIVE_HIGH
Definition: fxas21002.h:782
ARM_DRIVER_I2C * pCommDrv
Definition: mag3110_drv.h:32
int32_t gSystick
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
Definition: sensor_drv.h:97
char shieldString[ADS_MAX_STRING_LENGTH]
registerDeviceInfo_t deviceInfo
Definition: mag3110_drv.h:31
#define FXAS21002_DATA_SIZE
#define MPL3115_CTRL_REG3_IPOL1_HIGH
Definition: mpl3115.h:990
int16_t accel[3]
Definition: mma865x_drv.h:41
uint8_t streamingPacket[STREAMING_HEADER_LEN+FXLS8962_STREAM_DATA_SIZE]
GENERIC_DRIVER_GPIO Driver_GPIO_KSDK
Definition: gpio_driver.c:177
#define FXAS21002_I2C_ADDR
void Host_IO_Send(uint8_t *pMsg, size_t size, uint8_t encoding)
Definition: host_io_uart.c:136
void BOARD_SystickStart(int32_t *pStart)
Function to Record the Start systick.
Definition: systick_utils.c:44
#define MPL3115_CTRL_REG5_INT_CFG_PTH_MASK
Definition: mpl3115.h:1116
This structure defines the mpl3115 data buffer in Pressure Mode.
Definition: mpl3115_drv.h:45
#define P_THS_EVENT_ID
uint32_t BOARD_SystickElapsedTime_us(int32_t *pStart)
Function to compute the Elapsed Time.
Definition: systick_utils.c:64
#define MPL3115_CTRL_REG3_IPOL1_MASK
Definition: mpl3115.h:976
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.
Definition: mma865x_drv.c:61
#define EVENT_STREAM_ID
Definition: host_io_uart.h:33
#define MMA865x_DATA_SIZE
#define __END_READ_DATA__
Definition: sensor_drv.h:51
#define HOST_PRO_INT_DEV_TAG
Definition: host_io_uart.h:59
void BOARD_RunADS(const char *appName, char *boardString, char *shieldString, size_t bufferLength)
The function to register Application Name and initialte ADS.
#define FF_MT_WT_DBCNT
#define MPL3115_CTRL_REG4_INT_EN_PTH_INTENABLED
Definition: mpl3115.h:1062
#define MPL3115_CTRL_REG1_OST_MASK
Definition: mpl3115.h:849
The mma865x_drv.h file describes the MMA865x driver interface and structures.
#define MPL3115_CTRL_REG4_INT_EN_PTH_MASK
Definition: mpl3115.h:1036
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.
Definition: mag3110_drv.c:104
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.
Definition: mpl3115_drv.h:36
#define HOST_B_DRIVER
Definition: frdm_k64f.h:97
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
Definition: mma865x.h:1818
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.
Definition: mpl3115_drv.c:22
#define MMA865x_FF_MT_CFG_XEFE_MASK
Definition: mma865x.h:851
#define STREAMING_PAYLOAD_LEN
#define MAG3110_CTRL_REG1_DR_MASK
Definition: mag3110.h:404
uint16_t readFrom
Definition: sensor_drv.h:80
volatile bool bMma865xEventReady
#define MPL3115_PADDING_SIZE
char embAppName[ADS_MAX_STRING_LENGTH]
registerDeviceInfo_t deviceInfo
Definition: mma865x_drv.h:31
void(* toggle_pin)(pinID_t aPinId)
Definition: Driver_GPIO.h:48
#define ADS_MAX_STRING_LENGTH
#define MAG3110_CTRL_REG1_OS_MASK
Definition: mag3110.h:401
#define MMA865x_CTRL_REG2_MODS_HR
Definition: mma865x.h:1623
#define FF_MT_THS_VALUE
#define MAG3110_CTRL_REG2_AUTO_MSRT_EN_MASK
Definition: mag3110.h:464
#define FXAS21002_CTRL_REG1_DR_MASK
Definition: fxas21002.h:684
void BOARD_SystickEnable(void)
Function to enable systicks framework.
Definition: systick_utils.c:35
#define MAG3110_CTRL_REG2_RAW_RAW
Definition: mag3110.h:474
#define MPL3115_WHOAMI_VALUE
Definition: mpl3115.h:65
#define STREAMING_HEADER_LEN
Definition: host_io_uart.h:25
#define MAG3110_CTRL_REG2_AUTO_MSRT_EN_EN
Definition: mag3110.h:477
status_t SMC_SetPowerModeWait(void *arg)
Configures the system to WAIT power mode. API name used from Kinetis family to maintain compatibility...
Definition: lpc54114.c:155
#define MMA865x_XYZ_DATA_CFG_FS_2G
Definition: mma865x.h:542
#define MMA865x_FF_MT_CFG_ZEFE_MASK
Definition: mma865x.h:857
void(* pin_init)(pinID_t aPinId, gpio_direction_t dir, void *apPinConfig, gpio_isr_handler_t aIsrHandler, void *apUserData)
Definition: Driver_GPIO.h:41
This defines the sensor specific information.
Definition: mag3110_drv.h:29
ARM_DRIVER_I2C * pCommDrv
Definition: mpl3115_drv.h:39
This structure defines the Read command List.
Definition: sensor_drv.h:78
#define MMA8652_I2C_ADDR
This structure defines the mma865x raw data buffer.
Definition: mma865x_drv.h:38
ARM Systick Utilities.
#define FXAS21002_CTRL_REG2_INT_CFG_DRDY_MASK
Definition: fxas21002.h:760
#define MAG3110_WHOAMI_VALUE
Definition: mag3110.h:37
void MAG3110_CalibrateHardIronOffset(int16_t *xValue, int16_t *yValue, int16_t *zValue)
Calibrates the magnetometer reading by determining the current hard iron offset.
Definition: mag3110_drv.c:164
#define SDCD_FF_EVT_ID
gpioHandleKSDK_t GREEN_LED
Definition: frdm_k64f.c:188
int16_t mag[3]
Definition: mag3110_drv.h:41
#define MPL3115_CTRL_REG1_OST_SET
Definition: mpl3115.h:871
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
Definition: issdk_hal.h:35
void MMA865x_I2C_SetIdleTask(mma865x_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
Definition: mma865x_drv.c:53
uint8_t gStreamID
volatile bool bFxas21002DataReady
#define MMA865x_FF_MT_CFG_ELE_MASK
Definition: mma865x.h:863
#define MPL3115_I2C_ADDR
#define MPL3115_CTRL_REG5_INT_CFG_PTH_INT1
Definition: mpl3115.h:1142
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).
Definition: host_io_uart.h:57
#define MMA8652_WHOAMI_VALUE
Definition: mma865x.h:65
#define MMA865x_FF_MT_CFG_OAE_MASK
Definition: mma865x.h:860
#define SHIELD_NAME
#define MMA865x_FF_MT_THS_DBCNTM_MASK
Definition: mma865x.h:986
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.
Definition: mma865x_drv.c:22
void MAG3110_I2C_SetIdleTask(mag3110_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
Definition: mag3110_drv.c:53
#define MMA865x_FF_MT_CFG_OAE_FREEFALL
Definition: mma865x.h:872
#define MAG3110_CTRL_REG2_RAW_MASK
Definition: mag3110.h:461
registerDeviceInfo_t deviceInfo
Definition: mpl3115_drv.h:38
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
Definition: mma865x.h:871
#define EVENT_PAYLOAD_LEN
#define MMA865x_FF_MT_CFG_YEFE_EN
Definition: mma865x.h:878