2019-2020 LIS2DW12 Accelerometer Project
Dependencies: X_NUCLEO_IKS01A3
Diff: main.cpp
- Revision:
- 12:2c129618b350
- Parent:
- 10:3a7580daadda
- Child:
- 13:f4ad8550374a
--- a/main.cpp Tue Sep 17 09:22:38 2019 +0000 +++ b/main.cpp Tue Sep 17 12:33:08 2019 +0000 @@ -86,8 +86,16 @@ #define LSM6DSO_FS_XL 4 // Accelerometer full scale (2, 4, 8, 16g) #define LSM6DSO_XL_HM_MODE 1 // Accelerometer high-performance mode (0 enabled, 1 disabled) #define LSM6DSO_XL_ULP_EN 0 // Accelerometer ultra-low-power configuration (0 disabled, 1 enabled) +#define LSM6DSO_LPF2_XL_EN 1 // Accelerometer high-resolution selection (0 for 1st stage of digital filtering, 1 for 2nd stage) +#define LSM6DSO_HP_SLOPE_XL_EN 0 // Accelerometer high-pass filter selection (0 for low-pass, 1 for high-pass) +#define LSM6DSO_HPCF_XL 2 // Accelerometer filter configuration and cutoff setting (0 for ODR/4, 1 for ODR/10, 2 for ODR/20, 3 for ODR/45, 4 for ODR/100, 5 for ODR/200, 6 for ODR/400, 7 for ODR/800) #define LSM6DSO_ODR_G 16 // Gyroscope output data rate (12.5, 26, 52, 104, 208, 416, 833, 1.66k, 3.33k, 6.66kHz) #define LSM6DSO_FS_G 1000 // Gyroscope full scale (250, 500, 1000, 2000dps) +#define LSM6DSO_G_HM_MODE 1 // Gyroscope high-performance mode (0 enabled, 1 disabled) +#define LSM6DSO_LPF1_SEL_G 1 // Gyroscope digital LPF1 enable (0 disabled, 1 enabled) +#define LSM6DSO_FTYPE 3 // Gyroscope LPF1 bandwidth selection (0 ultra light, 1 very light, 2 light, 3 medium, 4 strong, 5 very strong, 6 aggressive, 7 xtreme) +#define LSM6DSO_HP_EN_G 1 // Gyroscope digital HPF enable (0 HPF disabled, 1 HPF enabled) +#define LSM6DSO_HPM_G 2 // Gyroscope HPF cutoff selection (0 for 16mHz, 1 for 65mHz, 10 for 260 mHz, 11 for 1.04Hz) /* Functions definition */ bool acquisition_task(bool verbose); @@ -258,6 +266,15 @@ printf("LSM6DSO XL_HM_MODE = %1d\r\n", read_reg_int); printf("LSM6DSO XL_ULP_EN = %1d\r\n", read_reg_int_1); + acc_gyro->set_x_lpf2_en(LSM6DSO_LPF2_XL_EN); + acc_gyro->get_x_lpf2_en(&read_reg_int); + printf("LSM6DSO LPF2_XL_EN = %1d\r\n", read_reg_int); + + acc_gyro->set_x_filter_config(LSM6DSO_HP_SLOPE_XL_EN, LSM6DSO_HPCF_XL); + acc_gyro->get_x_filter_config(&read_reg_int, &read_reg_int_1); + printf("LSM6DSO HP_SLOPE_XL_EN = %1d\r\n", read_reg_int); + printf("LSM6DSO HPCF_XL = %1d\r\n", read_reg_int_1); + acc_gyro->set_g_odr(LSM6DSO_ODR_G); acc_gyro->get_g_odr(&read_reg); printf("LSM6DSO ODR_G = %1.3f [Hz]\r\n", read_reg); @@ -266,6 +283,20 @@ acc_gyro->get_g_fs(&read_reg); printf("LSM6DSO FS_G = %1.3f [dps]\r\n", read_reg); + acc_gyro->set_g_power_mode(LSM6DSO_G_HM_MODE); + acc_gyro->get_g_power_mode(&read_reg_int); + printf("LSM6DSO G_HM_MODE = %1d\r\n", read_reg_int); + + acc_gyro->set_g_lpf_config(LSM6DSO_LPF1_SEL_G, LSM6DSO_FTYPE); + acc_gyro->get_g_lpf_config(&read_reg_int, &read_reg_int_1); + printf("LSM6DSO LPF1_SEL_G = %1d\r\n", read_reg_int); + printf("LSM6DSO FTYPE = %1d\r\n", read_reg_int_1); + + acc_gyro->set_g_hpf_config(LSM6DSO_HP_EN_G, LSM6DSO_HPM_G); + acc_gyro->get_g_hpf_config(&read_reg_int, &read_reg_int_1); + printf("LSM6DSO HP_EN_G = %1d\r\n", read_reg_int); + printf("LSM6DSO HPM_G = %1d\r\n", read_reg_int_1); + /* Print Flash memory information */ print_flash_info();