cancel
Showing results for 
Search instead for 
Did you mean: 

LSM303DLHC STM32F411E

ThienNguyen0301
Associate

Hello everyone,  I am working with the STM32F411E and i am trying to make the LSM303DLHC working on my board. At this moment i am using this lib: https://github.com/STMicroelectronics/STM32CubeL4/blob/master/Drivers/BSP/Components/lsm303dlhc/lsm303dlhc.c

The problem i am having is that it cant find accelero.c to understand the GetXYZ function code in the code AccelerometerDrv->GetXYZ(pDataXYZ);

ThienNguyen0301_1-1712166978775.png

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
MOBEJ
ST Employee

Hello @ThienNguyen0301 , 

In the accelero.h header file, we define a structure ACCELERO_DrvTypeDef. This structure includes a function pointer GetXYZ that is meant to point to a function which retrieves the x, y, and z acceleration data from the accelerometer.

In the Lsm303dhlc.c source file, we have the implementation of the function LSM303DLHC_AccReadXYZ . This function is specifically written to interact with the hardware to retrieve the accelerometer data.

The GetXYZ function pointer in the ACCELERO_DrvTypeDef structure is set to point to LSM303DLHC_AccReadXYZ. This means that when we call AccelerometerDrv->GetXYZ(pDataXYZ) in the code, it's actually calling the LSM303DLHC_AccReadXYZ function, which will execute and provide us with the accelerometer data.

If this solves your problem, please mark my answer as "Best Answer" by clicking on the "Select as Best" button, this can be helpful for Community users to find this solution faster. 

Thank you

BeST regards

MB

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

1 REPLY 1
MOBEJ
ST Employee

Hello @ThienNguyen0301 , 

In the accelero.h header file, we define a structure ACCELERO_DrvTypeDef. This structure includes a function pointer GetXYZ that is meant to point to a function which retrieves the x, y, and z acceleration data from the accelerometer.

In the Lsm303dhlc.c source file, we have the implementation of the function LSM303DLHC_AccReadXYZ . This function is specifically written to interact with the hardware to retrieve the accelerometer data.

The GetXYZ function pointer in the ACCELERO_DrvTypeDef structure is set to point to LSM303DLHC_AccReadXYZ. This means that when we call AccelerometerDrv->GetXYZ(pDataXYZ) in the code, it's actually calling the LSM303DLHC_AccReadXYZ function, which will execute and provide us with the accelerometer data.

If this solves your problem, please mark my answer as "Best Answer" by clicking on the "Select as Best" button, this can be helpful for Community users to find this solution faster. 

Thank you

BeST regards

MB

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.