The main focus of this article is to take you through creating a board configuration for your own board based on one of the NXP MCUs in the following lineup, all of which are supported by TouchGFX:
LPC435x(ARM Cortex-M4F + ARM Cortex-M0)
A large amount of work involved in porting TouchGFX to a specific MCU lies in configuring the
DMA-controllers. For the MCU lineup mentioned above, this work has already been done by TouchGFX.
Note: When porting to a new MCU, you’ll need to do this work yourself. If you wish to know more about porting TouchGFX, please see this article.
BoardConfiguration contains the initialization of additional hardware as well as TouchGFX itself. When porting to a board with an NXP MCU already supported by TouchGFX, basing yourself on a pre-existing board configuration can speed up the process.
Provided that we can use an existing MCU port, the following board configuration tasks remain:
- Initialization of hardware: System Clock, External RAM, External Flash, LCD, Touch, etc.
- Initialization of TouchGFX: Color depth, display size, framebuffer start address (SeeConfiguring TouchGFX).
Location: Board configurations in TouchGFX are located under
touchgfx/board/of your distribution. Place your own board configurations elsewhere to avoid losing them during upgrades to new TouchGFX versions.
Operating System: TouchGFX supports FreeRTOS v7.6.0 and v8.2.0 (Cortex-M7 support) and bundles these in its distribution. See any project example we provide (IAR, Keil, gcc) for how to include FreeRTOS in your own projects.
The remainder of this article uses the board configuration for the
TouchGFXDemoBoardRev1.1-4353-4.3 board to explain the steps involved in complete the porting for your own board.
In general, board configurations within TouchGFX seperate framework initialization from hardware initialization, the latter containing the largest portion of the work you must do yourself.
The main porting effort lies in the configuration of hardware peripherals like SDRAM, Touch driver, External Flash, etc, which are not specific to TouchGFX. Not all components are spefifically required for TouchGFx to run. In particular:
- RAM for frame buffer (typically external).
- External Flash for images: If your board has a non-memory mapped flash, please seethis article.
- Touchcontroller: As we’ll see shortly, the TouchGFX configuration requires a Touch controller driver to instantiate its
HAL. Please see this article for specific details on changing and creating touch controllers.
The first thing we’ll do when configuring TouchGFX is to instantiate and configure
HAL. We’ll start by defining the size of our display:
static const uint16_t DISPLAY_NATIVE_WIDTH = 480; static const uint16_t DISPLAY_NATIVE_HEIGHT = 272;
Common for all supported NXP MCU’s is that they use the Scatter-Gather feature for all
DMAtransfers which requres that we specify a list of transfer descriptors:
This descriptor list is passed to the MCU specialization of
Note: The transfer descriptor types for each NXP MCU may vary. It is the same for
LCP1788, but for
LPC4088it is called
DMA_TransferDescriptor_t, required by the class
TouchGFX supports two kinds of color depths, each of these represented as a TouchGFX LCD driver in
- 1 bit-per-pixel
- 16 bits-per-pixel
Since most boards will have a 16bpp capable displays, we’ll define the following display type:
The board also uses a Sitronix
ST1232 Touch Controller using a generic
I2C driver for
LPC43xx supported by TouchGFX.
I2C_LPC43xx i2c(0); ST1232TouchController tc(i2c, DISPLAY_NATIVE_WIDTH, DISPLAY_NATIVE_HEIGHT, FLIP_X_AXIS);
The following NXP
HAL specializations are available at this location
For this board, we’ll use the
LPC43xxHAL. Finally, we’ll instantiate the generic TouchGFX
HAL with the configuration we’ve defined so far:
HAL& hal = touchgfx_generic_init<NXP43XXHAL>(dma, display, tc, DISPLAY_NATIVE_WIDTH, DISPLAY_NATIVE_HEIGHT, 0, 0);
Note: See Optimization for further information on how to optimize DMA transfers for platforms that allow simultanous access to SDRAM from both DMA- and TFT-controllers, optimizing VSYNC timing and touch