Difference between revisions of "Using Keil µVision 5 MDK-ARM"

From uGFX Wiki
Jump to: navigation, search
(Structure)
(Structure)
 
(36 intermediate revisions by the same user not shown)
Line 1: Line 1:
This article will describe the necessary steps to successfully integrate the µGFX library into an existing Keil µVision 5 project.
+
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 ==
 
== Used tools ==
 
The following tools were used in this article:
 
The following tools were used in this article:
 
* Keil µVision 5.16a MDK-ARM Professional
 
* 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 ==
 
== 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:
+
Unfortunately 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:
 
<pre>
 
<pre>
 
.
 
.
Line 14: Line 16:
 
└── ugfx
 
└── ugfx
 
</pre>
 
</pre>
 +
 +
== 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 [[Getting_Started#Integrate_uGFX|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 <code>Add Group...</code> As this folder will contain some of the uGFX source files, we'll name it <code>ugfx</code>.
 +
Inside that newly create group we have to add the <code>gfx_mk.c</code> file which can be found in the <code>src</code> directory of the ugfx library.
 +
 +
[[File: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 <code>C/C++</code> tab of the <code>Target Options</code> dialog. The path needs to be added to the <code>Include Paths</code>.
 +
 +
[[File:using_keil_02.png]]
 +
[[File:using_keil_03.png]]
 +
 +
The last thing to do is copying the <code>gfxconf.example.h</code> from the uGFX library directory to the Keil project and renaming it to <code>gfxconf.h</code>. For detailed information about all available configuration settings, please see [[configuration]].<br>
 +
Note that this file also needs to be added to the <code>Include Paths</code>. 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).
 +
 +
[[File:using_keil_04.png]]
 +
[[File: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 <code>#include <gfx.h></code> and calling <code>gfxInit()</code> in your <code>main()</code> code.
 +
<syntaxhighlight lang=c>
 +
#include "gfx.h"
 +
 +
int main (void)
 +
{
 +
    // Initialize hardware and underlying system (if any) BEFORE calling gfxInit()
 +
 +
    gfxInit();
 +
 +
    while(1) {
 +
        gfxSleepMilliseconds(500);
 +
    }
 +
}
 +
</syntaxhighlight>
 +
 +
== 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.
 +
 +
[[File:using_keil_06.png]]
 +
[[File:using_keil_07.png]]
 +
 +
The following steps need to be performed:
 +
# Add the driver directory to the compiler include path (''../ugfx/drivers/gdisp/SSD1289'' in this case)
 +
# Copy the board file template from the driver directory to your project (''board_SSD1289.h'' in this case)
 +
# Add the driver source file to the ugfx group in the project tree (''gdisp_lld_SSD1289.c'' in this case)
 +
 +
== Keil RTX ==
 +
µGFX can run either BareMetal or with any underlying operating system. For Keil µVision users it might be interesting to use the Keil RTX RTOS.
 +
 +
uGFX fully supports the [http://www.keil.com/rl-arm/kernel.asp Keil RTX] RTOS. The Keil RTX port is activated by setting <code>GFX_USE_OS_KEIL</code> to <code>TRUE</code> in the [[configuration|configuration file]].
 +
Information on how Keil RTX can be added to a Keil µVision project can be found in the corresponding Keil RTX documentation provided by Keil/ARM.

Latest revision as of 20:44, 17 August 2016

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

Unfortunately 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 (../ugfx/drivers/gdisp/SSD1289 in this case)
  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)

Keil RTX

µGFX can run either BareMetal or with any underlying operating system. For Keil µVision users it might be interesting to use the Keil RTX RTOS.

uGFX fully supports the Keil RTX RTOS. The Keil RTX port is activated by setting GFX_USE_OS_KEIL to TRUE in the configuration file. Information on how Keil RTX can be added to a Keil µVision project can be found in the corresponding Keil RTX documentation provided by Keil/ARM.