Skip to main content
Senior
April 3, 2024
Solved

API is not coming up outside of the function body

  • April 3, 2024
  • 2 replies
  • 1891 views

Hi,

I am trying to add HAL_I2C_Mem_Read into my application. However, when I write the API in the region below, it is not auto filled, I can not use the API. On the other hand, when I add the API inside the above function it works.

How can I fix this ?

I have already added #include "stm32f4xx_hal_i2c.h" as header file.

Thanks.

 

demir_0-1712148947715.png

 

demir_1-1712148996290.png

 

 

    This topic has been closed for replies.
    Best answer by Andrew Neil

    @demir wrote:

    I have already added #include "stm32f4xx_hal_i2c.h" as header file.


    You shouldn't need to do that manually.

    Once you enable & configure I2C in the CubeIDE Device Configuration Tool (or CubeMX), and re-generate the code, it should do all this for you.

    These are for L4 rather than F4, but should give the idea:

    STM32L4 training: 05.5 Communication peripherals - Inter-integrated circuit interface (I2C) theory:

    https://www.youtube.com/watch?v=e4F_7WcYkdU&list=PLnMKNibPkDnEEvQWrDqVuu1w_iQ214GXi&index=31

    STM32L4 training: 05.6 Communication peripherals - Hands-on I2C:

    https://www.youtube.com/watch?v=_SuRDVcDaMo&list=PLnMKNibPkDnEEvQWrDqVuu1w_iQ214GXi&index=32

     

    2 replies

    mƎALLEm
    Technical Moderator
    April 3, 2024

    Hello,

    What is this?

    SofLit_0-1712151173054.png

     

    To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
    demirAuthor
    Senior
    April 3, 2024

    I have deliberately pointed out that to show there is no auto fill when I start to type HAL_I2C_M in that region, on the contrary when I start to type in the function body as HAL_I2C_M and press space, then I see the API in the suggestion list that is HAL_I2C_Mem_Read()

    In brief, my question is that, why HAL_I2C_Mem_Read is not useable outside of the function body ?

    Andrew Neil
    Andrew NeilBest answer
    Super User
    April 3, 2024

    @demir wrote:

    I have already added #include "stm32f4xx_hal_i2c.h" as header file.


    You shouldn't need to do that manually.

    Once you enable & configure I2C in the CubeIDE Device Configuration Tool (or CubeMX), and re-generate the code, it should do all this for you.

    These are for L4 rather than F4, but should give the idea:

    STM32L4 training: 05.5 Communication peripherals - Inter-integrated circuit interface (I2C) theory:

    https://www.youtube.com/watch?v=e4F_7WcYkdU&list=PLnMKNibPkDnEEvQWrDqVuu1w_iQ214GXi&index=31

    STM32L4 training: 05.6 Communication peripherals - Hands-on I2C:

    https://www.youtube.com/watch?v=_SuRDVcDaMo&list=PLnMKNibPkDnEEvQWrDqVuu1w_iQ214GXi&index=32

     

    A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.