cancel
Showing results for 
Search instead for 
Did you mean: 

Blocking external flash access to Touchgfx. What am I doing wrong?

manto.1
Senior

I am using external flash for  TouchGFX resources and also for saveing some parameters.  I am doing the saveing of parameters in runtime with following code (emulated eeprom is in external flash):

 

 

void eepromCtrl(){
	uint8_t EEpromQueueFillLevel = uxQueueMessagesWaiting(Queue_To_EEpromHandle);
	if((EEpromQueueFillLevel <= 0) ||  !enableEEpromWriting){
		return;
	}
	baseType = xQueueReceive(Queue_To_EEpromHandle, &eepromQueueMsg, portMAX_DELAY);
    semaphoreCount1 = osSemaphoreGetCount(binarySemaphorFlashHandle);

	if ((baseType == pdPASS) && (eepromQueueMsg.id > 0)) {
//		osSemaphoreAcquire(binarySemaphorFlashHandle, 0);
		osKernelLock();

		// Suspend necessary interrupts
		HAL_DMA2D_Suspend(&hdma2d);
		NVIC_DisableIRQ(DMA2D_IRQn);
		NVIC_DisableIRQ(TIM5_IRQn);

		// Perform flash write
		stat = ExtFlash_Abort(&hqspi);

		if(stat == EXT_FLASH_OK){
			ee_status = EE_WriteVariable32bits(eepromQueueMsg.id,eepromQueueMsg.value);
		}

		if(ee_status != EE_OK){
			writeFailedCount++;
		}

		// Perform flash cleanup if required
		if (ee_status == EE_CLEANUP_REQUIRED) {
			eepromCleanUpCount++;
			ee_status = EE_CleanUp();
			if (ee_status != EE_OK) {
				eepromCleanUpFailCount++;
			};
		}

		stat = ExtFlash_MemoryMap(&hqspi);
		// check if enterd memory mapped went ok
		if(stat != EXT_FLASH_OK){
			enterMemmroyMapFailCount++;
			while(stat != EXT_FLASH_OK){
				stat = ExtFlash_MemoryMap(&hqspi);
				enterMemmroyMapFailCount++;
				osDelay(1);
			}
		}

		// Resume interrupts
		NVIC_EnableIRQ(TIM5_IRQn);
		NVIC_EnableIRQ(DMA2D_IRQn);
		HAL_DMA2D_Resume(&hdma2d);

		osKernelUnlock();
		eepromWriteCount++;
		osSemaphoreRelease(binarySemaphorFlashHandle);

	}

}

 

 

 I want to have a binary semaphore that shoud be taken by touchgfx when it is accessing external flash and released when it is not. Where shoud I put this? I tried to do it in TaskEntry() but without success:

 

 

void TouchGFXHAL::taskEntry()
{
    /* USER CODE BEGIN taskEntry step 1 */

    /* USER CODE END taskEntry step 1 */

    enableLCDControllerInterrupt();
    enableInterrupts();

    /* USER CODE BEGIN taskEntry step 2 */

    /* USER CODE END taskEntry step 2 */

    OSWrappers::waitForVSync();
    backPorchExited();

    /* USER CODE BEGIN taskEntry step 3 */
    /* Enable the LCD, Send Display on DCS command to display */

    /* USER CODE END taskEntry step 3 */

    for (;;)
    {
        OSWrappers::waitForVSync();
        semaphoreStatus = osSemaphoreAcquire(binarySemaphorFlashHandle, 0);
        taskAliveCount[TASK_GUI_ID]++;
        backPorchExited();
        osSemaphoreRelease(binarySemaphorFlashHandle);
    }
}

 

@Martin KJELDSEN

@Romain DIELEMAN 

@Osman SOYKURT 

@Juliette CRESPO 

 

 

2 REPLIES 2

 I get error undefined reference to `eepromCtrl()'. My EndFrame() function looks like beloow. On top of TouchGFXHAL.cpp  I also included my librarry.#include "emulated_eeprom.h" so the fuznction should be defined? I this some c++ thing?

void TouchGFXHAL::endFrame()
{
    TouchGFXGeneratedHAL::endFrame();
	enableEEpromWriting = true;
	eepromCtrl();
    //osSemaphoreRelease(binarySemaphorFlashHandle);
}

@RetroInTheShade