cancel
Showing results for 
Search instead for 
Did you mean: 

Init sths34pf80.c / sths34pf80.h

jkutteh
Associate II

I am looking to interface with a sths34pf80 on a nucleo-f401re. I want to set up I2C to R/W to the registers and use the included functions.

 

 

BSP_I2C1_Init();
uint8_t ret=0;
STHS34PF80_Object_t pObj;
STHS34PF80_IO_t pIO;
STHS34PF80_Init(&pObj);
STHS34PF80_RegisterBusIO(&pObj, &pIO);
if(STHS34PF80_ReadID(&pObj, &ret)==0){
    //check status
}

 

 I have tried this above using the functions in sths34pf80.c/sths34pf80.h. Have not been able to get this to work. Any suggestions?

Thanks

3 REPLIES 3
Foued_KH
ST Employee

Hello @jkutteh , 

Did you try the HAL functions like HAL_I2C_Mem_Read/Write directly?

And make sure that you are setting the correct address.

Foued

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.

Hello @Foued_KH,

I did try the HAL functions and they work. I was looking to use the sths34pf80.h libraries so I can call functions like STHS34PF80_GetPresenceFlag.

Federica Bossi
ST Employee

Hi @jkutteh ,

Have you already looked at our PID examples on GitHub?

If this helps you, please mark my answer as "Best Answer" by clicking on the "Accept as Solution" button, this can be helpful for Community users to find this solution faster.

In order 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.