cancel
Showing results for 
Search instead for 
Did you mean: 

TouchGFX integration with Middlewares : USB Mass Storage and microSDCard.

Karan 123
Senior

Hi,

I am working on below setup:

Software Tool Chain:

STM32CubeMX 5.6.0

TouchGFX 4.13.0 Designer

STM32CubeIDE 1.3.0

STM32F746G Discovery Kit v3.0.1 (AT)

Hardware:

STM32F746G-DISCO (Discovery Board)

USB Mass Storage Drive (32 GB)

microSDCard (64 GB)

I have gone through below link studied and implemented examples given there.

https://support.touchgfx.com/docs/development/ui-development/touchgfx-engine-features/backend-communication/

with ADC and UART with TouchGFX.

I got (think) the most efficient way is to use TouchGFX Ecosystem with FreeRTOS MVP .

Now I have to integrate Middleware like USB Mass Storage Device , SDCARD FAT32 +exFAT

with TouchGFX GUI.

Unfortunately, There is no example so for on touchgfx.com.

In my application, I have to copy File from USB Mass Storage to SDCard with TouchGFX GUI (Scroll List) with Add/remove feature .

USB Mass Storage and SDCard with FATFS + exFAT works well without TouchGFX .

How to I transfer "File Names" from USB Mass Storage to TouchGFX GUI scroll list?

So for simplicity, I have created array in main.c then try to transfer to GUI Scroll List Items.

But so far there is no example I have seen on touchgfx website, Is this the prefect/right method of not ?

I have written some steps as attachment .

Please advice how to proceed this ..

Thank in advance ..

--

Karan

17 REPLIES 17

Bank holidays here, back now. There should be plenty of information out there on how to send messages between tasks. It's not a TouchGFX thing.

If you can't find anything i'll be ready with a quick guide later today on how to send something like a struct with data.

/Martin

Hi,

@Martin KJELDSEN (ST Employee) .. Many of Thanks for update..

Sorry... I couldn't find suitable tutorial to fulfill my task .Please guide me as below:

I want to propagate data (Array -2D) File Name in my case :

From

Application data (File Names) -> Model -> Presenter -> view -> Scroll List Items(Custom Container)

and

Scroll List Item -Select any one) (Custom Container) -> view -> Presenter -> Model -> Application

For further processing..

0693W000001pUoMQAU.jpg

--

Karan

Hi Martin,

​​

When can I expect ​quick guide to fulfill logic as per your message. ?

​Thanks

--

Karan​

Model.cpp
extern osMessageQId  GUIEvent;
...
void Model::handleMessage()
{
    osEvent event = osMessageGet(GUIevent, 0);  // Get GUIevent immediately
 
    if (event.status == osEventMessage)
    {
        // handle event
        ControlMessage* message = (ControlMessage*)event.value.p;
        switch (message->messageCode)
        {
        case SYSTEM_ERROR:
        .....
MyTask.cpp
typedef struct
{
    uint16_t messageCode;
    int16_t messageValue;
} ControlMessage;
...
    SomeMessage.messageValue = SYSTEM_ERROR;
    osMessagePut(GUIevent, (uint32_t)&SomeMessage, 0);

I hope it's clear - Your task sends the message with osMessagePut(). You define the messages you want in your program somewhere, and you can cast the data from the message queue (event.value.p) and then access the members of the struct.

/Martin

Hi,

Thanks for that..

Can I do like below ? What are the significance drawback of below method ?

extern  osMessageQId  messageQ_USB ;
char TxBuffer[MaxQueueSize][MaxElementsPerQueue]=
{
	 "BANSAL.bmp"     , "HELLO.png"   ,
     "TouchGFX.txt"   , "STM32F7.doc" ,
     "SCROLL.bmp"     , "NEW.xlsx"    ,
     "LIST2.jpg"        , "GOOD.bmp"    ,
     "ABC.png"        , "XYZ.bmp"
} ;

void Model::tick()
{
		  HAL_GPIO_WritePin(LED_GPIO_Port , LED_Pin , GPIO_PIN_RESET) ;
		  printf("\n\rTask1, Reading the data from queue");
 
		  for(int i=0;i<5;i++)
		  {
			  if(pdTRUE == xQueueReceive(messageQ_USB,RxBuffer[i],(TickType_t)100 ))
				{
					HAL_GPIO_WritePin(LED_GPIO_Port , LED_Pin , GPIO_PIN_SET) ;
					printf("\n\rBack in task1, Received data is:%s",RxBuffer[i]);
 
					USBRx(RxBuffer[i]) ;
				}
				else
				{
					HAL_GPIO_WritePin(LED_GPIO_Port , LED_Pin , GPIO_PIN_RESET) ;
					printf("\n\rBack in task1, No Data received");
				}
			}
			HAL_GPIO_WritePin(LED_GPIO_Port , LED_Pin , GPIO_PIN_SET) ;
 
			osThreadTerminate(USBRxTaskHandle);
 
}

In my application..

void USBMSDQueueTXRoutine()
{
	unsigned char i;
	printf("\n\rTask2, Filling the data onto queue");
 
	HAL_GPIO_WritePin(LED_GPIO_Port , LED_Pin , GPIO_PIN_RESET) ;
	for(i=0;i<5;i++)
	{
		if(pdTRUE == xQueueSend(messageQ_USB ,TxBuffer[i],(TickType_t)100  ) )
		{
			HAL_GPIO_WritePin(LED_GPIO_Port , LED_Pin , GPIO_PIN_SET) ;
			 printf("\n\rTask2: Successfully sent the data");
		}
		else
		{
			HAL_GPIO_WritePin(LED_GPIO_Port , LED_Pin , GPIO_PIN_RESET) ;
			printf("\n\rSending Failed");
		}
	}
	HAL_GPIO_WritePin(LED_GPIO_Port , LED_Pin , GPIO_PIN_SET) ;
	osThreadTerminate(USBTxTaskHandle);
 
}

Thanks..

--

Karan..

Wouldn't it be smarter to pass a structure pointer that encapsulates the complete content, and size/length/count information?

What's the point of sending single items with no delimiting?

Allocate a buffer to hold the queue content, fill that, pass the pointer as a queued message, and at the far end cast the unqueued message to a pointer, extract the content, and deallocate the buffer.

If you must send a list of ASCIIZ messages in an array, send a pointer the whole array, with some NUL termination at the end so you can scope the content.

The benefit of allocating a buffer (could be a small pool), rather than using a static one, is that you don't have to worry about the content changing in-flight, or managing the ownership or reception once you've queued it.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

@Martin KJELDSEN (ST Employee)

Still .. I unable to do that.. Do you have example that suit to my application like below?

https://community.st.com/s/question/0D50X0000AU4zodSQB/interfacing-with-hardware-in-touchgfx-applications

@clive1 (NFA Crew) (Community Member)

Thanks for update ...

->Allocate a buffer to hold the queue content, fill that, pass the pointer as a queued message, and at the far end cast the unqueued message to a pointer, extract the content, and deallocate the buffer.

How to do in program for FreeRTOS ?

->If you must send a list of ASCIIZ messages in an array, send a pointer the whole array, with some NUL termination at the end so you can scope the content.

You mean to say like below:

extern  osMessageQId  messageQ_USB ;
char TxBuffer[MaxQueueSize][MaxElementsPerQueue]=
{
	 "BANSAL.bmp\0"     , "HELLO.png\0"   ,
     "TouchGFX.txt\0"   , "STM32F7.doc\0" ,
     "SCROLL.bmp\0"     , "NEW.xlsx\0"    ,
     "LIST2.jpg\0"        , "GOOD.bmp\0"    ,
     "ABC.png\0"        , "XYZ.bmp\0"
} ;

--

Thanks..

Perhaps you have a programmer on your team? I think you need to confer with the lead on the project if you don't understand things. You can't expect ST staff to carry basic programming tasks/objectives.

No, not really. I don't understand why you have to pass multiple individual elements in the queue to simply unpack them on the other side. It is like talking a bus to a destination, and halfway along you make people get off the bus, cross the street, and get into a second bus, for little/no reason, when the first bus could have taken you all the way, with less effort.

  1. char TxBuffer[]=
  2. {
  3. "BANSAL.bmp\0" , "HELLO.png\0" ,
  4. "TouchGFX.txt\0" , "STM32F7.doc\0" ,
  5. "SCROLL.bmp\0" , "NEW.xlsx\0" ,
  6. "LIST2.jpg\0" , "GOOD.bmp\0" ,
  7. "ABC.png\0" , "XYZ.bmp\0",
  8. NULL
  9. } ;

xQueueSend(messageQ_USB ,(uint32_t)TxBuffer,(TickType_t)100 ); // Send once as a blob

Where the "handle / instance" is a pointer to some self-contained object. Personally I'd prefer the structure/object form that Martin suggested, but you keep coming back to this array.

Then enumerate through the list, filling the Scroll List with items until you encounter the NULL marking the end of the list, for cases where you've got more/less than 5 items

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..