cancel
Showing results for 
Search instead for 
Did you mean: 

Build errors with STM32 HAL libraries + MX Cube IDE on STM32F429I DIsco

LAlna.1
Associate II

I created a simple TouchGFX application , basically a single button that will turn LD3 Green (Port G 13) on and off

I used the MX Cube IDE to create the necessary interactions and functions. Then I created the button using TouchGFX environment.

But It fails to build.. It wont recognize the stm32fxx_hal.h file? although I see definitely see that file in the build ..

I tried using make command, and the TouchIDE itself and it still wont build..

I attached the folder here.. can you help?

1 ACCEPTED SOLUTION

Accepted Solutions
Martin KJELDSEN
Chief III

I also see that you've got all your hardware configuration inside the GUI code files (screen1view.cpp) - If you're running from the designer (GUI SIMULATOR ONLY) then it won't have the HARDWARE-related header file on its include path - this would typically be something that's on the path for the target-specific project , e.g. using EWARM, MDK-ARM, CubeIDE, etc.

Try to seperate GUI code and Hardware code.

You can use:

#ifndef SIMULATOR 
//hardware stuff, unknown to the designer
#endif

 It's good practice to go through the views presenter to contact the model to do anything hardware specific, so that your gui code is portable. Something like (simplified):

Screen1View.cpp

void Screen1View::led()
{
   presenter->toggleLed();
}

Screen1Presenter.cpp:

void Screen1Presenter::toggleLed() 
{
    model->toggleLed();
}

That completes the link from the view to the model where you could do one thing for the simulator and one thing for target (using the ifndef trick) if you want your simulator to exhibit certain behavior.

By moving the hardware specific code from your Screen1View to the model, guarding it with #ifndef SIMULATOR and instead just printing something if the button is pressed in the simulator, i can achieve the following in the simulator, whereas in my EWARM project the SIMULATOR flag would not be set and i would instead call the code you had originally in the led() function:

    HAL_GPIO_TOGGLEPIN(GPIOG, GPIO_PIN_13);
    HAL_DELAY(500);

0690X00000DBgtbQAD.png

 /Martin

View solution in original post

2 REPLIES 2
Martin KJELDSEN
Chief III

Did you start in CubeMX using the TouchGFX Generator, or how did you create this project? How are you building the project? I see EWARM, EWARM6, gcc and MDK-ARM folders in your zip file.

Martin KJELDSEN
Chief III

I also see that you've got all your hardware configuration inside the GUI code files (screen1view.cpp) - If you're running from the designer (GUI SIMULATOR ONLY) then it won't have the HARDWARE-related header file on its include path - this would typically be something that's on the path for the target-specific project , e.g. using EWARM, MDK-ARM, CubeIDE, etc.

Try to seperate GUI code and Hardware code.

You can use:

#ifndef SIMULATOR 
//hardware stuff, unknown to the designer
#endif

 It's good practice to go through the views presenter to contact the model to do anything hardware specific, so that your gui code is portable. Something like (simplified):

Screen1View.cpp

void Screen1View::led()
{
   presenter->toggleLed();
}

Screen1Presenter.cpp:

void Screen1Presenter::toggleLed() 
{
    model->toggleLed();
}

That completes the link from the view to the model where you could do one thing for the simulator and one thing for target (using the ifndef trick) if you want your simulator to exhibit certain behavior.

By moving the hardware specific code from your Screen1View to the model, guarding it with #ifndef SIMULATOR and instead just printing something if the button is pressed in the simulator, i can achieve the following in the simulator, whereas in my EWARM project the SIMULATOR flag would not be set and i would instead call the code you had originally in the led() function:

    HAL_GPIO_TOGGLEPIN(GPIOG, GPIO_PIN_13);
    HAL_DELAY(500);

0690X00000DBgtbQAD.png

 /Martin