Difference between revisions of "Using PSoC Creator"

From uGFX Wiki
Jump to: navigation, search
(Adding Drivers)
(Adding Drivers)
Line 54: Line 54:
  
 
The following steps need to be performed:
 
The following steps need to be performed:
# Add the driver directory to the compiler include path (''../ugfx_2.6/drivers/gdisp/ILI9341'' in this case)
+
# Add the driver directory to the compiler include path (<code>../ugfx_2.6/drivers/gdisp/ILI9341</code> in this case)
# Copy the [[Board File|board file]] template from the driver directory to your project (''board_ILI9341.h'' in this case)
+
# Copy the [[Board File|board file]] template from the driver directory to your project (<code>board_ILI9341.h</code> in this case)
# Add the driver source file to the project tree (''gdisp_lld_ILI9341.c'' in this case)
+
# Add the driver source file to the project tree (<code>gdisp_lld_ILI9341.c</code> in this case)

Revision as of 21:53, 17 August 2016

ILI9341 connected to PSoC 5LP via SPI.

This article will explain how the µGFX library can be added to an existing PSoC Creator project.

Used Tools

The following tools were used to create this guide:

  • PSoC Creator 3.3 CP3
  • PSoC 5LP Prototyping Kit (CY8CKIT-059)

However, this article has been kept as generic as possible and should be usable for any PSoC platform.

Structure

We recommend using the following folder structure:

.
├── Project 1
├── Project 2
├── Project 3
└── ugfx

Adding µGFX

This guide will describe how to add the µGFX library to a PSoC Creator project using the Single-File-Inclusion technique.

The first step is to add the file gfx_mk.c which can be found in the /src directory of the µGFX library directory to the project. Furthermore, we add our configuration file as well.

Psoc file structure 01.png

Next, we need to add the top level uGFX library directory and the driver directory to the compiler include path. This is done in the Build Settings dialog:

Psoc build settings.png Psoc include paths 01.png

At this stage you have successfully added the µGFX library to an existing PSoC Creator project and you should be able to compile without any errors after including #include <gfx.h> and calling gfxInit() in your main() code (if the requirements of the underlying system are met):

#include "gfx.h"
 
int main (void)
{	
    // Initialize hardware and underlying system (if any) BEFORE calling gfxInit()
 
    gfxInit();
 
    while(1) {
        gfxSleepMilliseconds(500);
    }
}

Adding Drivers

Drivers are being added by adding the drivers directory to the compiler include path and adding the driver source file(s) to the project file tree. The following is an example showing how to add the ILI9341 driver to the PSoC Creator project. However, adding any other uGFX drivers for displays, touchscreen, audio and so on is exactly the same.

Psoc file structure 02.png Psoc include paths 02.png

The following steps need to be performed:

  1. Add the driver directory to the compiler include path (../ugfx_2.6/drivers/gdisp/ILI9341 in this case)
  2. Copy the board file template from the driver directory to your project (board_ILI9341.h in this case)
  3. Add the driver source file to the project tree (gdisp_lld_ILI9341.c in this case)