KAI
STACK
T
HE
EIB / KNX C
OMMUNICATION
S
TACK
V
ERSION
1.60
P
ART
1: G
ENERAL
Author: Klaus Adler
Last Modification: 12.01.2012
KAIstack
-
© 2001-2012 TAPKO Technologies GmbH
Yorckstr. 22, 93049 Regensburg, Germany
The data contained herein are subject to change without notice. Tapko does not warrant for correctness or
completeness of the document.
The reproduction, transmission or use of this document or it’s contents is not permitted without written authority.
All rights reserved.
12.01.2012
2
KAIstack
Table of Contents -
2 T
ABLE OF
C
ONTENTS
2
3
Table of Contents ............................................................................................................. 3
General .............................................................................................................................. 7
3.1
Legal Aspects ............................................................................................................. 7
3.1.1
3.1.2
KAIstack ......................................................................................................................................... 7
Compiler.......................................................................................................................................... 7
4
Introduction ...................................................................................................................... 8
4.1
Hardware Structure .................................................................................................... 8
4.2
Program button / LED ................................................................................................ 9
4.2.1
4.2.2
Program LED .................................................................................................................................. 9
Program button................................................................................................................................ 9
4.3
4.3.1
Software Structure.................................................................................................... 10
KAIstack.......................................................................................................................................
10
4.4
Application Program ................................................................................................ 11
4.4.1
Calling the application .................................................................................................................. 11
4.4.2
Types of application ...................................................................................................................... 12
4.4.2.1
Fixed applications................................................................................................................ 12
4.4.2.2
Loadable applications .......................................................................................................... 14
4.5
4.6
Existing device models............................................................................................. 17
Group Communication............................................................................................. 19
4.6.1
Address table................................................................................................................................. 19
4.6.1.1
Device model: 0012, 0020, 0701 ......................................................................................... 19
4.6.2
Association table ........................................................................................................................... 20
4.6.2.1
Device model: 0012, 0020, 0701 ......................................................................................... 20
4.6.3
Group communication objects....................................................................................................... 21
4.6.3.1
Group object table (Communication object table)............................................................... 21
4.6.3.2
RAM flags ........................................................................................................................... 24
4.7
Interface objects ....................................................................................................... 25
4.7.1.1
Device model: 0012 Easy, 0020, 0701 ................................................................................ 25
4.7.2
Defining an interface object .......................................................................................................... 25
4.7.3
Defining the list of application interface objects........................................................................... 26
4.8
Memory .................................................................................................................... 27
4.8.1
Virtual BCU memory .................................................................................................................... 27
4.8.2
EEPROM data............................................................................................................................... 27
4.8.3
RAM data ...................................................................................................................................... 27
4.8.4
Variables ....................................................................................................................................... 27
4.8.4.1
RAM-Variables ................................................................................................................... 27
4.8.4.2
EEPROM-Variables ............................................................................................................ 27
4.8.4.3
Parameter ............................................................................................................................. 27
4.9
Using the EIB / KNX Stack ..................................................................................... 29
4.9.1
Directory structure ........................................................................................................................ 29
4.9.1.1
Global directory structure .................................................................................................... 29
4.9.1.2
Project / Application directory............................................................................................. 31
4.9.2
Build Process................................................................................................................................. 34
4.9.2.1
Overview over the build process for the target microcontroller .......................................... 34
4.9.2.2
General notes: ...................................................................................................................... 34
4.9.2.3
Microsoft Nmake ................................................................................................................. 35
4.9.2.4
Gnu Make ............................................................................................................................ 36
4.9.3
Development Environment ........................................................................................................... 37
4.9.3.1
Workspace structure in Visual C++ 6.0............................................................................... 37
4.9.3.2
Visual studio (Visual C++ 6.0) ............................................................................................ 37
4.9.4
Download to microcontroller ........................................................................................................ 38
4.9.4.1
MSP 430 (IAR C-Spy V1.x)................................................................................................ 38
4.9.4.2
MSP 430 (IAR Embedded Workbench) .............................................................................. 38
4.9.4.3
other tools ............................................................................................................................ 38
4.9.5
Modify Configuration Data (EEPROM) ....................................................................................... 39
12.01.2012
3
KAIstack
Table of Contents -
4.9.5.1
Modify EEPROM via EIB................................................................................................... 39
4.9.6
Import into ETS2........................................................................................................................... 39
4.10
Debugging ................................................................................................................ 40
Debug switch............................................................................................................................ 40
Variables for debugging: .......................................................................................................... 40
Internal message format ........................................................................................................... 40
Debug interface object.............................................................................................................. 40
4.10.1
4.10.2
4.10.3
4.10.4
5
Advanced Functions....................................................................................................... 41
5.1
Replacing system interface objects .......................................................................... 41
5.2
Adding properties to system interface objects ......................................................... 43
5.2.1.1
5.2.1.2
by replacing system interface objects .................................................................................. 43
by providing additional property list to the system.............................................................. 43
5.3
Defining User APDU-handler.................................................................................. 44
5.3.1
Management: APDU Handling ..................................................................................................... 44
5.3.1.1
Message format.................................................................................................................... 46
5.3.1.2
supported User APDUs........................................................................................................ 47
5.3.1.3
Example for an APDU handler ............................................................................................ 47
6
Notes ................................................................................................................................ 48
6.1
General ..................................................................................................................... 48
6.2
Working with EIB-Tools.......................................................................................... 48
6.2.1
Problems due to wrong mask version read.................................................................................... 48
6.3
Alignment of Parameter ........................................................................................... 48
6.4
Timing ...................................................................................................................... 48
6.5
Stack optimisation .................................................................................................... 48
7
Reference......................................................................................................................... 49
7.1
General Functions .................................................................................................... 49
7.1.1
Data Types .................................................................................................................................... 49
7.1.2
Type conversion ............................................................................................................................ 50
7.1.3
Bit masks....................................................................................................................................... 53
7.1.4
Memory Functions ........................................................................................................................ 55
7.1.5
System Time.................................................................................................................................. 57
7.1.6
Timer ............................................................................................................................................. 59
7.1.7
I
2
C ................................................................................................................................................. 63
7.1.8
Reset / Watchdog .......................................................................................................................... 68
7.1.9
Debouncing ................................................................................................................................... 70
7.1.9.1
Debouncing 1....................................................................................................................... 70
7.1.9.2
Debouncing 2....................................................................................................................... 72
7.1.10
Debug functions ....................................................................................................................... 74
7.2
EIB / KNX Functions............................................................................................... 76
7.2.1
EIB type conversion ...................................................................................................................... 76
7.2.1.1
Constant conversion............................................................................................................. 76
7.2.1.2
Data conversion ................................................................................................................... 78
7.2.2
Application calls............................................................................................................................ 80
7.2.3
Group (Communication) Objects .................................................................................................. 83
7.2.3.1
Definition of group objects .................................................................................................. 83
7.2.3.2
RAM-flags ........................................................................................................................... 83
7.2.3.3
Communication object values.............................................................................................. 87
7.2.4
Objects - Automatic repetition ...................................................................................................... 91
7.2.5
Interface Objects ........................................................................................................................... 94
7.2.6
Virtual BCU memory .................................................................................................................. 103
7.2.7
Parameter Access ........................................................................................................................ 105
7.2.8
Device Status / Information......................................................................................................... 106
7.2.8.1
Program mode.................................................................................................................... 107
7.2.8.2
Program button / LED ....................................................................................................... 109
7.2.9
Parameter declaration for ETS .................................................................................................... 112
7.2.10
Interrupt handling ................................................................................................................... 115
7.2.11
Messages Manipulation .......................................................................................................... 117
7.2.11.1
Global Message Variables ................................................................................................. 117
7.2.12
special API for loadable applications ..................................................................................... 126
12.01.2012
4
KAIstack
Table of Contents -
7.3
EIB / KNX Features ............................................................................................... 127
7.3.1
EIB-Easy (Controller mode) ....................................................................................................... 127
7.3.2
Link Services............................................................................................................................... 129
7.3.2.1
A_Link_Read..................................................................................................................... 129
7.3.2.2
A_Link_Write.................................................................................................................... 129
7.3.3
Network Parameter...................................................................................................................... 131
7.3.3.1
A_NetworkParameter_Read .............................................................................................. 131
7.3.4
Device Descriptor Read .............................................................................................................. 132
7.3.4.1
Device Descriptor Type 0 .................................................................................................. 132
7.3.4.2
Device Descriptor Type 2 .................................................................................................. 132
8
Configuration................................................................................................................ 133
8.1
Overview ................................................................................................................ 133
8.1.1
Stack Settings in project.h........................................................................................................... 133
8.1.1.1
Export to project.mic / project.gmic .................................................................................. 133
8.1.1.2
Platform selection .............................................................................................................. 133
8.1.1.3
Configuration in project.h.................................................................................................. 133
8.1.2
Application Settings in app.h ...................................................................................................... 135
8.1.3
Application Settings in app_data.c.............................................................................................. 136
8.1.4
Application Settings in project.c ................................................................................................. 137
8.2
Compiler Switches / Constants .............................................................................. 138
8.2.1
Global Settings ............................................................................................................................ 138
8.2.2
Debug .......................................................................................................................................... 140
8.2.2.1
_DEBUG ........................................................................................................................... 140
8.2.2.2
DB_TRACE....................................................................................................................... 140
8.2.2.3
DEBUG_WIN32 ............................................................................................................... 140
8.2.2.4
DB_APP_TRACE ............................................................................................................. 140
8.2.3
Easy controller mode................................................................................................................... 141
8.2.4
Application Identifiers................................................................................................................. 142
8.2.5
Size of the system tables ............................................................................................................. 144
8.2.6
Configuration of Timer ............................................................................................................... 145
8.2.7
Hardware type ............................................................................................................................. 146
8.2.8
Save............................................................................................................................................. 147
8.2.9
Application Layer........................................................................................................................ 148
8.2.10
Message System ..................................................................................................................... 149
8.2.11
Loadable Applications............................................................................................................ 150
8.2.12
Management ........................................................................................................................... 151
8.2.13
Miscellaneous ......................................................................................................................... 152
8.3
Make....................................................................................................................... 153
8.3.1
Microsoft Nmake ........................................................................................................................ 153
8.3.1.1
Variables............................................................................................................................ 153
8.3.1.2
Configuration of the application ........................................................................................ 154
8.3.1.3
Location of Files ................................................................................................................ 154
8.3.2
Gnu Make.................................................................................................................................... 155
8.3.2.1
Variables............................................................................................................................ 155
8.3.2.2
Configuration of the application ........................................................................................ 156
8.3.2.3
Location of Files ................................................................................................................ 158
8.4
8.4.1
8.4.2
Example files.......................................................................................................... 159
project.h....................................................................................................................................... 159
app.h............................................................................................................................................ 159
9
Tools............................................................................................................................... 160
9.1
Build Tools............................................................................................................. 160
9.1.1
MAP_S19 (Version 2.21)............................................................................................................ 160
9.1.2
SerNr2S19 ................................................................................................................................... 162
9.1.2.1
Command line parameter:.................................................................................................. 162
10
Versions ..................................................................................................................... 163
10.1 Release Notes ......................................................................................................... 163
10.2 Updating projects ................................................................................................... 168
10.3 Certification............................................................................................................ 169
10.3.1
10.3.2
No. 80/5757/02....................................................................................................................... 169
No. 89/6216/03....................................................................................................................... 169
12.01.2012
5
评论