Skip to main content
Visitor II
October 13, 2023
Question

Init sths34pf80.c / sths34pf80.h

  • October 13, 2023
  • 2 replies
  • 1523 views

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

    This topic has been closed for replies.

    2 replies

    ST Employee
    October 16, 2023

    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

    jkuttehAuthor
    Visitor II
    October 16, 2023

    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.

    Technical Moderator
    October 17, 2023

    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.