cancel
Showing results for 
Search instead for 
Did you mean: 

Call to OSWrappers::SignalVsync() from LTDC_IRQHandler in a TouchGFX application

RobNewbury
Associate III

I am using STM32F469i-Disco board with a custom DSI video mode LCD interface and TouchGFX.

The display is working and renders the initial screen, however the screen is not being updated.
I know the reason for this is because I am having difficulty defining the call to OSWrappers::signalVSync()  from the LTDC_IRQHandler() function in stm32f4xx_it.c, this is a requirement to unblock the TouchGFX Engine main loop. The LTDC interrupt is enabled and the function LTDC_IRQHandler() is being called (established by debug).

My software skills are not that strong and the problem that I am having is not understanding how to call the C++ function OSWrappers::signalVSync() from the C function LTDC_IRQHandler().

The TouchGFX manual shows an example for the STM32F7 as follows:

RobNewbury_0-1723886985388.png

Implementing this code in the STM32F4xx LTDC_IRQHandler() results in a syntax error when the directive extern "C" is encountered.

RobNewbury_1-1723887269677.png

I have included OSWrappers.hpp in my code and set the apropriate include paths for both GNU C and GNU C++ in the Eclipse project properties.

On building the project there are various C++ compilation errors which I think relate to the include of OSWrappers.hpp in stm32f4xx_it.c.

I suspect that there is something I am not understanding about calling the C++ OSWrapper function from C code, any assistance would be greatly appreciated.

RobNewbury_2-1723887842613.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
RobNewbury
Associate III

My brilliant colleague Charlie solved this for me by creating a new C++ wrapper writen in C++, this means that it can call other C++ functions but has it's functions defined as extern "C" so that they can in turn be called from C code.
So here is how it's done for the STM32F469i.

In folder Project>Core>Src create a new file "touchgfx_wrapper.cpp" containg the following code:-

#include <touchgfx/hal/OSWrappers.hpp>

 

extern "C" {

void signalVSync(void) {

touchgfx::OSWrappers::signalVSync();

}

}

RobNewbury_0-1724013954004.png

In folder Project>Core>Inc create header file "touchgfx_wrapper.h" containing the following

void signalVSync(void);

RobNewbury_3-1724014944360.png

 

In stm32f4xx_it.c, add #include "touchgfx_wrapper.h" to the user includes section

RobNewbury_4-1724015094988.png


In stm32f4xx_it.c add the call to signalVSync() in the function LTDC_IRQHandler() 

RobNewbury_2-1724014723427.png

All working now with the LCD updating at the frame rate. Thanks Charlie!

 

 

 

View solution in original post

1 REPLY 1
RobNewbury
Associate III

My brilliant colleague Charlie solved this for me by creating a new C++ wrapper writen in C++, this means that it can call other C++ functions but has it's functions defined as extern "C" so that they can in turn be called from C code.
So here is how it's done for the STM32F469i.

In folder Project>Core>Src create a new file "touchgfx_wrapper.cpp" containg the following code:-

#include <touchgfx/hal/OSWrappers.hpp>

 

extern "C" {

void signalVSync(void) {

touchgfx::OSWrappers::signalVSync();

}

}

RobNewbury_0-1724013954004.png

In folder Project>Core>Inc create header file "touchgfx_wrapper.h" containing the following

void signalVSync(void);

RobNewbury_3-1724014944360.png

 

In stm32f4xx_it.c, add #include "touchgfx_wrapper.h" to the user includes section

RobNewbury_4-1724015094988.png


In stm32f4xx_it.c add the call to signalVSync() in the function LTDC_IRQHandler() 

RobNewbury_2-1724014723427.png

All working now with the LCD updating at the frame rate. Thanks Charlie!