Skip to main content
DElli.1
Associate III
May 27, 2020
Question

is SPI communications possible with TouchGFX interactions.

  • May 27, 2020
  • 8 replies
  • 1106 views

I am using an STM32508 DK board and I am trying to press a button on the touch screen and gain a reading from an MCP3201 that is connected in the GPIO pins. I believe the code I have will work but when I put it into MainView for the button press the HAL GPIO commands are not recognized.

I am slightly new to using embedded microcontrollers this way and was wondering if it is possible to create a function that handles the GPIO commands in the main.c and then pull that function using MainView in TouchGFX?

This topic has been closed for replies.

8 replies

Jagdish Bisawa
Visitor II
May 31, 2020

Hi @DElli.1​ ,

From what you have described I understand that you want to read from the MCP3201, which is an ADC, when the button on the screen is pressed.

So, essentially, you have to know that the button is pressed & in response to this event you want to read the ADC. You can use the interaction facility in the Designer software to create a new interaction. You will have to create a new function & give the name of this function in the interaction options.

The interaction can be added after selecting the button on the screen & adding the interaction from the top right ( indicated by a finger pointing icon ).

/Jagdish Bisawa

DElli.1
DElli.1Author
Associate III
June 1, 2020

creating an interaction is not my issue. I can create interactions no problem but the problem lies in when I use those interaction functions to interact with the GPIO pins.

as soon as I write a command like HAL_GPIO_Write there is an error because it does not recognize the function. inside the view.cpp file.

Martin KJELDSEN
Principal III
June 2, 2020

Keep HAL code out of your Views. If you're trying to run the program from the designer simulator you'll get an error for sure. If you insist, you need the proper includes to make those functions available to the compiler.

/Martin

DElli.1
DElli.1Author
Associate III
June 2, 2020

I have been trying different includes but to no avail, I am new to the stm family and to projects as complex as this.

If the HAL code shouldn't be in views, I believe they only work in main.c.

Is it possible to create a function with HAL code in main.c and then export it to the views? And if this is not possible which includes would provide the functions to the compiler?

Jagdish Bisawa
Visitor II
June 2, 2020

Hi @DElli.1​ ,

This appears to be more of a compiler isue, rather than the TouchGFX framework. The code for HAL_GPIO_Write(...) is in one of the STM32Cube firmware files. The declaration of the same is in one of the header files, supplied by the STM32Cube firmware.

So, what you have to do is make available these files in your project & indicate the path of these files to the Makefile of your project.

/Jagdish Bisawa