68 _wire->endTransmission();
71 for(uint8_t i=0; i<len; i++)
72 *(data + i) =
_wire->read();
73 _wire->endTransmission();
94 for(uint8_t i=0; i<len; i++)
95 _wire->write(*(data + i));
96 _wire->endTransmission();
134 uint32_t tmp_data = 0;
135 uint8_t tmp_count = 0;
142 return (int16_t) (tmp_data / tmp_count);
150 return ((float_t)lsb * 0.98f / 16.0f);
158 return ((float_t)
get_raw_mean(request) * 0.98f / 16.0f);
166 return ((float_t)lsb * 1.95f / 16.0f);
174 return ((float_t)
get_raw_mean(request) * 1.95f / 16.0f);
182 return ((float_t)lsb * 3.91f / 16.0f);
190 return ((float_t)
get_raw_mean(request) * 3.91f / 16.0f);
198 return ((float_t)lsb / 16000.0f);
228 (uint8_t *)&ctrl_reg1, 1);
234 (uint8_t *)&ctrl_reg1, 1);
249 (uint8_t *)&ctrl_reg1, 1);
250 *val = ctrl_reg1.
xen;
264 (uint8_t *)&ctrl_reg1, 1);
270 (uint8_t *)&ctrl_reg1, 1);
285 (uint8_t *)&ctrl_reg1, 1);
286 *val = ctrl_reg1.
yen;
300 (uint8_t *)&ctrl_reg1, 1);
306 (uint8_t *)&ctrl_reg1, 1);
321 (uint8_t *)&ctrl_reg1, 1);
322 *val = ctrl_reg1.
zen;
336 (uint8_t *)&ctrl_reg1, 1);
340 ctrl_reg1.
pm = (uint8_t)val & 0x07U;
341 ctrl_reg1.
dr = ((uint8_t)val & 0x30U) >> 4;
343 (uint8_t *)&ctrl_reg1, 1);
358 (uint8_t *)&ctrl_reg1, 1);
360 switch ((ctrl_reg1.
dr << 4) + ctrl_reg1.
pm)
419 (uint8_t *)&ctrl_reg2, 1);
423 ctrl_reg2.
hpm = (uint8_t)val;
425 (uint8_t *)&ctrl_reg2, 1);
440 (uint8_t *)&ctrl_reg2, 1);
442 switch (ctrl_reg2.
hpm)
469 (uint8_t *)&ctrl_reg4, 1);
473 ctrl_reg4.
fs = (uint8_t)val;
475 (uint8_t *)&ctrl_reg4, 1);
490 (uint8_t *)&ctrl_reg4, 1);
492 switch (ctrl_reg4.
fs)
523 (uint8_t *)&ctrl_reg4, 1);
529 (uint8_t *)&ctrl_reg4, 1);
544 (uint8_t *)&ctrl_reg4, 1);
545 *val = ctrl_reg4.
bdu;
571 (uint8_t *)&status_reg, 1);
572 *val = status_reg.
zyxda;
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];
638 (uint8_t *)&ctrl_reg2, 1);
642 ctrl_reg2.
boot = val;
644 (uint8_t *)&ctrl_reg2, 1);
659 (uint8_t *)&ctrl_reg2, 1);
660 *val = ctrl_reg2.
boot;
674 (uint8_t *)&ctrl_reg4, 1);
678 ctrl_reg4.
st = (uint8_t)val;
680 (uint8_t *)&ctrl_reg4, 1);
695 (uint8_t *)&ctrl_reg4, 1);
697 switch (ctrl_reg4.
st)
728 (uint8_t *)&ctrl_reg4, 1);
732 ctrl_reg4.
ble = (uint8_t)val;
734 (uint8_t *)&ctrl_reg4, 1);
749 (uint8_t *)&ctrl_reg4, 1);
751 switch (ctrl_reg4.
ble)
788 (uint8_t *)&ctrl_reg2, 1);
792 ctrl_reg2.
hpcf = (uint8_t)val;
794 (uint8_t *)&ctrl_reg2, 1);
809 (uint8_t *)&ctrl_reg2, 1);
811 switch (ctrl_reg2.
hpcf)
846 (uint8_t *)&ctrl_reg2, 1);
850 ctrl_reg2.
hpen = (uint8_t)val & 0x03U;
851 ctrl_reg2.
fds = ((uint8_t)val & 0x04U) >> 2;
853 (uint8_t *)&ctrl_reg2, 1);
868 (uint8_t *)&ctrl_reg2, 1);
870 switch ((ctrl_reg2.
fds << 2) + ctrl_reg2.
hpen)
925 (uint8_t *)&dummy, 1);
973 (uint8_t *)&ctrl_reg4, 1);
977 ctrl_reg4.
sim = (uint8_t)val;
979 (uint8_t *)&ctrl_reg4, 1);
994 (uint8_t *)&ctrl_reg4, 1);
996 switch (ctrl_reg4.
sim)
1033 (uint8_t *)&ctrl_reg3, 1);
1037 ctrl_reg3.
i1_cfg = (uint8_t)val;
1039 (uint8_t *)&ctrl_reg3, 1);
1054 (uint8_t *)&ctrl_reg3, 1);
1056 switch (ctrl_reg3.
i1_cfg)
1092 (uint8_t *)&ctrl_reg3, 1);
1096 ctrl_reg3.
lir1 = (uint8_t)val;
1098 (uint8_t *)&ctrl_reg3, 1);
1114 (uint8_t *)&ctrl_reg3, 1);
1116 switch (ctrl_reg3.
lir1)
1143 (uint8_t *)&ctrl_reg3, 1);
1147 ctrl_reg3.
i2_cfg = (uint8_t)val;
1149 (uint8_t *)&ctrl_reg3, 1);
1164 (uint8_t *)&ctrl_reg3, 1);
1166 switch (ctrl_reg3.
i2_cfg)
1202 (uint8_t *)&ctrl_reg3, 1);
1206 ctrl_reg3.
lir2 = (uint8_t)val;
1208 (uint8_t *)&ctrl_reg3, 1);
1224 (uint8_t *)&ctrl_reg3, 1);
1226 switch (ctrl_reg3.
lir2)
1253 (uint8_t *)&ctrl_reg3, 1);
1257 ctrl_reg3.
pp_od = (uint8_t)val;
1259 (uint8_t *)&ctrl_reg3, 1);
1274 (uint8_t *)&ctrl_reg3, 1);
1276 switch (ctrl_reg3.
pp_od)
1303 (uint8_t *)&ctrl_reg3, 1);
1307 ctrl_reg3.
ihl = (uint8_t)val;
1309 (uint8_t *)&ctrl_reg3, 1);
1324 (uint8_t *)&ctrl_reg3, 1);
1326 switch (ctrl_reg3.
ihl)
1373 (uint8_t *)&int1_cfg, 1);
1410 int1_cfg.
aoi = (uint8_t) val;
1412 (uint8_t *)&int1_cfg, 1);
1428 switch (int1_cfg.
aoi)
1472 (uint8_t *)&int1_ths, 1);
1487 *val = int1_ths.
ths;
1501 (uint8_t *)&int1_duration, 1);
1505 int1_duration.
d = val;
1507 (uint8_t *)&int1_duration, 1);
1522 (uint8_t *)&int1_duration, 1);
1523 *val = int1_duration.
d;
1537 (uint8_t *)&int2_cfg, 1);
1548 (uint8_t *)&int2_cfg, 1);
1585 int2_cfg.
aoi = (uint8_t) val;
1587 (uint8_t *)&int2_cfg, 1);
1603 switch (int2_cfg.
aoi)
1647 (uint8_t *)&int2_ths, 1);
1662 *val = int2_ths.
ths;
1676 (uint8_t *)&int2_duration, 1);
1680 int2_duration.
d = val;
1682 (uint8_t *)&int2_duration, 1);
1697 (uint8_t *)&int2_duration, 1);
1698 *val = int2_duration.
d;
1722 (uint8_t *)&ctrl_reg5, 1);
1728 (uint8_t *)&ctrl_reg5, 1);
1743 (uint8_t *)&ctrl_reg5, 1);
1771 int1_cfg.
_6d = (uint8_t)val & 0x01U;
1772 int1_cfg.
aoi = ((uint8_t)val & 0x02U) >> 1;
1789 switch ((int1_cfg.
aoi << 1) + int1_cfg.
_6d)
1851 *val = int1_ths.
ths;
1868 int2_cfg.
_6d = (uint8_t)val & 0x01U;
1869 int2_cfg.
aoi = ((uint8_t)val & 0x02U) >> 1;
1871 (uint8_t *)&int2_cfg, 1);
1887 switch ((int2_cfg.
aoi << 1) + int2_cfg.
_6d)
1935 (uint8_t *)&int2_ths, 1);
1950 *val = int2_ths.
ths;
accelerometer IIS328DQ header file
#define IIS328DQ_INT2_CFG
#define IIS328DQ_INT2_DURATION
#define IIS328DQ_REFERENCE
#define ACCELEROMETER_SEMAPHORE_MAX_WAITING_TIME_MS
#define IIS328DQ_CTRL_REG1
#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.
@ IIS328DQ_6D_INT1_MOVEMENT
@ IIS328DQ_6D_INT1_DISABLE
@ IIS328DQ_6D_INT1_POSITION
@ IIS328DQ_6D_INT2_MOVEMENT
@ IIS328DQ_6D_INT2_DISABLE
@ IIS328DQ_6D_INT2_POSITION
int16_t _raw_scroll[3][ARR_REG_FILTER]
@ IIS328DQ_HP_ON_INT1_INT2_OUT
@ IIS328DQ_HP_ON_INT2_OUT
@ IIS328DQ_HP_ON_INT1_INT2
@ IIS328DQ_HP_ON_INT1_OUT
@ IIS328DQ_LSB_AT_LOW_ADD
@ IIS328DQ_MSB_AT_LOW_ADD
BinarySemaphore * _wireLock
@ IIS328DQ_INT1_ON_THRESHOLD_AND
@ IIS328DQ_INT1_ON_THRESHOLD_OR
@ 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.
@ IIS328DQ_REF_MODE_ENABLE
@ 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].