ISSDK  1.7
IoT Sensing Software Development Kit
fxls8962_demo.c
Go to the documentation of this file.
1 /*
2  * The Clear BSD License
3  * Copyright (c) 2016, Freescale Semiconductor, Inc.
4  * Copyright 2016-2017 NXP
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without modification,
8  * are permitted (subject to the limitations in the disclaimer below) provided
9  * that the following conditions are met:
10  *
11  * o Redistributions of source code must retain the above copyright notice, this list
12  * of conditions and the following disclaimer.
13  *
14  * o Redistributions in binary form must reproduce the above copyright notice, this
15  * list of conditions and the following disclaimer in the documentation and/or
16  * other materials provided with the distribution.
17  *
18  * o Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from this
20  * software without specific prior written permission.
21  *
22  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
27  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
30  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 /**
36  * @file fxls8962_demo.c
37  * @brief The fxls8962_demo.c file implements the ISSDK FXLS8962 sensor
38  * demo example demonstration with interrupt mode.
39  */
40 
41 //-----------------------------------------------------------------------
42 // SDK Includes
43 //-----------------------------------------------------------------------
44 #include "board.h"
45 #include "pin_mux.h"
46 #include "clock_config.h"
47 
48 //-----------------------------------------------------------------------
49 // CMSIS Includes
50 //-----------------------------------------------------------------------
51 #include "Driver_I2C.h"
52 #include "Driver_USART.h"
53 
54 //-----------------------------------------------------------------------
55 // ISSDK Includes
56 //-----------------------------------------------------------------------
57 #include "issdk_hal.h"
58 #include "gpio_driver.h"
59 #include "fxls8962_drv.h"
60 #include "host_io_uart.h"
61 #include "systick_utils.h"
62 #include "auto_detection_service.h"
63 
64 //-----------------------------------------------------------------------
65 // Macros
66 //-----------------------------------------------------------------------
67 #define FXLS8962_DATA_SIZE 8
68 #define FXLS8962_STREAM_DATA_SIZE 12
69 #define FXLS8962_STREAM_SELF_TEST_SIZE 18
70 /*! @brief Unique Name for this application which should match the target GUI pkg name. */
71 #define APPLICATION_NAME "FXLS8962 Accelerometer Demo"
72 /*! @brief Version to distinguish between instances the same application based on target Shield and updates. */
73 #define APPLICATION_VERSION "2.5"
74 #define HOST_CMD_RESET 6 /* 6 (Reset Sensor) */
75 #define HOST_CMD_SELFTEST 7 /* 7 (Self Test Sensor) */
76 
77 /*! @brief This structure defines the fxls8962 raw data buffer.*/
78 typedef struct
79 {
80  uint32_t timestamp; /*! The time, this sample was recorded. */
81  int16_t accel[3]; /*!< The accel data */
82  uint8_t sdcd;
83  int8_t temp;
84  int16_t selftest[3];
86 
87 //-----------------------------------------------------------------------
88 // Constants
89 //-----------------------------------------------------------------------
90 /*! @brief Register settings for Interrupt (non buffered) mode. */
92  /* Set Full-scale range as 4G. */
94  /* Clear SENS_CONFIG2 */
95  {FXLS8962_SENS_CONFIG2, 0x00, 0x00},
96  /* Disable Self-Test. */
98  /* Set Wake Mode ODR Rate as 12.5Hz. */
100  /* Enable Interrupts for Data Ready Events. */
102  /* Enable Temperature sensor. */
104  /* Set Self-Test ODR to 100 Hz. */
105  {0x38,0x05,0x00},
106  {0x2F,0x38,0x00},
107  {0x30,0xD8,0x00},
108  {0x33,0xC0,0x00},
109  {0x34,0x0F,0x00},
110  {0x35,0x40,0x00},
112 
113 /*! @brief Register settings for Interrupt (non buffered) mode. */
115  /* Disable Self-Test. */
117  /* Set Wake Mode ODR Rate as 12.5Hz. */
119  /* Enable Interrupts for Data Ready Events. */
121  /* Enable Temperature sensor. */
123  /* Set Self-Test ODR to 100 Hz. */
124  {0x38,0x05,0x00},
126 
128  /* Disable Self-Test. */
130  /* Set Full-scale range as 16G. */
132  /* Enable Interrupts for Data Ready Events. */
134  /* Enable Temperature sensor. */
136  /* Set Self-Test ODR to 100 Hz. */
137  {0x38,0x05,0x00},
139 
140 /*! @brief Register settings for Self-Test in X Axis (Positive polarity). */
142  /* Set Self Test Axis. */
147 
148 /*! @brief Register settings for Self-Test in X Axis (Negative polarity). */
150  /* Set Self Test Axis. */
155 
156 /*! @brief Register settings for Self-Test in Y Axis (Positive polarity). */
158  /* Set Self Test Axis. */
163 
164 /*! @brief Register settings for Self-Test in Y Axis (Negative polarity). */
166  /* Set Self Test Axis. */
171 
172 /*! @brief Register settings for Self-Test in Z Axis (Positive polarity). */
174  /* Set Self Test Axis. */
179 
180 /*! @brief Register settings for Self-Test in Z Axis (Negative polarity). */
182  /* Set Self Test Axis. */
187 
188 /*! @brief Address of Raw Accel Data in Normal Mode. */
191 
192 //-----------------------------------------------------------------------
193 // Global Variables
194 //-----------------------------------------------------------------------
197 volatile bool bStreamingEnabled = false, bFxls8962DataReady = false, bFxls8962Ready = false;
198 uint8_t gStreamID; /* The auto assigned Stream ID. */
204 int st_on =0, st_sample=0;
206 float fsr_scale;
207 
208 //-----------------------------------------------------------------------
209 // Functions
210 //-----------------------------------------------------------------------
211 /* This is the Sensor Data Ready ISR implementation.*/
212 void fxls8962_int_data_ready_callback(void *pUserData)
213 { /*! @brief Set flag to indicate Sensor has signalled data ready. */
214  bFxls8962DataReady = true;
215 }
216 
217 /* Handler for Device Info and Streaming Control Commands. */
219  uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse, size_t *hostMsgSize, size_t respBufferSize)
220 {
221  bool success = false;
222 
223  /* If it is Host requesting Device Info, send Board Name and Shield Name. */
224  if (tag == HOST_PRO_INT_DEV_TAG)
225  { /* Byte 1 : Payload - Length of APPLICATION_NAME (b)
226  * Bytes=b : Payload Application Name
227  * Byte b+1 : Payload - Length of BOARD_NAME (s)
228  * Bytes=s : Payload Board Name
229  * Byte b+s+2 : Payload - Length of SHIELD_NAME (v)
230  * Bytes=v : Payload Shield Name */
231 
232  size_t appNameLen = strlen(embAppName);
233  size_t boardNameLen = strlen(boardString);
234  size_t shieldNameLen = strlen(shieldString);
235 
236  if (respBufferSize >= boardNameLen + shieldNameLen + appNameLen + 3)
237  { /* We have sufficient buffer. */
238  *hostMsgSize = 0;
239  }
240  else
241  {
242  return false;
243  }
244 
245  hostResponse[*hostMsgSize] = appNameLen;
246  *hostMsgSize += 1;
247 
248  memcpy(hostResponse + *hostMsgSize, embAppName, appNameLen);
249  *hostMsgSize += appNameLen;
250 
251  hostResponse[*hostMsgSize] = boardNameLen;
252  *hostMsgSize += 1;
253 
254  memcpy(hostResponse + *hostMsgSize, boardString, boardNameLen);
255  *hostMsgSize += boardNameLen;
256 
257  hostResponse[*hostMsgSize] = shieldNameLen;
258  *hostMsgSize += 1;
259 
260  memcpy(hostResponse + *hostMsgSize, shieldString, shieldNameLen);
261  *hostMsgSize += shieldNameLen;
262 
263  return true;
264  }
265 
266  /* If it is Host sending Streaming Commands, take necessary actions. */
267  if ((tag == (HOST_PRO_INT_CMD_TAG | HOST_PRO_CMD_W_CFG_TAG)) &&
269  { /* Byte 1 : Payload - Operation Code (Start/Stop Operation Code)
270  * Byte 2 : Payload - Stream ID (Target Stream for carrying out operation) */
271  switch (hostCommand[0]) /* Execute desired operation (Start/Stop) on the requested Stream. */
272  {
273  case HOST_CMD_START:
274  if (hostCommand[1] == gStreamID && bFxls8962Ready && bStreamingEnabled == false)
275  {
277  bStreamingEnabled = true;
278  success = true;
279  }
280  break;
281  case HOST_CMD_STOP:
282  if (hostCommand[1] == gStreamID && bFxls8962Ready && bStreamingEnabled == true)
283  {
284  pGpioDriver->clr_pin(&GREEN_LED);
285  bStreamingEnabled = false;
286  success = true;
287  }
288  break;
289  case HOST_CMD_RESET:
290  if (hostCommand[1] == gStreamID && bFxls8962Ready)
291  {
292  do
293  {
294  status = FXLS8962_I2C_DeInit(&fxls8962Driver);
295  if (SENSOR_ERROR_NONE != status)
296  break;
299 
300  if (SENSOR_ERROR_NONE != status)
301  break;
302  status = FXLS8962_I2C_Configure(&fxls8962Driver, cFxls8962ConfigNormal2);
303  if (SENSOR_ERROR_NONE != status)
304  break;
305  success = true;
306  } while(0);
307  }
308  break;
309  case HOST_CMD_SELFTEST:
310  st_on=1;
311  st_sample=98;
312  rawData.selftest[0]=0;
313  rawData.selftest[1]=0;
314  rawData.selftest[2]=0;
315  /* Copy Raw samples to Streaming Buffer. */
317  /* Send streaming packet to Host. */
319  success = true;
320  break;
321  default:
322  break;
323  }
324  *hostMsgSize = 0; /* Zero payload in response. */
325  }
326 
327  if ((tag == (HOST_PRO_INT_CMD_TAG | HOST_PRO_CMD_W_REG_TAG)) && (*hostMsgSize >= 3))
328  {
329  /* If ODR set from GUI > 100 Hz set ODR to 100 Hz */
330  if(hostCommand[1]==0x17)
331  {
332  if(((hostCommand[2] & 0x0F)<5))
333  {
334  hostCommand[2]= ((hostCommand[2]&0xF0) | 0x05);
335  }
336  if((((hostCommand[2] & 0xF0)>>4)<5))
337  {
338  hostCommand[2]= ((hostCommand[2]&0x0F) | 0x50);
339  }
340  }
341 
342  /* Select the Sensitivity factor according to the FSR selected from the GUI*/
343  if(hostCommand[1]==0x15)
344  {
345  if(((hostCommand[2] & 0x06)==0x06))
346  {
347  fsr_scale=7.81;
348  }
349  if(((hostCommand[2] & 0x06)==0x04))
350  {
351  fsr_scale=3.91;
352  }
353  if(((hostCommand[2] & 0x06)==0x02))
354  {
355  fsr_scale=1.95;
356  }
357  if(((hostCommand[2] & 0x06)==0x00))
358  {
359  fsr_scale=0.98;
360  }
361  }
362 
363  /* If Self-Test ODR set from GUI > 100 Hz set ODR to 100 Hz */
364  if(hostCommand[1]==0x38 && hostCommand[2]<5)
365  {
366  hostCommand[2]=0x05;
367  }
368  if(hostCommand[1]==0x90)
369  {
370  st_on=1;
371  st_sample=98;
372  }
373  }
374  if ((tag == (HOST_PRO_INT_CMD_TAG | HOST_PRO_CMD_R_REG_TAG)) &&
375  (*hostMsgSize == 3))
376  {
377  /* Select the Sensitivity factor according to the FSR selected from the GUI*/
378  if(hostCommand[1]==0x15)
379  {
380  if((*hostResponse & 0x06)==0x06)
381  {
382  fsr_scale=7.81;
383  }
384  if((*hostResponse & 0x06)==0x04)
385  {
386  fsr_scale=3.91;
387  }
388  if((*hostResponse & 0x06)==0x02)
389  {
390  fsr_scale=1.95;
391  }
392  if((*hostResponse & 0x06)==0x00)
393  {
394  fsr_scale=0.98;
395  }
396  }
397  }
398  return success;
399 }
400 
401 /*!
402  * @brief Main function
403  */
404 int main(void)
405 {
406  int flag=0;
407  int32_t status;
409 
410  ARM_DRIVER_I2C *pI2cDriver = &I2C_S_DRIVER;
411  ARM_DRIVER_USART *pUartDriver = &HOST_S_DRIVER;
412 
413  /*! Initialize the MCU hardware. */
416 
417  /* Create the Short Application Name String for ADS. */
418  sprintf(embAppName, "%s:%s", APPLICATION_NAME, APPLICATION_VERSION);
419 
420  /* Run ADS. */
422 
423  /* Create the Full Application Name String for Device Info Response. */
425 
426  /*! Initialize FXLS8962 pin used by FRDM board */
428 
429  pGpioDriver->pin_init(&FXAS21002_CS, GPIO_DIRECTION_OUT, NULL, NULL, NULL);
430  pGpioDriver->clr_pin(&FXAS21002_CS);
431 
432  /*! Initialize RGB LED pin used by FRDM board */
433  pGpioDriver->pin_init(&GREEN_LED, GPIO_DIRECTION_OUT, NULL, NULL, NULL);
434 
435  /*! Initialize the I2C driver. */
436  status = pI2cDriver->Initialize(I2C_S_SIGNAL_EVENT);
437  if (ARM_DRIVER_OK != status)
438  {
439  return -1;
440  }
441 
442  /*! Set the I2C Power mode. */
443  status = pI2cDriver->PowerControl(ARM_POWER_FULL);
444  if (ARM_DRIVER_OK != status)
445  {
446  return -1;
447  }
448 
449  /*! Set the I2C bus speed. */
450  status = pI2cDriver->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
451  if (ARM_DRIVER_OK != status)
452  {
453  return -1;
454  }
455 
456  /*! Initialize the UART driver. */
457  status = pUartDriver->Initialize(HOST_S_SIGNAL_EVENT);
458  if (ARM_DRIVER_OK != status)
459  {
460  return -1;
461  }
462 
463  /*! Set the UART Power mode. */
464  status = pUartDriver->PowerControl(ARM_POWER_FULL);
465  if (ARM_DRIVER_OK != status)
466  {
467  return -1;
468  }
469 
470  /*! Set UART Baud Rate. */
471  status = pUartDriver->Control(ARM_USART_MODE_ASYNCHRONOUS, BOARD_DEBUG_UART_BAUDRATE);
472  if (ARM_DRIVER_OK != status)
473  {
474  return -1;
475  }
476 
477  /*! Initialize FXLS8962 sensor driver. */
480  if (SENSOR_ERROR_NONE == status)
481  {
482  /*! Set the task to be executed while waiting for I2C transactions to complete. */
484 
485  /*! Configure the FXLS8962 sensor. */
486  status = FXLS8962_I2C_Configure(&fxls8962Driver, cFxls8962ConfigNormal);
487  if (SENSOR_ERROR_NONE == status)
488  {
489  bFxls8962Ready = true;
490  }
491  }
492 
493  /*! Initialize streaming and assign a Stream ID. */
494  gStreamID =
495  Host_IO_Init(pUartDriver, (void *)fxls8962Driver.pCommDrv, &fxls8962Driver.deviceInfo, NULL, FXLS8962_I2C_ADDR);
496  /* Confirm if a valid Stream ID has been allocated for this stream. */
497  if (0 == gStreamID)
498  {
499  bFxls8962Ready = false;
500  }
501  else
502  {
503  /*! Populate streaming header. */
506  pGpioDriver->clr_pin(&GREEN_LED);
507  }
508 
509  rawData.selftest[0]=0;
510  rawData.selftest[1]=0;
511  rawData.selftest[2]=0;
512 
513  for (;;) /* Forever loop */
514  { /* Call UART Non-Blocking Receive. */
515  /* If Self-Test is selected*/
516  if(st_on)
517  { /* Call UART Non-Blocking Receive. */
519  switch(st_sample)
520  {
521  case 98:
522  status =FXLS8962_I2C_Configure(&fxls8962Driver, cFxls896216G); /* Configure 16G mode*/
523  break;
524  case 100:
525  status = FXLS8962_I2C_Configure(&fxls8962Driver, cFxls8962STXP);/* Enable Self-Test +X Axis*/
526  break;
527  case 200:
528  status = FXLS8962_I2C_Configure(&fxls8962Driver, cFxls8962STXN);/* Enable Self-Test -X Axis*/
529  break;
530  case 300:
531  status = FXLS8962_I2C_Configure(&fxls8962Driver, cFxls8962STYP);/* Enable Self-Test +Y Axis*/
532  break;
533  case 400:
534  status = FXLS8962_I2C_Configure(&fxls8962Driver, cFxls8962STYN);/* Enable Self-Test -Y Axis*/
535  break;
536  case 500:
537  status = FXLS8962_I2C_Configure(&fxls8962Driver, cFxls8962STZP);/* Enable Self-Test +Z Axis*/
538  break;
539  case 600:
540  status = FXLS8962_I2C_Configure(&fxls8962Driver, cFxls8962STZN);/* Enable Self-Test -Z Axis*/
541  break;
542  }
543  /* Process packets only if streaming has been enabled by Host and ISR is available.
544  * In ISR Mode we do not need to check Data Ready Register.
545  * The receipt of interrupt will indicate data is ready. */
546  if (false == bStreamingEnabled || false == bFxls8962DataReady)
547  {
548  SMC_SetPowerModeWait(SMC); /* Power save, wait if nothing to do. */
549  continue;
550  }
551  else
552  { /*! Clear the data ready flag, it will be set again by the ISR. */
553  bFxls8962DataReady = false;
554  pGpioDriver->toggle_pin(&GREEN_LED);
555  }
556 
557  /* Place device in Standby mode after acquiring close to 100 samples */
558  switch(st_sample)
559  {
560  case 99:
561  Register_I2C_Write(&I2C_S_DRIVER,&(fxls8962Driver.deviceInfo),0x18, 0x15,0x00,0x00,0x00);
562  break;
563  case 199:
564  Register_I2C_Write(&I2C_S_DRIVER,&(fxls8962Driver.deviceInfo),0x18, 0x15,0x00,0x00,0x00);
565  break;
566  case 299:
567  Register_I2C_Write(&I2C_S_DRIVER,&(fxls8962Driver.deviceInfo),0x18, 0x15,0x00,0x00,0x00);
568  break;
569  case 399:
570  Register_I2C_Write(&I2C_S_DRIVER,&(fxls8962Driver.deviceInfo),0x18, 0x15,0x00,0x00,0x00);
571  break;
572  case 499:
573  Register_I2C_Write(&I2C_S_DRIVER,&(fxls8962Driver.deviceInfo),0x18, 0x15,0x00,0x00,0x00);
574  break;
575  case 599:
576  Register_I2C_Write(&I2C_S_DRIVER,&(fxls8962Driver.deviceInfo),0x18, 0x15,0x00,0x00,0x00);
577  break;
578  }
579  /*! Read new raw sensor data from the FXLS8962. */
580  status = FXLS8962_I2C_ReadData(&fxls8962Driver, cFxls8962OutputNormal, data);
581  if (ARM_DRIVER_OK != status)
582  { /* Loop, if sample read failed. */
583  continue;
584  }
585 
586  /* Update timestamp from Systick framework. */
588 
589  /*! Convert the raw sensor data to signed 16-bit container for display to the debug port. */
590  rawData.accel[0] = (int16_t)(((int16_t)(((int16_t)data[3] << 8) | data[2]))); /*7.81 is the scale factor for 16 G mode */
591  rawData.accel[1] = (int16_t)(((int16_t)(((int16_t)data[5] << 8) | data[4])));
592  rawData.accel[2] = (int16_t)(((int16_t)(((int16_t)data[7] << 8) | data[6])));
593 
594  switch(st_sample)
595  {
596  case 100:
597  st_xp = (int16_t)(((int16_t)data[3] << 8) | data[2]);
599  break;
600  case 200:
601  st_xn = (int16_t)(((int16_t)data[3] << 8) | data[2]);
603  break;
604  case 300:
605  st_yp = (int16_t)(((int16_t)data[5] << 8) | data[4]);
607  break;
608  case 400:
609  st_yn = (int16_t)(((int16_t)data[5] << 8) | data[4]);
611  break;
612  case 500:
613  st_zp = (int16_t)(((int16_t)data[7] << 8) | data[6]);
615  break;
616  case 600:
617  st_zn = (int16_t)(((int16_t)data[7] << 8) | data[6]);
619  break;
620  case 700: /* Calculate Self-Test output */
621  rawData.selftest[0] =(st_xp-st_xn)/2;
622  rawData.selftest[1] =(st_yp-st_yn)/2;
623  rawData.selftest[2] =(st_zp-st_zn)/2;
624  st_on=0;
625  st_sample=98;
626  flag=1;
627  status = FXLS8962_I2C_Configure(&fxls8962Driver, cFxls896216G);
628  break;
629  default:
631  break;
632  }
633 
634  rawData.temp = data[1]+25;
635  rawData.sdcd = (data[0] & 0x10)>>4;
636 
637  /* Copy Raw samples to Streaming Buffer. */
640  }
641  else
642  {
643  /* Call UART Non-Blocking Receive. */
645 
646  /* Process packets only if streaming has been enabled by Host and ISR is available.
647  * In ISR Mode we do not need to check Data Ready Register.
648  * The receipt of interrupt will indicate data is ready. */
649  if (false == bStreamingEnabled || false == bFxls8962DataReady)
650  {
651  SMC_SetPowerModeWait(SMC); /* Power save, wait if nothing to do. */
652  continue;
653  }
654  else
655  { /*! Clear the data ready flag, it will be set again by the ISR. */
656  bFxls8962DataReady = false;
657  pGpioDriver->toggle_pin(&GREEN_LED);
658  }
659 
660  /*! Read new raw sensor data from the FXLS8962. */
661  status= FXLS8962_I2C_ReadData(&fxls8962Driver, cFxls8962OutputNormal, data);
662 
663  if (ARM_DRIVER_OK != status)
664  { /* Loop, if sample read failed. */
665  continue;
666  }
667 
668  /* Update timestamp from Systick framework. */
670 
671  /*! Convert the raw sensor data to signed 16-bit container for display to the debug port. */
672  rawData.accel[0] = (int16_t)(((int16_t)(((int16_t)data[3] << 8) | data[2])));
673  rawData.accel[1] = (int16_t)(((int16_t)(((int16_t)data[5] << 8) | data[4])));
674  rawData.accel[2] = (int16_t)(((int16_t)(((int16_t)data[7] << 8) | data[6])));
675 
676  rawData.temp = data[1]+25;
677  rawData.sdcd = (data[0] & 0x10)>>4;
678 
679  /* Copy Raw samples to Streaming Buffer. */
680  memcpy(streamingPacket + STREAMING_HEADER_LEN, &rawData, FXLS8962_STREAM_DATA_SIZE);
681  /* Send streaming packet to Host. */
682  Host_IO_Send(streamingPacket, sizeof(streamingPacket), HOST_FORMAT_HDLC);
683 
684  if(flag==1) /*Reset Self-Test Values */
685  {
686  rawData.selftest[0]=0;
687  rawData.selftest[1]=0;
688  rawData.selftest[2]=0;
689  flag=0;
690  }
691  }
692  }
693 }
uint32_t BOARD_SystickElapsedTime_us(int32_t *pStart)
Function to compute the Elapsed Time.
Definition: systick_utils.c:99
const registerwritelist_t cFxls8962STZP[]
Register settings for Self-Test in Z Axis (Positive polarity).
char boardString[ADS_MAX_STRING_LENGTH]
uint8_t streamingPacket1[STREAMING_HEADER_LEN+FXLS8962_STREAM_SELF_TEST_SIZE]
int16_t st_xp
#define __END_WRITE_DATA__
Definition: sensor_drv.h:71
#define FXLS8962_SENS_CONFIG1_FSR_16G
Definition: fxls8962.h:482
#define HOST_PRO_CMD_W_CFG_TAG
Definition: host_io_uart.h:89
#define FXLS8962_SENS_CONFIG2_ANIC_TEMP_EN
Definition: fxls8962.h:544
bool process_host_command(uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse, size_t *hostMsgSize, size_t respBufferSize)
int32_t FXLS8962_I2C_Initialize(fxls8962_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: fxls8962_drv.c:260
#define HOST_CMD_SELFTEST
Definition: fxls8962_demo.c:75
char embAppName[ADS_MAX_STRING_LENGTH]
#define HOST_S_SIGNAL_EVENT
Definition: frdm_k64f.h:120
void Host_IO_Receive(host_cmd_proc_fn_t process_host_command, uint8_t encoding)
Definition: host_io_uart.c:233
void(* pin_init)(pinID_t aPinId, gpio_direction_t dir, void *apPinConfig, gpio_isr_handler_t aIsrHandler, void *apUserData)
Definition: Driver_GPIO.h:67
#define HOST_PRO_CMD_W_REG_TAG
Definition: host_io_uart.h:91
#define BOARD_BootClockRUN
Definition: clock_config.h:45
const registerreadlist_t cFxls8962OutputNormal[]
Address of Raw Accel Data in Normal Mode.
int16_t st_dy
This defines the sensor specific information for I2C.
Definition: fxls8962_drv.h:70
#define FXLS8962_INT1
uint8_t data[FXLS8962_DATA_SIZE]
int32_t FXLS8962_I2C_Configure(fxls8962_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
Definition: fxls8962_drv.c:299
const registerwritelist_t cFxls8962STYP[]
Register settings for Self-Test in Y Axis (Positive polarity).
#define FXLS8962_SENS_CONFIG1_ST_AXIS_SEL_MASK
Definition: fxls8962.h:455
#define FXLS8962_SENS_CONFIG1_ST_AXIS_SEL_EN_Z
Definition: fxls8962.h:469
int32_t status
void(* toggle_pin)(pinID_t aPinId)
Definition: Driver_GPIO.h:74
volatile bool bFxls8962Ready
#define SHIELD_NAME
void fxls8962_int_data_ready_callback(void *pUserData)
void FXLS8962_I2C_SetIdleTask(fxls8962_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
Definition: fxls8962_drv.c:291
#define FXLS8962_SENS_CONFIG3_WAKE_ODR_12_5HZ
Definition: fxls8962.h:588
volatile bool bFxls8962DataReady
#define ADS_MAX_STRING_LENGTH
registerDeviceInfo_t deviceInfo
Definition: fxls8962_drv.h:72
#define HOST_PRO_INT_DEV_TAG
Definition: host_io_uart.h:85
uint8_t streamingPacket[STREAMING_HEADER_LEN+FXLS8962_STREAM_DATA_SIZE]
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
Definition: sensor_drv.h:123
fxls8962_i2c_sensorhandle_t fxls8962Driver
int16_t st_yn
#define HOST_PRO_INT_CMD_TAG
Bit aligned values for Host Protocol Interface IDs (Bits 5-6).
Definition: host_io_uart.h:83
const registerwritelist_t cFxls8962STYN[]
Register settings for Self-Test in Y Axis (Negative polarity).
const registerwritelist_t cFxls8962STZN[]
Register settings for Self-Test in Z Axis (Negative polarity).
int32_t FXLS8962_I2C_DeInit(fxls8962_i2c_sensorhandle_t *pSensorHandle)
The interface function to De Initialize sensor..
Definition: fxls8962_drv.c:373
#define __END_READ_DATA__
Definition: sensor_drv.h:77
#define FXLS8962_STREAM_DATA_SIZE
Definition: fxls8962_demo.c:68
const registerwritelist_t cFxls8962ConfigNormal[]
Register settings for Interrupt (non buffered) mode.
Definition: fxls8962_demo.c:91
int st_on
int32_t gSystick
#define APPLICATION_NAME
Unique Name for this application which should match the target GUI pkg name.
Definition: fxls8962_demo.c:71
int16_t st_xn
#define FXLS8962_DATA_SIZE
Definition: fxls8962_demo.c:67
#define FXLS8962_I2C_ADDR
GENERIC_DRIVER_GPIO * pGpioDriver
int st_sample
gpioHandleKSDK_t GREEN_LED
Definition: frdm_k64f.c:214
#define FXLS8962_SENS_CONFIG3_WAKE_ODR_MASK
Definition: fxls8962.h:574
#define HOST_CMD_RESET
Definition: fxls8962_demo.c:74
#define FXLS8962_SENS_CONFIG1_FSR_4G
Definition: fxls8962.h:478
const registerwritelist_t cFxls8962STXN[]
Register settings for Self-Test in X Axis (Negative polarity).
void Host_IO_Add_ISO_Header(uint8_t streamID, uint8_t *pStreamingPacket, size_t sizePayload)
Definition: host_io_uart.c:112
void Host_IO_Send(uint8_t *pMsg, size_t size, uint8_t encoding)
Definition: host_io_uart.c:162
#define FXLS8962_SENS_CONFIG1_ST_POL_MASK
Definition: fxls8962.h:452
void(* clr_pin)(pinID_t aPinId)
Definition: Driver_GPIO.h:73
#define HOST_PRO_CMD_R_REG_TAG
Definition: host_io_uart.h:92
The fxls8962_drv.h file describes the FXLS8962AF driver interface and structures. ...
void BOARD_SystickEnable(void)
Function to enable systicks framework.
Definition: systick_utils.c:70
#define FXLS8962_SENS_CONFIG1_ST_AXIS_SEL_EN_Y
Definition: fxls8962.h:468
#define FXLS8962_INT_EN_DRDY_EN_MASK
Definition: fxls8962.h:873
#define I2C_S_DEVICE_INDEX
Definition: issdk_hal.h:61
float fsr_scale
#define FXAS21002_CS
#define I2C_S_DRIVER
Definition: issdk_hal.h:59
int16_t st_zn
#define FXLS8962_SENS_CONFIG1_ST_AXIS_SEL_EN_X
Definition: fxls8962.h:467
GENERIC_DRIVER_GPIO Driver_GPIO_KSDK
Definition: gpio_driver.c:203
uint8_t gStreamID
typedef int32_t(DATA_FORMAT_Append_t))(void *pData
The interface function to append the data on the formated stream.
int16_t st_zp
#define FXLS8962_WHOAMI_VALUE
Definition: fxls8962.h:113
#define BOARD_DEBUG_UART_BAUDRATE
Definition: board.h:57
int16_t st_yp
const registerwritelist_t cFxls8962ConfigNormal2[]
Register settings for Interrupt (non buffered) mode.
ARM_DRIVER_I2C * pCommDrv
Definition: fxls8962_drv.h:73
Access structure of the GPIO Driver.
Definition: Driver_GPIO.h:64
#define FXLS8962_SENS_CONFIG2_ANIC_TEMP_MASK
Definition: fxls8962.h:519
void BOARD_SystickStart(int32_t *pStart)
Function to Record the Start systick.
Definition: systick_utils.c:79
ARM Systick Utilities.
void BOARD_RunADS(const char *appName, char *boardString, char *shieldString, size_t bufferLength)
The function to register Application Name and initialte ADS.
fxls8962_acceldataUser_t rawData
int32_t Register_I2C_Write(ARM_DRIVER_I2C *pCommDrv, registerDeviceInfo_t *devInfo, uint16_t slaveAddress, uint8_t offset, uint8_t value, uint8_t mask, bool repeatedStart)
The interface function to write a sensor register.
uint8_t Host_IO_Init(ARM_DRIVER_USART *pDrv, void *pBus, void *pDevInfo, void *spiSlaveParams, uint16_t slaveAddress)
Definition: host_io_uart.c:126
This structure defines the Write command List.
Definition: sensor_drv.h:94
int16_t st_dx
This structure defines the Read command List.
Definition: sensor_drv.h:104
#define SMC
Definition: lpc54114.h:144
The host_io_uart.h file contains the Host Protocol interface definitions and configuration.
#define FXLS8962_SENS_CONFIG1_ST_POL_POSITIVE
Definition: fxls8962.h:470
#define STREAMING_HEADER_LEN
Definition: host_io_uart.h:51
int32_t FXLS8962_I2C_ReadData(fxls8962_i2c_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer)
The interface function to read the sensor data.
Definition: fxls8962_drv.c:344
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:181
This structure defines the fxls8962 raw data buffer.
Definition: fxls8962_demo.c:78
#define FXLS8962_STREAM_SELF_TEST_SIZE
Definition: fxls8962_demo.c:69
#define FXLS8962_SENS_CONFIG1_ST_AXIS_SEL_DISABLED
Definition: fxls8962.h:465
#define FXLS8962_SENS_CONFIG1_FSR_MASK
Definition: fxls8962.h:446
#define APPLICATION_VERSION
Version to distinguish between instances the same application based on target Shield and updates...
Definition: fxls8962_demo.c:73
#define FXLS8962_INT_EN_DRDY_EN_EN
Definition: fxls8962.h:880
#define FXLS8962_SENS_CONFIG1_ST_POL_NEGATIVE
Definition: fxls8962.h:472
int main(void)
Main function.
#define I2C_S_SIGNAL_EVENT
Definition: issdk_hal.h:60
const registerwritelist_t cFxls8962STXP[]
Register settings for Self-Test in X Axis (Positive polarity).
#define HOST_S_DRIVER
Definition: frdm_k64f.h:119
volatile bool bStreamingEnabled
const registerwritelist_t cFxls896216G[]
char shieldString[ADS_MAX_STRING_LENGTH]