CodeWarrior Development Studio Component Development...

67
CodeWarrior Development Studio Component Development Environment User Guide Document Number: CWPEXCDEUG Rev 10.6, 02/2014

Transcript of CodeWarrior Development Studio Component Development...

Page 1: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

CodeWarrior Development StudioComponent DevelopmentEnvironment User Guide

Document Number: CWPEXCDEUGRev 10.6, 02/2014

Page 2: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

2 Freescale Semiconductor, Inc.

Page 3: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Contents

Section number Title Page

Chapter 1Getting started

1.1 Anatomy of component...................................................................................................................................................5

1.2 Driver..............................................................................................................................................................................6

1.3 Inheritance.......................................................................................................................................................................6

1.4 Template.........................................................................................................................................................................7

1.5 Interface..........................................................................................................................................................................7

Chapter 2Component Development Environment user interface

2.1 User interface..................................................................................................................................................................9

2.2 Project explorer...............................................................................................................................................................16

2.3 Component editor............................................................................................................................................................17

2.3.1 Component Category.........................................................................................................................................19

2.4 Properties editor..............................................................................................................................................................20

2.4.1 Creating Properties.............................................................................................................................................22

2.4.2 Managing Properties..........................................................................................................................................22

2.5 PropertyType editor........................................................................................................................................................23

2.6 Methods editor................................................................................................................................................................24

2.7 Events editor...................................................................................................................................................................27

2.8 User Types editor............................................................................................................................................................31

2.9 Constants editor..............................................................................................................................................................33

2.10 Driver editor....................................................................................................................................................................35

2.11 Documentation editor......................................................................................................................................................38

2.11.1 Help styles..........................................................................................................................................................40

2.12 Inheritance wizard...........................................................................................................................................................40

2.13 Deploy components........................................................................................................................................................44

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 3

Page 4: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Section number Title Page

Chapter 3Inheritance

3.1 Comparison with object oriented languages...................................................................................................................49

3.2 How ancestor component is selected?............................................................................................................................50

3.3 How are templates and interfaces used in inheritance process?.....................................................................................50

3.4 Methods inheritance........................................................................................................................................................51

3.5 Events inheritance...........................................................................................................................................................52

Chapter 4Macroprocessor

4.1 Driver processing............................................................................................................................................................55

4.2 Predefined macros and directives...................................................................................................................................56

4.3 Predefined global macros................................................................................................................................................57

4.4 Predefined local macros..................................................................................................................................................59

4.5 Macros defined from property........................................................................................................................................60

4.6 TST file...........................................................................................................................................................................62

4.7 CHG file..........................................................................................................................................................................63

4.7.1 Configuring methods and events of inherited and shared components.............................................................65

4.7.2 Feature link........................................................................................................................................................65

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

4 Freescale Semiconductor, Inc.

Page 5: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Chapter 1Getting startedThe Component Development Environment (CDE) is an Eclipse plug-in tool thatprovides a graphical interface to create, edit, and package embedded components. It cangenerate initialization code, fully operational drivers or package a software algorithm.

You can create new components using the Component Development Environment. Youonly need to determine Properties, Methods, and Events and make the implementation ofmethods and events. The CDE generates the script template with declaration files such as,header files in C as well as the structure of the source code. This tool facilitates thereusability of existing components by supporting inheritance of components, and helps inthe edition of the component by providing a full development environment that providescode completion, syntax coloring, and syntax error.

This chapter explains:

• Anatomy of a component• Driver• Inheritance• Template• Interface

1.1 Anatomy of componentA component is an object (software entity) that exposes a specific set of methods,properties, and events providing an abstraction for peripheral I/O and CPUs; a componentcan also be used to encapsulate software stacks or algorithms.

Types of components:

• Pure software algorithm• No hardware dependency

• Functionality extension• Delivers additional functionality

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 5

Page 6: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

• Inherits and extends the embedded component interface• Does not access hardware directly; therefore, there is no hardware dependency

• Peripheral driver• Uses initialization (init) components for peripheral initialization• Defines and implements peripheral functionality• Functions to access hardware• Hardware dependent; therefore, it defines HAL

A component can be accessed using properties, methods, and events.

Properties represent settings of the component during the design-time. Properties define:

• Component initialization state• Component settings and features supported in runtime• Component connection to the CPU (only for LDD components)

Methods are functions exposed by the component, available at runtime, and are used toset the component state and read the component results.

Events are callback functions exposed by the component to attend to asynchronous eventssuch as Interrupts.

If you select any event in the component, you must specify the name of the procedurelike event handler. This procedure will be called by a component driver when anassociated asynchronous event takes place (for example, hardware interrupt or someerror).

1.2 DriverA driver is a script that contains source code of all methods and events of a component.Every component (except the CPU driver) has a driver associated with it. After creationof a new component, you have to write the code of all its new (not inherited) methodsinto the driver of the component. The code is written in a special macro language.

1.3 InheritanceInheritance allows using and/or redefining methods and events of another component.This simplifies and speeds-up a process of creation of the new, embedded componentsand allows you to develop a platform-independent components by inheriting theplatform-independent components included in Processor Expert.

Driver

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

6 Freescale Semiconductor, Inc.

Page 7: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

1.4 TemplateA template holds the state of component's properties, methods, and events settings. Atemplate can additionally contain:

• Default value of each property, method (selected/unselected), and event (selected/unselected)

• Read-only feature if you can change the value of the property, method, and event

Every template contains association to a component that the template was created for (orfrom). This association allows using a template as a component representative. Like acomponent, the template can be added to user's project. The template acts like anordinary component with the only exception that it is already initialized.

There are two types of templates:

• Local templates - These templates can be used only by local interfaces that are storedin the same directory as the template (the directory of a component that is using thatinterface)

• Global template - These templates are visible for all interfaces. These templates arestored in the special directory Processor Expert base directory\templts. A change inthis template has an influence to all interfaces that use it.

1.5 InterfaceTo inherit functionality of other component in a new component, an interface has to bespecified. Interface is a list of methods and events that must be implemented by theancestor (inherited) component. If a component implements any interface (so it is suitablefor inheritance), it can be registered into this interface. If the component is registered inany interface, it is offered to user in Processor Expert.

NOTEIf you specify any interface, be sure that all methods and eventsfrom the interface are implemented by inherited component.You can call inherited methods from the driver, and you mustimplement all inherited events in your driver.

Specific initial settings of the ancestor component instance are required so that a templatecan be registered in interface instead of a component. Registration of components ortemplates into the interface can be done in the CDE during the interface creation/modification.

Chapter 1 Getting started

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 7

Page 8: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

There are two types of interfaces:

• Local interfaces - These interfaces can be used only by components where theseinterfaces are stored (the interface is stored with a component in the same directory).

• Global interfaces - These interfaces are visible for all components. These interfacesare stored in directory Processor Expert base directory\Beans, which is the basedirectory for all components. A change in this interface has an influence to allcomponents that use this.

Interface

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

8 Freescale Semiconductor, Inc.

Page 9: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Chapter 2Component Development Environment userinterfaceThe Component Development Environment (CDE) interface is used to create newcomponents. You can configure its properties, methods, and events.

This chapter explains:

• User interface• Project explorer• Component editor• Properties editor• PropertyType editor• Methods editor• Events editor• User Types editor• Constants editor• Driver editor• Documentation editor• Inheritance wizard• Deploy components

2.1 User interfaceIt allows you to understand the interface of Component Development Environment(CDE).

The CDE uses default C++ view and a Components view, in order to use the CDE. Youcan create an embedded component by selecting File-> New -> Embedded Component.In the figure below, the Project Explorer view displays the list of projects that are therein the workspace and the Components view displays the multiple components andinterfaces. This view also enables to create or import more than one component or

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 9

Page 10: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

interface in the new or an existing project. You can add or import a component into anexisting project in the Components view by popup menu. If you double-click on thecomponent in the Components view, the Component Editor appears.

Figure 2-1. Component development environment screen

The CDE consists of three types of menus:

• Component Creation Menu• Wizard Menu• Configuration Menu

The few main menu items are described below:

• Component Creation Menu: select File -> New -> Embedded Component; itdisplays the New Component Wizard and starts the creation of a new component.

User interface

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

10 Freescale Semiconductor, Inc.

Page 11: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Figure 2-2. Create new component screen

The Target Project screen appears. Enter the name of the project.

Chapter 2 Component Development Environment user interface

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 11

Page 12: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Figure 2-3. Target project screen

Click Next. The New Component screen appears. Enter the name of the componentand click Finish.

User interface

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

12 Freescale Semiconductor, Inc.

Page 13: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Figure 2-4. New component screen• Wizard menu: select File -> New -> Other...; the Select a Wizard screen appears.

On expanding the CDE, it displays the following list of wizards:• Category: Adds or deletes categories• Embedded Component: Starts the creation of a new component• Inherited Component: Starts the creation of a component by using the

inheritance wizard

Chapter 2 Component Development Environment user interface

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 13

Page 14: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Figure 2-5. Wizard menu• Configuration Menu: select Windows -> Preferences; it opens the Preferences

window for setting the CDE preferences. In the Preferences window, under theProcessor Expert node, select Paths; you can see the default path. Before you startwork on Processor Expert, you need to set the path of PEx directory as <InstallDir>\MCU\ProcessorExpert.

User interface

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

14 Freescale Semiconductor, Inc.

Page 15: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Figure 2-6. Preferences screen

To view CDE specific preferences, select Component Development Environmentunder the Processor Expert node, as shown in the figure below.

Figure 2-7. CDE preferences screen

Chapter 2 Component Development Environment user interface

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 15

Page 16: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

This table explains the fields of CDE preferences.

Table 2-1. CDE preferences

Field Description

Saving Dialog

Enable Save Dialog This will enable the saving popup dialog and it will addrevisions during saving

Auto Deploy Component when saved This will copy the Embedded Component files from theworkspace to the Processor Expert directory, enabling thenew component to be shown in the Component Library view

Debug Level

Enable Processor Expert Components Debug Verbose Mode It enables Processor Expert verbose mode. If this option isenabled, additional debug information will be shown inProcessor Expert console

Show Symbols in property tooltips It allows to show symbols in the tooltips

2.2 Project explorerIt lists the components currently available in the workspace. You can create or open asmany components as needed.

The Component Development Environment (CDE) always create a component's projectinside the workspace linked to the real component's files stored in the user's componentpath (Component Repository). There should be all component files in the Eclipse project,and later you can deploy the component into Processor Expert component repository.

Any deletion of components in the Project Explorer (workspace) only deletes linked filesin the workspace, but not the component in the repository. To delete a component fromthe repository, you need to open the Component Editor and right-click the component andselect Delete option.

Project explorer

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

16 Freescale Semiconductor, Inc.

Page 17: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Figure 2-8. Project explorer screen

2.3 Component editorIt holds the high level information related to the component, such as author version, theicon to show the copyright information when loaded in Processor Expert.

In the Component Editor, the project name is different from the component name. Everycomponent is represented as a tree of elements, such as Methods, Properties, and Events.Each element has a context menu and an associated editor. The Component Editor isdivided into two panels.

• Left Panel: displays internal component structure and all related files.• Right Panel: displays an editor for a selected item from component. Editor is also

divided into tabs. The number of tabs depend on the item that is being edited.

Chapter 2 Component Development Environment user interface

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 17

Page 18: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Figure 2-9. Component editor screen

This table explain the fields of Component Editor.

Table 2-2. Component details

Field Description

Header

Name Name of the component

Description Short description of the component

Author Author's name, that will appear in the source code header

Version Version number of the component. To indicate a beta version,use format 00.9XX. When you save the CDE, it will ask you ifa new revision needs to be added

Icon Component icon name, relative path to .bean withoutextension

Types File Comma-separated list of types-files (*.tps), relative path fromBeans\, without extension

File Version Component file format

Options Contains component specific options (CDE UI provides tooltip with detailed description)

Help Contains configuration of help style

Help type Define list of preselected help pages (templates)

Help Files List of help files with proper order based on selected type

Auto Save Driver Driver is saved automatically

Detailed Help Displays the detailed help

Table continues on the next page...

Component editor

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

18 Freescale Semiconductor, Inc.

Page 19: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Table 2-2. Component details (continued)

Field Description

Auto Save Help Auto saves the help

Compiler Select the compiler that can be used

2.3.1 Component Category

Every component can be sorted into some logic groups according to the function. Forexample, component fast Fourier belongs to SW-Math, component for encapsulatingsome display device belongs to HW-Display. Select the right category in the tree andclick OK.

This dialog window is accessible from Component editor.

Processor Expert sorts components by their category and creates logical groups in thecomponent selector.

Component categories are:

• HW• Sensor• Display• Communication• Converter

ADC

DAC

• Memory• Keypad/Keyboard• Port I/O• Peripherals

• SW• Virtual peripheral• OS configuration• Security• En/Decryption• (De)compression• Browser• Resource management• DSP

Chapter 2 Component Development Environment user interface

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 19

Page 20: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

• Controlling• Communication• Tutorials and demonstrations• Data• Math

• Internal peripherals• Port I/O• Interrupts• Timer• Communication• Measurement• Converter

ADC

DAC

• Memory

2.4 Properties editorIt allows you to view and edit the properties of a component.

To add the properties of a component, right-click the Properties element and select AddProperty option from the context menu. To select the type of property, select PropertyType from the drop-down list. Each Property Type dynamically modifies the editorshowing only the features for that particular property.

The panel on the left contains the list of the properties, and the features of the currentlyselected property are displayed on the right side. These features influence the behavior ofthe property in Processor Expert environment.

Properties editor

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

20 Freescale Semiconductor, Inc.

Page 21: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Figure 2-10. Properties editor screen

The properties can be reordered and copied using context menu as shown in figure below.You can also drag and drop the properties inside or outside groups.

Chapter 2 Component Development Environment user interface

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 21

Page 22: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Figure 2-11. Properties context menu screen

2.4.1 Creating Properties

A property can be added by right-clicking on the element Properties on the left panel andselecting Add Property from the context-menu. If the selected property is a group ofproperties, you can add a property to this group following the same procedure mentionedabove.

2.4.2 Managing Properties• Opening the property: Right-click the property and select Open option. The Property

editor will open.

Properties editor

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

22 Freescale Semiconductor, Inc.

Page 23: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

• Deleting: Right-click the property and select Delete option. If the selected property isa group of properties, all the properties in the group will also be deleted.

• Editing: You can edit the property by double-clicking the Property to open theProperty editor and then edit the settings.

• Display list of properties: For a complete list of component's properties, propertiesfeatures, and behavior of the properties in Processor Expert.

NOTEThis component contains all properties provided in basicversion of CDE.

2.5 PropertyType editorIt allows you to create your own enumerate types.

To create your own enumerate types using property type editor, right-click thePropertyTypes element and select the type of property to add.

Figure 2-12. PropertyType editor

The two property types are:

• Enumeration• Boolean

The following are the features:

Chapter 2 Component Development Environment user interface

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 23

Page 24: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

• Index - It is the unique number for each record.• Item name - It is the mandatory field. Enter the name of the item that is displayed in

the Processor Expert.• Item value - It is an optional field. The enumeration property in a macroprocessor

language defines its value from the Item value if defined, otherwise from the Itemname.

NOTEAll item value must be empty or defined at a time forcurrent property type. It is not allowed to have some itemvalues defined and the others not.

• Item hint - It is an optional field. This text will be displayed in processor expert as acontext help.

To define a global PropertyType, click Add New Global; this will create a new globaltps file which will be shared by other components. You can find the file in the directoryBeans\*.tps . If you want to keep the property type hidden from other component, addproperty types (Enum or Boolean) to the default created PropertyTypes file (same nameas the component).

To add an already created Global Property Type, right-click PropertyTypes and clickSelect Global From List. The following figure shows the list of all the Global Propertytype. If the list is empty it means you have never created a Global property type.

Figure 2-13. Global list screen

Methods editor

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

24 Freescale Semiconductor, Inc.

Page 25: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

2.6 Methods editorIt allows you to configure the methods of the component.

The created methods are listed on the left side, and properties of the selected method aredisplayed on the right side.

Figure 2-14. Methods editor screen

This table describes the properties of the method.

Table 2-3. Properties of the method

Field Description

Method Name Name of the method

Symbol Name of the symbol (the same name as in the left window)

GetTextValueIndex Determines if the item define index otherwise text value. Thisfeature is ignored if the item type contains user definedsymbols for each item. If this feature is TRUE for booleanitem, symbol is defined/undefined according to item's value.

Hint Hint displayed in the Processor Expert environment andmethod description of the help file

IsInAssembler If the method is implemented in Assembler or in C

IsInDefinitionModule If this feature is unchecked (method is not visible in theComponent Inspector), but still want the method to begenerated into the header file

ItemLevel It determines at what configuration level of Processor Expertin CodeWarrior this property will be shown. If set as Basic, theproperty will be shown when basic view is selected. If set asExpert, it will only be shown when expert view is selected

Table continues on the next page...

Chapter 2 Component Development Environment user interface

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 25

Page 26: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Table 2-3. Properties of the method (continued)

Field Description

MethodScope How the method will be inherited by default

PublicMethod If checked the method will be displayed in the ProcessorExpert Component Inspector

ReadOnly If the method is in Processor Expert read only that is theValue cannot be changed (generate code or don't generatecode)

ReturnHint Hint for the return type, displayed in the Processor Expertenvironment (default value you may set in Options - Defaultvalues page)

ReturnType Type of the returned value (void means that the method hasno return value)

Selected Generation source code into the driver (in Processor Expertcode design). There are four possibilities:

• YES - Method will be generated, it can be changed inProcessor Expert (sets ReadOnly to false and Value totrue)

• NO - Method will not be generated, it can be changed inProcessor Expert (sets ReadOnly to false and Value tofalse)

• NEVER - Method will not be generated, it cannot bechanged in Processor Expert (sets ReadOnly to trueand Value to false)

• ALWAYS - Method will be always generated, it cannotbe changed in Processor Expert (sets ReadOnly to trueand Value to true)

TypeChangeAble It determines if the item's type may be changeable in CHGscript

To view parameters of a Method; click Parameters tab of the Component Editor.

Figure 2-15. Method parameters

Methods editor

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

26 Freescale Semiconductor, Inc.

Page 27: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

This table explain the fields of Method Parameters.

Table 2-4. Method parameters

Field Description

Name Name of the parameter displayed and used in ProcessorExpert

Type Type of the parameter (selected from the list)

Passing How the parameter is passed to the method

Hint Hint for the parameter displayed in the Processor expertenvironment and parameter description in help files

2.7 Events editorIt allows you to configure the events of the component.

The created events are listed on the left side, and properties of the selected event aredisplayed on the right side. To add an event, right-click the Events element and selectAdd Event as shown in the figure below.

Chapter 2 Component Development Environment user interface

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 27

Page 28: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Figure 2-16. Events screen

The figure below shows the event editor.

Events editor

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

28 Freescale Semiconductor, Inc.

Page 29: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Figure 2-17. Events editor screen

This table explains the fields of Event Editor.

Table 2-5. Events editor

Field Description

Name Name of the event

Symbol Name of the event (the same name as in the left window)

DefineSymbol Determines the way how the item value will be defined formacroprocessor

EventName Name of the event procedure

EventScope How the event will be inherited by default

Expanded Determines if the group is expanded

Hint Hint displayed in the Processor Expert environment and eventdescription of the help file

IsInAssembler If the event is implemented in Assembler or in C

ItemLevel It determines at what configuration level of Processor Expertin CodeWarrior this property will be shown. If set as Basic, theproperty will be shown when basic view is selected. If set asExpert, it will only be shown when expert view is selected

Priority Determines the priority of the event routine

Table continues on the next page...

Chapter 2 Component Development Environment user interface

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 29

Page 30: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Table 2-5. Events editor (continued)

Field Description

ReadOnly If the event is in Processor Expert read only, the Value cannotbe changed (that is, if you generate code or don't generatecode)

Selected Generation source code into the driver (in Processor ExpertCode design). There are four possibilities:

• selYES - Event will be generated; it can be changed inProcessor Expert (sets ReadOnly to false and Value totrue)

• selNO - Event will not be generated; it can be changedin Processor Expert (sets ReadOnly to false and Valueto false)

• selNEVER - Event will not be generated; it cannot bechanged in Processor Expert (sets ReadOnly to trueand Value to false)

• selALWAYS - Event will be always generated; it cannotbe changed in Processor Expert (sets ReadOnly to trueand Value to true)

TypeChangeAble It determines if the item type may be changeable in CHGscript

Value Evaluates if the event is included in the component (it will begenerated into the driver or not in Processor Expert codedesign)

To view parameters of an Event, click Parameters tab in the editor as shown in thefigure below.

Figure 2-18. Event parameters screen

This table explains the fields of event parameters.

Table 2-6. Event parameters

Field Description

Name Name of the parameter displayed and used in ProcessorExpert

Type Type of the parameter (selected from the list)

Passing Type of passing parameter to the method

Hint Hint for the parameter displayed in the Processor expertenvironment and parameter description in help files

Events editor

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

30 Freescale Semiconductor, Inc.

Page 31: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

2.8 User Types editorIt allows you to specify user-defined types used in generated code.

The list of user types that you can create:

• Aliases• Arrays• Records• Pointers• Enums• User definitions

Figure 2-19. User types

To open user type editor, right-click Types Definition and select Add Type as shown inthe above figure. The following figure shows Types editor.

Chapter 2 Component Development Environment user interface

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 31

Page 32: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Figure 2-20. Types

This table explains the fields of User Type editor.

Table 2-7. User Type editor

Field Description

This defines Lists user-defined types

Type Name Type name as it will be stored in the types list (for ParameterType feature in Methods page and Events page, and forparameters type and return types of functions)

Is type Data Type

Hint Description of the selected type. It is used in help files

Generate to driver If the declaration is generated in the drivers

Generate to doc It will generate the User Type information into the HTMLdocumentation

Unique name If set to yes, the type will have the unique name, whichconsists of the name of the component and the Type Name.Two instances of one type of the component will have twodifferent declarations of this type. For example, thecomponent name is MyComponent. This component has oneuser type MyType and has selected the Unique name option.There are two instances in Processor Expert MB1 and MB2.After code generation, there will be two declared user types:

• MB1_MyType• MB2_MyType

The following describes the settings of User Type:

• Properties of type Alias:

User Types editor

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

32 Freescale Semiconductor, Inc.

Page 33: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

• Type Name - Name of the variable• Is type - Alias type is the same type as selected type

• Properties of type Array:• Type Name - Name of the variable• Low index - Low index of the array. The size of array is (high-low+1)• High index - High index of the array. The size of array is (high-low+1)• Is type - Type of array

• Properties of type Record:• Type Name - Name of the variable in the record• Hint - Description of the variable. It is used in help files

• Properties of type Pointer:• Type Name - Name of the variable• Is pointer to this type - This user type is a pointer to the selected type

• Properties of type Enum:• Type Name - Name of the variable• Hint - Description of the variable

• Properties of User:• Type Name - Name of the variable• User Definition - There is a user definition. User has full control of the user type.

User type can be defined either simple or complicated types, for example:

typedef int *TIntPtr;

typedef struct { float real; float imaginary; } TComplex;

• Hint - Description of the variable

2.9 Constants editorIt allows you to define a constant of the component that will be available to the user.

The left panel displays a list of the constants and the right panel displays a value andother properties of the selected constant. Constants can be added or removed by using theConstant context menu as shown in the figure below.

Chapter 2 Component Development Environment user interface

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 33

Page 34: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Figure 2-21. Constant screen

The figure below shows Constant Settings screen.

Constants editor

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

34 Freescale Semiconductor, Inc.

Page 35: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Figure 2-22. Constant editor

This table describes the fields of Constant Settings.

Table 2-8. Constant settings

Field Description

Constant Name Specifies an indentifier that will be used in the generated code

Constant Value Value that will be assigned to the constant

Constant Description Text used for the documentation

Of type Data type of the value

Generate to driver If the constant will be placed in the generated into the driverautomatically

Generate to doc Enables generation of the constant into the documentation

Unique name Enables generation of the constant with unique name. If thereare more instances of one component, each will contain adifferent constant name (usually there will be a prefix of thecomponent name)

2.10 Driver editorIt allows you to edit component driver file.

Chapter 2 Component Development Environment user interface

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 35

Page 36: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Driver built-in editor serves for editing implementation of methods and events, andincludes HTML help files and other files generated by the CDE. The component drivercan be edited by selecting the driver file, select Drivers > sw ><name of thecomponent>.drv file as shown in the figure below.

Figure 2-23. Component driver file

The driver editor supports all features supported by the Eclipse Editor. The following areProcessor Expert features:

• Color coding• Error syntax highlight for selected language (if editing driver files) and for

macroprocessor language when editing component files• The code is highlighted• If an alphabet is typed, the list of words starting with same alphabet is displayed. It is

content assist• The set of code can be folded or expanded• The text is highlighted with grey color if the same text is repeated in the code. It is

occurrence matcher• If same command is typed more than once then command matcher is displayed• Hints for commands

The following figures show all the above features.

Driver editor

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

36 Freescale Semiconductor, Inc.

Page 37: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Figure 2-24. Driver editor

Figure 2-25. Driver editor

Chapter 2 Component Development Environment user interface

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 37

Page 38: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

2.11 Documentation editorIt allows you to design or create documentation (help) for your components in HTMLformat.

You can add your HTML file, create HTML file, and preview the HTML file. Right-clickon the Documentation node, the three options are displayed.

• Add Custom Page - will open the File browser dialog and you can select the HTMLfile to be added to component.

• Create Custom Page - will show wizard with simple HTML template (that can bemodified) and this new page is added to the component.

• Preview - will open main HTML page in external browser.

The help files describe the Properties, User Types, Events, General Info, and Methods ofthe component. The hint associated with the items, such as Properties, User Types,Methods, or Events define the content of the item description.

Documentation editor

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

38 Freescale Semiconductor, Inc.

Page 39: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Figure 2-26. Documentation screen

To open the Documentation editor, select the required HTML file and right-click on it.From the context menu, select the Open option.

Chapter 2 Component Development Environment user interface

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 39

Page 40: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Figure 2-27. Documentation properties screen

From the context menu, you can also select Rename/Delete option to rename or deleteyour HTML file.

2.11.1 Help styles

Every component can set different style of HTML help. Each style has different list ofgenerated files. The HTML styles are available under the Documentation node of theComponent Editor. You can Open, Delete, and Rename the HTML file using the contextmenu. The basic set of files are:

• General - General information about the component, displayed as help for thecomponent in Processor Expert

• Methods - List of methods and their description (hints)• Events - List of events and their description (hints)• Properties - List of properties of the component and their description (hints)• User Types - Designed for usage in the driver interface

2.12 Inheritance wizardIt is designed for easy creation of new components that inherit functionality from othercomponents or add inheritance to an already created component.

Inheritance wizard

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

40 Freescale Semiconductor, Inc.

Page 41: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

It guides you through the whole inheritance process. This table explain the fields ofComponent Information page.

Table 2-9. Component information

Field Description

Name Name of a new inherited component

Component Description Description of the inherited component

NOTEUsing this wizard, you can either create a new inheritedcomponent or add inherited methods to an already-createdcomponent.

After entering the relevant information in Component Information page, click Next. Thefigure below shows the Interface definition page.

Figure 2-28. Interface definition page

Chapter 2 Component Development Environment user interface

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 41

Page 42: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

This table explains the fields of Interface definition page.

Table 2-10. Interface definition

Field Description

Inherit Selects if that specific method will be inherited

Scope Scope of the method - The visibility and reimplementation ofthe method

• Private - The method is implemented in an ancestor,and descendant can call it. This method is not visible inthe descendant (in the page Methods)

• Published - The method is implemented in an ancestor.It is also visible in the descendant (the same like if itwas method of the descendant), but is read only, that isyou cannot change its name, parameters, etc. Thedescendant generates only macro that calls theancestor

• Override - Combination of previous two ones, that ismethod is implemented in an ancestor but descendantoverrides this implementation

Mode There are seven values:• ALWAYS_REQUIRED - ALWAYS REQUIRED -

Method/event must be in the ancestor and is alwaysgenerated.

• REQUIRED_IF_EXIST - REQUIRED IF EXIST -Method/event is generated if it exists in the ancestor.

• OPTIONAL_MUST_EXIST - OPTIONALLYREQUIRED, BUT MUST EXIST - Method/event mustexist in descendant, it may not be set for generating(code design), but it can be changed in the CHG file ofthe descendant component. For more details, see CHGFile topic.

The method cannot be published, that is, the featureMethodScope cannot be published.

• OPTIONAL_IF_EXIST - OPTIONALLY REQUIRED,MAY NOT EXIST - Method/event may not exist, but if itexists it may not be set for generating (code design),but it can be changed in the CHG file of thedescendant. For more details, see CHG File topic.

The method cannot be published, that is, the featureMethodScope cannot be published.

• OWNER_MUST_EXIST - MAY NOT EXIST,GENERATE IF OWNER - Method/event may not exist;if exists it will be generated only if descendant hasmethod/event with the same name.

• OWNER_IF_EXIST - MUST EXIST, GENERATE IFOWNER - Method/event must exist; it will be generatedonly if descendant has method/event with the samename.

• SAME_AS_OWNER - The method may not exist inancestor component, and is generated if it is required indescendant component. The settings of descendantcomponent method is updated automatically.

Read Only Select if method is set as read-only

Inheritance wizard

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

42 Freescale Semiconductor, Inc.

Page 43: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

When you have to modify the interface, choose the appropriate inherited component(interface). In the Interface editor, select the Basic Settings pane, select the InterfaceName from the drop-down list and then click the Edit button to open and modify theinterface.

Figure 2-29. Interface editor

The following screen appears after clicking the Edit button.

Chapter 2 Component Development Environment user interface

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 43

Page 44: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Figure 2-30. Interface edit screen

For more information on Inheritance, see Inheritance chapter.

2.13 Deploy componentsIt allows you to deploy components into the Processor Expert component's user path.

When creating or importing components, all changes performed in the components aresaved inside the workspace. When the development for the component is completed, inorder to list these components under Component Library for their use, first they need tobe deployed into the Processor Expert component's user path.

NOTEIf the existing project contains the deployed component and theproject is opened then this project displays the deployedcomponent.

To deploy the component, right-click on the component name and select Deploy from thecontext menu as shown in the figure below.

Deploy components

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

44 Freescale Semiconductor, Inc.

Page 45: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Figure 2-31. Deploy component screen

The figure given below shows Deploy Component Wizard.

Chapter 2 Component Development Environment user interface

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 45

Page 46: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Figure 2-32. Deploy component wizard

Click Set User Directory as Default if you want to automatically set the path to usercomponent path.

To add or remove external files, click Add File or Remove File. Click Finish to deploythe component.

In order to reflect the latest change in the Component Library view, right-click andselect Refresh option from the context menu, as shown in the figure below.

Deploy components

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

46 Freescale Semiconductor, Inc.

Page 47: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Figure 2-33. Component library screen

Chapter 2 Component Development Environment user interface

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 47

Page 48: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Deploy components

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

48 Freescale Semiconductor, Inc.

Page 49: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Chapter 3InheritanceIn order to create hardware-independent components, it is necessary to implement themfor every processor you may use. Without the inheritance process, this would mean a lotof repeated coding.

The basic hardware components provided within Processor Expert cover the entirefunctionality of processors, and are hardware independent (in fact, they are hardwaredependent, but you have drivers for all CPUs supported in your version of ProcessorExpert). By inheriting from these components, you don't need any more to deal with thelow-level part of your components. By writing the high-level part of the algorithm, usinginherited hardware independent methods and events of components, you can keep thenew component hardware-independent.

CDE allows the creation of a new inherited component or directly adds inheritance to analready-created component by selecting the methods and events to inherit from (bycreating interfaces). Your own components can also be used for further inheritance byother components, providing a high level of re-usability to your work.

This chapter explains:

• Comparison with object oriented languages• How ancestor component is selected?• How are templates and interfaces used in inheritance process?• Methods inheritance• Events inheritance

3.1 Comparison with object oriented languagesIn Processor Expert, the inheritance is implemented in different way than in most objectoriented languages.

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 49

Page 50: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

A component (descendant) can inherit another component (ancestor), but the backgroundof the inheritance process is slightly different from what would a C++ or Object Pascalprogrammer expect. The main difference is that a descendant (newly created) componentcan replace the ancestor component with another one and, this can be done any time afterthe new component was created. In standard object oriented languages, the ancestorobject is declared in the definition of a new object, and from that moment it cannot bechanged.

3.2 How ancestor component is selected?When a component is inherited and its interface is created or specified, there is nobinding between the ancestor and the descendant component.

The interface is only a list of methods and events. To create a binding, the componentmust be registered into the interface. During the component setup in ComponentInspector view, the Processor Expert will allow you to choose any component thatsupports (is registered for) the desired interface to be the ancestor component.

3.3 How are templates and interfaces used in inheritanceprocess?

A component template represents a real component and is also used in inheritanceprocess.

Because you want the inherited component to be initialized (in a project, you want to setonly some properties of the descendant), the template for that component must beregistered instead of the component itself in the interface.

Details for use of templates and interfaces in the inheritance:

• Interfaces• Interface selection is done in the CDE (component design-time)• Interface specifies the methods and events needed by a new component, which is

done using this interface• Templates

• Template selection is done in Processor Expert (component run-time, usage ofthe component)

• Template settings should be CPU independent, because the CDE cannot set CPUdependent properties

How ancestor component is selected?

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

50 Freescale Semiconductor, Inc.

Page 51: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

• Template is the group of initialization values of the component for selectedinterface

• There is a possibility to disable editing of value of any property, method, orevent for chosen interface. This can be done by setting the property, method, orevent to Read Only in the template

3.4 Methods inheritanceAccording to the scope feature in interface, the Methods or Events can be inherited asPrivate, Override, or Published.

The Private methods and events are intended for use within the descendant componentonly. Methods and Events selected as Override or Published automatically appear in thedescendant component. Let us assume that a chosen ancestor component has a method M.The inheritance process requires an interface to be created. The following options (valuesof MethodScope) that are available for the ancestor's method M in the interface.

• Private - The method M does not appear in the descendant's methods list (in thecomponent inspector of the descendant component) and should be called only fromthe code of the descendant component. This option is suitable when we want to onlyuse the component without publishing its methods to the user.

• Override - The method M appears in the descendant methods list (in the componentinspector of the descendant component), but user can write his/her own code tochange its function (and also call the original method M of the ancestor if it isreasonable).

• Published - The method M behaves like the native method of the descendantcomponent. This approach does not mean any overhead; the method is generated as amacro calling the ancestor's method.

Chapter 3 Inheritance

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 51

Page 52: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Figure 3-1. Methods inheritance

3.5 Events inheritanceAccording to the scope feature in interface, the Methods or Events can be inherited asPrivate, Override, or Published.

Let us assume that a chosen ancestor component has an event E. The inheritance processrequires an interface to be created. The following options (values of EventScope) that areavailable for the ancestor's event E in the interface:

• Private - The event E does not appear in the descendant component events list andshould be used for internal processing of the events from the ancestor component.

Events inheritance

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

52 Freescale Semiconductor, Inc.

Page 53: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

• Override - The event E appears in the descendant component events list andcomponent author can write his/her own code before and/or after calling the user'sevent handling routine.

• Published - The event E appears in the descendant component events list and theevent behaves like the native event of the descendant component. User's eventhandling routine is called directly.

Chapter 3 Inheritance

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 53

Page 54: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Figure 3-2. Events inheritance

Events inheritance

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

54 Freescale Semiconductor, Inc.

Page 55: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Chapter 4MacroprocessorThe text of the component driver is processed by Processor Expert macroprocessor. Thisis special macroprocessor designed for this kind of component drivers. Themacroprocessor supports:

• Conditional translation• Includes• Evaluation of simple expressions• Lists for cycles• Error output• Global macros• Local macros

• Local macros are defined by Processor Expert and contain setting of thecomponent in Processor Expert. This macro cannot be changed by a driver.

• New local macros can be defined and modified by a driver.• Generating to several part

For more information, see Macro-processor Language Reference Manual.

This chapter explains:• Driver processing• Predefined macros and directives• Predefined global macros• Predefined local macros• Macros defined from property• TST• CHG

4.1 Driver processingEvery component has at least one driver. The text of the component driver is processedby Processor Expert macroprocessor.

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 55

Page 56: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

The driver consists of sections. Section is component implementation for one compilerand language. Sections consist of subsections. Text or code is generated into filespecified by subsection name or parameters. The Processor Expert has a specialmacroprocessor designed for component drivers. The output from the component drivercan be generated to several files. If the line starts with character % as a first non-spacecharacter on the line, macroprocessor consider the following word as a command. Thepredefined macros by Processor Expert are:

• List of global macros• List of local macros• Macros defined from a property• List of special macros and directives

You can write a script files TST file and CHG file for testing of component setting.

Driver or TST file are included to the Processor Expert from SRC file. SRC file is locatedat: ProcessorExpert\Drivers\ and has the same name as the component. If there are moredrivers for one component, SRC file contains conditional translation which choose theright driver.

4.2 Predefined macros and directivesThere is a list of predefined macros and directives provided by Processor Expert.

To replace a macro by its value, write the name of macro after character %. Each line ofthe driver is processed from the right side to the left side, and all macros are replaced.Special macros and directives:

• %% - character %• %{def_name}, %'{def_name}', %"{def_name}", %~{def_name}~ - is replaced by def_value.• %for_index_1 - is replaced by index of actual variable of for-cycle from range:

1...number of items in the list.• %for_index_0 - is replaced by index of actual variable of for-cycle from range:

0...number of items in the list-1.• %list_size({def_list}) - number of items in the list.• %str_length({string}) - string length; number of characters in the string• %str_length({def_name}) - string length; number of characters of the macro value.

Macro cannot be a list.• %short_path({value}) - converts path to short path for MS-DOS 16-bit application. The

value must be macro or string between brackets. The path should exist on the disk.

Predefined macros and directives

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

56 Freescale Semiconductor, Inc.

Page 57: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

• %[{index},{def_list}] - returns item from the list def_list with index equal to index.Index of first items is 1. Result is empty string if the requested index is out of range.def_list must be defined.

• %; - is replaced by sequence of characters that defined comment to the end of line.See also global macro %CommentLine.

• %. - is replaced by separator of module name and method name. The separator isdefined according to selected language, usually it is character _ (underscore).

• %{ - is replaced by sequence of characters that begins a multi-line comment.• %} - is replaced by sequence of characters that ends a multi-line comment.• %#{srcf}{dstf}[-]{number} - contents signed 32-bit integer number from srcf to dstf

format. Supported formats of srcf:• nothing - decimal number• 2 - binary number

Supported formats of dstf:

• h - selected format of high level language• a - selected format of assembler - data• aa - selected format of assembler - address• ab - selected format of assembler - binary data

• %#b{number} - converts 8-bit number (0...256) from decimal to hexadecimal format(without prefix or suffix)

• %#w{number} - converts 16-bit number (0...65535) from decimal to hexadecimalformat (without prefix or suffix)

• %#l{number} - converts 32-bit number from decimal to hexadecimal format(without prefix or suffix)

Access to inherited items:

• %@{inhr_property}@{def_name} - value of macro def_name from inherited componentpointed by property inhr_property.

• %[@{inhr_property}@{index},{def_list}] - returns item from the list from inheritedcomponent, with item's index equal to index. inhr_property is a symbol of propertyfor inheritance.

4.3 Predefined global macrosGlobal macros are macros defined by Processor Expert for the project.

Chapter 4 Macroprocessor

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 57

Page 58: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

They are the same for all components in the project and are not changed during the codegeneration. This table explains the predefined global macros.

Table 4-1. Predefined global macros

Field Description

Language, Compiler, Version

Language identification of selected target language: MODULA, ANSIC,JAVA, ASM

Compiler identification of selected target compiler

CommentLine is defined if there is sequence of characters which startscomment to the end of line for selected target language.Value of the macro is this sequence

PEversion version of Processor Expert, format XX.XX

TimeStamp date and time of code generation

CPU, interrupt vector table

CPUvariant selected target CPU type (from CPU properties)

CPUtype type of the target CPU component

CPUfamily target CPU family

CPUproducer producer of the target CPU

InterruptTableType type of the interrupt vector table

InterruptVectorType type of the interrupt vector

Clock, speed modes

Xtal_kHz frequency of Xtal of the CPU, integer number

HighClock_kHz clock frequency in front of system prescaler in high speedmode, integer number

LowClock_kHz clock frequency in front of system prescaler in low speedmode, integer number

SlowClock_kHz clock frequency in front of system prescaler in slow speedmode, integer number

CPUsystem_ticks number of ticks behind system prescaler, list of three valuesfor every speed mode

CPUrunSpeedModeNum number of supported speed modes in the target CPU

SetHighSpeedMode defined if high speed mode is supported in the target CPU(high speed mode must be supported)

SetLowSpeedMode defined if low speed mode is supported in the target CPU

SetSleepMode defined if slow speed mode is supported in the target CPU

names of all common prescalers initialization value, names depend on the CPU descriptiondatabase

Modules

ProjectName name of the project

ProjectModule name of the main module

ProcessorModule name of the CPU module

ProcessorName name of the CPU component

ModuleList list of all component modules in the project (without CPUmodule)

Table continues on the next page...

Predefined global macros

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

58 Freescale Semiconductor, Inc.

Page 59: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Table 4-1. Predefined global macros (continued)

Field Description

EventModuleList list of all event modules in the project

ExternalModules list of all external programs in the project

ExternalModuleExts list of corresponding extensions of external programs

ExternalModuleDir list of corresponding directories of external programs

ExternalModuleRelDir list of corresponding relative directories of external programs

DriverExtension extension of driver filename, DRV or DMO or TST

Directories

Dir_Project directory of the current project

DirRel_Events, DirRel_Binary relative path from project-directory to drivers

directory and binary-directory

DirRel_EventToBinary relative path from code-directory to binary-directory

Dir_Drivers, Dir_Events, Dir_Binary absolute path for drivers, event modules and binary files. Youshould always use relative paths

Dir_Compiler absolute path of external compiler; it is defined as externaltool

4.4 Predefined local macrosLocal macros are macros defined by Processor Expert for each component.

A component can define its own local macros. These macros can also be changed in thedriver. Other components have no access to macros defined by other components.

Each driver should define the following macros:

• DriverVersion - Version of the driver, format XX.XX• DriverAuthor - Name of the author of the driver• DriverDate - Date of last modification of the driver, format: DD.MM.YYYY

There are local macros defined for every component dependent on list of component'sproperties, methods, and events. Macros defined by Processor Expert cannot be changedby driver. Other components have no access to macros of another component withexception of inheritance.

List of macros defined for each component:

• DeviceType - Type of the component• DeviceName - Name of the component• ModuleName - Name of the component driver. It must be identifier• Comment - User comment to the component. List of strings.• runHighSpeed - Defined if component is supported in high speed mode

Chapter 4 Macroprocessor

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 59

Page 60: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

• runLowSpeed - Defined if component is supported in low speed mode• runSleep - Defined if component is supported in slow speed mode• runSpeedMode - List of supported speed modes, values: Yes/No• runSpeedModeNum - Number of supported speed modes• method - For each method of the component that must be implemented in the driver;

the name of the method is defined as a macro. Value of the macro is same as thename

• method_Hint - Hint for the corresponding method• event - For each event user requests to handle in his code, the name of event is

defined as a macro. Value of the macro is name of event handler function• eventPrior - event priority. It is defined only if the event support priority• eventModule - event module of corresponding event• event_Hint - hint for the event• MethodList - list of requested methods• MethodHints - list of corresponding hints for the requested methods• EventList - list of requested events• EventModules - list of corresponding event modules

4.5 Macros defined from propertyEvery property defines the unique symbol in the component. The symbol is the name ofthe macro defined for the component driver in the Processor Expert.

The symbol should not begin with the character underscore '_'. The value of the macro isvalue of the property set in Processor Expert Component Inspector.

NOTEInteger values are always defined as decimal numbers.

Some properties have detailed information defined as macros. The name of the macro iscompleted from the name of the property (feature Symbol) and the suffix. The suffixdepends on the type of the property. The following properties have defined the detailedinformation:

• List of items• NumItems - the number of the items in list• MaxItem - the maximal index of the item (that is, NumItems-1)

• Date• Day - the day of the date stored in property (ranges from 1 to 31)• Month - the month of the date stored in property (ranges from 1 to 12)• MonthLong - the name of the month (language depends on the current country

which is set in windows)

Macros defined from property

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

60 Freescale Semiconductor, Inc.

Page 61: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

• MonthShort - the name of the month (language depends on the current countrywhich is set in windows) - short version

• Year - the year of the date stored in property (format is XXXX)• DayOfWeek - the day in the week (ranges from 0-monday to 6-sunday)• DayOfWeekLong - the name of the day (language depends on the current

country which is set in windows)• DayOfWeekShort - the name of the day (language depends on the current

country which is set in windows) - short version• Time

• Hour - the hour of the time stored in property• Min - the minute of the time stored in property• Sec - the second of the time stored in property

• String list

Macro without suffix - the list of lines of the text. If user does not enter any text, themacro is not defined.

• Len - list of corresponding lengths of lines in the string-list (number ofcharacters on each line)

• Lines - the number of the lines in the string-list• List - list of lines; every line is defined as a list of characters (this macro is

available if the feature DefineList is set to value True)• External file

• FileName - only the name of the file (without the path)• ShortPath - the whole name of the file (with the path) for DOS applications• Value - binary values in a file (depends on the settings of the feature FileDefine)• ValueList - binary values in a file (depends on the settings of the feature

FileDefine)• External bitmap file

• Width - width of the picture• Height - height of the picture• Size - the size of the picture (the number of the occupied bytes in a memory)

• Directory• (one character underscore) - the directory ends with '\'• (two characters underscore) - the directory doesn't end with '\'

• Address in CPU address space• External - yes if any address from selected address range is inside external

memory, otherwise no• Internal - yes if any address from selected address range is inside internal

memory, otherwise no• RAM - yes if any address from selected address range is inside RAM, otherwise

no

Chapter 4 Macroprocessor

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 61

Page 62: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

• ROM - yes if any address from selected address range is inside ROM, otherwiseno

• FLASH - yes if any address from selected address range is inside FLASH,otherwise no

• EEPROM - yes if any address from selected address range is inside EEPROM,otherwise no

NOTEThere is complete component BasicProperties in thisversion of the CDE. This component contains allproperties provided in basic version of the CDE.

4.6 TST fileThe TST file is a script that describes implementation-dependent tests of the componentsetting.

It runs from Processor Expert only if the component is set up correctly. Componentmodules won't be generated if any error is reported from the TST file. The TST file isstored in the same directory as the driver; the file-name is also the same and the file-extension is TST. You can edit TST file directly in Component DevelopmentEnvironment. For more information, see Driver Processing topic.

The list of macros defined for the TST file is the same as macros for the driver. You canuse all macroprocessor commands in the TST file as in the component driver. Messagesfrom the TST script are reported using the commands %error, %warning, %hint toProcessor Expert Error window. The TST script cannot define any global macrosaccessible from other TST files or drivers.

WarningIf you write any TST file for your component, any warning andhint will NOT be generated from the driver. All warnings andhints should be generated from the TST file.

Example:

%if Property1="MASTER"

%error Sorry - this feature is not implemented yet.

%endif

%-

TST file

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

62 Freescale Semiconductor, Inc.

Page 63: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

%if Property2="0"

%hint Define buffer for better performance.

%endif

There is complete component BasicProperties in this version of CDE. This componentcontains example of TST and CHG files.

4.7 CHG fileThe CHG file is a script for testing the component settings, and controls the componentbehaviour in the Component Inspector view in Processor Expert.

This file should implement implementation-independent tests and report errors if thecomponent setting is incorrect (component function is not defined for this componentsettings). For example, the CHG file can generate error if the buffer size is lower than 16bytes. You can generate error messages using commands: %error, %warning, %hint or youcan change or read the value of any property/method/event using special commands %setand %get. These commands can be used only in CHG files.

The following is the syntax of Set command:

%set {Symbol} {FeatureSymbol} {Value}

Description:

• {Symbol} is a symbol of any property, method, or event• {FeatureSymbol} is a symbol from following list• {Value} is a new value for the feature. Value is text to the end of line.

List of FeatureSymbols:

• ReadOnly - you can enable/disable changing of value of any property.

{Symbol} must be symbol of any property.

{Value} must be yes or no.

• Selection - you can enable/disable changing of selection of any method or event, forexample, if method will be generated to the driver and if event will be called fromthe driver.

{Symbol} must be symbol of any method or event.

{Value} must be

Chapter 4 Macroprocessor

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 63

Page 64: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

• always (the method/event must be selected) or• never (the method/event cannot be selected) or• enable (you can change selection)

• Value - you can change the value of any property.

{Symbol} must be symbol of any property.

{Value} must be value for the property (the same as you can enter in the ProcessorExpert Component Inspector). Integer value can be expressed in enhanced format.

• MinValue, MaxValue - you can change the minimal and maximal possible value ofthe property.

{Symbol} must be symbol of property of type: integer number, real number, or list ofitems.

{Value} must be decimal number.

WarningIf you change any value of the property, the macros areNOT changed to the end of CHG file. You can read thevalue of any property using %get command.

The following is the syntax of Get command:

Syntax:

%get({Symbol},{FeatureSymbol})

List of known symbols is the same as for %set command. Result is value of selectedfeature.

Example:

%if defined(Property1) & Property1="MASTER"

%error Sorry - this feature is not implemented yet.

%endif

%-

%if defined(OutputBufferSize) & OutputBufferSize="0"

%set SendData Selection never

%else

%set SendData Selection enable

CHG file

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

64 Freescale Semiconductor, Inc.

Page 65: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

%endif

There is complete component BasicProperties in this version of CDE. This componentcontains example of CHG file and TST file.

4.7.1 Configuring methods and events of inherited and sharedcomponents

It is necessary to configure methods and events of inherited and shared components.

For optionally required methods/events, it is possible to use the following commands inthe descendant component:

• %set @{InhrSymbol}@{Symbol} Selection always - The generation of the method/event will be enabled without a possibility to enable it by the Processor Expert user.It is necessary, for example, if the descendant needs the method/event.

• %set @{InhrSymbol}@{Symbol} Selection enable - This option can be used toenable the method/event if the descendant doesn't need the method/event.

• %set @{InhrSymbol}@{Symbol} Selection never - The generation of the method/event will be disabled without a possibility to enable it by the Processor Expert user.This command is available for inherited components only.

Description of the symbols:

• {InhrSymbol} is a symbol of the inherited component (interface) property.• {Symbol} is a name of the method/event.

4.7.2 Feature link

Some property features need to be linked to a specific property. For example, thedirection feature of a Pin (Pin/Port) property needs to be linked to a Direction property.Thus, when you create a Pin property, you need to create also a Direction property.

The features of many properties can be linked to the same property.

For example, the direction feature of 8 Pin properties can be linked to the same Directionproperty. As a consequence, they will all have the same direction.

In the direction feature of the Pin property, you will then select the symbol of theDirection property. Some links are already available within Processor Expert. Forexample, for the direction feature of a Pin Property, you can select _PE_OutputDir(output only) or _PE_InputDir (input only). In this case, you do not need to create aDirection property. These links are listed in the next paragraph.

Chapter 4 Macroprocessor

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

Freescale Semiconductor, Inc. 65

Page 66: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

Available Links:

• _PE_OutputDir: Direction property fixed to output• Type=TDrctItem• Symbol=_PE_OutputDir

• _PE_InputDir: Direction property fixed to input• Type=TDrctItem• Symbol=_PE_InputDir

• _PE_False: Boolean property fixed to false• Type=TBoolItem• Symbol=_PE_False

CHG file

CodeWarrior Development Studio Component Development Environment User Guide, Rev. 10.6, 02/2014

66 Freescale Semiconductor, Inc.

Page 67: CodeWarrior Development Studio Component Development ...cache.freescale.com/files/soft_dev_tools/doc/user... · CodeWarrior Development Studio Component Development Environment ...

How to Reach Us:

Home Page:freescale.com

Web Support:freescale.com/support

Information in this document is provided solely to enable system andsoftware implementers to use Freescale products. There are no expressor implied copyright licenses granted hereunder to design or fabricateany integrated circuits based on the information in this document.Freescale reserves the right to make changes without further notice toany products herein.

Freescale makes no warranty, representation, or guarantee regardingthe suitability of its products for any particular purpose, nor doesFreescale assume any liability arising out of the application or use ofany product or circuit, and specifically disclaims any and all liability,including without limitation consequential or incidental damages.“Typical” parameters that may be provided in Freescale data sheetsand/or specifications can and do vary in different applications, andactual performance may vary over time. All operating parameters,including “typicals,” must be validated for each customer application bycustomer's technical experts. Freescale does not convey any licenseunder its patent rights nor the rights of others. Freescale sells productspursuant to standard terms and conditions of sale, which can be foundat the following address: freescale.com/SalesTermsandConditions.

Freescale, the Freescale logo, CodeWarrior, and Processor Expert aretrademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off.All other product or service names are the property of their respectiveowners.

© 2011–2014 Freescale Semiconductor, Inc.

Document Number CWPEXCDEUGRevision 10.6, 02/2014