Skip to content

Commit

Permalink
Setup exploration
Browse files Browse the repository at this point in the history
  • Loading branch information
YannLocatelli committed Feb 16, 2024
1 parent a79cb75 commit 9b76514
Showing 1 changed file with 86 additions and 3 deletions.
89 changes: 86 additions & 3 deletions drivers/CoreIMU/source/CoreLSM6DSOX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,92 @@ void CoreLSM6DSOX::setGyrDataReadyInterrupt()
lsm6dsox_dataready_pulsed_t drdy_pulsed {LSM6DSOX_DRDY_PULSED};
lsm6dsox_data_ready_mode_set(&_register_io_function, drdy_pulsed);

lsm6dsox_pin_int1_route_t gyro_int1 {
.drdy_xl = PROPERTY_ENABLE,
.den_flag = PROPERTY_ENABLE,
{
lsm6dsox_ff_dur_set(&_register_io_function, 0x06);

lsm6dsox_ff_threshold_set(&_register_io_function, LSM6DSOX_FF_TSH_312mg);

} // free-fall settings

{
/* Enable Tap detection on X, Y, Z */
lsm6dsox_tap_detection_on_z_set(&_register_io_function, PROPERTY_ENABLE);
lsm6dsox_tap_detection_on_y_set(&_register_io_function, PROPERTY_ENABLE);
lsm6dsox_tap_detection_on_x_set(&_register_io_function, PROPERTY_ENABLE);

/* Set Tap threshold to 01000b, therefore the tap threshold
* is 500 mg (= 12 * FS_XL / 32 )
*/
lsm6dsox_tap_threshold_x_set(&_register_io_function, 0x01);
lsm6dsox_tap_threshold_y_set(&_register_io_function, 0x01);
lsm6dsox_tap_threshold_z_set(&_register_io_function, 0x01);

lsm6dsox_tap_axis_priority_set(&_register_io_function, LSM6DSOX_YZX);

/* Configure Single and Double Tap parameter
*
* For the maximum time between two consecutive detected taps, the DUR
* field of the INT_DUR2 register is set to 0111b, therefore the Duration
* time is 538.5 ms (= 7 * 32 * ODR_XL)
*
* The SHOCK field of the INT_DUR2 register is set to 11b, therefore
* the Shock time is 57.36 ms (= 3 * 8 * ODR_XL)
*
* The QUIET field of the INT_DUR2 register is set to 11b, therefore
* the Quiet time is 28.68 ms (= 3 * 4 * ODR_XL)
*/
lsm6dsox_tap_dur_set(&_register_io_function, 0x07);
lsm6dsox_tap_quiet_set(&_register_io_function, 0x03);
lsm6dsox_tap_shock_set(&_register_io_function, 0x03);

/* Enable Single and Double Tap detection. */
lsm6dsox_tap_mode_set(&_register_io_function, LSM6DSOX_BOTH_SINGLE_DOUBLE);

} // tap settings

{
/* Apply high-pass digital filter on Wake-Up function */
lsm6dsox_xl_hp_path_internal_set(&_register_io_function, LSM6DSOX_USE_SLOPE);

lsm6dsox_xl_usr_offset_on_wkup_set(&_register_io_function, 0);

} // wakeup and activity settings

{
/* Set Wake-Up threshold: 1 LSb corresponds to FS_XL/2^6 */
lsm6dsox_wkup_threshold_set(&_register_io_function, 2);

lsm6dsox_wkup_ths_weight_set(&_register_io_function, LSM6DSOX_LSb_FS_DIV_64);

/* Set duration for Activity detection to 9.62 ms (= 2 * 1 / ODR_XL) */
lsm6dsox_wkup_dur_set(&_register_io_function, 0x02);

} // wakeup settings

{
// /* Set duration for Activity detection to 9.62 ms (= 2 * 1 / ODR_XL) */
// lsm6dsox_wkup_dur_set(&_register_io_function, 0x02);
// /* Set Activity/Inactivity threshold to 62.5 mg */
// lsm6dsox_wkup_threshold_set(&_register_io_function, 0x02);

/* Set duration for Inactivity detection to 4.92 s (= 2 * 512 / ODR_XL) */
lsm6dsox_act_sleep_dur_set(&_register_io_function, 0x02);

/* Inactivity configuration: XL to 12.5 in LP, gyro to Power-Down */
lsm6dsox_act_mode_set(&_register_io_function, LSM6DSOX_XL_AND_GY_NOT_AFFECTED);

} // activity settings

lsm6dsox_pin_int1_route_t gyro_int1;
lsm6dsox_pin_int1_route_get(&_register_io_function, &gyro_int1);
gyro_int1 = {
.drdy_xl = PROPERTY_ENABLE,
.den_flag = PROPERTY_ENABLE,
.double_tap = PROPERTY_ENABLE,
.free_fall = PROPERTY_ENABLE,
.wake_up = PROPERTY_ENABLE,
.single_tap = PROPERTY_ENABLE,
.sleep_change = PROPERTY_ENABLE,
};
lsm6dsox_pin_int1_route_set(&_register_io_function, gyro_int1);

Expand Down

0 comments on commit 9b76514

Please sign in to comment.