2025-03-06 1:25 AM - last edited on 2025-03-06 1:41 AM by Andrew Neil
Hi all,
I'm trying to understand how can I use this ST lib to activated interrupt if accelerometer data ready. I already use this lib but I don't use interrupt mode, right now I'd like to try it.
So if I understand well I have to use
int32_t lsm6dso32_pin_int1_route_set(const stmdev_ctx_t *ctx,
lsm6dso32_pin_int1_route_t *val)
I've find it in the datasheet :
. Write INT1_CTRL = 01h // Accelerometer data-ready interrupt on INT1 in Startup sequence part 4.1, so if I want to activate the interrupt I have to write 0x01 in INT1_CTRL register, but I'm little lost to how to use
typedef struct
{
lsm6dso32_int1_ctrl_t int1_ctrl;
lsm6dso32_md1_cfg_t md1_cfg;
lsm6dso32_emb_func_int1_t emb_func_int1;
lsm6dso32_fsm_int1_a_t fsm_int1_a;
lsm6dso32_fsm_int1_b_t fsm_int1_b;
} lsm6dso32_pin_int1_route_t;
and
typedef struct
{
#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
uint8_t int1_drdy_xl : 1;
uint8_t int1_drdy_g : 1;
uint8_t int1_boot : 1;
uint8_t int1_fifo_th : 1;
uint8_t int1_fifo_ovr : 1;
uint8_t int1_fifo_full : 1;
uint8_t int1_cnt_bdr : 1;
uint8_t den_drdy_flag : 1;
#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
uint8_t den_drdy_flag : 1;
uint8_t int1_cnt_bdr : 1;
uint8_t int1_fifo_full : 1;
uint8_t int1_fifo_ovr : 1;
uint8_t int1_fifo_th : 1;
uint8_t int1_boot : 1;
uint8_t int1_drdy_g : 1;
uint8_t int1_drdy_xl : 1;
#endif /* DRV_BYTE_ORDER */
} lsm6dso32_int1_ctrl_t;
or maybe I can simply use
ret = lsm6dso32_write_reg(ctx, LSM6DSO32_INT1_CTRL,
(uint8_t *)&val->int1_ctrl, 1);
to write 0x01H ?
2025-03-06 5:25 AM
Hi @SBaro.11 ,
You need to include the necessary headers: the lsm6dso32_reg.h
header file contains the necessary definitions and function prototypes. Then initialize the device context that is specific of your hardware setup (setting up the I2C or SPI communication and initializing the stmdev_ctx_t
structure).
Configure the INT1_CTRL
register: create a function that sets the int1_drdy_xl
bit in the int1_ctrl
member of the lsm6dso32_pin_int1_route_t
structure. Finally, write the configuration to the device: the lsm6dso32_pin_int1_route_set
function writes the configuration to the device.