cancel
Showing results for 
Search instead for 
Did you mean: 

[SOLVED] [LSM6DSL] Are we initializing it properly?

Carlos Diaz R.
Associate III

Hi,

We will test the LSM6DSL for a design update, we would like to get the LSM6DSL of the IKS01A2 working without the BSP code so we can understand what's behind the abstractions layers of the examples.

As far as we understand we should have two LSM6DSL_Object_t instances (one for each IC for the project) and then register the IO Ctx for each of those LSM6DSL_Object_t instances, here is how we do it for one of them:

int32_t my_lsm6dsl_write(uint16_t dev, uint16_t reg, uint8_t *data, uint16_t length)
{
        /* Send data to be written with the BusType */
	return LSM6DSL_OK;
}
 
int32_t my_lsm6dsl_read(uint16_t dev, uint16_t reg, uint8_t *data, uint16_t length)
{
        /* Send data to be read with the BusType */
	return LSM6DSL_OK;
}
 
int32_t my_get_tick(void)
{
	return (int32_t) HAL_GetTick();
}
 
int32_t my_Init_Func(void)
{
        /* Init BusType peripheral */
	return LSM6DSL_OK;
}
 
int32_t my_DeInit_Func(void)
{
        /* DeInit BusType peripheral */
	return LSM6DSL_OK;
}
 
int main(void)
{
 
...
 
    LSM6DSL_Object_t mems_cpu;
 
    LSM6DSL_IO_t mems_cpu_io = {
        .Init = my_Init_Func,
        .DeInit = my_DeInit_Func,
 
        .ReadReg = my_lsm6dsl_read,
        .WriteReg = my_lsm6dsl_write,
        .GetTick = my_get_tick,
 
        .BusType = LSM6DSL_I2C_BUS,
        .Address = /* I2C Address of LSM6DSL in the eval board */,
};
 
LSM6DSL_RegisterBusIO(&mems_cpu, &mems_cpu_io);
 
uint8_t mems_cpu_id = 0;
LSM6DSL_ReadID(&mems_cpu, &mems_cpu_id);
 
if (LSM6DSL_ID == mems_cpu_id) {
    DBG_println("No device with ID: %d found", LSM6DSL_ID);
}
}

And then we should be able to use the functions of the LSM6DSL.h file, are we on the right path?

Also, when configuring the sensor on CubeMX it asks me for the Bus to control the MEMS Sensor, it doesn't set up the WriteReg and ReadReg functions with this information?

0690X0000087XRuQAM.png

Kind regards.

4 REPLIES 4
Carlos Diaz R.
Associate III

Solved, reading the examples and using the BSP support was enough to get it working.

good

you could share your findings in MEMS&Sensors ST Community page --> https://community.st.com/s/group/0F90X000000AXsjSAG/mems-and-sensors

regards

Hi,

I will when i have some free time, all i did was configure properly the BSP of the MEMS component.