ISSDK  1.8
IoT Sensing Software Development Kit
fxls8962_demo.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 fxls8962_demo.c
11  * @brief The fxls8962_demo.c file implements the ISSDK FXLS8962 sensor
12  * demo example demonstration with interrupt mode.
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 "fxls8962_drv.h"
34 #include "host_io_uart.h"
35 #include "systick_utils.h"
36 #include "auto_detection_service.h"
37 
38 //-----------------------------------------------------------------------
39 // Macros
40 //-----------------------------------------------------------------------
41 #define FXLS8962_DATA_SIZE 8
42 #define FXLS8962_STREAM_DATA_SIZE 12
43 #define FXLS8962_STREAM_SELF_TEST_SIZE 18
44 /*! @brief Unique Name for this application which should match the target GUI pkg name. */
45 #define APPLICATION_NAME "FXLS8962 Accelerometer Demo"
46 /*! @brief Version to distinguish between instances the same application based on target Shield and updates. */
47 #define APPLICATION_VERSION "2.5"
48 #define HOST_CMD_RESET 6 /* 6 (Reset Sensor) */
49 #define HOST_CMD_SELFTEST 7 /* 7 (Self Test Sensor) */
50 
51 /*! @brief This structure defines the fxls8962 raw data buffer.*/
52 typedef struct
53 {
54  uint32_t timestamp; /*! The time, this sample was recorded. */
55  int16_t accel[3]; /*!< The accel data */
56  uint8_t sdcd;
57  int8_t temp;
58  int16_t selftest[3];
60 
61 //-----------------------------------------------------------------------
62 // Constants
63 //-----------------------------------------------------------------------
64 /*! @brief Register settings for Interrupt (non buffered) mode. */
66  /* Set Full-scale range as 4G. */
68  /* Clear SENS_CONFIG2 */
69  {FXLS8962_SENS_CONFIG2, 0x00, 0x00},
70  /* Disable Self-Test. */
72  /* Set Wake Mode ODR Rate as 12.5Hz. */
74  /* Enable Interrupts for Data Ready Events. */
76  /* Enable Temperature sensor. */
78  /* Set Self-Test ODR to 100 Hz. */
79  {0x38,0x05,0x00},
80  {0x2F,0x38,0x00},
81  {0x30,0xD8,0x00},
82  {0x33,0xC0,0x00},
83  {0x34,0x0F,0x00},
84  {0x35,0x40,0x00},
86 
87 /*! @brief Register settings for Interrupt (non buffered) mode. */
89  /* Disable Self-Test. */
91  /* Set Wake Mode ODR Rate as 12.5Hz. */
93  /* Enable Interrupts for Data Ready Events. */
95  /* Enable Temperature sensor. */
97  /* Set Self-Test ODR to 100 Hz. */
98  {0x38,0x05,0x00},
100 
102  /* Disable Self-Test. */
104  /* Set Full-scale range as 16G. */
106  /* Enable Interrupts for Data Ready Events. */
108  /* Enable Temperature sensor. */
110  /* Set Self-Test ODR to 100 Hz. */
111  {0x38,0x05,0x00},
113 
114 /*! @brief Register settings for Self-Test in X Axis (Positive polarity). */
116  /* Set Self Test Axis. */
121 
122 /*! @brief Register settings for Self-Test in X Axis (Negative polarity). */
124  /* Set Self Test Axis. */
129 
130 /*! @brief Register settings for Self-Test in Y Axis (Positive polarity). */
132  /* Set Self Test Axis. */
137 
138 /*! @brief Register settings for Self-Test in Y Axis (Negative polarity). */
140  /* Set Self Test Axis. */
145 
146 /*! @brief Register settings for Self-Test in Z Axis (Positive polarity). */
148  /* Set Self Test Axis. */
153 
154 /*! @brief Register settings for Self-Test in Z Axis (Negative polarity). */
156  /* Set Self Test Axis. */
161 
162 /*! @brief Address of Raw Accel Data in Normal Mode. */
165 
166 //-----------------------------------------------------------------------
167 // Global Variables
168 //-----------------------------------------------------------------------
171 volatile bool bStreamingEnabled = false, bFxls8962DataReady = false, bFxls8962Ready = false;
172 uint8_t gStreamID; /* The auto assigned Stream ID. */
178 int st_on =0, st_sample=0;
180 float fsr_scale;
181 
182 //-----------------------------------------------------------------------
183 // Functions
184 //-----------------------------------------------------------------------
185 /* This is the Sensor Data Ready ISR implementation.*/
186 void fxls8962_int_data_ready_callback(void *pUserData)
187 { /*! @brief Set flag to indicate Sensor has signalled data ready. */
188  bFxls8962DataReady = true;
189 }
190 
191 /* Handler for Device Info and Streaming Control Commands. */
193  uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse, size_t *hostMsgSize, size_t respBufferSize)
194 {
195  bool success = false;
196 
197  /* If it is Host requesting Device Info, send Board Name and Shield Name. */
198  if (tag == HOST_PRO_INT_DEV_TAG)
199  { /* Byte 1 : Payload - Length of APPLICATION_NAME (b)
200  * Bytes=b : Payload Application Name
201  * Byte b+1 : Payload - Length of BOARD_NAME (s)
202  * Bytes=s : Payload Board Name
203  * Byte b+s+2 : Payload - Length of SHIELD_NAME (v)
204  * Bytes=v : Payload Shield Name */
205 
206  size_t appNameLen = strlen(embAppName);
207  size_t boardNameLen = strlen(boardString);
208  size_t shieldNameLen = strlen(shieldString);
209 
210  if (respBufferSize >= boardNameLen + shieldNameLen + appNameLen + 3)
211  { /* We have sufficient buffer. */
212  *hostMsgSize = 0;
213  }
214  else
215  {
216  return false;
217  }
218 
219  hostResponse[*hostMsgSize] = appNameLen;
220  *hostMsgSize += 1;
221 
222  memcpy(hostResponse + *hostMsgSize, embAppName, appNameLen);
223  *hostMsgSize += appNameLen;
224 
225  hostResponse[*hostMsgSize] = boardNameLen;
226  *hostMsgSize += 1;
227 
228  memcpy(hostResponse + *hostMsgSize, boardString, boardNameLen);
229  *hostMsgSize += boardNameLen;
230 
231  hostResponse[*hostMsgSize] = shieldNameLen;
232  *hostMsgSize += 1;
233 
234  memcpy(hostResponse + *hostMsgSize, shieldString, shieldNameLen);
235  *hostMsgSize += shieldNameLen;
236 
237  return true;
238  }
239 
240  /* If it is Host sending Streaming Commands, take necessary actions. */
241  if ((tag == (HOST_PRO_INT_CMD_TAG | HOST_PRO_CMD_W_CFG_TAG)) &&
243  { /* Byte 1 : Payload - Operation Code (Start/Stop Operation Code)
244  * Byte 2 : Payload - Stream ID (Target Stream for carrying out operation) */
245  switch (hostCommand[0]) /* Execute desired operation (Start/Stop) on the requested Stream. */
246  {
247  case HOST_CMD_START:
248  if (hostCommand[1] == gStreamID && bFxls8962Ready && bStreamingEnabled == false)
249  {
251  bStreamingEnabled = true;
252  success = true;
253  }
254  break;
255  case HOST_CMD_STOP:
256  if (hostCommand[1] == gStreamID && bFxls8962Ready && bStreamingEnabled == true)
257  {
258  pGpioDriver->clr_pin(&GREEN_LED);
259  bStreamingEnabled = false;
260  success = true;
261  }
262  break;
263  case HOST_CMD_RESET:
264  if (hostCommand[1] == gStreamID && bFxls8962Ready)
265  {
266  do
267  {
268  status = FXLS8962_I2C_DeInit(&fxls8962Driver);
269  if (SENSOR_ERROR_NONE != status)
270  break;
273 
274  if (SENSOR_ERROR_NONE != status)
275  break;
276  status = FXLS8962_I2C_Configure(&fxls8962Driver, cFxls8962ConfigNormal2);
277  if (SENSOR_ERROR_NONE != status)
278  break;
279  success = true;
280  } while(0);
281  }
282  break;
283  case HOST_CMD_SELFTEST:
284  st_on=1;
285  st_sample=98;
286  rawData.selftest[0]=0;
287  rawData.selftest[1]=0;
288  rawData.selftest[2]=0;
289  /* Copy Raw samples to Streaming Buffer. */
291  /* Send streaming packet to Host. */
293  success = true;
294  break;
295  default:
296  break;
297  }
298  *hostMsgSize = 0; /* Zero payload in response. */
299  }
300 
301  if ((tag == (HOST_PRO_INT_CMD_TAG | HOST_PRO_CMD_W_REG_TAG)) && (*hostMsgSize >= 3))
302  {
303  /* If ODR set from GUI > 100 Hz set ODR to 100 Hz */
304  if(hostCommand[1]==0x17)
305  {
306  if(((hostCommand[2] & 0x0F)<5))
307  {
308  hostCommand[2]= ((hostCommand[2]&0xF0) | 0x05);
309  }
310  if((((hostCommand[2] & 0xF0)>>4)<5))
311  {
312  hostCommand[2]= ((hostCommand[2]&0x0F) | 0x50);
313  }
314  }
315 
316  /* Select the Sensitivity factor according to the FSR selected from the GUI*/
317  if(hostCommand[1]==0x15)
318  {
319  if(((hostCommand[2] & 0x06)==0x06))
320  {
321  fsr_scale=7.81;
322  }
323  if(((hostCommand[2] & 0x06)==0x04))
324  {
325  fsr_scale=3.91;
326  }
327  if(((hostCommand[2] & 0x06)==0x02))
328  {
329  fsr_scale=1.95;
330  }
331  if(((hostCommand[2] & 0x06)==0x00))
332  {
333  fsr_scale=0.98;
334  }
335  }
336 
337  /* If Self-Test ODR set from GUI > 100 Hz set ODR to 100 Hz */
338  if(hostCommand[1]==0x38 && hostCommand[2]<5)
339  {
340  hostCommand[2]=0x05;
341  }
342  if(hostCommand[1]==0x90)
343  {
344  st_on=1;
345  st_sample=98;
346  }
347  }
348  if ((tag == (HOST_PRO_INT_CMD_TAG | HOST_PRO_CMD_R_REG_TAG)) &&
349  (*hostMsgSize == 3))
350  {
351  /* Select the Sensitivity factor according to the FSR selected from the GUI*/
352  if(hostCommand[1]==0x15)
353  {
354  if((*hostResponse & 0x06)==0x06)
355  {
356  fsr_scale=7.81;
357  }
358  if((*hostResponse & 0x06)==0x04)
359  {
360  fsr_scale=3.91;
361  }
362  if((*hostResponse & 0x06)==0x02)
363  {
364  fsr_scale=1.95;
365  }
366  if((*hostResponse & 0x06)==0x00)
367  {
368  fsr_scale=0.98;
369  }
370  }
371  }
372  return success;
373 }
374 
375 /*!
376  * @brief Main function
377  */
378 int main(void)
379 {
380  int flag=0;
381  int32_t status;
383 
384  ARM_DRIVER_I2C *pI2cDriver = &I2C_S_DRIVER;
385  ARM_DRIVER_USART *pUartDriver = &HOST_S_DRIVER;
386 
387  /*! Initialize the MCU hardware. */
390 
391  /* Create the Short Application Name String for ADS. */
392  sprintf(embAppName, "%s:%s", APPLICATION_NAME, APPLICATION_VERSION);
393 
394  /* Run ADS. */
396 
397  /* Create the Full Application Name String for Device Info Response. */
399 
400  /*! Initialize FXLS8962 pin used by FRDM board */
402 
403  /*! Initialize RGB LED pin used by FRDM board */
404  pGpioDriver->pin_init(&GREEN_LED, GPIO_DIRECTION_OUT, NULL, NULL, NULL);
405 
406  /*! Initialize the I2C driver. */
407  status = pI2cDriver->Initialize(I2C_S_SIGNAL_EVENT);
408  if (ARM_DRIVER_OK != status)
409  {
410  return -1;
411  }
412 
413  /*! Set the I2C Power mode. */
414  status = pI2cDriver->PowerControl(ARM_POWER_FULL);
415  if (ARM_DRIVER_OK != status)
416  {
417  return -1;
418  }
419 
420  /*! Set the I2C bus speed. */
421  status = pI2cDriver->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
422  if (ARM_DRIVER_OK != status)
423  {
424  return -1;
425  }
426 
427  /*! Initialize the UART driver. */
428  status = pUartDriver->Initialize(HOST_S_SIGNAL_EVENT);
429  if (ARM_DRIVER_OK != status)
430  {
431  return -1;
432  }
433 
434  /*! Set the UART Power mode. */
435  status = pUartDriver->PowerControl(ARM_POWER_FULL);
436  if (ARM_DRIVER_OK != status)
437  {
438  return -1;
439  }
440 
441  /*! Set UART Baud Rate. */
442  status = pUartDriver->Control(ARM_USART_MODE_ASYNCHRONOUS, BOARD_DEBUG_UART_BAUDRATE);
443  if (ARM_DRIVER_OK != status)
444  {
445  return -1;
446  }
447 
448  /*! Initialize FXLS8962 sensor driver. */
451  if (SENSOR_ERROR_NONE == status)
452  {
453  /*! Set the task to be executed while waiting for I2C transactions to complete. */
455 
456  /*! Configure the FXLS8962 sensor. */
457  status = FXLS8962_I2C_Configure(&fxls8962Driver, cFxls8962ConfigNormal);
458  if (SENSOR_ERROR_NONE == status)
459  {
460  bFxls8962Ready = true;
461  }
462  }
463 
464  /*! Initialize streaming and assign a Stream ID. */
465  gStreamID =
466  Host_IO_Init(pUartDriver, (void *)fxls8962Driver.pCommDrv, &fxls8962Driver.deviceInfo, NULL, FXLS8962_I2C_ADDR);
467  /* Confirm if a valid Stream ID has been allocated for this stream. */
468  if (0 == gStreamID)
469  {
470  bFxls8962Ready = false;
471  }
472  else
473  {
474  /*! Populate streaming header. */
477  pGpioDriver->clr_pin(&GREEN_LED);
478  }
479 
480  rawData.selftest[0]=0;
481  rawData.selftest[1]=0;
482  rawData.selftest[2]=0;
483 
484  for (;;) /* Forever loop */
485  { /* Call UART Non-Blocking Receive. */
486  /* If Self-Test is selected*/
487  if(st_on)
488  { /* Call UART Non-Blocking Receive. */
490  switch(st_sample)
491  {
492  case 98:
493  status =FXLS8962_I2C_Configure(&fxls8962Driver, cFxls896216G); /* Configure 16G mode*/
494  break;
495  case 100:
496  status = FXLS8962_I2C_Configure(&fxls8962Driver, cFxls8962STXP);/* Enable Self-Test +X Axis*/
497  break;
498  case 200:
499  status = FXLS8962_I2C_Configure(&fxls8962Driver, cFxls8962STXN);/* Enable Self-Test -X Axis*/
500  break;
501  case 300:
502  status = FXLS8962_I2C_Configure(&fxls8962Driver, cFxls8962STYP);/* Enable Self-Test +Y Axis*/
503  break;
504  case 400:
505  status = FXLS8962_I2C_Configure(&fxls8962Driver, cFxls8962STYN);/* Enable Self-Test -Y Axis*/
506  break;
507  case 500:
508  status = FXLS8962_I2C_Configure(&fxls8962Driver, cFxls8962STZP);/* Enable Self-Test +Z Axis*/
509  break;
510  case 600:
511  status = FXLS8962_I2C_Configure(&fxls8962Driver, cFxls8962STZN);/* Enable Self-Test -Z Axis*/
512  break;
513  }
514  /* Process packets only if streaming has been enabled by Host and ISR is available.
515  * In ISR Mode we do not need to check Data Ready Register.
516  * The receipt of interrupt will indicate data is ready. */
517  if (false == bStreamingEnabled || false == bFxls8962DataReady)
518  {
519  SMC_SetPowerModeWait(SMC); /* Power save, wait if nothing to do. */
520  continue;
521  }
522  else
523  { /*! Clear the data ready flag, it will be set again by the ISR. */
524  bFxls8962DataReady = false;
525  pGpioDriver->toggle_pin(&GREEN_LED);
526  }
527 
528  /* Place device in Standby mode after acquiring close to 100 samples */
529  switch(st_sample)
530  {
531  case 99:
532  Register_I2C_Write(&I2C_S_DRIVER,&(fxls8962Driver.deviceInfo),0x18, 0x15,0x00,0x00,0x00);
533  break;
534  case 199:
535  Register_I2C_Write(&I2C_S_DRIVER,&(fxls8962Driver.deviceInfo),0x18, 0x15,0x00,0x00,0x00);
536  break;
537  case 299:
538  Register_I2C_Write(&I2C_S_DRIVER,&(fxls8962Driver.deviceInfo),0x18, 0x15,0x00,0x00,0x00);
539  break;
540  case 399:
541  Register_I2C_Write(&I2C_S_DRIVER,&(fxls8962Driver.deviceInfo),0x18, 0x15,0x00,0x00,0x00);
542  break;
543  case 499:
544  Register_I2C_Write(&I2C_S_DRIVER,&(fxls8962Driver.deviceInfo),0x18, 0x15,0x00,0x00,0x00);
545  break;
546  case 599:
547  Register_I2C_Write(&I2C_S_DRIVER,&(fxls8962Driver.deviceInfo),0x18, 0x15,0x00,0x00,0x00);
548  break;
549  }
550  /*! Read new raw sensor data from the FXLS8962. */
551  status = FXLS8962_I2C_ReadData(&fxls8962Driver, cFxls8962OutputNormal, data);
552  if (ARM_DRIVER_OK != status)
553  { /* Loop, if sample read failed. */
554  continue;
555  }
556 
557  /* Update timestamp from Systick framework. */
559 
560  /*! Convert the raw sensor data to signed 16-bit container for display to the debug port. */
561  rawData.accel[0] = (int16_t)(((int16_t)(((int16_t)data[3] << 8) | data[2]))); /*7.81 is the scale factor for 16 G mode */
562  rawData.accel[1] = (int16_t)(((int16_t)(((int16_t)data[5] << 8) | data[4])));
563  rawData.accel[2] = (int16_t)(((int16_t)(((int16_t)data[7] << 8) | data[6])));
564 
565  switch(st_sample)
566  {
567  case 100:
568  st_xp = (int16_t)(((int16_t)data[3] << 8) | data[2]);
570  break;
571  case 200:
572  st_xn = (int16_t)(((int16_t)data[3] << 8) | data[2]);
574  break;
575  case 300:
576  st_yp = (int16_t)(((int16_t)data[5] << 8) | data[4]);
578  break;
579  case 400:
580  st_yn = (int16_t)(((int16_t)data[5] << 8) | data[4]);
582  break;
583  case 500:
584  st_zp = (int16_t)(((int16_t)data[7] << 8) | data[6]);
586  break;
587  case 600:
588  st_zn = (int16_t)(((int16_t)data[7] << 8) | data[6]);
590  break;
591  case 700: /* Calculate Self-Test output */
592  rawData.selftest[0] =(st_xp-st_xn)/2;
593  rawData.selftest[1] =(st_yp-st_yn)/2;
594  rawData.selftest[2] =(st_zp-st_zn)/2;
595  st_on=0;
596  st_sample=98;
597  flag=1;
598  status = FXLS8962_I2C_Configure(&fxls8962Driver, cFxls896216G);
599  break;
600  default:
602  break;
603  }
604 
605  rawData.temp = data[1]+25;
606  rawData.sdcd = (data[0] & 0x10)>>4;
607 
608  /* Copy Raw samples to Streaming Buffer. */
611  }
612  else
613  {
614  /* Call UART Non-Blocking Receive. */
616 
617  /* Process packets only if streaming has been enabled by Host and ISR is available.
618  * In ISR Mode we do not need to check Data Ready Register.
619  * The receipt of interrupt will indicate data is ready. */
620  if (false == bStreamingEnabled || false == bFxls8962DataReady)
621  {
622  SMC_SetPowerModeWait(SMC); /* Power save, wait if nothing to do. */
623  continue;
624  }
625  else
626  { /*! Clear the data ready flag, it will be set again by the ISR. */
627  bFxls8962DataReady = false;
628  pGpioDriver->toggle_pin(&GREEN_LED);
629  }
630 
631  /*! Read new raw sensor data from the FXLS8962. */
632  status= FXLS8962_I2C_ReadData(&fxls8962Driver, cFxls8962OutputNormal, data);
633 
634  if (ARM_DRIVER_OK != status)
635  { /* Loop, if sample read failed. */
636  continue;
637  }
638 
639  /* Update timestamp from Systick framework. */
641 
642  /*! Convert the raw sensor data to signed 16-bit container for display to the debug port. */
643  rawData.accel[0] = (int16_t)(((int16_t)(((int16_t)data[3] << 8) | data[2])));
644  rawData.accel[1] = (int16_t)(((int16_t)(((int16_t)data[5] << 8) | data[4])));
645  rawData.accel[2] = (int16_t)(((int16_t)(((int16_t)data[7] << 8) | data[6])));
646 
647  rawData.temp = data[1]+25;
648  rawData.sdcd = (data[0] & 0x10)>>4;
649 
650  /* Copy Raw samples to Streaming Buffer. */
651  memcpy(streamingPacket + STREAMING_HEADER_LEN, &rawData, FXLS8962_STREAM_DATA_SIZE);
652  /* Send streaming packet to Host. */
653  Host_IO_Send(streamingPacket, sizeof(streamingPacket), HOST_FORMAT_HDLC);
654 
655  if(flag==1) /*Reset Self-Test Values */
656  {
657  rawData.selftest[0]=0;
658  rawData.selftest[1]=0;
659  rawData.selftest[2]=0;
660  flag=0;
661  }
662  }
663  }
664 }
int16_t st_dx
const registerwritelist_t cFxls8962STZN[]
Register settings for Self-Test in Z Axis (Negative polarity).
GENERIC_DRIVER_GPIO * pGpioDriver
#define FXLS8962_INT_EN_DRDY_EN_EN
Definition: fxls8962.h:857
int16_t st_yp
int32_t gSystick
uint8_t Host_IO_Init(ARM_DRIVER_USART *pDrv, void *pBus, void *pDevInfo, void *spiSlaveParams, uint16_t slaveAddress)
Definition: host_io_uart.c:100
int st_sample
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
const registerwritelist_t cFxls8962STYP[]
Register settings for Self-Test in Y Axis (Positive polarity).
#define HOST_PRO_CMD_R_REG_TAG
Definition: host_io_uart.h:66
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 FXLS8962_SENS_CONFIG1_ST_AXIS_SEL_EN_Z
Definition: fxls8962.h:446
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.
const registerwritelist_t cFxls8962STZP[]
Register settings for Self-Test in Z Axis (Positive polarity).
The host_io_uart.h file contains the Host Protocol interface definitions and configuration.
The fxls8962_drv.h file describes the FXLS8962AF driver interface and structures. ...
volatile bool bFxls8962DataReady
#define FXLS8962_SENS_CONFIG2_ANIC_TEMP_MASK
Definition: fxls8962.h:496
#define FXLS8962_INT1
int16_t st_xp
const registerwritelist_t cFxls8962ConfigNormal[]
Register settings for Interrupt (non buffered) mode.
Definition: fxls8962_demo.c:65
#define FXLS8962_SENS_CONFIG1_FSR_16G
Definition: fxls8962.h:459
#define FXLS8962_INT_EN_DRDY_EN_MASK
Definition: fxls8962.h:850
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:240
#define HOST_PRO_CMD_W_CFG_TAG
Definition: host_io_uart.h:63
int16_t st_yn
Access structure of the GPIO Driver.
Definition: Driver_GPIO.h:38
#define SMC
Definition: lpc54114.h:118
#define FXLS8962_SENS_CONFIG1_ST_POL_MASK
Definition: fxls8962.h:429
const registerreadlist_t cFxls8962OutputNormal[]
Address of Raw Accel Data in Normal Mode.
void fxls8962_int_data_ready_callback(void *pUserData)
const registerwritelist_t cFxls8962STXP[]
Register settings for Self-Test in X Axis (Positive polarity).
float fsr_scale
#define __END_WRITE_DATA__
Definition: sensor_drv.h:45
int st_on
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.
#define HOST_S_SIGNAL_EVENT
Definition: frdm_k64f.h:94
int32_t status
#define FXLS8962_SENS_CONFIG3_WAKE_ODR_MASK
Definition: fxls8962.h:551
This defines the sensor specific information for I2C.
Definition: fxls8962_drv.h:44
#define I2C_S_SIGNAL_EVENT
Definition: issdk_hal.h:34
#define I2C_S_DRIVER
Definition: issdk_hal.h:33
int main(void)
Main function.
void Host_IO_Add_ISO_Header(uint8_t streamID, uint8_t *pStreamingPacket, size_t sizePayload)
Definition: host_io_uart.c:86
bool process_host_command(uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse, size_t *hostMsgSize, size_t respBufferSize)
#define HOST_PRO_CMD_W_REG_TAG
Definition: host_io_uart.h:65
#define BOARD_DEBUG_UART_BAUDRATE
Definition: board.h:31
#define BOARD_BootClockRUN
Definition: clock_config.h:19
uint8_t gStreamID
fxls8962_i2c_sensorhandle_t fxls8962Driver
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
Definition: sensor_drv.h:97
int16_t st_dy
#define HOST_CMD_RESET
Definition: fxls8962_demo.c:48
#define FXLS8962_SENS_CONFIG3_WAKE_ODR_12_5HZ
Definition: fxls8962.h:565
uint8_t streamingPacket[STREAMING_HEADER_LEN+FXLS8962_STREAM_DATA_SIZE]
GENERIC_DRIVER_GPIO Driver_GPIO_KSDK
Definition: gpio_driver.c:177
void Host_IO_Send(uint8_t *pMsg, size_t size, uint8_t encoding)
Definition: host_io_uart.c:136
#define FXLS8962_SENS_CONFIG1_ST_POL_POSITIVE
Definition: fxls8962.h:447
void BOARD_SystickStart(int32_t *pStart)
Function to Record the Start systick.
Definition: systick_utils.c:44
const registerwritelist_t cFxls896216G[]
const registerwritelist_t cFxls8962STXN[]
Register settings for Self-Test in X Axis (Negative polarity).
const registerwritelist_t cFxls8962STYN[]
Register settings for Self-Test in Y Axis (Negative polarity).
#define FXLS8962_SENS_CONFIG1_ST_AXIS_SEL_DISABLED
Definition: fxls8962.h:442
uint32_t BOARD_SystickElapsedTime_us(int32_t *pStart)
Function to compute the Elapsed Time.
Definition: systick_utils.c:64
int32_t FXLS8962_I2C_DeInit(fxls8962_i2c_sensorhandle_t *pSensorHandle)
The interface function to De Initialize sensor..
Definition: fxls8962_drv.c:360
int16_t st_zp
uint8_t data[FXLS8962_DATA_SIZE]
#define FXLS8962_DATA_SIZE
Definition: fxls8962_demo.c:41
#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 FXLS8962_SENS_CONFIG1_ST_AXIS_SEL_MASK
Definition: fxls8962.h:432
uint8_t streamingPacket1[STREAMING_HEADER_LEN+FXLS8962_STREAM_SELF_TEST_SIZE]
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:331
int16_t st_zn
This structure defines the fxls8962 raw data buffer.
Definition: fxls8962_demo.c:52
volatile bool bFxls8962Ready
#define HOST_CMD_SELFTEST
Definition: fxls8962_demo.c:49
#define FXLS8962_STREAM_DATA_SIZE
Definition: fxls8962_demo.c:42
uint16_t readFrom
Definition: sensor_drv.h:80
const registerwritelist_t cFxls8962ConfigNormal2[]
Register settings for Interrupt (non buffered) mode.
Definition: fxls8962_demo.c:88
char boardString[ADS_MAX_STRING_LENGTH]
ARM_DRIVER_I2C * pCommDrv
Definition: fxls8962_drv.h:47
#define FXLS8962_SENS_CONFIG1_ST_POL_NEGATIVE
Definition: fxls8962.h:449
void(* toggle_pin)(pinID_t aPinId)
Definition: Driver_GPIO.h:48
#define ADS_MAX_STRING_LENGTH
#define FXLS8962_STREAM_SELF_TEST_SIZE
Definition: fxls8962_demo.c:43
void BOARD_SystickEnable(void)
Function to enable systicks framework.
Definition: systick_utils.c:35
int16_t st_xn
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:286
#define STREAMING_HEADER_LEN
Definition: host_io_uart.h:25
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 FXLS8962_SENS_CONFIG1_FSR_4G
Definition: fxls8962.h:455
char embAppName[ADS_MAX_STRING_LENGTH]
void(* pin_init)(pinID_t aPinId, gpio_direction_t dir, void *apPinConfig, gpio_isr_handler_t aIsrHandler, void *apUserData)
Definition: Driver_GPIO.h:41
#define FXLS8962_SENS_CONFIG2_ANIC_TEMP_EN
Definition: fxls8962.h:521
This structure defines the Read command List.
Definition: sensor_drv.h:78
ARM Systick Utilities.
#define FXLS8962_SENS_CONFIG1_FSR_MASK
Definition: fxls8962.h:423
gpioHandleKSDK_t GREEN_LED
Definition: frdm_k64f.c:188
#define I2C_S_DEVICE_INDEX
Definition: issdk_hal.h:35
#define APPLICATION_NAME
Unique Name for this application which should match the target GUI pkg name.
Definition: fxls8962_demo.c:45
fxls8962_acceldataUser_t rawData
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:278
#define FXLS8962_I2C_ADDR
fxls896x_selftest_t selftest
#define APPLICATION_VERSION
Version to distinguish between instances the same application based on target Shield and updates...
Definition: fxls8962_demo.c:47
#define FXLS8962_WHOAMI_VALUE
Definition: fxls8962.h:87
#define HOST_PRO_INT_CMD_TAG
Bit aligned values for Host Protocol Interface IDs (Bits 5-6).
Definition: host_io_uart.h:57
#define SHIELD_NAME
#define FXLS8962_SENS_CONFIG1_ST_AXIS_SEL_EN_X
Definition: fxls8962.h:444
volatile bool bStreamingEnabled
#define FXLS8962_SENS_CONFIG1_ST_AXIS_SEL_EN_Y
Definition: fxls8962.h:445
char shieldString[ADS_MAX_STRING_LENGTH]
registerDeviceInfo_t deviceInfo
Definition: fxls8962_drv.h:46
#define HOST_S_DRIVER
Definition: frdm_k64f.h:93