Using Keil µVision 5 MDK-ARM

From uGFX Wiki
Revision as of 19:16, 14 December 2015 by Tectu (Talk | contribs) (Adding Drivers)

Jump to: navigation, search

This article will describe the necessary steps to successfully integrate the µGFX library into an existing Keil µVision 5 project. This article won't cover how uGFX can be downloaded as this is explained in the Getting Started article.

Used tools

The following tools were used in this article:

  • Keil µVision 5.16a MDK-ARM Professional

Note: The same guide applies for all Keil µVision versions. You don't need to use the Professional version.

Structure

Sadly Keil µVision doesn't really support a way of defining variables. Therefore, the µGFX library directory needs to be somewhere near the project directory. We recommend using the following structure:

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

Adding µGFX

Keil µVision doesn't support using Makefiles. Therefore, we'll use the single-file technique to add µGFX to an existing Keil project. For more information, see Integrate uGFX.

We start by creating a new group in the project tree on the left side by right-clicking on the project top level folder and selecting Add Group... As this folder will contain some of the uGFX source files, we'll name it ugfx. Inside that newly create group we have to add the gfx_mk.c file which can be found in the src directory of the ugfx library.

Using keil 01.png

Next, we need to add the top level uGFX library directory to the compiler include path. This is done in the C/C++ tab of the Target Options dialog. The path needs to be added to the Include Paths.

Using keil 02.png Using keil 03.png

The last thing to do is copying the gfxconf.example.h from the uGFX library directory to the Keil project and renaming it to gfxconf.h. For detailed information about all available configuration settings, please see configuration.
Note that this file also needs to be added to the Include Paths. In this case we placed the configuration file in the top-level project directory so we simply add the project directory to the include paths (. is the path to the current directory).

Using keil 04.png Using keil 05.png

At this stage you have successfully added the µGFX library to an existing Keil µVision project and you should be able to compile without any errors after including #include <gfx.h> and calling gfxInit() in your main() code.

#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 uGFX group directory in the project tree. The following is an example showing how to add the SSD1289 driver to the Keil project. However, adding any other uGFX drivers for displays, touchscreen, audio and so on is exactly the same.

Using keil 06.png Using keil 07.png

The following steps need to be performed:

  1. Add the driver directory to the compiler include path
  2. Copy the board file template from the driver directory to your project (board_SSD1289.h in this case)
  3. Add the driver source file to the ugfx group in the project tree (gdisp_lld_SSD1289.c in this case)