Skip to main content
Luca1
Associate III
June 15, 2020
Solved

Link TouchGFX project in STM32CubeIde

  • June 15, 2020
  • 6 replies
  • 1848 views

Hi to all!,

I try to run a Gui designed with TouchGFX on my hardware ( a Nucleo-F767ZI board and a 7" display with touchscreen).

I have created a new c++ project for doing this and I have selected the LL implementations of the periphericals that i use in my project. The first issue that I have noticed are that all files generated have a .c and .h extentions. Also the code generated from the device configuration tool aren't in OO style, but are the standard c style, i don't see any object in this files.

However the code generated by the TouchGfx designer are in the OO style.

The problem now is that i need to call a c++ function from the c code 

 (for example the OSWrappers::signalVSync function from my EXTI interrupt routine), and this cause some compile problems. At this point I don't know if I need to implements some wrapper module to call a c++ code or if I have done some error to configure the project.

The TouchGFX documentation, don't tell nothing about this, so i'm expect that the link from TouchGFX and my hardware is a simple task and not an invasive task (create a wrapper for example).

Please, someone can explain me how i correctly link the TouchGFX project in the STM32CubeIDE?

This topic has been closed for replies.
Best answer by Alexandre RENOUX

Hello,

Yes you will probably need a wrapper. If you look at the Application Templates available in TouchGFX Designer, you will find in the code how TouchGFX is linked to the C code project (for instance you can take F746G-DISCO Application Template).

To sum it up (considering you are using FreeRTOS but with bare metal it is also possible to link), you call MX_TouchGFX_Init() defined in app_touchgfx.c (this is the wrapper). Then it will call touchgfx_init() in TouchGFXConfiguration.cpp. With the same idea, you also declare a thread in main.c that you create and start in main() function. This function will call MX_TouchGFX_Process() defined in app_touchgfx.c, which will call touchgfx_taskEntry() defined in TouchGFXConfiguration.cpp.

/Alexandre

6 replies

Alexandre RENOUX
Alexandre RENOUXBest answer
Visitor II
June 15, 2020

Hello,

Yes you will probably need a wrapper. If you look at the Application Templates available in TouchGFX Designer, you will find in the code how TouchGFX is linked to the C code project (for instance you can take F746G-DISCO Application Template).

To sum it up (considering you are using FreeRTOS but with bare metal it is also possible to link), you call MX_TouchGFX_Init() defined in app_touchgfx.c (this is the wrapper). Then it will call touchgfx_init() in TouchGFXConfiguration.cpp. With the same idea, you also declare a thread in main.c that you create and start in main() function. This function will call MX_TouchGFX_Process() defined in app_touchgfx.c, which will call touchgfx_taskEntry() defined in TouchGFXConfiguration.cpp.

/Alexandre

Luca1
Luca1Author
Associate III
June 15, 2020

Hi Alexandre, thank you so much for the reply.

I'ts not a problem to create a wrapper. Now i look into the Application Templates in TouchGFX Designer to see the details.

Is there any documents that explain how to extends the TouchGFX and the STM32CubeIDE code using custom code?

I'm new to the STM32 enviroment and it's not easy for me (in the software engineering way) understand how to extends the code generate from the device configuration tool and integrate this code with my code.

Obviosly everything can be done, but if extist a standard way I would to follows this way! So any application note, documents, guidelines that explain the structure and how integrate the code of an STM32 project (including TouchGFX and other STM32 framework's) it's really appreciate from me.

Alexandre RENOUX
Visitor II
June 16, 2020

Hello,

I don't know for the other frameworks but you will find some information on how to create a TouchGFX project at the following link : https://support.touchgfx.com/docs/development/board-bring-up/board-introduction

Personally, I think looking at the Applications Templates code and their CubeMX configuration helps a lot in understanding how a TouchGFX project is structured.

/Alexandre

Luca1
Luca1Author
Associate III
June 16, 2020

Hi Alexandre, many thanks for the reply!

looking into the TouchGFX documentation I found an usefull article on how TouchGFX project is structured, it's is located a few pages after the document that you linked me:

https://support.touchgfx.com/docs/development/touchgfx-hal-development/touchgfx-generator

In this page it's explaned what are the files that the user can modify with custom code. After I finish the TouchGFX part of my project, i try to search if there is the same documentation for the CubeMX.

I think that this problem (how the generated code is structured) it's not trivial because with the code generator, the user can't write his code everywhere, so i think that is usefull to know what files one can modify.

In my case I have added an "extern C method" in the TouchGFXHAL class (that is located in the TouchGFX target folder) and I have created a wrapper module in the Core src folder that call the "extern C method" defined in the TouchGFXHAL class. I haven't tested yet, so i don't know if this work at the moment. 

However my criticism is about the "spaghetti style" of this approach. I prefer to mantain the TouchGFX code in the TouchGFx folder and not in other folder, but at this moment i think that this is not possible because I need to modify the TouchGFX code generator project pattern if I want to add some files in the TouchGFX folder, or i'm wrong?