Stima V4 Slave RAIN  4.2
accelerometer.cpp
Go to the documentation of this file.
1 
30 #include "drivers/accelerometer.h"
31 
34 {
35 }
36 
41 Accelerometer::Accelerometer(TwoWire *wire, BinarySemaphore *wireLock, uint8_t i2c_address)
42 {
43  _wire = wire;
44  _wireLock = wireLock;
45  _i2c_address = i2c_address;
46  // Reset scroll filter array;
47  for(uint8_t scrl=0; scrl<ARR_REG_FILTER; scrl++) {
48  _raw_scroll[0][scrl] = INT16_MAX;
49  _raw_scroll[1][scrl] = INT16_MAX;
50  _raw_scroll[2][scrl] = INT16_MAX;
51  }
52 }
53 
59 int32_t Accelerometer::iis328dq_read_reg(uint8_t reg, uint8_t *data, uint16_t len)
60 {
61  // Try lock Semaphore
62  if (_wireLock->Take(Ticks::MsToTicks(ACCELEROMETER_SEMAPHORE_MAX_WAITING_TIME_MS)))
63  {
64  /* Read multiple command */
65  reg |= 0x80;
66  _wire->beginTransmission(_i2c_address);
67  _wire->write(reg);
68  _wire->endTransmission();
69  _wire->beginTransmission(_i2c_address);
70  _wire->requestFrom(_i2c_address, len);
71  for(uint8_t i=0; i<len; i++)
72  *(data + i) = _wire->read();
73  _wire->endTransmission();
74  _wireLock->Give();
75  return 0;
76  } else
77  return 1;
78 }
79 
85 int32_t Accelerometer::iis328dq_write_reg(uint8_t reg, uint8_t *data, uint16_t len)
86 {
87  // Try lock Semaphore
88  if (_wireLock->Take(Ticks::MsToTicks(ACCELEROMETER_SEMAPHORE_MAX_WAITING_TIME_MS)))
89  {
90  // /* Write multiple command */
91  reg|=0x80;
92  _wire->beginTransmission(_i2c_address);
93  _wire->write(reg);
94  for(uint8_t i=0; i<len; i++)
95  _wire->write(*(data + i));
96  _wire->endTransmission();
97  _wireLock->Give();
98  return 0;
99  } else
100  return 1;
101 }
102 
116 void Accelerometer::push_raw_data(int16_t *data_raw)
117 {
118  // Scroll Value
119  for(uint8_t i = (ARR_REG_FILTER-1); i>0; i--) {
120  _raw_scroll[0][i] = _raw_scroll[0][i-1];
121  _raw_scroll[1][i] = _raw_scroll[1][i-1];
122  _raw_scroll[2][i] = _raw_scroll[2][i-1];
123  }
124  // Add New
125  _raw_scroll[0][0] = data_raw[0];
126  _raw_scroll[1][0] = data_raw[1];
127  _raw_scroll[2][0] = data_raw[2];
128 }
129 
134  uint32_t tmp_data = 0;
135  uint8_t tmp_count = 0;
136  for(uint8_t i=0; i<ARR_REG_FILTER; i++) {
137  if((_raw_scroll[request][i]>=-16000) && (_raw_scroll[request][i]<=16000)) {
138  tmp_data += _raw_scroll[request][i];
139  tmp_count++;
140  }
141  }
142  return (int16_t) (tmp_data / tmp_count);
143 }
144 
149 {
150  return ((float_t)lsb * 0.98f / 16.0f);
151 }
152 
157 {
158  return ((float_t)get_raw_mean(request) * 0.98f / 16.0f);
159 }
160 
165 {
166  return ((float_t)lsb * 1.95f / 16.0f);
167 }
168 
173 {
174  return ((float_t)get_raw_mean(request) * 1.95f / 16.0f);
175 }
176 
181 {
182  return ((float_t)lsb * 3.91f / 16.0f);
183 }
184 
189 {
190  return ((float_t)get_raw_mean(request) * 3.91f / 16.0f);
191 }
192 
197 {
198  return ((float_t)lsb / 16000.0f);
199 }
200 
205 {
206  return ((float_t)get_raw_mean(request) / 16000.0f);
207 }
208 
223 {
224  iis328dq_ctrl_reg1_t ctrl_reg1;
225  int32_t ret;
226 
228  (uint8_t *)&ctrl_reg1, 1);
229 
230  if (ret == 0)
231  {
232  ctrl_reg1.xen = val;
234  (uint8_t *)&ctrl_reg1, 1);
235  }
236 
237  return ret;
238 }
239 
244 {
245  iis328dq_ctrl_reg1_t ctrl_reg1;
246  int32_t ret;
247 
249  (uint8_t *)&ctrl_reg1, 1);
250  *val = ctrl_reg1.xen;
251 
252  return ret;
253 }
254 
259 {
260  iis328dq_ctrl_reg1_t ctrl_reg1;
261  int32_t ret;
262 
264  (uint8_t *)&ctrl_reg1, 1);
265 
266  if (ret == 0)
267  {
268  ctrl_reg1.yen = val;
270  (uint8_t *)&ctrl_reg1, 1);
271  }
272 
273  return ret;
274 }
275 
280 {
281  iis328dq_ctrl_reg1_t ctrl_reg1;
282  int32_t ret;
283 
285  (uint8_t *)&ctrl_reg1, 1);
286  *val = ctrl_reg1.yen;
287 
288  return ret;
289 }
290 
295 {
296  iis328dq_ctrl_reg1_t ctrl_reg1;
297  int32_t ret;
298 
300  (uint8_t *)&ctrl_reg1, 1);
301 
302  if (ret == 0)
303  {
304  ctrl_reg1.zen = val;
306  (uint8_t *)&ctrl_reg1, 1);
307  }
308 
309  return ret;
310 }
311 
316 {
317  iis328dq_ctrl_reg1_t ctrl_reg1;
318  int32_t ret;
319 
321  (uint8_t *)&ctrl_reg1, 1);
322  *val = ctrl_reg1.zen;
323 
324  return ret;
325 }
326 
331 {
332  iis328dq_ctrl_reg1_t ctrl_reg1;
333  int32_t ret;
334 
336  (uint8_t *)&ctrl_reg1, 1);
337 
338  if (ret == 0)
339  {
340  ctrl_reg1.pm = (uint8_t)val & 0x07U;
341  ctrl_reg1.dr = ((uint8_t)val & 0x30U) >> 4;
343  (uint8_t *)&ctrl_reg1, 1);
344  }
345 
346  return ret;
347 }
348 
353 {
354  iis328dq_ctrl_reg1_t ctrl_reg1;
355  int32_t ret;
356 
358  (uint8_t *)&ctrl_reg1, 1);
359 
360  switch ((ctrl_reg1.dr << 4) + ctrl_reg1.pm)
361  {
362  case IIS328DQ_ODR_OFF:
363  *val = IIS328DQ_ODR_OFF;
364  break;
365 
366  case IIS328DQ_ODR_Hz5:
367  *val = IIS328DQ_ODR_Hz5;
368  break;
369 
370  case IIS328DQ_ODR_1Hz:
371  *val = IIS328DQ_ODR_1Hz;
372  break;
373 
374  case IIS328DQ_ODR_5Hz2:
375  *val = IIS328DQ_ODR_5Hz2;
376  break;
377 
378  case IIS328DQ_ODR_5Hz:
379  *val = IIS328DQ_ODR_5Hz;
380  break;
381 
382  case IIS328DQ_ODR_10Hz:
383  *val = IIS328DQ_ODR_10Hz;
384  break;
385 
386  case IIS328DQ_ODR_50Hz:
387  *val = IIS328DQ_ODR_50Hz;
388  break;
389 
390  case IIS328DQ_ODR_100Hz:
391  *val = IIS328DQ_ODR_100Hz;
392  break;
393 
394  case IIS328DQ_ODR_400Hz:
395  *val = IIS328DQ_ODR_400Hz;
396  break;
397 
398  case IIS328DQ_ODR_1kHz:
399  *val = IIS328DQ_ODR_1kHz;
400  break;
401 
402  default:
403  *val = IIS328DQ_ODR_OFF;
404  break;
405  }
406 
407  return ret;
408 }
409 
414 {
415  iis328dq_ctrl_reg2_t ctrl_reg2;
416  int32_t ret;
417 
419  (uint8_t *)&ctrl_reg2, 1);
420 
421  if (ret == 0)
422  {
423  ctrl_reg2.hpm = (uint8_t)val;
425  (uint8_t *)&ctrl_reg2, 1);
426  }
427 
428  return ret;
429 }
430 
435 {
436  iis328dq_ctrl_reg2_t ctrl_reg2;
437  int32_t ret;
438 
440  (uint8_t *)&ctrl_reg2, 1);
441 
442  switch (ctrl_reg2.hpm)
443  {
445  *val = IIS328DQ_NORMAL_MODE;
446  break;
447 
450  break;
451 
452  default:
453  *val = IIS328DQ_NORMAL_MODE;
454  break;
455  }
456 
457  return ret;
458 }
459 
464 {
465  iis328dq_ctrl_reg4_t ctrl_reg4;
466  int32_t ret;
467 
469  (uint8_t *)&ctrl_reg4, 1);
470 
471  if (ret == 0)
472  {
473  ctrl_reg4.fs = (uint8_t)val;
475  (uint8_t *)&ctrl_reg4, 1);
476  }
477 
478  return ret;
479 }
480 
485 {
486  iis328dq_ctrl_reg4_t ctrl_reg4;
487  int32_t ret;
488 
490  (uint8_t *)&ctrl_reg4, 1);
491 
492  switch (ctrl_reg4.fs)
493  {
494  case IIS328DQ_2g:
495  *val = IIS328DQ_2g;
496  break;
497 
498  case IIS328DQ_4g:
499  *val = IIS328DQ_4g;
500  break;
501 
502  case IIS328DQ_8g:
503  *val = IIS328DQ_8g;
504  break;
505 
506  default:
507  *val = IIS328DQ_2g;
508  break;
509  }
510 
511  return ret;
512 }
513 
518 {
519  iis328dq_ctrl_reg4_t ctrl_reg4;
520  int32_t ret;
521 
523  (uint8_t *)&ctrl_reg4, 1);
524 
525  if (ret == 0)
526  {
527  ctrl_reg4.bdu = val;
529  (uint8_t *)&ctrl_reg4, 1);
530  }
531 
532  return ret;
533 }
534 
539 {
540  iis328dq_ctrl_reg4_t ctrl_reg4;
541  int32_t ret;
542 
544  (uint8_t *)&ctrl_reg4, 1);
545  *val = ctrl_reg4.bdu;
546 
547  return ret;
548 }
549 
554 {
555  int32_t ret;
556 
557  ret = iis328dq_read_reg(IIS328DQ_STATUS_REG, (uint8_t *) val, 1);
558 
559  return ret;
560 }
561 
566 {
567  iis328dq_status_reg_t status_reg;
568  int32_t ret;
569 
571  (uint8_t *)&status_reg, 1);
572  *val = status_reg.zyxda;
573 
574  return ret;
575 }
576 
592 {
593  uint8_t buff[6];
594  int32_t ret;
595 
596  ret = iis328dq_read_reg(IIS328DQ_OUT_X_L, buff, 6);
597  val[0] = (int16_t)buff[1];
598  val[0] = (val[0] * 256) + (int16_t)buff[0];
599  val[1] = (int16_t)buff[3];
600  val[1] = (val[1] * 256) + (int16_t)buff[2];
601  val[2] = (int16_t)buff[5];
602  val[2] = (val[2] * 256) + (int16_t)buff[4];
603 
604  return ret;
605 }
606 
621 {
622  int32_t ret;
623 
624  ret = iis328dq_read_reg(IIS328DQ_WHO_AM_I, buff, 1);
625 
626  return ret;
627 }
628 
633 {
634  iis328dq_ctrl_reg2_t ctrl_reg2;
635  int32_t ret;
636 
638  (uint8_t *)&ctrl_reg2, 1);
639 
640  if (ret == 0)
641  {
642  ctrl_reg2.boot = val;
644  (uint8_t *)&ctrl_reg2, 1);
645  }
646 
647  return ret;
648 }
649 
653 int32_t Accelerometer::iis328dq_boot_get(uint8_t *val)
654 {
655  iis328dq_ctrl_reg2_t ctrl_reg2;
656  int32_t ret;
657 
659  (uint8_t *)&ctrl_reg2, 1);
660  *val = ctrl_reg2.boot;
661 
662  return ret;
663 }
664 
669 {
670  iis328dq_ctrl_reg4_t ctrl_reg4;
671  int32_t ret;
672 
674  (uint8_t *)&ctrl_reg4, 1);
675 
676  if (ret == 0)
677  {
678  ctrl_reg4.st = (uint8_t)val;
680  (uint8_t *)&ctrl_reg4, 1);
681  }
682 
683  return ret;
684 }
685 
690 {
691  iis328dq_ctrl_reg4_t ctrl_reg4;
692  int32_t ret;
693 
695  (uint8_t *)&ctrl_reg4, 1);
696 
697  switch (ctrl_reg4.st)
698  {
699  case IIS328DQ_ST_DISABLE:
700  *val = IIS328DQ_ST_DISABLE;
701  break;
702 
704  *val = IIS328DQ_ST_POSITIVE;
705  break;
706 
708  *val = IIS328DQ_ST_NEGATIVE;
709  break;
710 
711  default:
712  *val = IIS328DQ_ST_DISABLE;
713  break;
714  }
715 
716  return ret;
717 }
718 
723 {
724  iis328dq_ctrl_reg4_t ctrl_reg4;
725  int32_t ret;
726 
728  (uint8_t *)&ctrl_reg4, 1);
729 
730  if (ret == 0)
731  {
732  ctrl_reg4.ble = (uint8_t)val;
734  (uint8_t *)&ctrl_reg4, 1);
735  }
736 
737  return ret;
738 }
739 
744 {
745  iis328dq_ctrl_reg4_t ctrl_reg4;
746  int32_t ret;
747 
749  (uint8_t *)&ctrl_reg4, 1);
750 
751  switch (ctrl_reg4.ble)
752  {
755  break;
756 
759  break;
760 
761  default:
763  break;
764  }
765 
766  return ret;
767 }
768 
783 {
784  iis328dq_ctrl_reg2_t ctrl_reg2;
785  int32_t ret;
786 
788  (uint8_t *)&ctrl_reg2, 1);
789 
790  if (ret == 0)
791  {
792  ctrl_reg2.hpcf = (uint8_t)val;
794  (uint8_t *)&ctrl_reg2, 1);
795  }
796 
797  return ret;
798 }
799 
804 {
805  iis328dq_ctrl_reg2_t ctrl_reg2;
806  int32_t ret;
807 
809  (uint8_t *)&ctrl_reg2, 1);
810 
811  switch (ctrl_reg2.hpcf)
812  {
814  *val = IIS328DQ_CUT_OFF_8Hz;
815  break;
816 
818  *val = IIS328DQ_CUT_OFF_16Hz;
819  break;
820 
822  *val = IIS328DQ_CUT_OFF_32Hz;
823  break;
824 
826  *val = IIS328DQ_CUT_OFF_64Hz;
827  break;
828 
829  default:
830  *val = IIS328DQ_CUT_OFF_8Hz;
831  break;
832  }
833 
834  return ret;
835 }
836 
841 {
842  iis328dq_ctrl_reg2_t ctrl_reg2;
843  int32_t ret;
844 
846  (uint8_t *)&ctrl_reg2, 1);
847 
848  if (ret == 0)
849  {
850  ctrl_reg2.hpen = (uint8_t)val & 0x03U;
851  ctrl_reg2.fds = ((uint8_t)val & 0x04U) >> 2;
853  (uint8_t *)&ctrl_reg2, 1);
854  }
855 
856  return ret;
857 }
858 
863 {
864  iis328dq_ctrl_reg2_t ctrl_reg2;
865  int32_t ret;
866 
868  (uint8_t *)&ctrl_reg2, 1);
869 
870  switch ((ctrl_reg2.fds << 2) + ctrl_reg2.hpen)
871  {
872  case IIS328DQ_HP_DISABLE:
873  *val = IIS328DQ_HP_DISABLE;
874  break;
875 
876  case IIS328DQ_HP_ON_OUT:
877  *val = IIS328DQ_HP_ON_OUT;
878  break;
879 
880  case IIS328DQ_HP_ON_INT1:
881  *val = IIS328DQ_HP_ON_INT1;
882  break;
883 
884  case IIS328DQ_HP_ON_INT2:
885  *val = IIS328DQ_HP_ON_INT2;
886  break;
887 
890  break;
891 
894  break;
895 
898  break;
899 
902  break;
903 
904  default:
905  *val = IIS328DQ_HP_DISABLE;
906  break;
907  }
908 
909  return ret;
910 }
911 
920 {
921  uint8_t dummy;
922  int32_t ret;
923 
925  (uint8_t *)&dummy, 1);
926 
927  return ret;
928 }
929 
934 {
935  int32_t ret;
936 
937  ret = iis328dq_write_reg(IIS328DQ_REFERENCE, (uint8_t *)&val, 1);
938 
939  return ret;
940 }
941 
946 {
947  int32_t ret;
948 
949  ret = iis328dq_read_reg(IIS328DQ_REFERENCE, val, 1);
950 
951  return ret;
952 }
953 
968 {
969  iis328dq_ctrl_reg4_t ctrl_reg4;
970  int32_t ret;
971 
973  (uint8_t *)&ctrl_reg4, 1);
974 
975  if (ret == 0)
976  {
977  ctrl_reg4.sim = (uint8_t)val;
979  (uint8_t *)&ctrl_reg4, 1);
980  }
981 
982  return ret;
983 }
984 
989 {
990  iis328dq_ctrl_reg4_t ctrl_reg4;
991  int32_t ret;
992 
994  (uint8_t *)&ctrl_reg4, 1);
995 
996  switch (ctrl_reg4.sim)
997  {
998  case IIS328DQ_SPI_4_WIRE:
999  *val = IIS328DQ_SPI_4_WIRE;
1000  break;
1001 
1002  case IIS328DQ_SPI_3_WIRE:
1003  *val = IIS328DQ_SPI_3_WIRE;
1004  break;
1005 
1006  default:
1007  *val = IIS328DQ_SPI_4_WIRE;
1008  break;
1009  }
1010 
1011  return ret;
1012 }
1013 
1028 {
1029  iis328dq_ctrl_reg3_t ctrl_reg3;
1030  int32_t ret;
1031 
1033  (uint8_t *)&ctrl_reg3, 1);
1034 
1035  if (ret == 0)
1036  {
1037  ctrl_reg3.i1_cfg = (uint8_t)val;
1039  (uint8_t *)&ctrl_reg3, 1);
1040  }
1041 
1042  return ret;
1043 }
1044 
1049 {
1050  iis328dq_ctrl_reg3_t ctrl_reg3;
1051  int32_t ret;
1052 
1054  (uint8_t *)&ctrl_reg3, 1);
1055 
1056  switch (ctrl_reg3.i1_cfg)
1057  {
1059  *val = IIS328DQ_PAD1_INT1_SRC;
1060  break;
1061 
1064  break;
1065 
1066  case IIS328DQ_PAD1_DRDY:
1067  *val = IIS328DQ_PAD1_DRDY;
1068  break;
1069 
1070  case IIS328DQ_PAD1_BOOT:
1071  *val = IIS328DQ_PAD1_BOOT;
1072  break;
1073 
1074  default:
1075  *val = IIS328DQ_PAD1_INT1_SRC;
1076  break;
1077  }
1078 
1079  return ret;
1080 }
1081 
1087 {
1088  iis328dq_ctrl_reg3_t ctrl_reg3;
1089  int32_t ret;
1090 
1092  (uint8_t *)&ctrl_reg3, 1);
1093 
1094  if (ret == 0)
1095  {
1096  ctrl_reg3.lir1 = (uint8_t)val;
1098  (uint8_t *)&ctrl_reg3, 1);
1099  }
1100 
1101  return ret;
1102 }
1103 
1109 {
1110  iis328dq_ctrl_reg3_t ctrl_reg3;
1111  int32_t ret;
1112 
1114  (uint8_t *)&ctrl_reg3, 1);
1115 
1116  switch (ctrl_reg3.lir1)
1117  {
1118  case IIS328DQ_INT1_PULSED:
1119  *val = IIS328DQ_INT1_PULSED;
1120  break;
1121 
1122  case IIS328DQ_INT1_LATCHED:
1123  *val = IIS328DQ_INT1_LATCHED;
1124  break;
1125 
1126  default:
1127  *val = IIS328DQ_INT1_PULSED;
1128  break;
1129  }
1130 
1131  return ret;
1132 }
1133 
1138 {
1139  iis328dq_ctrl_reg3_t ctrl_reg3;
1140  int32_t ret;
1141 
1143  (uint8_t *)&ctrl_reg3, 1);
1144 
1145  if (ret == 0)
1146  {
1147  ctrl_reg3.i2_cfg = (uint8_t)val;
1149  (uint8_t *)&ctrl_reg3, 1);
1150  }
1151 
1152  return ret;
1153 }
1154 
1159 {
1160  iis328dq_ctrl_reg3_t ctrl_reg3;
1161  int32_t ret;
1162 
1164  (uint8_t *)&ctrl_reg3, 1);
1165 
1166  switch (ctrl_reg3.i2_cfg)
1167  {
1169  *val = IIS328DQ_PAD2_INT2_SRC;
1170  break;
1171 
1174  break;
1175 
1176  case IIS328DQ_PAD2_DRDY:
1177  *val = IIS328DQ_PAD2_DRDY;
1178  break;
1179 
1180  case IIS328DQ_PAD2_BOOT:
1181  *val = IIS328DQ_PAD2_BOOT;
1182  break;
1183 
1184  default:
1185  *val = IIS328DQ_PAD2_INT2_SRC;
1186  break;
1187  }
1188 
1189  return ret;
1190 }
1191 
1197 {
1198  iis328dq_ctrl_reg3_t ctrl_reg3;
1199  int32_t ret;
1200 
1202  (uint8_t *)&ctrl_reg3, 1);
1203 
1204  if (ret == 0)
1205  {
1206  ctrl_reg3.lir2 = (uint8_t)val;
1208  (uint8_t *)&ctrl_reg3, 1);
1209  }
1210 
1211  return ret;
1212 }
1213 
1219 {
1220  iis328dq_ctrl_reg3_t ctrl_reg3;
1221  int32_t ret;
1222 
1224  (uint8_t *)&ctrl_reg3, 1);
1225 
1226  switch (ctrl_reg3.lir2)
1227  {
1228  case IIS328DQ_INT2_PULSED:
1229  *val = IIS328DQ_INT2_PULSED;
1230  break;
1231 
1232  case IIS328DQ_INT2_LATCHED:
1233  *val = IIS328DQ_INT2_LATCHED;
1234  break;
1235 
1236  default:
1237  *val = IIS328DQ_INT2_PULSED;
1238  break;
1239  }
1240 
1241  return ret;
1242 }
1243 
1248 {
1249  iis328dq_ctrl_reg3_t ctrl_reg3;
1250  int32_t ret;
1251 
1253  (uint8_t *)&ctrl_reg3, 1);
1254 
1255  if (ret == 0)
1256  {
1257  ctrl_reg3.pp_od = (uint8_t)val;
1259  (uint8_t *)&ctrl_reg3, 1);
1260  }
1261 
1262  return ret;
1263 }
1264 
1269 {
1270  iis328dq_ctrl_reg3_t ctrl_reg3;
1271  int32_t ret;
1272 
1274  (uint8_t *)&ctrl_reg3, 1);
1275 
1276  switch (ctrl_reg3.pp_od)
1277  {
1278  case IIS328DQ_PUSH_PULL:
1279  *val = IIS328DQ_PUSH_PULL;
1280  break;
1281 
1282  case IIS328DQ_OPEN_DRAIN:
1283  *val = IIS328DQ_OPEN_DRAIN;
1284  break;
1285 
1286  default:
1287  *val = IIS328DQ_PUSH_PULL;
1288  break;
1289  }
1290 
1291  return ret;
1292 }
1293 
1298 {
1299  iis328dq_ctrl_reg3_t ctrl_reg3;
1300  int32_t ret;
1301 
1303  (uint8_t *)&ctrl_reg3, 1);
1304 
1305  if (ret == 0)
1306  {
1307  ctrl_reg3.ihl = (uint8_t)val;
1309  (uint8_t *)&ctrl_reg3, 1);
1310  }
1311 
1312  return ret;
1313 }
1314 
1319 {
1320  iis328dq_ctrl_reg3_t ctrl_reg3;
1321  int32_t ret;
1322 
1324  (uint8_t *)&ctrl_reg3, 1);
1325 
1326  switch (ctrl_reg3.ihl)
1327  {
1328  case IIS328DQ_ACTIVE_HIGH:
1329  *val = IIS328DQ_ACTIVE_HIGH;
1330  break;
1331 
1332  case IIS328DQ_ACTIVE_LOW:
1333  *val = IIS328DQ_ACTIVE_LOW;
1334  break;
1335 
1336  default:
1337  *val = IIS328DQ_ACTIVE_HIGH;
1338  break;
1339  }
1340 
1341  return ret;
1342 }
1343 
1358 {
1359  iis328dq_int1_cfg_t int1_cfg;
1360  int32_t ret;
1361 
1362  ret = iis328dq_read_reg(IIS328DQ_INT1_CFG, (uint8_t *)&int1_cfg, 1);
1363 
1364  if (ret == 0)
1365  {
1366  int1_cfg.xlie = val.int1_xlie;
1367  int1_cfg.xhie = val.int1_xhie;
1368  int1_cfg.ylie = val.int1_ylie;
1369  int1_cfg.yhie = val.int1_yhie;
1370  int1_cfg.zlie = val.int1_zlie;
1371  int1_cfg.zhie = val.int1_zhie;
1373  (uint8_t *)&int1_cfg, 1);
1374  }
1375 
1376  return ret;
1377 }
1378 
1383 {
1384  iis328dq_int1_cfg_t int1_cfg;
1385  int32_t ret;
1386 
1387  ret = iis328dq_read_reg(IIS328DQ_INT1_CFG, (uint8_t *)&int1_cfg, 1);
1388  val->int1_xlie = int1_cfg.xlie;
1389  val->int1_xhie = int1_cfg.xhie;
1390  val->int1_ylie = int1_cfg.ylie;
1391  val->int1_yhie = int1_cfg.yhie;
1392  val->int1_zlie = int1_cfg.zlie;
1393  val->int1_zhie = int1_cfg.zhie;
1394 
1395  return ret;
1396 }
1397 
1402 {
1403  iis328dq_int1_cfg_t int1_cfg;
1404  int32_t ret;
1405 
1406  ret = iis328dq_read_reg(IIS328DQ_INT1_CFG, (uint8_t *)&int1_cfg, 1);
1407 
1408  if (ret == 0)
1409  {
1410  int1_cfg.aoi = (uint8_t) val;
1412  (uint8_t *)&int1_cfg, 1);
1413  }
1414 
1415  return ret;
1416 }
1417 
1422 {
1423  iis328dq_int1_cfg_t int1_cfg;
1424  int32_t ret;
1425 
1426  ret = iis328dq_read_reg(IIS328DQ_INT1_CFG, (uint8_t *)&int1_cfg, 1);
1427 
1428  switch (int1_cfg.aoi)
1429  {
1432  break;
1433 
1436  break;
1437 
1438  default:
1440  break;
1441  }
1442 
1443  return ret;
1444 }
1445 
1450 {
1451  int32_t ret;
1452 
1453  ret = iis328dq_read_reg(IIS328DQ_INT1_SRC, (uint8_t *) val, 1);
1454 
1455  return ret;
1456 }
1457 
1462 {
1463  iis328dq_int1_ths_t int1_ths;
1464  int32_t ret;
1465 
1466  ret = iis328dq_read_reg(IIS328DQ_INT1_THS, (uint8_t *)&int1_ths, 1);
1467 
1468  if (ret == 0)
1469  {
1470  int1_ths.ths = val;
1472  (uint8_t *)&int1_ths, 1);
1473  }
1474 
1475  return ret;
1476 }
1477 
1482 {
1483  iis328dq_int1_ths_t int1_ths;
1484  int32_t ret;
1485 
1486  ret = iis328dq_read_reg(IIS328DQ_INT1_THS, (uint8_t *)&int1_ths, 1);
1487  *val = int1_ths.ths;
1488 
1489  return ret;
1490 }
1491 
1496 {
1497  iis328dq_int1_duration_t int1_duration;
1498  int32_t ret;
1499 
1501  (uint8_t *)&int1_duration, 1);
1502 
1503  if (ret == 0)
1504  {
1505  int1_duration.d = val;
1507  (uint8_t *)&int1_duration, 1);
1508  }
1509 
1510  return ret;
1511 }
1512 
1517 {
1518  iis328dq_int1_duration_t int1_duration;
1519  int32_t ret;
1520 
1522  (uint8_t *)&int1_duration, 1);
1523  *val = int1_duration.d;
1524 
1525  return ret;
1526 }
1527 
1532 {
1533  iis328dq_int2_cfg_t int2_cfg;
1534  int32_t ret;
1535 
1537  (uint8_t *)&int2_cfg, 1);
1538 
1539  if (ret == 0)
1540  {
1541  int2_cfg.xlie = val.int2_xlie;
1542  int2_cfg.xhie = val.int2_xhie;
1543  int2_cfg.ylie = val.int2_ylie;
1544  int2_cfg.yhie = val.int2_yhie;
1545  int2_cfg.zlie = val.int2_zlie;
1546  int2_cfg.zhie = val.int2_zhie;
1548  (uint8_t *)&int2_cfg, 1);
1549  }
1550 
1551  return ret;
1552 }
1553 
1558 {
1559  iis328dq_int2_cfg_t int2_cfg;
1560  int32_t ret;
1561 
1562  ret = iis328dq_read_reg(IIS328DQ_INT2_CFG, (uint8_t *)&int2_cfg, 1);
1563  val->int2_xlie = int2_cfg.xlie;
1564  val->int2_xhie = int2_cfg.xhie;
1565  val->int2_ylie = int2_cfg.ylie;
1566  val->int2_yhie = int2_cfg.yhie;
1567  val->int2_zlie = int2_cfg.zlie;
1568  val->int2_zhie = int2_cfg.zhie;
1569 
1570  return ret;
1571 }
1572 
1577 {
1578  iis328dq_int2_cfg_t int2_cfg;
1579  int32_t ret;
1580 
1581  ret = iis328dq_read_reg(IIS328DQ_INT2_CFG, (uint8_t *)&int2_cfg, 1);
1582 
1583  if (ret == 0)
1584  {
1585  int2_cfg.aoi = (uint8_t) val;
1587  (uint8_t *)&int2_cfg, 1);
1588  }
1589 
1590  return ret;
1591 }
1592 
1597 {
1598  iis328dq_int2_cfg_t int2_cfg;
1599  int32_t ret;
1600 
1601  ret = iis328dq_read_reg(IIS328DQ_INT2_CFG, (uint8_t *)&int2_cfg, 1);
1602 
1603  switch (int2_cfg.aoi)
1604  {
1607  break;
1608 
1611  break;
1612 
1613  default:
1615  break;
1616  }
1617 
1618  return ret;
1619 }
1620 
1625 {
1626  int32_t ret;
1627 
1628  ret = iis328dq_read_reg(IIS328DQ_INT2_SRC, (uint8_t *) val, 1);
1629 
1630  return ret;
1631 }
1632 
1637 {
1638  iis328dq_int2_ths_t int2_ths;
1639  int32_t ret;
1640 
1641  ret = iis328dq_read_reg(IIS328DQ_INT2_THS, (uint8_t *)&int2_ths, 1);
1642 
1643  if (ret == 0)
1644  {
1645  int2_ths.ths = val;
1647  (uint8_t *)&int2_ths, 1);
1648  }
1649 
1650  return ret;
1651 }
1652 
1657 {
1658  iis328dq_int2_ths_t int2_ths;
1659  int32_t ret;
1660 
1661  ret = iis328dq_read_reg(IIS328DQ_INT2_THS, (uint8_t *)&int2_ths, 1);
1662  *val = int2_ths.ths;
1663 
1664  return ret;
1665 }
1666 
1671 {
1672  iis328dq_int2_duration_t int2_duration;
1673  int32_t ret;
1674 
1676  (uint8_t *)&int2_duration, 1);
1677 
1678  if (ret == 0)
1679  {
1680  int2_duration.d = val;
1682  (uint8_t *)&int2_duration, 1);
1683  }
1684 
1685  return ret;
1686 }
1687 
1692 {
1693  iis328dq_int2_duration_t int2_duration;
1694  int32_t ret;
1695 
1697  (uint8_t *)&int2_duration, 1);
1698  *val = int2_duration.d;
1699 
1700  return ret;
1701 }
1702 
1717 {
1718  iis328dq_ctrl_reg5_t ctrl_reg5;
1719  int32_t ret;
1720 
1722  (uint8_t *)&ctrl_reg5, 1);
1723 
1724  if (ret == 0)
1725  {
1726  ctrl_reg5.turnon = val;
1728  (uint8_t *)&ctrl_reg5, 1);
1729  }
1730 
1731  return ret;
1732 }
1733 
1738 {
1739  iis328dq_ctrl_reg5_t ctrl_reg5;
1740  int32_t ret;
1741 
1743  (uint8_t *)&ctrl_reg5, 1);
1744  *val = ctrl_reg5.turnon;
1745 
1746  return ret;
1747 }
1748 
1763 {
1764  iis328dq_int1_cfg_t int1_cfg;
1765  int32_t ret;
1766 
1767  ret = iis328dq_read_reg(IIS328DQ_INT1_CFG, (uint8_t *)&int1_cfg, 1);
1768 
1769  if (ret == 0)
1770  {
1771  int1_cfg._6d = (uint8_t)val & 0x01U;
1772  int1_cfg.aoi = ((uint8_t)val & 0x02U) >> 1;
1773  ret = iis328dq_write_reg(IIS328DQ_INT1_CFG, (uint8_t *)&int1_cfg, 1);
1774  }
1775 
1776  return ret;
1777 }
1778 
1783 {
1784  iis328dq_int1_cfg_t int1_cfg;
1785  int32_t ret;
1786 
1787  ret = iis328dq_read_reg(IIS328DQ_INT1_CFG, (uint8_t *)&int1_cfg, 1);
1788 
1789  switch ((int1_cfg.aoi << 1) + int1_cfg._6d)
1790  {
1792  *val = IIS328DQ_6D_INT1_DISABLE;
1793  break;
1794 
1797  break;
1798 
1801  break;
1802 
1803  default:
1804  *val = IIS328DQ_6D_INT1_DISABLE;
1805  break;
1806  }
1807 
1808  return ret;
1809 }
1810 
1815 {
1816  int32_t ret;
1817 
1818  ret = iis328dq_read_reg(IIS328DQ_INT1_SRC, (uint8_t *) val, 1);
1819 
1820  return ret;
1821 }
1822 
1827 {
1828  iis328dq_int1_ths_t int1_ths;
1829  int32_t ret;
1830 
1831  ret = iis328dq_read_reg(IIS328DQ_INT1_THS, (uint8_t *)&int1_ths, 1);
1832 
1833  if (ret == 0)
1834  {
1835  int1_ths.ths = val;
1836  ret = iis328dq_write_reg(IIS328DQ_INT1_THS, (uint8_t *)&int1_ths, 1);
1837  }
1838 
1839  return ret;
1840 }
1841 
1846 {
1847  iis328dq_int1_ths_t int1_ths;
1848  int32_t ret;
1849 
1850  ret = iis328dq_read_reg(IIS328DQ_INT1_THS, (uint8_t *)&int1_ths, 1);
1851  *val = int1_ths.ths;
1852 
1853  return ret;
1854 }
1855 
1860 {
1861  iis328dq_int2_cfg_t int2_cfg;
1862  int32_t ret;
1863 
1864  ret = iis328dq_read_reg(IIS328DQ_INT2_CFG, (uint8_t *)&int2_cfg, 1);
1865 
1866  if (ret == 0)
1867  {
1868  int2_cfg._6d = (uint8_t)val & 0x01U;
1869  int2_cfg.aoi = ((uint8_t)val & 0x02U) >> 1;
1871  (uint8_t *)&int2_cfg, 1);
1872  }
1873 
1874  return ret;
1875 }
1876 
1881 {
1882  iis328dq_int2_cfg_t int2_cfg;
1883  int32_t ret;
1884 
1885  ret = iis328dq_read_reg(IIS328DQ_INT2_CFG, (uint8_t *)&int2_cfg, 1);
1886 
1887  switch ((int2_cfg.aoi << 1) + int2_cfg._6d)
1888  {
1890  *val = IIS328DQ_6D_INT2_DISABLE;
1891  break;
1892 
1895  break;
1896 
1899  break;
1900 
1901  default:
1902  *val = IIS328DQ_6D_INT2_DISABLE;
1903  break;
1904  }
1905 
1906  return ret;
1907 }
1908 
1913 {
1914  int32_t ret;
1915 
1916  ret = iis328dq_read_reg(IIS328DQ_INT2_SRC, (uint8_t *) val, 1);
1917 
1918  return ret;
1919 }
1920 
1925 {
1926  iis328dq_int2_ths_t int2_ths;
1927  int32_t ret;
1928 
1929  ret = iis328dq_read_reg(IIS328DQ_INT2_THS, (uint8_t *)&int2_ths, 1);
1930 
1931  if (ret == 0)
1932  {
1933  int2_ths.ths = val;
1935  (uint8_t *)&int2_ths, 1);
1936  }
1937 
1938  return ret;
1939 }
1940 
1945 {
1946  iis328dq_int2_ths_t int2_ths;
1947  int32_t ret;
1948 
1949  ret = iis328dq_read_reg(IIS328DQ_INT2_THS, (uint8_t *)&int2_ths, 1);
1950  *val = int2_ths.ths;
1951 
1952  return ret;
1953 }
1954 
accelerometer IIS328DQ header file
#define IIS328DQ_INT2_CFG
#define IIS328DQ_INT2_DURATION
#define IIS328DQ_REFERENCE
#define ACCELEROMETER_SEMAPHORE_MAX_WAITING_TIME_MS
Definition: accelerometer.h:44
#define IIS328DQ_OUT_X_L
#define IIS328DQ_CTRL_REG1
#define ARR_REG_FILTER
Definition: accelerometer.h:61
#define IIS328DQ_WHO_AM_I
#define IIS328DQ_HP_FILTER_RESET
#define IIS328DQ_INT1_DURATION
#define IIS328DQ_INT2_SRC
#define IIS328DQ_CTRL_REG4
#define IIS328DQ_INT1_CFG
#define IIS328DQ_INT1_SRC
#define IIS328DQ_CTRL_REG5
#define IIS328DQ_INT2_THS
#define IIS328DQ_INT1_THS
#define IIS328DQ_CTRL_REG2
#define IIS328DQ_STATUS_REG
#define IIS328DQ_CTRL_REG3
int32_t iis328dq_write_reg(uint8_t reg, uint8_t *data, uint16_t len)
Write generic device register.
int16_t _raw_scroll[3][ARR_REG_FILTER]
@ IIS328DQ_HP_ON_INT1_INT2_OUT
BinarySemaphore * _wireLock
@ IIS328DQ_INT1_ON_THRESHOLD_AND
@ IIS328DQ_INT1_ON_THRESHOLD_OR
TwoWire * _wire
@ IIS328DQ_PAD1_INT1_OR_INT2_SRC
Accelerometer()
Constructor Class.
int32_t iis328dq_read_reg(uint8_t reg, uint8_t *data, uint16_t len)
Read generic device register.
uint8_t _i2c_address
@ IIS328DQ_PAD2_INT1_OR_INT2_SRC
@ IIS328DQ_INT2_ON_THRESHOLD_OR
@ IIS328DQ_INT2_ON_THRESHOLD_AND
int32_t iis328dq_data_format_set(iis328dq_ble_t val)
Big/Little Endian Data selection.[set].
int32_t iis328dq_boot_set(uint8_t val)
Reboot memory content. Reload the calibration parameters.[set].
int32_t iis328dq_device_id_get(uint8_t *buff)
Device Who am I.[get].
int32_t iis328dq_data_format_get(iis328dq_ble_t *val)
Big/Little Endian Data selection.[get].
int32_t iis328dq_boot_get(uint8_t *val)
Reboot memory content. Reload the calibration parameters.[get].
int32_t iis328dq_self_test_get(iis328dq_st_t *val)
Linear acceleration sensor self-test enable.[get].
int32_t iis328dq_self_test_set(iis328dq_st_t val)
Linear acceleration sensor self-test enable.[set].
int32_t iis328dq_reference_mode_set(iis328dq_hpm_t val)
High pass filter mode selection.[set].
int32_t iis328dq_axis_x_data_set(uint8_t val)
X axis enable/disable.[set].
int32_t iis328dq_full_scale_get(iis328dq_fs_t *val)
Accelerometer full-scale selection.[get].
int32_t iis328dq_block_data_update_set(uint8_t val)
Block data update.[set].
int32_t iis328dq_flag_data_ready_get(uint8_t *val)
Accelerometer new data available.[get].
int32_t iis328dq_axis_x_data_get(uint8_t *val)
X axis enable/disable.[get].
int32_t iis328dq_axis_y_data_set(uint8_t val)
Y axis enable/disable.[set].
int32_t iis328dq_axis_z_data_set(uint8_t val)
Z axis enable/disable.[set].
int32_t iis328dq_data_rate_get(iis328dq_dr_t *val)
Accelerometer data rate selection.[get].
int32_t iis328dq_full_scale_set(iis328dq_fs_t val)
Accelerometer full-scale selection.[set].
int32_t iis328dq_axis_y_data_get(uint8_t *val)
Y axis enable/disable.[get].
int32_t iis328dq_status_reg_get(iis328dq_status_reg_t *val)
The STATUS_REG register is read by the interface.[get].
int32_t iis328dq_data_rate_set(iis328dq_dr_t val)
Accelerometer data rate selection.[set].
int32_t iis328dq_block_data_update_get(uint8_t *val)
Block data update.[get].
int32_t iis328dq_axis_z_data_get(uint8_t *val)
Z axis enable/disable.[get].
int32_t iis328dq_reference_mode_get(iis328dq_hpm_t *val)
High pass filter mode selection.[get].
int32_t iis328dq_acceleration_raw_get(int16_t *val)
Linear acceleration output register. The value is expressed as a 16-bit word in two’s complement....
int32_t iis328dq_hp_bandwidth_get(iis328dq_hpcf_t *val)
High pass filter cut-off frequency configuration.[get].
int32_t iis328dq_hp_reference_value_set(uint8_t val)
Reference value for high-pass filter.[set].
int32_t iis328dq_hp_path_get(iis328dq_hpen_t *val)
Select High Pass filter path.[get].
int32_t iis328dq_hp_reference_value_get(uint8_t *val)
Reference value for high-pass filter.[get].
int32_t iis328dq_hp_bandwidth_set(iis328dq_hpcf_t val)
High pass filter cut-off frequency configuration.[set].
int32_t iis328dq_hp_path_set(iis328dq_hpen_t val)
Select High Pass filter path.[set].
int32_t iis328dq_hp_reset_get(void)
Reading at this address zeroes instantaneously the content of the internal high pass-filter....
int32_t iis328dq_int2_notification_set(iis328dq_lir2_t val)
Latch interrupt request on INT2_SRC register, with INT2_SRC register cleared by reading INT2_SRC itse...
int32_t iis328dq_int1_notification_set(iis328dq_lir1_t val)
Latch interrupt request on INT1_SRC register, with INT1_SRC register cleared by reading INT1_SRC regi...
int32_t iis328dq_pin_mode_get(iis328dq_pp_od_t *val)
Push-pull/open drain selection on interrupt pads.[get].
int32_t iis328dq_pin_polarity_get(iis328dq_ihl_t *val)
Interrupt active-high/low.[get].
int32_t iis328dq_pin_int2_route_get(iis328dq_i2_cfg_t *val)
Data signal on INT 2 pad control bits.[get].
int32_t iis328dq_pin_int1_route_set(iis328dq_i1_cfg_t val)
Data signal on INT 1 pad control bits.[set].
int32_t iis328dq_pin_mode_set(iis328dq_pp_od_t val)
Push-pull/open drain selection on interrupt pads.[set].
int32_t iis328dq_pin_polarity_set(iis328dq_ihl_t val)
Interrupt active-high/low.[set].
int32_t iis328dq_pin_int1_route_get(iis328dq_i1_cfg_t *val)
Data signal on INT 1 pad control bits.[get].
int32_t iis328dq_pin_int2_route_set(iis328dq_i2_cfg_t val)
Data signal on INT 2 pad control bits.[set].
int32_t iis328dq_int1_notification_get(iis328dq_lir1_t *val)
Latch interrupt request on INT1_SRC register, with INT1_SRC register cleared by reading INT1_SRC regi...
int32_t iis328dq_int2_notification_get(iis328dq_lir2_t *val)
Latch interrupt request on INT2_SRC register, with INT2_SRC register cleared by reading INT2_SRC itse...
void push_raw_data(int16_t *data_raw)
Push data row for scroll mean sensibility data.
float_t iis328dq_from_fs2_to_mg(int16_t lsb)
Read istant value accelerometer scaled on 2G to mg.
float_t iis328dq_from_fs8_to_mg(int16_t lsb)
Read istant value accelerometer scaled on 8G to mg.
int16_t get_raw_mean(coordinate request)
Get mean value from scroll filter raw array.
float_t iis328dq_from_fsx_to_inc(int16_t lsb)
Read istant value accelerometer scaled 0-100% to inclinometer value.
float_t iis328dq_from_fs4_to_mg(int16_t lsb)
Read istant value accelerometer scaled on 4G to mg.
int32_t iis328dq_spi_mode_get(iis328dq_sim_t *val)
SPI 3- or 4-wire interface.[get].
int32_t iis328dq_spi_mode_set(iis328dq_sim_t val)
SPI 3- or 4-wire interface.[set].
int32_t iis328dq_int1_6d_mode_set(iis328dq_int1_6d_t val)
Configure the 6d on interrupt 1 generator.[set].
int32_t iis328dq_int2_6d_treshold_set(uint8_t val)
Interrupt 2 threshold.[set].
int32_t iis328dq_int2_6d_mode_get(iis328dq_int2_6d_t *val)
Configure the 6d on interrupt 2 generator.[get].
int32_t iis328dq_int2_6d_treshold_get(uint8_t *val)
Interrupt 2 threshold.[get].
int32_t iis328dq_int1_6d_src_get(iis328dq_int1_src_t *val)
6D on interrupt generator 1 source register.[get]
int32_t iis328dq_int2_6d_src_get(iis328dq_int2_src_t *val)
6D on interrupt generator 2 source register.[get]
int32_t iis328dq_int1_6d_mode_get(iis328dq_int1_6d_t *val)
Configure the 6d on interrupt 1 generator.[get].
int32_t iis328dq_int2_6d_mode_set(iis328dq_int2_6d_t val)
Configure the 6d on interrupt 2 generator.[set].
int32_t iis328dq_int1_6d_treshold_set(uint8_t val)
Interrupt 1 threshold.[set].
int32_t iis328dq_int1_6d_treshold_get(uint8_t *val)
Interrupt 1 threshold.[get].
int32_t iis328dq_wkup_to_sleep_get(uint8_t *val)
Turn-on mode selection for sleep to wake function.[get].
int32_t iis328dq_wkup_to_sleep_set(uint8_t val)
Turn-on mode selection for sleep to wake function.[set].
int32_t iis328dq_int2_treshold_set(uint8_t val)
Interrupt 2 threshold.[set].
int32_t iis328dq_int1_on_threshold_conf_set(int1_on_th_conf_t val)
Configure the interrupt 1 threshold sign.[set].
int32_t iis328dq_int1_treshold_set(uint8_t val)
Interrupt 1 threshold.[set].
int32_t iis328dq_int1_on_threshold_mode_get(iis328dq_int1_aoi_t *val)
AND/OR combination of Interrupt 1 events.[get].
int32_t iis328dq_int2_on_threshold_conf_set(int2_on_th_conf_t val)
Configure the interrupt 2 threshold sign.[set].
int32_t iis328dq_int1_treshold_get(uint8_t *val)
Interrupt 1 threshold.[get].
int32_t iis328dq_int2_treshold_get(uint8_t *val)
Interrupt 2 threshold.[get].
int32_t iis328dq_int2_src_get(iis328dq_int2_src_t *val)
Interrupt generator 1 on threshold source register.[get].
int32_t iis328dq_int1_dur_set(uint8_t val)
Duration value for interrupt 1 generator.[set].
int32_t iis328dq_int1_on_threshold_mode_set(iis328dq_int1_aoi_t val)
AND/OR combination of Interrupt 1 events.[set].
int32_t iis328dq_int2_on_threshold_mode_get(iis328dq_int2_aoi_t *val)
AND/OR combination of Interrupt 2 events.[get].
int32_t iis328dq_int1_dur_get(uint8_t *val)
Duration value for interrupt 1 generator.[get].
int32_t iis328dq_int1_on_threshold_conf_get(int1_on_th_conf_t *val)
Configure the interrupt 1 threshold sign.[get].
int32_t iis328dq_int2_dur_get(uint8_t *val)
Duration value for interrupt 2 generator.[get].
int32_t iis328dq_int2_on_threshold_conf_get(int2_on_th_conf_t *val)
Configure the interrupt 2 threshold sign.[get].
int32_t iis328dq_int2_on_threshold_mode_set(iis328dq_int2_aoi_t val)
AND/OR combination of Interrupt 2 events.[set].
int32_t iis328dq_int2_dur_set(uint8_t val)
Duration value for interrupt 2 generator.[set].
int32_t iis328dq_int1_src_get(iis328dq_int1_src_t *val)
Interrupt generator 1 on threshold source register.[get].