FreeRtos and LVGL

Hi everyone,
I want to integrate LVGL on an STM32 ARM MCU with FreeRtos.
I wanted to create a task that executes lv_task_handler () cyclically. All GUI updates will be in the same task where the lv_task_handler () function will be called.
The only “lv_…” functions outside this task are “lv_tick_inc()” which will be called in an interrupt routine and lv_flush_ready () which is called at the end of each SPI transfer (only when colors are sent).
Do I have to take precautions with any Mutexes or semaphores?

No, that sounds fine.

Hi I3uri1993,

When the hardware SPI is used to read the data, it is best to use the interrupt mutex semaphore protection.

Hi Lucifer,
I want to use SPI with DMA for better performance. A interrupt is triggered when DMA+SPI transfer is completed in background.
I can’t allow “lv_flush_ready” to be executed while I’m running “lv_task_handler”, is that correct?
I have to use interrupt semaphores for that?

With DMA the usual scenario is to call lv_flush_ready() from a “DMA ready” interrupt.
So you can simply call it.

In the documentation I read:
Try to avoid calling LittlevGL function from an interrupts (except lv_tick_inc() ). But if you really need to do this you have to disable the interrupt which uses LittlevGL functions while lv_task_handler is running. It’s a better approach to set a flag or other value and periodically check it in an lv_task .
Does It conflict with your answer?

It was really conflicting. I updated the documentation.

@l3uri1993 do you have achieved? Can you give some suggestions? I will do it

Have you looked at this ?

I have since changed to the following, that way no mutex required,

static V RunEvery400Ms ( V )
{
	static UI ticksLastRun;
	UI ticksNow;

	UI msElapsed = Osa_msElapsedFrTicksMarked( ticksLastRun, &ticksNow );
	if( msElapsed >= 400 )
	{
		ticksLastRun = ticksNow;
		Screens_Every400ms();
	}
}

static V RunEvery1000Ms ( V )
{
	static UI ticksLastRun;
	UI ticksNow;

	UI msElapsed = Osa_msElapsedFrTicksMarked( ticksLastRun, &ticksNow );
	if( msElapsed >= 1000 )
	{
		ticksLastRun = ticksNow;
		Screens_Every1000ms();
	}
}

static V TaskLVGL ( PV p )
{
	for( ; ; )
	{
		vTaskDelay( pdMS_TO_TICKS(10) );
		
		RunEvery400Ms();
		RunEvery1000Ms();
		
		lv_task_handler();
	}
}