Stima V4 Slave RAIN  4.2
accelerometer.h
Go to the documentation of this file.
1 
30 /* Define to prevent recursive inclusion -------------------------------------*/
31 #ifndef _ACCELEROMETER_H
32 #define _ACCELEROMETER_H
33 
34 
35 /* Includes ------------------------------------------------------------------*/
36 #include <STM32FreeRTOS.h>
37 #include "ticks.hpp"
38 #include "thread.hpp"
39 #include "semaphore.hpp"
40 #include "Wire.h"
41 
42 using namespace cpp_freertos;
43 
44 #define ACCELEROMETER_SEMAPHORE_MAX_WAITING_TIME_MS (1000)
45 
48 #define ACCELEROMETER_IIS328DQ_I2C_ADDR_DEFAULT (0x19)
49 #define ACCELEROMETER_WAIT_CHECK_HARDWARE (5)
50 #define ACCELEROMETER_MAX_CHECK_ATTEMPT (5)
52 #define IIS328DQ_ID 0x32
53 
55 #define DRV_LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
56 #define DRV_BIG_ENDIAN __ORDER_BIG_ENDIAN__
57 #define DRV_BYTE_ORDER __BYTE_ORDER__
58 #define PROPERTY_DISABLE (0U)
59 #define PROPERTY_ENABLE (1U)
60 
61 #define ARR_REG_FILTER 30
62 
63 // Class Accelerometer implementation
65 
66 public:
67 
68  // ********* Typedef Structure and register ******** //
69 
70  // Local COORD for gestion raw_data
71  enum coordinate {
72  X,
73  Y,
74  Z
75  };
76 
77  typedef struct
78  {
79  #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
80  uint8_t bit0 : 1;
81  uint8_t bit1 : 1;
82  uint8_t bit2 : 1;
83  uint8_t bit3 : 1;
84  uint8_t bit4 : 1;
85  uint8_t bit5 : 1;
86  uint8_t bit6 : 1;
87  uint8_t bit7 : 1;
88  #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
89  uint8_t bit7 : 1;
90  uint8_t bit6 : 1;
91  uint8_t bit5 : 1;
92  uint8_t bit4 : 1;
93  uint8_t bit3 : 1;
94  uint8_t bit2 : 1;
95  uint8_t bit1 : 1;
96  uint8_t bit0 : 1;
97  #endif /* DRV_BYTE_ORDER */
98  } bitwise_t;
99 
100  #define IIS328DQ_WHO_AM_I 0x0FU
101  #define IIS328DQ_CTRL_REG1 0x20U
102  typedef struct
103  {
104  #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
105  uint8_t xen : 1;
106  uint8_t yen : 1;
107  uint8_t zen : 1;
108  uint8_t dr : 2;
109  uint8_t pm : 3;
110  #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
111  uint8_t pm : 3;
112  uint8_t dr : 2;
113  uint8_t zen : 1;
114  uint8_t yen : 1;
115  uint8_t xen : 1;
116  #endif /* DRV_BYTE_ORDER */
118 
119  #define IIS328DQ_CTRL_REG2 0x21U
120  typedef struct
121  {
122  #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
123  uint8_t hpcf : 2;
124  uint8_t hpen : 2;
125  uint8_t fds : 1;
126  uint8_t hpm : 2;
127  uint8_t boot : 1;
128  #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
129  uint8_t boot : 1;
130  uint8_t hpm : 2;
131  uint8_t fds : 1;
132  uint8_t hpen : 2;
133  uint8_t hpcf : 2;
134  #endif /* DRV_BYTE_ORDER */
136 
137  #define IIS328DQ_CTRL_REG3 0x22U
138  typedef struct
139  {
140  #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
141  uint8_t i1_cfg : 2;
142  uint8_t lir1 : 1;
143  uint8_t i2_cfg : 2;
144  uint8_t lir2 : 1;
145  uint8_t pp_od : 1;
146  uint8_t ihl : 1;
147  #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
148  uint8_t ihl : 1;
149  uint8_t pp_od : 1;
150  uint8_t lir2 : 1;
151  uint8_t i2_cfg : 2;
152  uint8_t lir1 : 1;
153  uint8_t i1_cfg : 2;
154  #endif /* DRV_BYTE_ORDER */
156 
157  #define IIS328DQ_CTRL_REG4 0x23U
158  typedef struct
159  {
160  #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
161  uint8_t sim : 1;
162  uint8_t st : 3; /* STsign + ST */
163  uint8_t fs : 2;
164  uint8_t ble : 1;
165  uint8_t bdu : 1;
166  #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
167  uint8_t bdu : 1;
168  uint8_t ble : 1;
169  uint8_t fs : 2;
170  uint8_t st : 3; /* STsign + ST */
171  uint8_t sim : 1;
172  #endif /* DRV_BYTE_ORDER */
174 
175  #define IIS328DQ_CTRL_REG5 0x24U
176  typedef struct
177  {
178  #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
179  uint8_t turnon : 2;
180  uint8_t not_used_01 : 6;
181  #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
182  uint8_t not_used_01 : 6;
183  uint8_t turnon : 2;
184  #endif /* DRV_BYTE_ORDER */
186 
187  #define IIS328DQ_HP_FILTER_RESET 0x25U
188  #define IIS328DQ_REFERENCE 0x26U
189  #define IIS328DQ_STATUS_REG 0x27U
190  typedef struct
191  {
192  #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
193  uint8_t xda : 1;
194  uint8_t yda : 1;
195  uint8_t zda : 1;
196  uint8_t zyxda : 1;
197  uint8_t _xor : 1;
198  uint8_t yor : 1;
199  uint8_t zor : 1;
200  uint8_t zyxor : 1;
201  #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
202  uint8_t zyxor : 1;
203  uint8_t zor : 1;
204  uint8_t yor : 1;
205  uint8_t _xor : 1;
206  uint8_t zyxda : 1;
207  uint8_t zda : 1;
208  uint8_t yda : 1;
209  uint8_t xda : 1;
210  #endif /* DRV_BYTE_ORDER */
212 
213  #define IIS328DQ_OUT_X_L 0x28U
214  #define IIS328DQ_OUT_X_H 0x29U
215  #define IIS328DQ_OUT_Y_L 0x2AU
216  #define IIS328DQ_OUT_Y_H 0x2BU
217  #define IIS328DQ_OUT_Z_L 0x2CU
218  #define IIS328DQ_OUT_Z_H 0x2DU
219  #define IIS328DQ_INT1_CFG 0x30U
220  typedef struct
221  {
222  #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
223  uint8_t xlie : 1;
224  uint8_t xhie : 1;
225  uint8_t ylie : 1;
226  uint8_t yhie : 1;
227  uint8_t zlie : 1;
228  uint8_t zhie : 1;
229  uint8_t _6d : 1;
230  uint8_t aoi : 1;
231  #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
232  uint8_t aoi : 1;
233  uint8_t _6d : 1;
234  uint8_t zhie : 1;
235  uint8_t zlie : 1;
236  uint8_t yhie : 1;
237  uint8_t ylie : 1;
238  uint8_t xhie : 1;
239  uint8_t xlie : 1;
240  #endif /* DRV_BYTE_ORDER */
242 
243  #define IIS328DQ_INT1_SRC 0x31U
244  typedef struct
245  {
246  #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
247  uint8_t xl : 1;
248  uint8_t xh : 1;
249  uint8_t yl : 1;
250  uint8_t yh : 1;
251  uint8_t zl : 1;
252  uint8_t zh : 1;
253  uint8_t ia : 1;
254  uint8_t not_used_01 : 1;
255  #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
256  uint8_t not_used_01 : 1;
257  uint8_t ia : 1;
258  uint8_t zh : 1;
259  uint8_t zl : 1;
260  uint8_t yh : 1;
261  uint8_t yl : 1;
262  uint8_t xh : 1;
263  uint8_t xl : 1;
264  #endif /* DRV_BYTE_ORDER */
266 
267  #define IIS328DQ_INT1_THS 0x32U
268  typedef struct
269  {
270  #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
271  uint8_t ths : 7;
272  uint8_t not_used_01 : 1;
273  #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
274  uint8_t not_used_01 : 1;
275  uint8_t ths : 7;
276  #endif /* DRV_BYTE_ORDER */
278 
279  #define IIS328DQ_INT1_DURATION 0x33U
280  typedef struct
281  {
282  #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
283  uint8_t d : 7;
284  uint8_t not_used_01 : 1;
285  #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
286  uint8_t not_used_01 : 1;
287  uint8_t d : 7;
288  #endif /* DRV_BYTE_ORDER */
290 
291  #define IIS328DQ_INT2_CFG 0x34U
292  typedef struct
293  {
294  #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
295  uint8_t xlie : 1;
296  uint8_t xhie : 1;
297  uint8_t ylie : 1;
298  uint8_t yhie : 1;
299  uint8_t zlie : 1;
300  uint8_t zhie : 1;
301  uint8_t _6d : 1;
302  uint8_t aoi : 1;
303  #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
304  uint8_t aoi : 1;
305  uint8_t _6d : 1;
306  uint8_t zhie : 1;
307  uint8_t zlie : 1;
308  uint8_t yhie : 1;
309  uint8_t ylie : 1;
310  uint8_t xhie : 1;
311  uint8_t xlie : 1;
312  #endif /* DRV_BYTE_ORDER */
314 
315  #define IIS328DQ_INT2_SRC 0x35U
316  typedef struct
317  {
318  #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
319  uint8_t xl : 1;
320  uint8_t xh : 1;
321  uint8_t yl : 1;
322  uint8_t yh : 1;
323  uint8_t zl : 1;
324  uint8_t zh : 1;
325  uint8_t ia : 1;
326  uint8_t not_used_01 : 1;
327  #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
328  uint8_t not_used_01 : 1;
329  uint8_t ia : 1;
330  uint8_t zh : 1;
331  uint8_t zl : 1;
332  uint8_t yh : 1;
333  uint8_t yl : 1;
334  uint8_t xh : 1;
335  uint8_t xl : 1;
336  #endif /* DRV_BYTE_ORDER */
338 
339  #define IIS328DQ_INT2_THS 0x36U
340  typedef struct
341  {
342  #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
343  uint8_t ths : 7;
344  uint8_t not_used_01 : 1;
345  #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
346  uint8_t not_used_01 : 1;
347  uint8_t ths : 7;
348  #endif /* DRV_BYTE_ORDER */
350 
351  #define IIS328DQ_INT2_DURATION 0x37U
352  typedef struct
353  {
354  #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
355  uint8_t d : 7;
356  uint8_t not_used_01 : 1;
357  #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
358  uint8_t not_used_01 : 1;
359  uint8_t d : 7;
360  #endif /* DRV_BYTE_ORDER */
362 
363  // Accelerometer IIS328DQ_Register_Union
364  typedef union
365  {
381  uint8_t byte;
382  } iis328dq_reg_t;
383 
384  // *************** Class Constructor *************** //
385 
386  Accelerometer();
387  Accelerometer(TwoWire *_wire, BinarySemaphore *_wireLock, uint8_t _i2c_address = ACCELEROMETER_IIS328DQ_I2C_ADDR_DEFAULT);
388 
389  // ************ Library implemenmtation ************ //
390 
391  int32_t iis328dq_read_reg(uint8_t reg, uint8_t *data, uint16_t len);
392  int32_t iis328dq_write_reg(uint8_t reg, uint8_t *data, uint16_t len);
393 
394  void push_raw_data(int16_t *data_raw);
395  int16_t get_raw_mean(coordinate request);
396 
397  float_t iis328dq_from_fs2_to_mg(int16_t lsb);
398  float_t iis328dq_from_fs2_to_mg(coordinate request);
399  float_t iis328dq_from_fs4_to_mg(int16_t lsb);
400  float_t iis328dq_from_fs4_to_mg(coordinate request);
401  float_t iis328dq_from_fs8_to_mg(int16_t lsb);
402  float_t iis328dq_from_fs8_to_mg(coordinate request);
403 
404  float_t iis328dq_from_fsx_to_inc(int16_t lsb);
405  float_t iis328dq_from_fsx_to_inc(coordinate request);
406 
407  int32_t iis328dq_axis_x_data_set(uint8_t val);
408  int32_t iis328dq_axis_x_data_get(uint8_t *val);
409 
410  int32_t iis328dq_axis_y_data_set(uint8_t val);
411  int32_t iis328dq_axis_y_data_get(uint8_t *val);
412 
413  int32_t iis328dq_axis_z_data_set(uint8_t val);
414  int32_t iis328dq_axis_z_data_get(uint8_t *val);
415 
416  typedef enum
417  {
418  IIS328DQ_ODR_OFF = 0x00,
419  IIS328DQ_ODR_ON = 0x01,
420  IIS328DQ_ODR_Hz5 = 0x02,
421  IIS328DQ_ODR_1Hz = 0x03,
422  IIS328DQ_ODR_5Hz2 = 0x04,
423  IIS328DQ_ODR_5Hz = 0x05,
424  IIS328DQ_ODR_10Hz = 0x06,
425  IIS328DQ_ODR_50Hz = 0x01,
426  IIS328DQ_ODR_100Hz = 0x11,
427  IIS328DQ_ODR_400Hz = 0x21,
428  IIS328DQ_ODR_1kHz = 0x31,
429  } iis328dq_dr_t;
430  int32_t iis328dq_data_rate_set(iis328dq_dr_t val);
431  int32_t iis328dq_data_rate_get(iis328dq_dr_t *val);
432 
433  typedef enum
434  {
435  IIS328DQ_NORMAL_MODE = 0,
436  IIS328DQ_REF_MODE_ENABLE = 1,
437  } iis328dq_hpm_t;
438  int32_t iis328dq_reference_mode_set(iis328dq_hpm_t val);
439  int32_t iis328dq_reference_mode_get(iis328dq_hpm_t *val);
440 
441  typedef enum
442  {
443  IIS328DQ_2g = 0,
444  IIS328DQ_4g = 1,
445  IIS328DQ_8g = 3,
446  } iis328dq_fs_t;
447  int32_t iis328dq_full_scale_set(iis328dq_fs_t val);
448  int32_t iis328dq_full_scale_get(iis328dq_fs_t *val);
449 
450  int32_t iis328dq_block_data_update_set(uint8_t val);
451  int32_t iis328dq_block_data_update_get(uint8_t *val);
452 
453  int32_t iis328dq_status_reg_get(iis328dq_status_reg_t *val);
454 
455  int32_t iis328dq_flag_data_ready_get(uint8_t *val);
456 
457  int32_t iis328dq_acceleration_raw_get(int16_t *val);
458 
459  int32_t iis328dq_device_id_get(uint8_t *buff);
460 
461  int32_t iis328dq_boot_set(uint8_t val);
462  int32_t iis328dq_boot_get(uint8_t *val);
463 
464  typedef enum
465  {
466  IIS328DQ_ST_DISABLE = 0,
467  IIS328DQ_ST_POSITIVE = 1,
468  IIS328DQ_ST_NEGATIVE = 5,
469  } iis328dq_st_t;
470  int32_t iis328dq_self_test_set(iis328dq_st_t val);
471  int32_t iis328dq_self_test_get(iis328dq_st_t *val);
472 
473  typedef enum
474  {
475  IIS328DQ_LSB_AT_LOW_ADD = 0,
476  IIS328DQ_MSB_AT_LOW_ADD = 1,
477  } iis328dq_ble_t;
478  int32_t iis328dq_data_format_set(iis328dq_ble_t val);
479  int32_t iis328dq_data_format_get(iis328dq_ble_t *val);
480 
481  typedef enum
482  {
483  IIS328DQ_CUT_OFF_8Hz = 0,
484  IIS328DQ_CUT_OFF_16Hz = 1,
485  IIS328DQ_CUT_OFF_32Hz = 2,
486  IIS328DQ_CUT_OFF_64Hz = 3,
487  } iis328dq_hpcf_t;
488  int32_t iis328dq_hp_bandwidth_set(iis328dq_hpcf_t val);
489  int32_t iis328dq_hp_bandwidth_get(iis328dq_hpcf_t *val);
490 
491  typedef enum
492  {
493  IIS328DQ_HP_DISABLE = 0,
494  IIS328DQ_HP_ON_OUT = 4,
495  IIS328DQ_HP_ON_INT1 = 1,
496  IIS328DQ_HP_ON_INT2 = 2,
497  IIS328DQ_HP_ON_INT1_INT2 = 3,
498  IIS328DQ_HP_ON_INT1_INT2_OUT = 7,
499  IIS328DQ_HP_ON_INT2_OUT = 6,
500  IIS328DQ_HP_ON_INT1_OUT = 5,
501  } iis328dq_hpen_t;
502  int32_t iis328dq_hp_path_set(iis328dq_hpen_t val);
503  int32_t iis328dq_hp_path_get(iis328dq_hpen_t *val);
504 
505  int32_t iis328dq_hp_reset_get(void);
506 
507  int32_t iis328dq_hp_reference_value_set(uint8_t val);
508  int32_t iis328dq_hp_reference_value_get(uint8_t *val);
509 
510  typedef enum
511  {
512  IIS328DQ_SPI_4_WIRE = 0,
513  IIS328DQ_SPI_3_WIRE = 1,
514  } iis328dq_sim_t;
515  int32_t iis328dq_spi_mode_set(iis328dq_sim_t val);
516  int32_t iis328dq_spi_mode_get(iis328dq_sim_t *val);
517 
518  typedef enum
519  {
520  IIS328DQ_PAD1_INT1_SRC = 0,
521  IIS328DQ_PAD1_INT1_OR_INT2_SRC = 1,
522  IIS328DQ_PAD1_DRDY = 2,
523  IIS328DQ_PAD1_BOOT = 3,
524  } iis328dq_i1_cfg_t;
525  int32_t iis328dq_pin_int1_route_set(iis328dq_i1_cfg_t val);
526  int32_t iis328dq_pin_int1_route_get(iis328dq_i1_cfg_t *val);
527 
528  typedef enum
529  {
530  IIS328DQ_INT1_PULSED = 0,
531  IIS328DQ_INT1_LATCHED = 1,
532  } iis328dq_lir1_t;
533  int32_t iis328dq_int1_notification_set(iis328dq_lir1_t val);
534  int32_t iis328dq_int1_notification_get(iis328dq_lir1_t *val);
535 
536  typedef enum
537  {
538  IIS328DQ_PAD2_INT2_SRC = 0,
539  IIS328DQ_PAD2_INT1_OR_INT2_SRC = 1,
540  IIS328DQ_PAD2_DRDY = 2,
541  IIS328DQ_PAD2_BOOT = 3,
542  } iis328dq_i2_cfg_t;
543  int32_t iis328dq_pin_int2_route_set(iis328dq_i2_cfg_t val);
544  int32_t iis328dq_pin_int2_route_get(iis328dq_i2_cfg_t *val);
545 
546  typedef enum
547  {
548  IIS328DQ_INT2_PULSED = 0,
549  IIS328DQ_INT2_LATCHED = 1,
550  } iis328dq_lir2_t;
551  int32_t iis328dq_int2_notification_set(iis328dq_lir2_t val);
552  int32_t iis328dq_int2_notification_get(iis328dq_lir2_t *val);
553 
554  typedef enum
555  {
556  IIS328DQ_PUSH_PULL = 0,
557  IIS328DQ_OPEN_DRAIN = 1,
558  } iis328dq_pp_od_t;
559  int32_t iis328dq_pin_mode_set(iis328dq_pp_od_t val);
560  int32_t iis328dq_pin_mode_get(iis328dq_pp_od_t *val);
561 
562  typedef enum
563  {
564  IIS328DQ_ACTIVE_HIGH = 0,
565  IIS328DQ_ACTIVE_LOW = 1,
566  } iis328dq_ihl_t;
567  int32_t iis328dq_pin_polarity_set(iis328dq_ihl_t val);
568  int32_t iis328dq_pin_polarity_get(iis328dq_ihl_t *val);
569 
570  typedef struct
571  {
572  uint8_t int1_xlie : 1;
573  uint8_t int1_xhie : 1;
574  uint8_t int1_ylie : 1;
575  uint8_t int1_yhie : 1;
576  uint8_t int1_zlie : 1;
577  uint8_t int1_zhie : 1;
579  int32_t iis328dq_int1_on_threshold_conf_set(int1_on_th_conf_t val);
580  int32_t iis328dq_int1_on_threshold_conf_get(int1_on_th_conf_t *val);
581 
582  typedef enum
583  {
584  IIS328DQ_INT1_ON_THRESHOLD_OR = 0,
585  IIS328DQ_INT1_ON_THRESHOLD_AND = 1,
586  } iis328dq_int1_aoi_t;
587  int32_t iis328dq_int1_on_threshold_mode_set(iis328dq_int1_aoi_t val);
588  int32_t iis328dq_int1_on_threshold_mode_get(iis328dq_int1_aoi_t *val);
589 
590  int32_t iis328dq_int1_src_get(iis328dq_int1_src_t *val);
591 
592  int32_t iis328dq_int1_treshold_set(uint8_t val);
593  int32_t iis328dq_int1_treshold_get(uint8_t *val);
594 
595  int32_t iis328dq_int1_dur_set(uint8_t val);
596  int32_t iis328dq_int1_dur_get(uint8_t *val);
597 
598  typedef struct
599  {
600  uint8_t int2_xlie : 1;
601  uint8_t int2_xhie : 1;
602  uint8_t int2_ylie : 1;
603  uint8_t int2_yhie : 1;
604  uint8_t int2_zlie : 1;
605  uint8_t int2_zhie : 1;
607  int32_t iis328dq_int2_on_threshold_conf_set(int2_on_th_conf_t val);
608  int32_t iis328dq_int2_on_threshold_conf_get(int2_on_th_conf_t *val);
609 
610  typedef enum
611  {
612  IIS328DQ_INT2_ON_THRESHOLD_OR = 0,
613  IIS328DQ_INT2_ON_THRESHOLD_AND = 1,
614  } iis328dq_int2_aoi_t;
615  int32_t iis328dq_int2_on_threshold_mode_set(iis328dq_int2_aoi_t val);
616  int32_t iis328dq_int2_on_threshold_mode_get(iis328dq_int2_aoi_t *val);
617 
618  int32_t iis328dq_int2_src_get(iis328dq_int2_src_t *val);
619 
620  int32_t iis328dq_int2_treshold_set(uint8_t val);
621  int32_t iis328dq_int2_treshold_get(uint8_t *val);
622 
623  int32_t iis328dq_int2_dur_set(uint8_t val);
624  int32_t iis328dq_int2_dur_get(uint8_t *val);
625 
626  int32_t iis328dq_wkup_to_sleep_set(uint8_t val);
627  int32_t iis328dq_wkup_to_sleep_get(uint8_t *val);
628 
629  typedef enum
630  {
631  IIS328DQ_6D_INT1_DISABLE = 0,
632  IIS328DQ_6D_INT1_MOVEMENT = 1,
633  IIS328DQ_6D_INT1_POSITION = 3,
634  } iis328dq_int1_6d_t;
635  int32_t iis328dq_int1_6d_mode_set(iis328dq_int1_6d_t val);
636  int32_t iis328dq_int1_6d_mode_get(iis328dq_int1_6d_t *val);
637 
638  int32_t iis328dq_int1_6d_src_get(iis328dq_int1_src_t *val);
639 
640  int32_t iis328dq_int1_6d_treshold_set(uint8_t val);
641  int32_t iis328dq_int1_6d_treshold_get(uint8_t *val);
642 
643  typedef enum
644  {
645  IIS328DQ_6D_INT2_DISABLE = 0,
646  IIS328DQ_6D_INT2_MOVEMENT = 1,
647  IIS328DQ_6D_INT2_POSITION = 3,
648  } iis328dq_int2_6d_t;
649  int32_t iis328dq_int2_6d_mode_set(iis328dq_int2_6d_t val);
650  int32_t iis328dq_int2_6d_mode_get(iis328dq_int2_6d_t *val);
651 
652  int32_t iis328dq_int2_6d_src_get(iis328dq_int2_src_t *val);
653 
654  int32_t iis328dq_int2_6d_treshold_set(uint8_t val);
655  int32_t iis328dq_int2_6d_treshold_get(uint8_t *val);
656 
657  // ********** Private Variables Semaphore ********** //
658 
659 protected:
660 private:
661  TwoWire *_wire;
662  BinarySemaphore *_wireLock;
663  uint8_t _i2c_address;
664  int16_t _raw_scroll[3][ARR_REG_FILTER];
665 };
666 
667 typedef struct
668 {
669  uint8_t config_valid;
671  float offset_x;
672  float offset_y;
673  float offset_z;
675 
676 #endif /* _ACCELEROMETR_H */
677 
678 
#define ARR_REG_FILTER
Definition: accelerometer.h:61
#define ACCELEROMETER_IIS328DQ_I2C_ADDR_DEFAULT
Definition: accelerometer.h:48
BinarySemaphore * _wireLock
TwoWire * _wire
uint8_t _i2c_address
Accelerometer::iis328dq_dr_t module_power
module updating frequency (enabled)
uint8_t config_valid
Inizialization Byte Config.
float offset_y
offset_y to 0
float offset_x
offset_x to 0
float offset_z
offset_z to 0
iis328dq_status_reg_t status_reg
iis328dq_int1_ths_t int1_ths
iis328dq_ctrl_reg4_t ctrl_reg4
iis328dq_int2_cfg_t int2_cfg
iis328dq_ctrl_reg3_t ctrl_reg3
iis328dq_int2_src_t int2_src
iis328dq_ctrl_reg1_t ctrl_reg1
iis328dq_int1_cfg_t int1_cfg
iis328dq_int1_duration_t int1_duration
iis328dq_int1_src_t int1_src
iis328dq_int2_duration_t int2_duration
iis328dq_int2_ths_t int2_ths
iis328dq_ctrl_reg5_t ctrl_reg5
iis328dq_ctrl_reg2_t ctrl_reg2