ISSDK  1.8
IoT Sensing Software Development Kit
fxls896xaf_freemaster_demo.c
Go to the documentation of this file.
1 /*
2  * Copyright 2021 NXP
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 
8 /**
9  * @file fxls896xaf_freemaster_demo.c
10  * @brief The fxls896xaf_freemaster_demo.c file implements FreeMASTER demo using the ISSDK
11  * FXLS896xAF sensor driver example demonstration with interrupt mode.
12  */
13 
14 //-----------------------------------------------------------------------
15 // SDK Includes
16 //-----------------------------------------------------------------------
17 #include "pin_mux.h"
18 #include "clock_config.h"
19 #include "board.h"
20 #include "fsl_debug_console.h"
21 #include "math.h"
22 #include "fsl_uart.h"
23 #include "fsl_common.h"
24 #include "freemaster.h"
25 #include "freemaster_serial_uart.h"
26 //-----------------------------------------------------------------------
27 // CMSIS Includes
28 //-----------------------------------------------------------------------
29 #include "Driver_I2C.h"
30 
31 //-----------------------------------------------------------------------
32 // ISSDK Includes
33 //-----------------------------------------------------------------------
34 #include "issdk_hal.h"
35 #include "gpio_driver.h"
36 #include "fxls896x_drv.h"
37 #include "systick_utils.h"
38 
39 //-----------------------------------------------------------------------
40 // Macros
41 //-----------------------------------------------------------------------
42 #define FXLS896x_NUM_REGISTERS (FXLS896x_SELF_TEST_CONFIG2 + 1)
43 #define FF_A_FFMT_THS (0x08) /* FreeFall Threshold Value. */
44 #define A_FFMT_COUNT (0x18) /* Freefall/motion debounce count value. */
45 #define PL_COUNT (0x15) /* Pulse debounce count value. */
46 #define ASLP_COUNTER (0x07) /* Auto Sleep after ~5s. */
47 #define ACCEL_2G_SENS (0.000976) /* Sensitivity factor for 2G FS */
48 #define ACCEL_4G_SENS (0.001953) /* Sensitivity factor for 4G FS */
49 #define ACCEL_8G_SENS (0.003906) /* Sensitivity factor for 8G FS */
50 #define ACCEL_16G_SENS (0.007813) /* Sensitivity factor for 16G FS */
51 #define N (100U) /* Number of samples used to measure offset/noise */
52 #define RAW_ACCEL_DATA_SIZE (6U) /* Accel Data Size */
53 #define MAX8BITSTORAGE (255U)
54 #define FXLS896x_DATA_SIZE 6
55 //-----------------------------------------------------------------------
56 // Constants
57 //-----------------------------------------------------------------------
58 /*! @brief Defines the register write list to configure FXLS896x in Interrupt mode. */
60  /*! Set Full-scale range as 4G. */
62  /*! Clear SENS_CONFIG2 */
63  {FXLS896x_SENS_CONFIG2, 0x00, 0x00},
64  /*! Disable Self-Test. */
66  /*! Set Wake Mode ODR Rate as 12.5Hz. */
68  /*! Enable Interrupts for Data Ready Events. */
70  /*! Enable Temperature sensor. */
72  /*! Set Self-Test ODR to 100 Hz. */
73  {0x38,0x05,0x00},
74  {0x2F,0x38,0x00},
75  {0x30,0xD8,0x00},
76  {0x33,0xC0,0x00},
77  {0x34,0xFF,0x00},
78  {0x35,0x40,0x00},
80 
81 /*! @brief Register settings for Self-Test in X Axis (Positive polarity). */
83  /* Set Self Test Axis. */
88 
89 /*! @brief Register settings for Self-Test in X Axis (Negative polarity). */
91  /* Set Self Test Axis. */
96 
97 /*! @brief Register settings for Self-Test in Y Axis (Positive polarity). */
99  /* Set Self Test Axis. */
104 
105 /*! @brief Register settings for Self-Test in Y Axis (Negative polarity). */
107  /* Set Self Test Axis. */
112 
113 /*! @brief Register settings for Self-Test in Z Axis (Positive polarity). */
115  /* Set Self Test Axis. */
120 
121 /*! @brief Register settings for Self-Test in Z Axis (Negative polarity). */
123  /* Set Self Test Axis. */
128 
129 /*! @brief Address of Raw Accel Data in Normal Mode. */
132 
134  {.readFrom = FXLS896x_WHO_AM_I, .numBytes = 1}, __END_READ_DATA__};
135 
136 /*! @brief Prepare the register read for INT Status Register. */
138  {.readFrom = FXLS896x_INT_STATUS, .numBytes = 1}, __END_READ_DATA__};
139 
140 /*! @brief Prepare the register read for FullScale range Register. */
142  {.readFrom = FXLS896x_SENS_CONFIG1, .numBytes = 1}, __END_READ_DATA__};
143 
144 /*! @brief FXLS896x register list to read all registers */
147 
148 //-----------------------------------------------------------------------
149 // Global Variables
150 //-----------------------------------------------------------------------
151 /*! @brief This structure defines the fxls896x all registers metadata.*/
152 typedef struct
153 {
154  uint8_t offset;
155  uint8_t value;
156  uint8_t trigger;
157  uint8_t read_offset;
158  uint8_t read_value;
159  uint8_t read_trigger;
160  uint8_t readall_value[FXLS896x_NUM_REGISTERS];
161  uint8_t readall_size;
162  uint8_t readall_trigger;
163  uint8_t toggle;
164  uint8_t trigger_accel_offnoise;
165  uint8_t trigger_selftest;
166  uint8_t fs_value;
167  uint8_t mods_value;
168  uint8_t odr_value;
169  uint8_t reg_addr[FXLS896x_NUM_REGISTERS];
170  uint8_t dataready_cntr;
171  float accel[3];
172  int16_t accelraw[3];
173  uint8_t sdcd;
174  int8_t temp;
175  int16_t selftest[3];
176  uint32_t timestamp;
178 //-----------------------------------------------------------------------
179 /*! @brief This structure defines the fxls896x offset and noise calculation parameters. */
180 typedef struct
181 {
182  float offx;
183  float offy;
184  float offz;
185  float rmsx;
186  float rmsy;
187  float rmsz;
188  uint8_t complete_accel_offnoise;
190 
191 /*! @brief This structure defines variables to compute self-test output change (STOC) and self-test offset (STOF). */
192 typedef struct
193 {
194  int16_t x_stoc;
195  int16_t y_stoc;
196  int16_t z_stoc;
197  int16_t x_stof;
198  int16_t y_stof;
199  int16_t z_stof;
200  uint8_t complete_selftest;
202 
203 /*! @brief This structure defines the fxls896x raw data buffer.*/
204 typedef struct
205 {
206  int16_t xdata; /*!< The x accel data */
207  int16_t ydata; /*!< The y accel data */
208  int16_t zdata; /*!< The z accel data */
209 } sensor_data;
210 
211 
212 typedef union rawdata
213 {
214  uint8_t byte_data[sizeof(sensor_data)];
216 }RAW_DATA;
217 
218 /*! @brief This structure defines the fxls896x host operation type.*/
220 {
225 
227 
228 /*******************************************************************************
229  * Globals
230  ******************************************************************************/
231 
236 uint8_t prev_toggle = 1;
237 volatile bool bFxls896xIntFlag = false;
238 
239 static FMSTR_U8 recBuffer[1024*10];
240 FMSTR_REC_BUFF recBuffCfg;
241 FMSTR_REC_VAR recVar;
242 FMSTR_REC_CFG recCfg;
243 
245 static unsigned char pipe3_rxb[512];
246 static unsigned char pipe3_txb[0x1000];
247 
248 uint8_t axis=0;
249 /* variables to store self-test values (Positive(P) + / Negative(N) -) */
250 int16_t XSTP[2]={0,0},YSTP[2]={0,0},ZSTP[2]={0,0},XSTN[2]={0,0},YSTN[2]={0,0},ZSTN[2]={0,0};
251 
252 
253 /*******************************************************************************
254  * Local functions
255  ******************************************************************************/
256  /*! @brief Function to initialize target communication to FreeMASTER host.
257  * @details This function initializes FreeMASTER UART communication.
258  * @param[in] void.
259  * @return void.
260  */
261 static void init_freemaster_uart(void);
262 /*! @brief ISR for FXLS896x interrupt source event.
263  * @details This function implements ISR for FXLS896x INT source.
264  * @param[in] void *.
265  * @return void.
266  */
267 void fxls896x_isr_callback(void *pUserData);
268 /*! @brief Function to apply FXLS896x register write operation.
269  * @details This function apply FXLS896x register write based on write trigger from host.
270  * @param[in] fxls896x_i2c_sensorhandle_t fxls896xDriver, FXLS896x sensor I2C handle.
271  * @param[in] uint8_t offset, the address of the register to start writing from.
272  * @param[in] uint8_t value, value to write on register offset.
273  * @return returns the status of the operation.
274  */
276 /*! @brief Function to apply FXLS896x register read operation.
277  * @details This function apply FXLS896x register read based on read trigger from host.
278  * @param[in] fxls896x_i2c_sensorhandle_t fxls896xDriver, FXLS896x sensor I2C handle.
279  * @param[in] uint8_t offset, the address of the register to read from.
280  * @param[in/out] uint8_t *value, pointer to output buffer.
281  * @return returns the status of the operation.
282  */
283 int32_t apply_register_read(fxls896x_i2c_sensorhandle_t fxls896xDriver, uint8_t offset, uint8_t *value);
284 /*! @brief Function to apply FXLS896x register read-all operation.
285  * @details This function apply FXLS896x all-registers read based on read-all trigger from host.
286  * @param[in] fxls896x_i2c_sensorhandle_t fxls896xDriver, FXLS896x sensor I2C handle.
287  * @return returns the status of the operation.
288  */
290 /*! @brief Function to update dropdown selection.
291  * @details This function updates the dropdown selection values in real-time based on read/write/read-all triggers.
292  * @param[in/out] fxls896x_allregs_t *registers, pointer to FXLS896x all-registers metadata.
293  * @param[in] uint8_t caller, called from which operation type.
294  * @return returns the status of the operation.
295  */
296 int32_t update_dropdown_selection(fxls896x_allregs_t *registers, uint8_t caller);
297 /*! @brief Function to initialize offset noise measurement.
298  * @details This function initializes offset noise measurement metadata.
299  * @param[in/out] fxls896x_offset_noise_t *offnoiseptr, pointer to FXLS896x offset noise metadata.
300  * @return void.
301  */
302 void offset_noise_init(fxls896x_offset_noise_t *offnoiseptr);
303 /*! @brief Function to measure accelerometer offset noise.
304  * @details This function measures accelerometer offset noise.
305  * @param[in] fxls896x_acceldata_t *rawData, pointer to FXLS896x rawdata metadata.
306  * @param[in/out] fxls896x_offset_noise_t *offnoiseptr, pointer to FXLS896x offset noise metadata.
307  * @param[in] float sens, FXLS896x sensitivity based on FS configuration.
308  * @return void.
309  */
310 void accel_off_noise(fxls896x_acceldata_t* rawData, fxls896x_offset_noise_t *offnoiseptr, float sens);
311 /*! @brief Function to initialize FXLS896x self test metadata.
312  * @details This function initializes FXLS896x self test metadata.
313  * @param[in/out] fxls896x_selftest_t *selftest, pointer to FXLS896x selftest metadata.
314  * @return void.
315  */
316 void selftest_init(fxls896x_selftest_t *selftest);
317 /*! @brief Function to perform FXLS896x self test.
318  * @details This function performs FXLS896x self test.
319  * @param[in] fxls896x_i2c_sensorhandle_t fxls896xDriver, FXLS896x sensor I2C handle.
320  * @param[in/out] fxls896x_selftest_t *selftest, pointer to FXLS896x selftest metadata.
321  * @return returns the status of the operation..
322  */
324 void FRM_Recorder_Init();
325 
326 /*******************************************************************************
327  * Code
328  ******************************************************************************/
329 void fxls896x_isr_callback(void *pUserData)
330 { /*! @brief Set flag to indicate Sensor has signalled data ready. */
331  bFxls896xIntFlag = true;
332 }
333 
334 /* Create TSA table and add output variables. */
335 /*!
336  * @brief Target Side Addressable (TSA) table created for this application.
337  */
339  FMSTR_TSA_STRUCT(fxls896x_acceldata_t)
340 
341  FMSTR_TSA_STRUCT(fxls896x_allregs_t)
342  FMSTR_TSA_MEMBER(fxls896x_allregs_t, offset, FMSTR_TSA_UINT8)
343  FMSTR_TSA_MEMBER(fxls896x_allregs_t, value, FMSTR_TSA_UINT8)
344  FMSTR_TSA_MEMBER(fxls896x_allregs_t, trigger, FMSTR_TSA_UINT8)
345  FMSTR_TSA_MEMBER(fxls896x_allregs_t, read_offset, FMSTR_TSA_UINT8)
346  FMSTR_TSA_MEMBER(fxls896x_allregs_t, read_value, FMSTR_TSA_UINT8)
347  FMSTR_TSA_MEMBER(fxls896x_allregs_t, read_trigger, FMSTR_TSA_UINT8)
348  FMSTR_TSA_MEMBER(fxls896x_allregs_t, readall_value, FMSTR_TSA_UINT8)
349  FMSTR_TSA_MEMBER(fxls896x_allregs_t, readall_size, FMSTR_TSA_UINT8)
350  FMSTR_TSA_MEMBER(fxls896x_allregs_t, readall_trigger, FMSTR_TSA_UINT8)
351  FMSTR_TSA_MEMBER(fxls896x_allregs_t, trigger_accel_offnoise, FMSTR_TSA_UINT8)
352  FMSTR_TSA_MEMBER(fxls896x_allregs_t, trigger_selftest, FMSTR_TSA_UINT8)
353  FMSTR_TSA_MEMBER(fxls896x_allregs_t, fs_value, FMSTR_TSA_UINT8)
354  FMSTR_TSA_MEMBER(fxls896x_allregs_t, mods_value, FMSTR_TSA_UINT8)
355  FMSTR_TSA_MEMBER(fxls896x_allregs_t, odr_value, FMSTR_TSA_UINT8)
356  FMSTR_TSA_MEMBER(fxls896x_allregs_t, toggle, FMSTR_TSA_UINT8)
357  FMSTR_TSA_MEMBER(fxls896x_allregs_t, reg_addr, FMSTR_TSA_UINT8)
358  FMSTR_TSA_MEMBER(fxls896x_allregs_t, accel, FMSTR_TSA_FLOAT)
359  FMSTR_TSA_MEMBER(fxls896x_allregs_t, accelraw, FMSTR_TSA_SINT16)
360  FMSTR_TSA_MEMBER(fxls896x_allregs_t, sdcd, FMSTR_TSA_UINT8)
361  FMSTR_TSA_MEMBER(fxls896x_allregs_t, temp, FMSTR_TSA_SINT8)
362  FMSTR_TSA_MEMBER(fxls896x_allregs_t, selftest, FMSTR_TSA_SINT16)
363  FMSTR_TSA_MEMBER(fxls896x_allregs_t, dataready_cntr, FMSTR_TSA_UINT8)
364  FMSTR_TSA_MEMBER(fxls896x_allregs_t, timestamp, FMSTR_TSA_UINT32)
365 
366  FMSTR_TSA_STRUCT(fxls896x_offset_noise_t)
367  FMSTR_TSA_MEMBER(fxls896x_offset_noise_t, offx, FMSTR_TSA_FLOAT)
368  FMSTR_TSA_MEMBER(fxls896x_offset_noise_t, offy, FMSTR_TSA_FLOAT)
369  FMSTR_TSA_MEMBER(fxls896x_offset_noise_t, offz, FMSTR_TSA_FLOAT)
370  FMSTR_TSA_MEMBER(fxls896x_offset_noise_t, rmsx, FMSTR_TSA_FLOAT)
371  FMSTR_TSA_MEMBER(fxls896x_offset_noise_t, rmsy, FMSTR_TSA_FLOAT)
372  FMSTR_TSA_MEMBER(fxls896x_offset_noise_t, rmsz, FMSTR_TSA_FLOAT)
373  FMSTR_TSA_MEMBER(fxls896x_offset_noise_t, complete_accel_offnoise, FMSTR_TSA_UINT8)
374 
375 
376  FMSTR_TSA_STRUCT(fxls896x_selftest_t)
377  FMSTR_TSA_MEMBER(fxls896x_selftest_t, x_stoc, FMSTR_TSA_SINT16)
378  FMSTR_TSA_MEMBER(fxls896x_selftest_t, y_stoc, FMSTR_TSA_SINT16)
379  FMSTR_TSA_MEMBER(fxls896x_selftest_t, z_stoc, FMSTR_TSA_SINT16)
380  FMSTR_TSA_MEMBER(fxls896x_selftest_t, x_stof, FMSTR_TSA_SINT16)
381  FMSTR_TSA_MEMBER(fxls896x_selftest_t, y_stof, FMSTR_TSA_SINT16)
382  FMSTR_TSA_MEMBER(fxls896x_selftest_t, z_stof, FMSTR_TSA_SINT16)
383  FMSTR_TSA_MEMBER(fxls896x_selftest_t, complete_selftest, FMSTR_TSA_UINT8)
384 
385  FMSTR_TSA_RO_VAR(rawData, FMSTR_TSA_USERTYPE(fxls896x_acceldata_t))
386 
387  FMSTR_TSA_RW_VAR(registers, FMSTR_TSA_USERTYPE(fxls896x_allregs_t))
388 
389  FMSTR_TSA_RO_VAR(offnoise_data, FMSTR_TSA_USERTYPE(fxls896x_offset_noise_t))
390 
391  FMSTR_TSA_RO_VAR(selftest, FMSTR_TSA_USERTYPE(fxls896x_selftest_t))
392 
393 FMSTR_TSA_TABLE_END()
394 
395 FMSTR_TSA_TABLE_LIST_BEGIN()
396  FMSTR_TSA_TABLE(main_table)
397 FMSTR_TSA_TABLE_LIST_END()
398 
399 /*!
400  * @brief FreeMASTER recorder initialization
401  */
402 void FRM_Recorder_Init()
403 {
404  /* Do local configuration of additional recorder */
405 
406  /* Setup the additional recorder raw buffer */
407  recBuffCfg.addr = recBuffer;
408  recBuffCfg.size = sizeof(recBuffer);
409  recBuffCfg.basePeriod_ns = 0; /* Unknown period */
410  recBuffCfg.name = "FXLS896x 3-Axis Accelerometer Data";
411 
412  FMSTR_RecorderCreate(1, &recBuffCfg);
413 }
414 
415 /*!
416  * @brief Main function
417  */
418 
419 int main(void)
420 {
421  int32_t status;
422  uint8_t whoami = 0;
423  uint8_t regdata;
424  float sensitivity = ACCEL_4G_SENS;
425 
426  ARM_DRIVER_I2C *I2Cdrv = &I2C_S_DRIVER; // Now using the shield.h value!!!
429 
430  /*! Initialize the MCU hardware. */
431  BOARD_InitPins();
435 
436  /*! Initialize FXLS896x_INT1 pin used by FRDM board */
437  pGpioDriver->pin_init(&FXLS896x_INT1, GPIO_DIRECTION_IN, NULL, &fxls896x_isr_callback, NULL);
438 
439  /*! Initialize RGB LED pin used by FRDM board */
440  pGpioDriver->pin_init(&GREEN_LED, GPIO_DIRECTION_OUT, NULL, NULL, NULL);
441 
442  /*! FreeMASTER communication layer initialization */
443  init_freemaster_uart();
444 
445  /*! Initialize the I2C driver. */
446  status = I2Cdrv->Initialize(I2C_S_SIGNAL_EVENT);
447  if (ARM_DRIVER_OK != status)
448  {
449  return -1;
450  }
451 
452  /*! Set the I2C Power mode. */
453  status = I2Cdrv->PowerControl(ARM_POWER_FULL);
454  if (ARM_DRIVER_OK != status)
455  {
456  return -1;
457  }
458 
459  /*! Set the I2C bus speed. */
460  status = I2Cdrv->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
461  if (ARM_DRIVER_OK != status)
462  {
463  return -1;
464  }
465 
466  /*! Initialize FXLS896x sensor driver. */
468  &whoami);
469  if (SENSOR_ERROR_NONE != status)
470  {
471  return status;
472  }
473 
474  /*! Set the task to be executed while waiting for I2C transactions to complete. */
476 
477  /*! Configure the FXLS896x sensor. */
478  status = FXLS896x_I2C_Configure(&fxls896xDriver, cFxls896xConfigNormal);
479  if (SENSOR_ERROR_NONE != status)
480  {
481  return status;
482  }
483 
484  /*! FreeMASTER Driver Initialization */
485  FMSTR_Init();
486 
487  /*! FreeMASTER Recorder Initialization */
489 
490  /*! Open FreeMASTER Pipe and get a Pipe handle */
491  FMSTR_HPIPE hpipe = FMSTR_PipeOpen(3, NULL, (FMSTR_ADDR)pipe3_rxb, sizeof(pipe3_rxb), (FMSTR_ADDR)pipe3_txb, sizeof(pipe3_txb),
492  FMSTR_PIPE_TYPE_ANSI_TERMINAL, "streaming");
493 
494  /*! Initialize trigger flags */
495  registers.toggle = 1;
496  registers.trigger = 0;
497  registers.read_trigger = 0;
498  registers.read_value = 0;
499  registers.readall_trigger = 0;
500  registers.trigger_accel_offnoise=0;
501  registers.trigger_selftest=0;
502  registers.dataready_cntr = 0;
503  registers.selftest[0]=0;
504  registers.selftest[1]=0;
505  registers.selftest[2]=0;
506  registers.timestamp = 0;
507 
508  for(int i = 0; i < FXLS896x_NUM_REGISTERS; i++)
509  {
510  registers.readall_value[i] = 0;
511  }
512 
513  for (;;) /* Forever loop */
514  {
515 
516  /*! Calling Recorder#0 in execution loop for generic high-speed variables sampling. */
517  FMSTR_Recorder(0);
518 
519  /*! FreeMASTER host communication polling mode */
520  FMSTR_Poll();
521 
522  /*! Check for any write register trigger from Host */
523  if (registers.trigger == 1)
524  {
525  /*! Apply Register Write */
526  status = apply_register_write(fxls896xDriver, registers.offset, registers.value);
527  if (SENSOR_ERROR_NONE != status)
528  {
529  return status;
530  }
531  registers.trigger = 0;
532  /*! Update drop down menu selection based on updated register write */
534  }
535 
536  /*! Check for any read register trigger from Host */
537  if (registers.read_trigger == 1)
538  {
539  /*! Apply Register Write */
540  status = apply_register_read(fxls896xDriver, registers.read_offset, &(registers.read_value));
541  if (SENSOR_ERROR_NONE != status)
542  {
543  return status;
544  }
545  registers.read_trigger = 0;
546  /*! Update drop down menu selection based on updated register read */
548  }
549 
550  /*! Check for any read all register trigger from Host */
551  if (registers.readall_trigger == 1)
552  {
553  /*! Apply Register Write */
554  status = apply_register_readall(fxls896xDriver);
555  if (SENSOR_ERROR_NONE != status)
556  {
557  return status;
558  }
559  registers.readall_trigger = 0;
561  /*! Update drop down menu selection based on updated all register read */
563  }
564 
565  /*! Wait for data ready interrupt from the FXLS896x. */
566  if (false == bFxls896xIntFlag)
567  { /* Loop, if new sample is not available. */
569  continue;
570  }
571  else
572  { /*! Clear the data ready flag, it will be set again by the ISR. */
573  bFxls896xIntFlag = false;
574  pGpioDriver->toggle_pin(&GREEN_LED);
575  }
576 
577  /*! Calling Recorder#1 for sampling sensor data when we get sensor data ready interrupt based on ODR. */
578  FMSTR_Recorder(1);
579 
580  /*! Read new raw sensor data from the FXLS896x. */
581  status = FXLS896x_I2C_ReadData(&fxls896xDriver, FXLS896x_ALL_REG_READ, registers.reg_addr);
582  if (ARM_DRIVER_OK != status)
583  {
584  return -1;
585  }
586 
587  /* Update timestamp from Systick framework. */
589 
590  /*! Increment data ready counter and check for rollover */
591  registers.dataready_cntr++;
592  if(MAX8BITSTORAGE == registers.dataready_cntr)
593  {
594  registers.dataready_cntr = 0;
595  }
596 
597  registers.temp = registers.reg_addr[1]+25;
598  registers.sdcd = (registers.reg_addr[0] & 0x10)>>4;
599 
600  /*! Convert the raw sensor data to signed 16-bit container for display to the debug port. */
601  rawData.accel[0] = (int16_t)(((int16_t)(((int16_t)registers.reg_addr[3] << 8) | registers.reg_addr[2])));
602  rawData.accel[1] = (int16_t)(((int16_t)(((int16_t)registers.reg_addr[5] << 8) | registers.reg_addr[4])));
603  rawData.accel[2] = (int16_t)(((int16_t)(((int16_t)registers.reg_addr[7] << 8) | registers.reg_addr[6])));
604 
605  registers.accelraw[0] = rawData.accel[0];
606  registers.accelraw[1] = rawData.accel[1];
607  registers.accelraw[2] = rawData.accel[2];
608 
609  /*! Add data log into Pipe TX */
610  FMSTR_PipePrintf(hpipe, "%d\t%d\t%d\t%d\t%d\n", registers.timestamp, registers.dataready_cntr, registers.accelraw[0], registers.accelraw[1], registers.accelraw[2]);
611 
612  status = FXLS896x_I2C_ReadData(&fxls896xDriver, cFXLS896x_whoami, (uint8_t *)&registers.reg_addr[13]);
613 
614  /*! Check the FS and apply sensitivity */
615  status = FXLS896x_I2C_ReadData(&fxls896xDriver, cFXLS896x_fs_src, &regdata);
616  if ((regdata & FXLS896x_SENS_CONFIG1_FSR_MASK) == 2)
617  {
618  sensitivity = ACCEL_4G_SENS;
619  }
620  else if ((regdata & FXLS896x_SENS_CONFIG1_FSR_MASK) == 4)
621  {
622  sensitivity = ACCEL_8G_SENS;
623  }
624  else if ((regdata & FXLS896x_SENS_CONFIG1_FSR_MASK) == 6)
625  {
626  sensitivity = ACCEL_16G_SENS;
627  }
628  else
629  {
630  sensitivity = ACCEL_2G_SENS;
631  }
632 
633  /*! Convert raw values to Gs */
634  registers.accel[0] = (float) (rawData.accel[0] * sensitivity);
635  registers.accel[1] = (float) (rawData.accel[1] * sensitivity);
636  registers.accel[2] = (float) (rawData.accel[2] * sensitivity);
637 
638  if (prev_toggle != registers.toggle)
639  {
640  pGpioDriver->toggle_pin(&GREEN_LED);
641  prev_toggle = registers.toggle;
642  }
643 
644  /*! Call offset and noise calculation function for FXLS896x */
645  if (registers.trigger_accel_offnoise == 1)
646  {
647  accel_off_noise(&(rawData), &(offnoise_data), sensitivity);
648  if (offnoise_data.complete_accel_offnoise == 1)
649  {
650  registers.trigger_accel_offnoise = 0;
651  }
652  }
653 
654  /*! Call self-test function */
655  if (registers.trigger_selftest == 1)
656  {
657  perform_selftest(fxls896xDriver, &selftest);
658  if (selftest.complete_selftest == 1)
659  {
660  registers.trigger_selftest = 0;
661 
662  /*! Re-Configure the FXLS896x sensor to default configuration */
663  status = FXLS896x_I2C_Configure(&fxls896xDriver, cFxls896xConfigNormal);
664  if (SENSOR_ERROR_NONE != status)
665  {
666  return status;
667  }
668  }
669  }
670 
671  }
672 }
673 
674 
675 /*!
676  * @brief Service register write trigger from Host
677  */
678 int32_t apply_register_write(fxls896x_i2c_sensorhandle_t fxls896xDriver, uint8_t offset, uint8_t value)
679 {
680  int32_t status;
681 
682  if (offset > FXLS896x_NUM_REGISTERS)
683  {
685  }
686 
687  registerwritelist_t fxls896x_register_write[] = {
688  /*! Set register offset with provided value */
689  {offset, value, 0},
691 
692  status = FXLS896x_I2C_Configure(&fxls896xDriver, fxls896x_register_write);
693  if (SENSOR_ERROR_NONE != status)
694  {
695  return SENSOR_ERROR_WRITE;
696  }
697 
698  return SENSOR_ERROR_NONE;
699 }
700 
701 /*!
702  * @brief Service register read trigger from Host
703  */
704 int32_t apply_register_read(fxls896x_i2c_sensorhandle_t fxls896xDriver, uint8_t read_offset, uint8_t *read_value)
705 {
706  int32_t status;
707 
708  if (read_offset > FXLS896x_NUM_REGISTERS)
709  {
711  }
712 
713  registerreadlist_t fxls896x_register_read[] = {
714  /*! Set register offset with provided value */
715  {.readFrom = read_offset, .numBytes = 1}, __END_READ_DATA__};
716 
717  status = FXLS896x_I2C_ReadData(&fxls896xDriver, fxls896x_register_read, read_value);
718  if (SENSOR_ERROR_NONE != status)
719  {
720  return SENSOR_ERROR_WRITE;
721  }
722 
723  return SENSOR_ERROR_NONE;
724 }
725 
726 /*!
727  * @brief Service register read all trigger from Host
728  */
730 {
731  int32_t status;
732 
733  for (int reg_offset = FXLS896x_INT_STATUS; reg_offset <= FXLS896x_SELF_TEST_CONFIG2; reg_offset++)
734  {
735  registerreadlist_t fxls896x_register_readall[] = {
736  /*! Set register offset with provided value */
737  {.readFrom = reg_offset, .numBytes = 1}, __END_READ_DATA__};
738 
739  status = FXLS896x_I2C_ReadData(&fxls896xDriver, fxls896x_register_readall, &(registers.readall_value[reg_offset]));
740  if (SENSOR_ERROR_NONE != status)
741  {
742  return SENSOR_ERROR_READ;
743  }
744  }
745 
746  return SENSOR_ERROR_NONE;
747 }
748 
749 /*!
750  * @brief Update drop down selection values based on register write, read or readall.
751  */
753 {
754 
756 
757  switch (caller)
758  {
759  case FXLS896x_REG_WRITE:
760 
761  /*! Update drop down option based on updated read value */
762  if(FXLS896x_SENS_CONFIG1 == registers->offset) //FS Selection
763  {
764  registers->fs_value = registers->value;
765  }
766  else if (FXLS896x_SENS_CONFIG2 == registers->offset)
767  {
768  registers->mods_value = registers->value;
769  }
770  else if (FXLS896x_SENS_CONFIG3 == registers->offset)
771  {
772  registers->odr_value = registers->value;
773  }
774  break;
775  case FXLS896x_REG_READ: //Called from Register Read
776 
777  /*! Update drop down option based on updated read value */
778  if(FXLS896x_SENS_CONFIG1 == registers->read_offset) //FS Selection
779  {
780  registers->fs_value = registers->read_value;
781  }
782  else if (FXLS896x_SENS_CONFIG2 == registers->read_offset)
783  {
784  registers->mods_value = registers->read_value;
785  }
786  else if (FXLS896x_SENS_CONFIG3 == registers->read_offset)
787  {
788  registers->odr_value = registers->read_value;
789  }
790  break;
791  case FXLS896x_ALLREG_READ: //Called from Register ReadAll
792 
793  /*! Update drop down option based on updated read values */
794  registers->fs_value = registers->reg_addr[FXLS896x_SENS_CONFIG1];
795  registers->mods_value = registers->reg_addr[FXLS896x_SENS_CONFIG2];
796  registers->odr_value = registers->reg_addr[FXLS896x_SENS_CONFIG3];
797  break;
798  default:
800  break;
801  }
802 
803  return status;
804 
805 }
806 
807 /*******************************************************************************
808  * OFFSET NOISE CALCULATION
809  ******************************************************************************/
810 
811 /*!
812  * @brief Initialize Offset-Noise Variables
813  */
815 {
816  offnoiseptr->offx = 0.0;
817  offnoiseptr->offy = 0.0;
818  offnoiseptr->offz = 0.0;
819  offnoiseptr->rmsx = 0.0;
820  offnoiseptr->rmsy = 0.0;
821  offnoiseptr->rmsz = 0.0;
822  offnoiseptr->complete_accel_offnoise = 0;
823 }
824 
825 
826 /* Calculate Offset & Noise for FXLS896x */
827 void accel_off_noise(fxls896x_acceldata_t* rawData, fxls896x_offset_noise_t *offnoiseptr, float sens)
828 {
829  uint16_t j;
830  static uint16_t k=0;
831  static uint16_t cntr=0;
832  static float stdx=0;
833  static float stdy=0;
834  static float stdz=0;
835  static float xx[N], yy[N], zz[N];
836  static float xm[N], ym[N], zm[N];
837  static float xsq[N], ysq[N], zsq[N];
838  float am[3];
839  static float sumx=0.0;
840  static float sumy=0.0;
841  static float sumz=0.0;
842 
843  /* Init offset noise variables */
844  offset_noise_init(offnoiseptr);
845 
846  cntr++;
847 
848  /* Store Accel samples and calculate sum for configured N */
849  if(cntr < N)
850  {
851  am[0]=rawData->accel[0]*sens;
852  am[1]=rawData->accel[1]*sens;
853  am[2]=rawData->accel[2]*sens;
854  xx[k]=am[0];
855  yy[k]=am[1];
856  zz[k]=am[2];
857  sumx+=am[0];
858  sumy+=am[1];
859  sumz+=am[2];
860  k+=1;
861  offnoiseptr->complete_accel_offnoise = 0;
862  }
863 
864  /* Measure offset and RMS */
865  if(cntr == N)
866  {
867  /* Measure average */
868  sumx=sumx/(N-1);
869  sumy=sumy/(N-1);
870  sumz=sumz/(N-1);
871 
872  /* Measure offset */
873  offnoiseptr->offx=0-sumx;
874  offnoiseptr->offy=0-sumy;
875  offnoiseptr->offz=1-sumz;
876 
877  /* Measure standard deviation */
878  for(j=0; j<N-1; j++)
879  {
880  xm[j]=xx[j]-sumx;
881  ym[j]=yy[j]-sumy;
882  zm[j]=zz[j]-sumz;
883 
884  xsq[j]=(float)pow(xm[j],2);
885  ysq[j]=(float)pow(ym[j],2);
886  zsq[j]=(float)pow(zm[j],2);
887  stdx+=xsq[j];
888  stdy+=ysq[j];
889  stdz+=zsq[j];
890  }
891  stdx=stdx/(N-2);
892  stdy=stdy/(N-2);
893  stdz=stdz/(N-2);
894 
895  /* Measure RMS */
896  offnoiseptr->rmsx=(float)pow(stdx,0.5);
897  offnoiseptr->rmsy=(float)pow(stdy,0.5);
898  offnoiseptr->rmsz=(float)pow(stdz,0.5);
899 
900  /* Set the completion flag */
901  offnoiseptr->complete_accel_offnoise = 1;
902 
903  /* Reset local storage */
904  cntr = k = 0;
905  sumx = sumy = sumz = 0;
906  stdx = stdy = stdz = 0;
907  }
908 }
909 
910 /*!
911  * @brief Initialize Offset-Noise Variables
912  */
914 {
915  selftest->x_stoc = 0;
916  selftest->y_stoc = 0;
917  selftest->z_stoc = 0;
918  selftest->x_stof = 0;
919  selftest->y_stof = 0;
920  selftest->z_stof = 0;
921  selftest->complete_selftest = 0;
922 }
923 
924 
926 {
927  int32_t status;
928 
929  axis=0;
930 
931  /* Initialize self-test parameters */
932  selftest_init(selftest);
933 
934  while (axis<6)
935  {
936 
937  switch(axis)
938  {
939  case 0:status = FXLS896x_I2C_Configure(&fxls896xDriver, cFxls896xSTXP);break;
940  case 1:status = FXLS896x_I2C_Configure(&fxls896xDriver, cFxls896xSTXN);break;
941  case 2:status = FXLS896x_I2C_Configure(&fxls896xDriver, cFxls896xSTYP);break;
942  case 3:status = FXLS896x_I2C_Configure(&fxls896xDriver, cFxls896xSTYN);break;
943  case 4:status = FXLS896x_I2C_Configure(&fxls896xDriver, cFxls896xSTZP);break;
944  case 5:status = FXLS896x_I2C_Configure(&fxls896xDriver, cFxls896xSTZN);break;
945  default:break;
946  }
947 
948  if (ARM_DRIVER_OK != status)
949  {
950  return status;
951  }
952 
953  int counter =0;
954  for(counter=0;counter<1;counter++)
955  {
956 
957  // In ISR Mode we do not need to check Data Ready Register.
958  // The receipt of interrupt will indicate data is ready.
959  RAW_DATA data_ = {0x00};
960  while(false == bFxls896xIntFlag)
961  {
962 
963  }
964 
965  /*! Set device to Standby mode. */
967  if (ARM_DRIVER_OK != status)
968  {
969  return SENSOR_ERROR_WRITE;
970  }
971 
972 
973  bFxls896xIntFlag = false;
974  //pGpioDriver->toggle_pin(&RED_LED);
975 
976  /*! Read new raw sensor data from the FXLS896x. */
977  status = FXLS896x_I2C_ReadData(&fxls896xDriver, cFxls896xOutputNormal, &data_.byte_data[0]);
978  if (ARM_DRIVER_OK != status)
979  { /* Read did not work, so loop. */
980  continue;
981  }
982 
983  /* store the self-test values for each axis & for each polarity*/
984  switch(axis)
985  {
986  case 0: XSTP[counter]= data_.dat.xdata;break;
987  case 1: XSTN[counter]= data_.dat.xdata;break;
988  case 2: YSTP[counter]= data_.dat.ydata;break;
989  case 3: YSTN[counter]= data_.dat.ydata;break;
990  case 4: ZSTP[counter]= data_.dat.zdata;break;
991  case 5: ZSTN[counter]= data_.dat.zdata;break;
992  default:break;
993  }
994 
995  }
996 
997  BOARD_DELAY_ms(1000);
998  axis++;
999  }
1000 
1001  /* compute self-test output change*/
1002  selftest->x_stoc=(XSTP[0]-XSTN[0])/2;
1003  selftest->y_stoc=(YSTP[0]-YSTN[0])/2;
1004  selftest->z_stoc=(ZSTP[0]-ZSTN[0])/2;
1005 
1006  /* compute self-test offset*/
1007  selftest->x_stof=(XSTP[0]+XSTN[0])/2;
1008  selftest->y_stof=(YSTP[0]+YSTN[0])/2;
1009  selftest->z_stof=(ZSTP[0]+ZSTN[0])/2;
1010 
1011  selftest->complete_selftest = 1;
1012  return SENSOR_ERROR_NONE;
1013 }
1014 
1015 /*!
1016  * @brief UART Module initialization (UART is a the standard block included e.g. in K22F)
1017  */
1018 static void init_freemaster_uart(void)
1019 {
1020  uart_config_t config;
1021 
1022  /*
1023  * config.baudRate_Bps = 115200U;
1024  * config.parityMode = kUART_ParityDisabled;
1025  * config.stopBitCount = kUART_OneStopBit;
1026  * config.txFifoWatermark = 0;
1027  * config.rxFifoWatermark = 1;
1028  * config.enableTx = false;
1029  * config.enableRx = false;
1030  */
1031  UART_GetDefaultConfig(&config);
1032  config.baudRate_Bps = 115200U;
1033  config.enableTx = false;
1034  config.enableRx = false;
1035 
1036  UART_Init((UART_Type*)BOARD_DEBUG_UART_BASEADDR, &config, BOARD_DEBUG_UART_CLK_FREQ);
1037 
1038  /* Register communication module used by FreeMASTER driver. */
1039  FMSTR_SerialSetBaseAddress((UART_Type*)BOARD_DEBUG_UART_BASEADDR);
1040 
1041 #if FMSTR_SHORT_INTR || FMSTR_LONG_INTR
1042  /* Enable UART interrupts. */
1043  EnableIRQ(BOARD_UART_IRQ);
1044  EnableGlobalIRQ(0);
1045 #endif
1046 }
1047 
1048 #if FMSTR_SHORT_INTR || FMSTR_LONG_INTR
1049 /*
1050 * Application interrupt handler of communication peripheral used in interrupt modes
1051 * of FreeMASTER communication.
1052 *
1053 * NXP MCUXpresso SDK framework defines interrupt vector table as a part of "startup_XXXXXX.x"
1054 * assembler/C file. The table points to weakly defined symbols, which may be overwritten by the
1055 * application specific implementation. FreeMASTER overrides the original weak definition and
1056 * redirects the call to its own handler.
1057 *
1058 */
1059 
1060 void BOARD_UART_IRQ_HANDLER(void)
1061 {
1062  /* Call FreeMASTER Interrupt routine handler */
1063  FMSTR_SerialIsr();
1064  /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1065  exception return operation might vector to incorrect interrupt */
1066 #if defined __CORTEX_M && (__CORTEX_M == 4U)
1067  __DSB();
1068 #endif
1069 }
1070 #endif
1071 
const registerreadlist_t cFXLS896x_whoami[]
int16_t ZSTN[2]
FMSTR_REC_VAR recVar
int32_t perform_selftest(fxls896x_i2c_sensorhandle_t fxls896xDriver, fxls896x_selftest_t *selftest)
Function to perform FXLS896x self test.
enum fxls896x_operation_type fxls896x_operation_type_t
This structure defines the fxls896x host operation type.
#define BOARD_UART_IRQ
Definition: board.h:27
The fxls896x_drv.h file describes the FXLS8964/67AF driver interface and structures.
#define FXLS896x_SENS_CONFIG2_ANIC_TEMP_EN
Definition: fxls896x.h:521
This structure defines the Write command List.
Definition: sensor_drv.h:68
#define FXLS896x_SENS_CONFIG1_FSR_4G
Definition: fxls896x.h:455
#define ACCEL_8G_SENS
const registerreadlist_t cFXLS896x_fs_src[]
Prepare the register read for FullScale range Register.
int32_t status
#define FXLS896x_SENS_CONFIG3_WAKE_ODR_12_5HZ
Definition: fxls896x.h:565
#define FXLS896x_I2C_ADDR
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
const registerwritelist_t cFxls896xSTXN[]
Register settings for Self-Test in X Axis (Negative polarity).
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.
This structure defines the fxls896x all registers metadata.
#define FXLS896x_SENS_CONFIG1_ST_POL_POSITIVE
Definition: fxls896x.h:447
void BOARD_DELAY_ms(uint32_t delay_ms)
Function to insert delays.
Definition: systick_utils.c:81
FMSTR_REC_CFG recCfg
#define BOARD_DEBUG_UART_CLK_FREQ
Definition: board.h:26
int main(void)
Main function.
int32_t apply_register_readall(fxls896x_i2c_sensorhandle_t fxls896xDriver)
Function to apply FXLS896x register read-all operation.
#define MAX8BITSTORAGE
int32_t FXLS896x_I2C_Initialize(fxls896x_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: fxls896x_drv.c:239
int16_t XSTN[2]
Access structure of the GPIO Driver.
Definition: Driver_GPIO.h:38
registerDeviceInfo_t deviceInfo
Definition: fxls896x_drv.h:45
#define SMC
Definition: lpc54114.h:118
const registerwritelist_t cFxls896xSTZN[]
Register settings for Self-Test in Z Axis (Negative polarity).
int32_t apply_register_read(fxls896x_i2c_sensorhandle_t fxls896xDriver, uint8_t offset, uint8_t *value)
Function to apply FXLS896x register read operation.
const registerreadlist_t cFxls896xOutputNormal[]
Address of Raw Accel Data in Normal Mode.
union rawdata RAW_DATA
int16_t XSTP[2]
#define FXLS896x_SENS_CONFIG1_ST_AXIS_SEL_MASK
Definition: fxls896x.h:432
#define FXLS896x_SENS_CONFIG1_FSR_16G
Definition: fxls896x.h:459
const registerwritelist_t cFxls896xSTYP[]
Register settings for Self-Test in Y Axis (Positive polarity).
const registerreadlist_t FXLS896x_ALL_REG_READ[]
FXLS896x register list to read all registers.
This structure defines variables to compute self-test output change (STOC) and self-test offset (STOF...
uint8_t axis
#define __END_WRITE_DATA__
Definition: sensor_drv.h:45
const registerwritelist_t cFxls896xSTYN[]
Register settings for Self-Test in Y Axis (Negative polarity).
#define FXLS896x_DATA_SIZE
typedef int32_t(DATA_FORMAT_Append_t))(void *pData
The interface function to append the data on the formated stream.
int32_t apply_register_write(fxls896x_i2c_sensorhandle_t fxls896xDriver, uint8_t offset, uint8_t value)
Function to apply FXLS896x register write operation.
int16_t YSTN[2]
#define FXLS896x_NUM_REGISTERS
int32_t gSystick
This structure defines the fxls896x raw data buffer.
Definition: fxls896x_drv.h:52
#define FXLS896x_SENS_CONFIG1_ST_POL_MASK
Definition: fxls896x.h:429
#define I2C_S_SIGNAL_EVENT
Definition: issdk_hal.h:34
#define I2C_S_DRIVER
Definition: issdk_hal.h:33
#define FXLS896x_SENS_CONFIG1_ST_AXIS_SEL_EN_Z
Definition: fxls896x.h:446
const registerwritelist_t cFxls896xConfigNormal[]
Defines the register write list to configure FXLS896x in Interrupt mode.
void accel_off_noise(fxls896x_acceldata_t *rawData, fxls896x_offset_noise_t *offnoiseptr, float sens)
Function to measure accelerometer offset noise.
int16_t YSTP[2]
#define FXLS896x_SENS_CONFIG1_ST_POL_NEGATIVE
Definition: fxls896x.h:449
#define BOARD_BootClockRUN
Definition: clock_config.h:19
This structure defines the fxls896x offset and noise calculation parameters.
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
Definition: sensor_drv.h:97
#define FXLS896x_SENS_CONFIG1_FSR_MASK
Definition: fxls896x.h:423
fxls896x_operation_type
This structure defines the fxls8962 host operation type.
GENERIC_DRIVER_GPIO Driver_GPIO_KSDK
Definition: gpio_driver.c:177
GENERIC_DRIVER_GPIO * pGpioDriver
int16_t ZSTP[2]
#define FXLS896x_INT_EN_DRDY_EN_MASK
Definition: fxls896x.h:850
uint8_t prev_toggle
This defines the sensor specific information for I2C.
Definition: fxls896x_drv.h:43
uint32_t BOARD_SystickElapsedTime_us(int32_t *pStart)
Function to compute the Elapsed Time.
Definition: systick_utils.c:64
fxls896x_allregs_t registers
FMSTR_REC_BUFF recBuffCfg
#define BOARD_UART_IRQ_HANDLER
Definition: board.h:28
#define FXLS896x_SENS_CONFIG1_ST_AXIS_SEL_EN_Y
Definition: fxls896x.h:445
fxls896x_offset_noise_t offnoise_data
int32_t FXLS896x_I2C_Configure(fxls896x_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
Definition: fxls896x_drv.c:285
#define __END_READ_DATA__
Definition: sensor_drv.h:51
int32_t FXLS896x_I2C_ReadData(fxls896x_i2c_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer)
The interface function to read the sensor data.
Definition: fxls896x_drv.c:330
FMSTR_TSA_TABLE_BEGIN(main_table)
Target Side Addressable (TSA) table created for this application.
void offset_noise_init(fxls896x_offset_noise_t *offnoiseptr)
Function to initialize offset noise measurement.
#define FXLS896x_SENS_CONFIG2_ANIC_TEMP_MASK
Definition: fxls896x.h:496
void fxls896x_isr_callback(void *pUserData)
ISR for FXLS896x interrupt source event.
#define BOARD_DEBUG_UART_BASEADDR
Definition: board.h:24
ARM_DRIVER_I2C * I2Cdrv
int32_t update_dropdown_selection(fxls896x_allregs_t *registers, uint8_t caller)
Function to update dropdown selection.
uint16_t readFrom
Definition: sensor_drv.h:80
void selftest_init(fxls896x_selftest_t *selftest)
Function to initialize FXLS896x self test metadata.
fxls896x_i2c_sensorhandle_t fxls896xDriver
void FXLS896x_I2C_SetIdleTask(fxls896x_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
Definition: fxls896x_drv.c:277
void(* toggle_pin)(pinID_t aPinId)
Definition: Driver_GPIO.h:48
volatile bool bFxls896xIntFlag
uint8_t reg_addr[FXLS896x_NUM_REGISTERS]
void BOARD_SystickEnable(void)
Function to enable systicks framework.
Definition: systick_utils.c:35
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
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 structure defines the Read command List.
Definition: sensor_drv.h:78
ARM Systick Utilities.
#define FXLS896x_INT1
const registerreadlist_t cFXLS896x_int_src[]
Prepare the register read for INT Status Register.
#define ACCEL_16G_SENS
#define ACCEL_4G_SENS
gpioHandleKSDK_t GREEN_LED
Definition: frdm_k64f.c:188
const registerwritelist_t cFxls896xSTZP[]
Register settings for Self-Test in Z Axis (Positive polarity).
#define I2C_S_DEVICE_INDEX
Definition: issdk_hal.h:35
void FRM_Recorder_Init()
void BOARD_InitDebugConsole(void)
Definition: board.c:15
#define FXLS896x_SENS_CONFIG1_ST_AXIS_SEL_DISABLED
Definition: fxls896x.h:442
void BOARD_InitPins(void)
Configures pin routing and optionally pin electrical features.
Definition: pin_mux.c:47
#define FXLS896x_SENS_CONFIG1_ST_AXIS_SEL_EN_X
Definition: fxls896x.h:444
fxls896x_selftest_t selftest
fxls896x_acceldata_t rawData
#define FXLS896x_INT_EN_DRDY_EN_EN
Definition: fxls896x.h:857
#define FXLS896x_SENS_CONFIG3_WAKE_ODR_MASK
Definition: fxls896x.h:551
#define ACCEL_2G_SENS
uint8_t readall_value[FXLS896x_NUM_REGISTERS]
This structure defines the fxls8962 raw data buffer.
uint8_t byte_data[sizeof(sensor_data)]
const registerwritelist_t cFxls896xSTXP[]
Register settings for Self-Test in X Axis (Positive polarity).