Creating a simple APP
In this tutorial,you will use DAVE™ SDK to create a simple "Hello World" application (APP). This tutorial describes the process of creating a new APP project where the build is automatically managed by DAVE™ SDK,and running the APP in DAVE™ 4.
To create a simple "Hello World" APP using DAVE™ SDK,perform the following steps:
Step 1: Create a new APP project
-
Select File > New > Project...
-
Select the type of project to create. For this tutorial,select DAVE SDK Project... and click Next.
-
The DAVE SDK Project wizard opens.
Expand DAVE Projects list and select APP Project. After that click Next.
-
The DAVE APP Project view appears.
- In the Project name field,type a name for the project,such as HelloWorld.
- In the APP name field,type a name for the APP,such as HELLOWORLD.
APP name must be always written in UPPERCASE.
- Click Finish.
-
In the left-up part of the screen you Could see the APP project folder (HelloWorld),expand it and you will see some additional folders.
-
MANIFEST folder
- Groovy code used for User Interface logic
-
doc folder
- Location of generated APP documentation
-
docgen folder
- Source files required for APP documentation generation
-
Templates folder
- Code generation templates and files to be copied during code generation
-
Uimodel folder
- User Interface configuration files
-
MANIFEST folder
Step 2: UI Design
-
At the APP project explorer (HelloWorld),expand the Uimodel folder and double click HELLOWORLD.ui.
A new tab called HELLOWORLD.ui should appear at the right. -
Drop a GInteger widget into the APP UI.
-
Select a default value for the widget,such as "0".
-
Now it is time to save the UI and generate the UI interface.
- You can save the UI and generate the UI interface in two ways:
-
Pressing the diskette icon under the menu bar
-
Pressing the button combination CTRL+S
-
-
By saving,DAVE™ SDK automatically generates the HELLOWORD_GUI.manifest file.
This file is the interface between UI and the user defined manifest HELLOWORLD.manifest.
- You can save the UI and generate the UI interface in two ways:
Step 3: Write a template for code generation
-
By default,DAVE™ SDK will add a file here called like your APP name but in lowercase,in this case helloworld.tmpl.
-
Open the template by double click on helloworld.tmpl in the project explorer.
-
copy the following code into helloworld.tmpl and Save the template.
1 2 3 4 5 6
for (HELLOWORLD app in appInstancesList) { // Create a macro for each instance of the APP out.print(""" #define ${app.getInstanceLabel()}_MYINTEGER ${app.ginteger_1.value} """) }
GUI values can be read directly from the UI bypassing the APP manifest.
Step 4: Update the APP manifest
-
Open HELLOWORLD.manifest file
-
Define the devices that are compatible with this APP by modifying the softwareIDs APP property as in the code below:
1 2 3 4 5
def softwareIDs = [ "XMC4.5.00.F144.ALL":"1.0.0", "XMC4.4.00.F100.*":"1.0.0", "XMC1.3.01.Q024.*":"1.0.0" ]
-
At the end of the manifest file,look for the method called generateFiles(). This method is executed on code generation event,and you can call some special methods inside generateFiles() to execute code generation based on the templates.
Replace the content of the method generateFiles() with the one below and Save:
1 2 3
def generateFiles(){ generate("HelloWorld.tmpl", "HELLOWORLD.h") }
Step 5: Create an Update Site
-
Update Sites are used to distribute a set of APPs and install them in DAVE™.
Add a new update site project by File > New > DAVE SDK Project... -
Select Update Site Project and click Next.
-
In the Project Name field introduce a name for the project,such as myUpdateSite.
You must select at least one APP from the list below,in this case we only have one possible APP,so select HelloWorld APP.
Click Finish. -
If you have more APPs available in the workspace and you want to add them to the Update Site,you can do it later by right click in myUpdateSite folder > DAVE Update Site > Add APPs.
Step 6: Import the APP into DAVE™
-
Open DAVE™ 4 and select a workspace.
-
Importing APPs into DAVE™ workspace is possible using the Update Site folder stored in DAVE™ SDK workspace.
Go to Help > Install DAVE APP/Example/Device Library... -
This will show up the Library Manager Wizard window,and we need to add the Device Library,so click Add... button.
-
Click Local and select your DAVE™ SDK Update Site folder,in this case myUpdateSite. After that click OK.
-
Select the HelloWorld checkBox and click Next.
-
Accept the terms of the license agreements and click Finish.
-
Restart DAVE™ for the installation changes take effect clicking OK button.
-
Create a DAVE™ CE project going to File > New > DAVE Project... and select Infineon Projects > ARM-GCC Application > DAVE CE Project.
In the Project Name field enter a name for the project,such as HelloWorld.
Click Next.It is supposed you have installed de proper device description libraries in DAVE™ 4,otherwise you can not continue and you must install this libraries before,for more information please refer to DAVE™ 4 help contents.
-
Select a Target,such as XMC4500-F144x1024 and click Finish.
Remember you have to select a device which you have declared in the softwareIDs variable in your APP manifest.
1 2 3 4 5
def softwareIDs = [ "XMC4.5.00.F144.ALL":"1.0.0", "XMC1.3.01.Q024.*":"1.0.0" ]
Step 7: Template Debugging
-
Now we are able to debug the template we have created before. First we need to add our HELLOWORLD APP,so click Add New APP button
-
Select HELLOWORLD APP and click Add,then click Close.
-
You can observe how our HELLOWORLD APP have been added successfully,and you can expand Dave > Model > APPS > HELLOWORLD > v1_0_0 > Templates to find our HelloWorld.tmpl template,the one which we are going to debug.
-
Before debugging,we need to enable the Template Debug.
Go to DAVE > Advanced > Template Debugging and click Enabled.In DAVE™ it is possible to easily debug templates execution. Enabling template debugging will make visible the template debug profile.
As a side effect,some Java/Groovy context menu items are activated,user shall ignore them. -
We are going to create a template debug configuration.
Right click on Debug Arrow,click Debug Configurations... -
Double click APP Code Generation Debug,then close the window clicking Close button.
-
Now double click HELLOWORLD_0 APP in the APP Dependency Tree,this will show you the APP UI we had programmed before in DAVE™ SDK.
-
Enter a value such as 123 and close the tab.
-
Now open HelloWorld.tmpl by clicking it twice and add a breakpoint at line 8.
-
Time to debug! Click on Debug HelloWorld button.
-
The Debug Configurations window will appear,select the New_configuration we have created before and click on Debug button.
-
A new window ask you about a perspective switch,click Yes.
-
Congratulations,you are Now able to debug your template!
Running this debug profile has the same effect like pressing the Generate Code button,but DAVE™ will show the debug perspective on first breakpoint.
-
Now you can see the generated code based on the template.
Go to Dave > Generated > HELLOWORLD and open HELLOWORLD.h
Step 8: Explore by yourself!
- You have learned the basic steps through an APP development process,keep exploring a little bit more HELLOWORLD APP!
- Try to add another instance of the same APP.
- Play with the GInteger values.
- Try to generate the code with and without debugging.
- Look at the generated code results.
- Enjoy!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。