Top Banner
External Use TM Hands-On Workshop: Component Development Environment for Processor Expert Software Configuration Tool FTF-SDS-F0121 Apr 10, 2014 Greg Hemstreet | Manager, Processor Expert team
140

Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

Mar 26, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

External Use

TM

Hands-On Workshop: Component Development Environment for Processor Expert Software Configuration ToolFTF-SDS-F0121

A p r 1 0 , 2 0 1 4

Greg Hemstreet | Manager, Processor Expert team

Page 2: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 1

Agenda• Introduction− Processor Expert Introduction− Embedded Components− Component Development Environment− Macro Language Introduction

• What have you done for me lately…− New Features− New Script Editor− Future Extensions

• Lab 1: Building your first component• Lab 2: Configuring a header file• Lab 3: Advanced Component: Accelerometer• Summary

Page 3: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 2

Introduction

Page 4: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 3

Processor Expert System

Components Library

ComponentInspector

Projects View

Problems ViewComponents

View

Source Editor

Page 5: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 4

Processor Expert IS

• A rapid application design tool

• A graphical user interface (GUI) that allows an application to be specified by the functionality needed

• An expert system that immediately flags resource conflicts and incorrect settings

• An automatic code generator that creates tested, optimized C code tuned to the application and specific Freescale processor

Page 6: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 5

Processor Expert

• Creates production-ready runtime software that is…

• Initialization source code for the chosen processor OR− (out of reset to known operating configuration)

• Based on logical device drivers OR− hardware-specific peripheral drivers with a known application programming interface

(API)

• Configuration data OR− used during the chip/board reset process− operating system bootloader

• Software functionality defined by a user− For a hardware module or software system− Any set of software functions can be put into an Embedded Component

Page 7: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 6

Processor Expert BENEFITS

• Faster application development resulting in higher quality code• Reduces complexity of product documentation• Extends commercial operating system functions• Supports customer’s hardware configuration, not just Freescale’s boards• Eases migration between Freescale devices

Page 8: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 7

Processor Expert Components…

Page 9: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 8

Embedded Components

• Component− Building block of an application− Functionality separated into small objects− Components have an interface (similar to the way classes have in object-oriented

programming)− Each Embedded Component is a code generator

with a user interface for changing propertiesand a script (called a driver) that generates output,using the properties of the component.

Methods

Source CodeComponent

Events

Properties

Configuration tool

Pure software algorithm

Functionality extension

Peripheral driver Component types

Properties• Modify/Customize object behavior• Set during design-time

Methods• Procedures that can be executed• Function calls (prototypes & implementation)Events

• Indication of state changing• Usually implementation of ISRs

Optional output classifications used by Processor Expert for components generating source code.

ConfigurationComponent

Propertiesfile

Page 10: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 9

What Is a Component?

• A reusable module to configure and/or implement software

• A bounded bit of software code that has one or more of…− Properties

Configured at design time in Component InspectorControl the generated output (source code, header, config file)

− MethodsThe functions (API) that implement the features of the software

− EventsThe “hooks” that result from or cause state changes (e.g. an interrupt)

• A script engine to act on design time properties, and generate one or more files (normally source code text files but can create any ASCII or binary file).

Page 11: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 10

Processor Expert Actions on Components

• Each component must act on a set of actions:− Inspector – display contents of properties into the Component Inspector.− Generate Code – each component’s DRV script is executed to respond to this action saving output as files into

the associated Project.− Help on Component – the component must provide a set of help files that describe the component.− Save – each component must be able to store the persistent data associated with the properties of the

component into the project.− Open – when a project is opened, the persistent store is retrieved by the component from the the project− Rename - renames the component instance in the project.

• Optionally:− Display Methods with active/inactive state.− Drag/Drop Methods – generates the function’s prototype for paste into source files.− Configuration Registers – hardware related components can define the registers modified by the component so

a register view can be displayed.− Custom Views - defined to support additional tabs in the Component Inspector.− Reconfigure… - defined to act as a component wizard that can reconfigure the properties of the component

based on some predefined logic – ie. read the SPD and define the DDR3 configuration.

The Component Development Environment helps create all the associated elements of the component to perform these actions!

Page 12: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 11

Kinds of Components

• Configuration component− Properties only – sets up or defines the behavior of hardware− E.g. DDR configuration; device tree initialization

• Hardware component− Hardware drivers− Defines and implements functionality at runtime− E.g. the classic peripheral driver, CPU configuration

• Software component− Pure software, little/no hardware dependency− Any kind of algorithm or operation – e.g. data encryption

• RTOS adapter− Special type of component to adapt other components to an RTOS− Used during code generation

Page 13: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 12

Configuration Example: DDR Memory

• Currently implemented for QorIQ Configuration Suite− Will likely be used for future

microcontrollers

• Wizard so you can use presetsor import from a memory file

• Configuration validated for consistency, errors and warnings will be displayed

• Tool’s output is a C file containingmemory registers values

Use a preset or import a memory file

Page 14: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 13

DDR configuration/validation

13

Allows for connection to board

Goes through validation and operational stages

Choose from preset tests or create your own

patterns/tests.

Looks for valid configurations and

chooses best settings.

Allows review of each test in each cell to review

issues/errors.

Page 15: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 14

Software Example: An Entire Stack as Component

• Example: FATFS

User chooses what functions to generate, optimizing code size

Page 16: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 15

RTOS Adapter Example: FreeRTOS Component

Method to generateConfiguration Properties

Page 17: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 16

Benefits of Embedded Components

Page 18: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 17

Enhancing Existing Source Code

• Convert existing software to Embedded Components− Allows you to leverage the full capabilities of the silicon− Simplifies code generated

Adds clarity to the application during test and debugLowers the risk of defects

− Allows for inheritance in standard C code• Enhances portability− Code becomes processor and RTOS agnostic

• Enhances optimizability− It can be customized by setting properties

Page 19: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 18

Reuse Has Real Value

• Processor Expert Software enables− Hardware- and OS-agnostic components− Reusability = greater efficiencies and productivity

• Write once, use many times− Don’t reinvent the wheel - it costs too much

• “Now I have a working USB-CDC card in less than 24 hours! That's great. In fact I am very new to PE. Having old habits, such as to enjoy writing every code by hand down to every bit, it would take me months to complete the project. This experiment will make me change my approach to microprocessor programming.”

Page 20: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 19

Buy, Don’t Build

• Nothing more efficient than instant functionality• Embedded Components are here today

Page 21: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 20

NanoSSL™/ NanoSSH™ Client for Freescale MQX: Security options with significant cost savings

• Ultra-small at less than one-fifth the size of a typical SSL/SSH client • Freescale hardware Crypto Acceleration Unit (CAU) Performance ~7x 3DES, ~ 3x AES, ~ 2X SHA1 • Minimal impact on flash ROM utilization

• Secure Shell (SSH) encrypts communications between hosts over an insecure network, and it’s great for logging into and executing commands on networked computers. It’s also useful for tunneling, port-forwarding and secure file transfers using the SFTP protocol.

RFC-compliant with support for TLS 1.270+ ciphers including AES, PSK, DH, RSA FIPS 140-2 option

• Secure Sockets Layer/Transport Layer Security (SSL/TLS) - authenticates endpoints and encrypts channels to provide session privacy and security on the Internet. The standard operates at a higher level in the OSI stack than IPsec, and supports peer negotiation for algorithm selection, public key-based exchange of secret session keys and X.509 certificates.

• Cryptography support includes AES, ARC4, Blowfish, 3DES, HMAC SHA1/MD5, RSA and DSA, Diffie-Hellman and NSA Suite B

One-time “unlocking” fee of $199 to access source code with unlimited binary distributionAvailable via Buy Direct www.freescale.com/embeddedcomponents

+$10,000of software

bundled with Freescale

MCU’s!

Page 22: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 21

Mocana Component

Code Generation

Preset Configurations

Ciphers Selection

SSH Configuration

Component Selection

Page 23: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 22

Hardware Abstraction Layer

• Provides an interface between hardware and software so applications can be device independent− HAL encapsulates peripherals of MCU− Applications access hardware through HAL

Modeling Layer

Application Layer

Customer Drivers

SMAC encapsulation

Display adapter

CustomerDrivers

High LevelDrivers

High Level Drivers

LCD driverMotor Controldriver

External memory driver

Terminal communication

Low Level DriversUART driver

SPITimersdriver

CAN driver I2C driverPWM driver

GPIO drivers

CPU Core

UART Ports PWMTimersCAN SPI I2C

DMA COP

Low LevelDrivers

ApplicationLayer

Processor

Page 24: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 23

Component Development Environment

Page 25: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 24

Introduction – Component Development Environment

• Component Development Environment (CDE)− Is a set of CDT tools that supports creation of Embedded Components

for Processor Expert− Environment to create, edit and package components using graphical

interface− CDE is an Eclipse plug-in included in

Code Warrior 10.xMicrocontroller Driver SuiteQorIQ Configuration Suite RAppID initialization suite

− Supports Eclipse-hosted platforms (Windows and Linux)

Page 26: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 25

CDE Features

• GUI to create Component API• Each Component is editable in

separate view – Component Editor• CDE edits componenst in a Workspace

project, later it can be deployed into Processor Expert system

• Creates and maintains Component scripts− Build-in script editor

Multiple components in

one project

Page 27: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 26

Component EditorComponent Editor is now

separated view

Component Parts

Item detail editor (or method code editor)

Page 28: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 27

Component Inheritance

• Like Object Oriented environments− Components can “inherit” properties and methods of other components− Adding functionality or modifying the functionality of the inherited

component− Multiple-inheritance is also supported so a component can leverage

multiple blocks, I2C and a timer, for example.

• Creating inherited components (using Inheritance Wizard)• Exclusive methods used• Publishing several methods/events• Shared components• Create and manage interface for inherited components

Page 29: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 28

Import/Export component capability

• Using Components requires them to be added to the Component Library

• CDE allows you to:− Import Components

import an existing component into CDE to make changes− Export Component into update package

for sharing with others− Deploy component

to your User Components Library

Page 30: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 29

CDE Editions

• Edition based on licensing− Community Edition

software components and interfaces creations, free for non-commercial use− Standard Edition for commercial use

Software components and interface creationIncluded in Standard Edition CodeWarriorAvailable for purchase at Freescale.com

− Professional Edition RTOS adapter components creationIncluded in Professional Edition CodeWarriorAdditional featuresAvailable for purchase at Freescale.com

Page 31: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 30

Macro Language Introduction

Page 32: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 31

Processor Expert’s Component Macro Language

• Macro Language− More information can be found in Component Development Environment help

systemHelp Contents• User Interface Drivers Page Macroprocessor

• The macro-processor is designed to process:− Component drivers− TST files− CHG files The generated code is modified according to properties.

You can understand the component driver as a script, which conditionally generates output – in this case C source code.

The conditions are in the macro language and the expressions use macro definitions.

Page 33: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 32

Processor Expert’s Macro Language

• The Processor Expert provides several pre-defined macros− Global macros− Local macros− Macros defined from any property

Eg – a property called AllowEcho can be referenced by %AllowEcho which resolves to the value of the AllowEcho property as defined in the Component Inspector.

− Special macros and directives− Inherited items− Examples:

Type and name of the component (%DeviceName)Name of the module (name of driver) (%ModuleName)Value of the secure character property (%SecureChar)Inherited method call (%'ModuleName'%.ReceiveChar() )Comment (%- This is comment of macro language )

Page 34: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 33

Processor Expert’s Macro Language

• The Processor Expert provides several macro commands− Conditional translation− Macro definition− Comments and text formatting− Errors− Lists− Expressions− Examples

• Condition:%if %AllowEcho='yes'%'ModuleName'%.SendChar(c);

%endif• Local macro definitions:

%define TestSymbolBool TRUE • Global macro definitions:

%define_prj TotalCount 100 • Errors and warnings will be shown in Error Window:

%error The component MySerial cannot be generated.

Page 35: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 34

Component Drivers

• The driver file of component− Extension *.DRV – the file is stored in the Drivers/SW (or Drivers/{family})

directory• Source file – *.SRC− This file defines all drivers used by the component depending on selected CPU,

compiler etc.− Stored in the Drivers directory

• Include files – *.INC− This files are used for description of methods and also for description of method

parameters− Include description of component settings into the generated code− Stored in the Drivers/Common directory

Page 36: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 35

Templates and Interfaces

• Templates− Every component setting can be customized and stored as a Template− A Template is an Embedded Component with pre-defined settings

• Interfaces− Are used to define component interface

Methods and events, their return types and parameters

− Used for component inheritance or sharing• Templates and interfaces are stored − In the Beans/<component_name>/ directory, if the template or interface is local

only− In the Templts directory, if the template or interface is defined globally

Page 37: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 36

CHG and TST Files

• CHG and TST files are scripts designed to proceed immediate checking of component settings− Exclude some dependency checking from application code to design-time code− Range error checking− Dependency on properties checking (e.g. on operating mode)− Prevent users to create faulty combination of component settings− Implement independent tests− Can change Embedded Component settings− Allow reporting errors, warnings and hints.

• These files extensions are abbreviations of change and test.− CHG script is started every time any property is changed− TST script is started every time all properties of the component has been set without

errors.• These scripts are written using Processor Expert macro language

Page 38: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 37

CHG Script Example

Condition

Test property value (symbol)

Set property selection (enable/disable)

Define symbol Report error

Include sub-routine

Test property has changed

Page 39: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 38

Macro Language Commands

• Conditions in conditional translation%if-%else-%endif

− defined({def_name})

condition is evaluated as true if macro {def_name} is defined

− {condvalue} = {condvalue}

string compare− {condvalue} >N {condvalue}

string compare - compares N charactersif N number is 0 then strings are formatted to the same length.

• Spaces are inserted at the beginning of shorter one.

• Strings are compared after formatting.

− {condition} | {condition}

logical or, {condition} should not contain & operator. If the first {condition} is true then the result is true (short evaluation).

− {condition} & {condition}

logical and, {condition} cannot contain | operator. If the first {condition} is false then the result is false (short evaluation).

Page 40: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 39

Macro Language Commands

• Special command− %set {Symbol} {FeatureSymbol} {Value}

{Symbol} is a symbol of any property, method or event {FeatureSymbol} is a symbol from the following list (see Feature symbols below){Value} is a new value for the feature. Value is any text till the end of line

• Feature symbols:− ReadOnly - enable/disable changing of value of any property.

{Symbol} must be symbol of any property.{Value} must be yes or no.

− Selection – possibility to enable/disable changing of selection of any method or event, e.g. if method will be generated to the driver and if event will be called from the driver.{Symbol} must be symbol of any method or event.{Value} must be • always (the method/event is always selected) or • never (the method/event cannot be selected) or • enable (the user can change selection).

Page 41: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 40

Macro Language Commands

− Value - change value of any property.{Symbol} must be symbol of any property.{Value} must be value for the property (the same as entered in the Processor Expert component inspector).

− MinValue, MaxValue - change the minimal and maximal possible value of the property.{Symbol} must be symbol of property of type: • integer number• real number • list of items.{Value} must be decimal number.

• Warning: − If any value of the property is changed, the macros are NOT changed to the end of CHG file. − Read the value of any property using %get command.

Page 42: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 41

Macro Language Commands

• Get command syntax:− %get({Symbol},{FeatureSymbol})

− List of known symbols is the same as for %set command.− Result is value of selected feature.

• Reporting massages− An error messages can be generated explicitly using these commands:

%error

%warning

%hint

− Value of any property/method/event can be changed using special command %setThis command can be used only in CHG files.

Page 43: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 42

Summary

• The Macro Language is the scripting language used inside Processor Expert embedded components.− Drivers – generate the output from a component when “Generate Code” is

executed in Processor Expert.− CHG / TST are scripts created by the CDE to allow for condition tests when

properties are changed.CHG – for checking, calculating other properties based on a change in a property value within a Component InspectorTST – for checking dependencies between components

• Macro language includes expression evaluation and conditional logic using a simple C-preprocessor type mechanism.

• Supports calling external code (command line tools, DLL, shared objects, and Java methods).

• Future: support for predefined sets of JavaScript and Perl functions…

Page 44: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 43

What have you done for me lately?

Page 45: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 44

Recent Features in Component Development Environment…• Multiple Embedded Components in one Eclipse project− local and global interfaces are included

• Import of components from Processor Expert package (if not licensed)

• New script editor− Help for Macro language commands integrated into script editor

• Custom page in component documentation supported• Interface editing - allow edit interface from component• Doxygen support• Interface editing - allow edit interface from component• New Component Inspector layout/rendering− New property attributes for Tabs View

Page 46: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 45

New “Tabs view” for Component Inspector

• Old style Component Inspector− “hidden” sections− Vertical scrolling essential− Did not use standard keyboard equivalents− Used non-standard UI elements

• New style Component Inspector− Introduces tabbed sections− Provides a property tree explorer− Allows for multiple columns of properties− Uses only standard UI elements− Decorations are used for each UI element for

errors, and detailed description fields.

Page 47: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 46

New Script Editor

• Syntax highlighting• Content assist• Folding support• Hints for commands• Occurrence

matcher• Command matcher

Code highlighting

support

Content assist

Folding support

Hints for commands

Page 48: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 47

Future Extensions

• Support of CDE/PEx repository• Automatically download/update components• Multiple repositories

Short Term Plan

Planned Features

CDE Community

•Component preview •Item Editor re-design•Drag&Drop copying properties•Components inside Processor Expert project•Integrated macro-language on-line, context sensitive help•Script debugger•Command line for multi-component operations

• Automatic refresh of edited component in Processor Expert project• Copy&Paste properties and other component parts

Page 49: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 48

Where to get more information

• Google Processor Expert!

• Sign-in to Freescale.com

• Videos/tutorials on ourweb site.

• Our website…− www.freescale.com/ProcessorExpert

• Communties− https://community.freescale.com/community/pex− http://mcuoneclipse.com/

Page 50: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 49

FTF Sessions on Processor Expert for Microcontrollers

Day TimeSession IDFTF‐SDS‐ Title

Wed.  12:45 F0123Processor Expert Software for Microcontrollers ‐Overview session

Wed. 2:00 F0428Hands‐on: Using the Kinetis Design Studio, Kinetis SDK and Processor Expert Configuration tools.

Wed.  2:00 F0067Hands‐on: Using IAR with Processor Expert Microcontroller Driver Suite.

Thurs. 12:45 F0122 User Forum: Processor Expert SoftwareFriday 9:30 F0121 Hands‐on: Component Development Environment

Added sessions:

Tues. 1:00 F0428Hands‐on: Using the Kinetis Design Studio, Kinetis SDK and Processor Expert Configuration tools.

Thurs. 2:00 F0431Hands‐on: Using IAR with Processor Expert Microcontroller Driver Suite.

Page 51: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 50

FTF Sessions on Processor Expert for QorIQ Devices

Day TimeSession IDFTF‐SDS‐ Title

Wed.  11:30 F0199 Introduction to the QorIQ Configuration Suite

Thurs. 2:00 F0200Learn How to Optimally Utilize the QorIQ Configuration Suite (QCS) for Custom QorIQ Boards

Thurs. 12:45 F0122 User Forum: Processor Expert SoftwareFriday 9:30 F0121 Hands‐on: Component Development Environment

Page 52: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 51

Lab 1: Building a component

Page 53: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 52

Lab 1: ErrorDetection ComponentIn this lab we will build a simple component to calculate parity of an integer value. You will learn how to create, edit and deploy Processor Expert Components.

Create a Component Project

Edit Properties, Methods and Events

Deploy the component

Use the component in a project

Page 54: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 53

Lab 1: Building a component

• Simple Embedded Component – ErrorDetection− One method – GetParityBit− One property – Use even parity – determines whether odd or even parity should be used

• Computing parity− The number of ones in the data byte are counted.− A zero or one is added to make the count odd or even

(depending on whether "odd parity" or "even parity" is selected).

− Computing even parity uses XOR-ing of the bits of the data together.

1^0^1^0^0^1^0^1 = 0

Parity Data Data with ParityOdd 10100101 101001011Even 10100101 101001010

Page 55: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 54

Project Creation

• Select File -> New -> Embedded Component• Type “CDE_Lab1” for the Project name• Type “ErrorDetection” Component name• Click on Finish

CDE_Lab1ErrorDetection

1 2

Page 56: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 55

Driver Suite 10.4 – Lab1 Project View

• Should look something like this…You may need to collapse other panels to see the perspective

this way…

Page 57: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 56

Component Information

• Component attributes are available in Help and in generated comments…

• Header− Add a description− Add your name− Provide a version− Define an icon

• Options− UI Component name

ErrorDetection− Set Shortcut

ErrDe

Name in Component Library

Default name used for source file generation

Page 58: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 57

Define Properties

• Select Properties folder − Click right button and select: Add Property− Select Property type: Boolean yes/noEnter:− ItemName:

Use even parity

− Symbol:EvenParity

− TypeSpecName:typeYesNo

Page 59: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 58

Define Methods

• Select Methods folder− Click right button and select: Add Method

Enter:− Method_Name:

getParityBit− ReturnType:

uint8_t • Switch to Parameters tab• Click on Add Parameter button

Enter:− Name:

Data− Type:

uint8_t

Page 60: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 59

Edit Method’s Source Code%-BW_METHOD_BEGIN getParityBit%ifdef getParityBit%define! ParData%define! RetVal%include Common\ErrorDetectiongetParityBit.incuint8_t %'ModuleName'%.%getParityBit(uint8_t Data){%CODE_BEGINint i, res = 0;// Compute parity using shifting and XORfor (i = 0; i < 8; i++) {

res = res ^ (Data >> i);}%if %EvenParity = 'yes'return (uint8_t)(res & 1); // mask result%elsereturn (uint8_t)(~res & 1); // mask result%endif

%CODE_END}%endif %-getParityBit%-BW_METHOD_END getParityBit

Copy this text fromDesktop\CDE\labs\

getParityBit.c

Go to the method’s Source Tab

Page 61: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 60

Deploy the component to your Component Library

• Save the component – using Save All• Deploy the component by selecting “Deploy”

Page 62: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 61

Test the Component

• Test the component with a simple application− Specification:

The test application calls the component’s method with several parameters. The result is visible in the debugger window.Only the ErrorDetection component is used in the test application.

− Create a new project for Kinetis Freedom boardStart New → Bareboard projectUse Processor Expert

− Click right button on Components Library and select “Refresh” command− Add the following component into the project:

ErrorDetection

Page 63: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 62

Create new application project in workspace

• File->New->New Processor Expert Project

Select the MK64FN1M0xx12

Page 64: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 63

Components Library

• Select the Components Library

• You may need to refresh− Use F5

• Select Add to project

Page 65: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 64

Add our ErrorDetection component to your project…

See our component short cut:nameand below it the method.

See the property we created here…Note that the component name can be changed to be more meaningful.

Page 66: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 65

Generate the code

• When you generate the code for the project

… you get the ErrDe1.h and ErrDe1.c file.

Page 67: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 66

Processor Expert generates the ErrDe1.c/.h files

Header for the file contains information about the component and generates doxygen tags automatically.

Every Method’s prototype is properly documented using a standard template.

Of course, the method’s source code is generated.

Page 68: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 67

Write Application Code

• Test the application (continued)− Generate the source code− Write the following code in the main() function:/* User includes (#include below this line is not maintained by Processor Expert) */volatile uint8_t Parity;

void main(void){

/* Write your local variable definition here */

/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/PE_low_level_init();/*** End of Processor Expert internal initialization. ***/

// test the functionality even oddParity = ErrDe1_getParityBit(1); // 1 0Parity = ErrDe1_getParityBit(21); // 1 0Parity = ErrDe1_getParityBit(255); // 0 1Parity = ErrDe1_getParityBit(254); // 1 0Parity = ErrDe1_getParityBit(136); // 0 1

/*** Don't write any code pass this line, or it will be deleted during code generation. ***//*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/for(;;){}/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/

} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/

Either copy from the slide orFile>Open

{desktop}/CDE/labs/ParityTest.c

Page 69: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 68

Build, Debug and Run Application

• If using Driver Suite:− Launch IAR − Build a new project and connect the project− Compile & Debug

• If using Kinetis Design Studio:− Compile & Debug

• If using CodeWarrior:− Compile & Debug

Page 70: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 69

Test the Application

Check the value of Parity to see the result of the method

Change the ErrDe1component property

and debug again

Page 71: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 70

Lab 2: Building a configuration component

Page 72: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 71

Component Description

• Create a component to generate a configuration header file based on the properties settings of the component.

• Two properties will be defined to control the macros:− Max Packet Length− Debug Level Macro // Configure Application values

// Debug Level off,info,error (1-3)#define DBG_LEVEL %DbgLvl

%ifdef AppGrp// Packet Length Min Value 10 Max#define MAX_PKT_LEN %MaxPkt%else// Packet Length default#define MAX_PKT_LEN 20%endif

Page 73: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 72

Create CDE_Lab2 project

• Project Name CDE_Lab2

• With HeaderConfig component

Page 74: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 73

New Component Information

• Enter specifics about the component in the Component Editor.

1

2

3

4

Page 75: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 74

Add a Property

• We will add the group property • In the Components view, expand the − Expand the component− Right-click on Properties and select

“Add Property”

• A Property settings window will appear

1

2

3

Page 76: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 75

• Property Type = Group –boolean (expanded/not expanded)

• Item Name = Application Configuration

• Symbol = AppGrp(case critical)

• Define Symbol = DEFINED UNDEFINED

Configure the Property

1

2

3

4

Page 77: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 76

Add a Packet Length Property

• The Application Group property itself contains other properties

• We will add an Integer-Numberproperty to hold the value of Max Packet Size

• Right-click on Application Configuration property and select “Add Property” − A Property Settings window will

appear for the new property

1 2

Page 78: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 77

Configure the Property

• Property Type = Integer number – signed

• Item Name = Max Packet Length

• Symbol = MaxPkt(case critical)

• MaxValue = 100

• MinValue = 10

• Value = 20

1

2

3

4

5

6

Page 79: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 78

Add a Property Type

• A property type is a data type that can be referenced by a property. We will use an enumerated type to represent different debug levels.

• We will add a property type named typeDebugLevel to represent the different debug levels

• Right-click HeaderConfigunder Property Types and select Add Enum Property Type

• A settings window willappear 1

2

Page 80: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 79

Configure the typeDebugLevel enum

• Name = typeDebugLevel

• Click Add Item three times

• Match the items with the screenshot

• 0:Off, 1, No Debug

• 1: Info, 2, Just Information Debug

• 2: Error, 3, Error Debug Log

1

2: three times

3: Fill In the table

Page 81: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 80

Add an Enumeration Property

• Next we add a property that will use the enumerated type• Right-click Properties and select “Add Property”− A settings window will appear

Page 82: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 81

Configure the Property

• Property Type = Enumeration

• Item Name = Debug Log Level

• Symbol = DbgLvl(case critical)

• TypeSpecName= typeDebugLevel(at the end of the list)

• Value = Info (this is the initial value)

1

2

3

4 5

Page 83: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 82

.drv file modification…

• The .drv file generates the header file (code)− This is where you specify the output based on property settings

• In Project ExplorerDrivers sw− Double click the drv file to

open it

• Turn on line numbers foreasy navigation− Right click in the left margin− Show line numbers

1

2

Page 84: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 83

Add Code to the Driver File

• In the lab folder for this course, locate lab2.h− copy comments and code

• Go to line 104 of .drv file,− paste in comments and code

• Save the Component

Page 85: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 84

Deploy the Component

• Deploy the component

1

Page 86: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 85

Create a new project

• Create a new Processor Expert Project− File New Processor Expert Project− Use the Kinetis MK64F1M− Just follow the prompts

• Refresh the library− Right click on the Component Library

and select Refresh

1

2

3 4

TestLab2

Filter: MK64

Page 87: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 86

Add the Component to the TestLab2 project

• Add HeaderConfigcomponent to the project− Make sure you selected the

project file first, so it is added to the correct project

• Next, select the Config component…

1

2

Page 88: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 87

Component Inspector shows our grouped properties

• Play with the Component Inspector values and see that our drop-down uses our enum type…

…OR…

Page 89: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 88

Results

• Change the parameters and see the results in the generated code

• Look at the generated code− Open HdCfg1.h in

Generated_Code from project explorer

− Or Right-mouse click and choose Open File…

2

1

Page 90: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 89

Lab 3: Advanced Component: Accelerometer

Page 91: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 90

Lab 3: Advanced Component AccelerometerIn this lab we will build a accelerometer component to detect taps. You will learn how to create, edit, inherit and deploy Processor Expert Components.

Create a Sensor Component

Create Component Test Application

Test a component in IAR Workbench

Page 92: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 91

Creating a Sensor Component

• File > New > Embedded component

Page 93: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 92

Project for Component Development

• Specify project name mysensor

Page 94: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 93

Component Name

• Specify component name mysensor• Click Finish button

Page 95: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 94

Component View

• The new component appears in the Components view in CDE folder.

Page 96: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 95

Adding Component Description

Page 97: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 96

Inheriting of I2C_LDD component

• Add new inherited property• Select I2C_LDD component• Change ID of the inherited

component to I2CBUS• Click Next button

Page 98: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 97

Inheriting of I2C_LDD component

• Select exclusive usage mode• Click Next button

Page 99: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 98

Inheriting of I2C_LDD component

• Choose Inherit = ‘Yes’ for the following events− OnMasterBlockSent− OnMasterBlockReceived− OnBusStopDetected

• Click Next button

Page 100: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 99

Inheriting of ExtInt_LDD (external interrupt)

• Choose Inherit another component option• Click Next button

Page 101: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 100

Inheriting of ExtInt_LDD (external interrupt)

• Select ExtInt_LDD component• Change ID of the inherited component to EXTINT• Click Next button

Page 102: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 101

Inheriting of ExtInt_LDD component

• Select exclusive usage mode• Click Next button

Page 103: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 102

Inheriting of ExtInt_LDD (external interrupt)

• Click Finish button

Page 104: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 103

Adding new Init method

• Add new method• Specify method name Init• Specify method’s hint

Page 105: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 104

Writing Init method source code

• Select Init method• Select Source tab

Page 106: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 105

Writing Init method source code

Use Copy&Paste to put code in RED between %CODE_BEGIN and %CODE_END tags.void %'ModuleName'%.%ReadRegister(uint8_t RegAddr, uint8_t *DestData)

{

%CODE_BEGINuint8_t temp;

uint32_t time;

/* Initialize inherited I2C component */

I2CDeviceData = %@I2CBUS@'ModuleName'%.Init(NULL);

/* Initialize inherited external interrupt component */

ExtIntDeviceData = %@EXTINT@'ModuleName'%.Init(NULL);

/* Reset accelerometer */

sensor.write_buffer[0] = FXOS8700CQ_CTRL_REG2_ADDRESS;

sensor.write_buffer[1] = 0x40;  // RST bit

%@I2CBUS@'ModuleName'%.MasterSendBlock(I2CDeviceData, &sensor.write_buffer[0], 2, LDD_I2C_SEND_STOP);

for(time=0 ; time<30000 ; time++);  // at least 1 ms wait to perform sensor RESET

sensor.operation = idle;

Page 107: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 106

Writing Init method source code/*Initialize accelerometer */temp = 0x08;%'ModuleName'%.WriteRegister(FXOS8700CQ_CTRL_REG1_ADDRESS, &temp); //Standby mode, 400 Hz sample ratetemp = 0x15;  // single pulse detection%'ModuleName'%.WriteRegister(FXOS8700CQ_PULSE_CFG_ADDRESS, &temp);  //Enable X and Y and Z Single Pulsetemp =  0x05;%'ModuleName'%.WriteRegister(FXOS8700CQ_PULSE_THSX_ADDRESS, &temp); // Set X Threshold to 1.575gtemp =  0x05;%'ModuleName'%.WriteRegister(FXOS8700CQ_PULSE_THSY_ADDRESS, &temp); // Set Y Threshold to 1.575gtemp =  0x04;%'ModuleName'%.WriteRegister(FXOS8700CQ_PULSE_THSZ_ADDRESS, &temp); // Set X Threshold to 1.575gtemp = 0x50;%'ModuleName'%.WriteRegister(FXOS8700CQ_PULSE_TMLT_ADDRESS, &temp); // 50 mstemp = 0xF0;%'ModuleName'%.WriteRegister(FXOS8700CQ_PULSE_LTCY_ADDRESS, &temp); // 300 mstemp = 0x08;%'ModuleName'%.WriteRegister(FXOS8700CQ_CTRL_REG4_ADDRESS, &temp); //Enable Pulse Interrupt Block in System CTRL_REG4temp = 0x08;%'ModuleName'%.WriteRegister(FXOS8700CQ_CTRL_REG5_ADDRESS, &temp); //Route Pulse Interrupt Block to INT1 hardware Pin%'ModuleName'%.ReadRegister(FXOS8700CQ_CTRL_REG1_ADDRESS, &temp); // Read config register 1temp |= 0x01;%'ModuleName'%.WriteRegister(FXOS8700CQ_CTRL_REG1_ADDRESS, &temp);

%CODE_BEGIN}

Page 108: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 107

Adding new WriteRegister method

• Add new method• Specify method name WriteRegister• Specify method’s hint

Page 109: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 108

Adding WriteRegister method parameters

• Select WriteRegister method• Select Parameters tab• Clock Add Parameter

Page 110: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 109

Adding WriteRegister method parameters

• Specify 1st parameter RegAddr• Type: uint8_t• Passing: Value

• Click Add Parameter

• Specify the 2nd parameter SrcData• Type: uint8_t• Passing: Address

Page 111: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 110

Writing WriteRegister driver code

• Select WriteRegister method• Select Source tab

Page 112: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 111

Writing WriteRegister driver code

Use Copy&Paste to put code in RED between %CODE_BEGIN and %CODE_END tags.

void %'ModuleName'%.%WriteRegister(uint8_t RegAddr, uint8_t *SrcData)

{

%CODE_BEGIN

if(sensor.operation != idle)

return;

sensor.write_buffer[0] = RegAddr;

sensor.write_buffer[1] = *SrcData;

sensor.operation = write_reg;

%@I2CBUS@'ModuleName'%.MasterSendBlock(I2CDeviceData, &sensor.write_buffer[0], 2, LDD_I2C_SEND_STOP);

while(sensor.operation != stop_detected);

sensor.operation = idle;

%CODE_END

}

Page 113: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 112

Adding new ReadRegister method

• Add new method• Specify method name ReadRegister• Specify method’s hint

Page 114: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 113

Adding ReadRegister method parameters

• Select ReadRegister method• Select Parameters tab• Clock Add Parameter

Page 115: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 114

Adding ReadRegister method parameters

• Specify 1st parameter RegAddr• Type: uint8_t• Passing: Value

• Click Add Parameter

• Specify the 2nd parameter DestData• Type: uint8_t• Passing: Address

Page 116: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 115

Writing ReadRegister driver code

• Select ReadRegister method• Select Source tab

Page 117: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 116

Creating ReadRegister driver code

Use Copy&Paste to put code in RED between %CODE_BEGIN and %CODE_END tags.

void %'ModuleName'%.%ReadRegister(uint8_t RegAddr, uint8_t *DestData)

{

%CODE_BEGIN

if(sensor.operation != idle)

return;

sensor.write_buffer[0] = RegAddr;

sensor.operation = read_reg;

%@I2CBUS@'ModuleName'%.MasterSendBlock(I2CDeviceData, &sensor.write_buffer[0], 1, LDD_I2C_NO_SEND_STOP);

while(sensor.operation != block_sent);

%@I2CBUS@'ModuleName'%.MasterReceiveBlock(I2CDeviceData, DestData, 1, LDD_I2C_SEND_STOP);

while(sensor.operation != stop_detected);

sensor.operation = idle;

%CODE_END

}

Page 118: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 117

Adding new OnTapDetect event

• Add new event• Specify method name OnTapDetect• Specify method’s hint

Page 119: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 118

Writing the rest of driver

• Add new event• Specify method name OnTapDetect• Specify method’s hint

Page 120: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 119

Writing the rest of the driver code

• Open mysensor.drv file in default editor

Page 121: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 120

Writing types, constants, global variables #1

Use Copy&Paste to put code in RED after %-BW_IMPLEMENT_START comment.

%‐BW_IMPLEMENT_START%‐*****************************************************************************************************typedef enum{block_received,block_sent,stop_detected,read_reg,write_reg,idle

}TOperation;

typedef struct{TOperation operation;uint8_t write_buffer[16];

}TFXOS8700CQ;

#define DEVICE_TIMEOUT 100000U

// FXOS8700CQ internal register addresses#define FXOS8700CQ_STATUS_ADDRESS 0x00#define FXOS8700CQ_OUT_X_MSB_ADDRESS 0x01#define FXOS8700CQ_OUT_X_LSB_ADDRESS 0x02#define FXOS8700CQ_OUT_Y_MSB_ADDRESS 0x03#define FXOS8700CQ_OUT_Y_LSB_ADDRESS 0x04#define FXOS8700CQ_OUT_Z_MSB_ADDRESS 0x05#define FXOS8700CQ_OUT_Z_LSB_ADDRESS 0x06#define FXOS8700CQ_F_SETUP_ADDRESS 0x09#define FXOS8700CQ_TRIG_CFG_ADDRESS 0x0A#define FXOS8700CQ_SYSMOD_ADDRESS 0x0B#define FXOS8700CQ_INT_SOURCE_ADDRESS 0x0C#define FXOS8700CQ_WHO_AM_I_ADDRESS 0x0D#define FXOS8700CQ_XYZ_DATA_CFG_ADDRESS 0x0E#define FXOS8700CQ_HP_FILTER_CUTOFF_ADDRESS 0x0F#define FXOS8700CQ_PL_STATUS_ADDRESS 0x10

Page 122: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 121

Writing types, constants, global variables #2

#define FXOS8700CQ_PL_CFG_ADDRESS 0x11#define FXOS8700CQ_PL_COUNT_ADDRESS 0x12#define FXOS8700CQ_PL_BF_ZCOMP_ADDRESS 0x13#define FXOS8700CQ_P_L_THS_REG_ADDRESS 0x14#define FXOS8700CQ_FF_MT_CFG_ADDRESS 0x15#define FXOS8700CQ_FF_MT_SRC_ADDRESS 0x16#define FXOS8700CQ_FF_MT_THS_ADDRESS 0x17#define FXOS8700CQ_FF_MT_COUNT_ADDRESS 0x18#define FXOS8700CQ_TRANSIENT_CFG_ADDRESS 0x1D#define FXOS8700CQ_TRANSIENT_SRC_ADDRESS 0x1E#define FXOS8700CQ_TRANSIENT_THS_ADDRESS 0x1F#define FXOS8700CQ_TRANSIENT_COUNT_ADDRESS 0x20#define FXOS8700CQ_PULSE_CFG_ADDRESS 0x21#define FXOS8700CQ_PULSE_SRC_ADDRESS 0x22#define FXOS8700CQ_PULSE_THSX_ADDRESS 0x23#define FXOS8700CQ_PULSE_THSY_ADDRESS 0x24#define FXOS8700CQ_PULSE_THSZ_ADDRESS 0x25#define FXOS8700CQ_PULSE_TMLT_ADDRESS 0x26#define FXOS8700CQ_PULSE_LTCY_ADDRESS 0x27#define FXOS8700CQ_PULSE_WIND_ADDRESS 0x28#define FXOS8700CQ_ASLP_COUNT_ADDRESS 0x29#define FXOS8700CQ_CTRL_REG1_ADDRESS 0x2A#define FXOS8700CQ_CTRL_REG2_ADDRESS 0x2B#define FXOS8700CQ_CTRL_REG3_ADDRESS 0x2C#define FXOS8700CQ_CTRL_REG4_ADDRESS 0x2D#define FXOS8700CQ_CTRL_REG5_ADDRESS 0x2E#define FXOS8700CQ_OFF_X_ADDRESS 0x2F#define FXOS8700CQ_OFF_Y_ADDRESS 0x30#define FXOS8700CQ_OFF_Z_ADDRESS 0x31

TFXOS8700CQ sensor;LDD_TDeviceData *I2CDeviceData, *ExtIntDeviceData;

Page 123: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 122

Writing inherited OnInterrupt event code

Use Copy&Paste to put code in RED between %CODE_BEGIN and %CODE_END tags.

%‐INHERITED_EVENT_BEGIN EXTINT OnInterrupt%ifdef @EXTINT@OnInterrupt%include Common\GeneralInternal.inc (OnInterrupt)void %@EXTINT@OnInterrupt(LDD_TUserData *UserDataPtr){%CODE_BEGINuint8_t temp = 0;

%'ModuleName'%.ReadRegister(FXOS8700CQ_INT_SOURCE_ADDRESS, &temp);if(temp & 0x08U) {

%'ModuleName'%.ReadRegister(FXOS8700CQ_PULSE_SRC_ADDRESS, &temp);}%'OnTapDetect'();

%CODE_END}%endif %‐ @EXTINT@OnInterrupt%‐INHERITED_EVENT_END EXTINT OnInterrupt

Page 124: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 123

Writing OnBusStopDetected event code

Use Copy&Paste to put code in RED between %CODE_BEGIN and %CODE_END tags.

%‐INHERITED_EVENT_BEGIN I2CBUS OnBusStopDetected%ifdef @I2CBUS@OnBusStopDetected%include Common\GeneralInternal.inc (OnBusStopDetected)void %@I2CBUS@OnBusStopDetected(LDD_TUserData *UserDataPtr){%CODE_BEGINsensor.operation = stop_detected;%CODE_END}%endif %‐ @I2CBUS@OnBusStopDetected%‐INHERITED_EVENT_END I2CBUS OnBusStopDetected

Page 125: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 124

Writing OnMasterBlockReceived event code

Use Copy&Paste to put code in RED between %CODE_BEGIN and %CODE_END tags.

%‐INHERITED_EVENT_BEGIN I2CBUS OnMasterBlockReceived%ifdef @I2CBUS@OnMasterBlockReceived%include Common\GeneralInternal.inc (OnMasterBlockReceived)void %@I2CBUS@OnMasterBlockReceived(LDD_TUserData *UserDataPtr){%CODE_BEGINsensor.operation = block_received;%CODE_END}%endif %‐ @I2CBUS@OnMasterBlockReceived%‐INHERITED_EVENT_END I2CBUS OnMasterBlockReceived

Page 126: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 125

Writing OnMasterBlockSent event code

Use Copy&Paste to put code in RED between %CODE_BEGIN and %CODE_END tags.

%‐INHERITED_EVENT_BEGIN I2CBUS OnMasterBlockSent%ifdef @I2CBUS@OnMasterBlockSent%include Common\GeneralInternal.inc (OnMasterBlockSent)void %@I2CBUS@OnMasterBlockSent(LDD_TUserData *UserDataPtr){%CODE_BEGINsensor.operation = block_sent;%CODE_END}%endif %‐ @I2CBUS@OnMasterBlockSent%‐INHERITED_EVENT_END I2CBUS OnMasterBlockSent

Page 127: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 126

Implementation (hands-on)

Page 128: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 127

Creating New PEx Project

• File > New > Processor Expert Project

Page 129: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 128

Creating New PEx Project

• Specify project name myapp• Click Next button

Page 130: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 129

Creating New PEx Project

• Type MK64 to the filter – Processor to be used …• Select MK64FN1M0xxx12 MCU• Click Next button

Page 131: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 130

Creating New PEx Project

• Click Next button

Page 132: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 131

Creating New PEx Project

• Select IAR ARM C Compiler• Click Finish button

Page 133: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 132

Adding mysensor component to the project

• Add mysensor component from component selector to the project (category SW > User Components)

Page 134: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 133

Configuring mysensor component

• Select I2CBUS1 component – open component inspector by double-click

• Select maximal interrupt priority

Page 135: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 134

Configuring mysensor component

• Select 20.97MHz internal frequency – click “…” button to select frequency

• Bits 0-2: Select 011• Bits 3-5: Select 100• Slave address: 0x1D

Page 136: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 135

Configuring mysensor component

• Select EXTINT1 component – open component inspector by double-click on Bit1 component

• Select CMP0_IN0/… input pin• Select falling edge

Page 137: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 136

Adding BitIO_LDD component – LED control

• Add BitIO_LDD to the project and open component inspector by double-click on the component

• Component name: Led• Pin for I/O: PTE26 – green LED• Direction: Output• Init value: 1• Auto init: Yes

Page 138: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 137

Generating code

• Click on Generate button

Generate code

Page 139: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

External Use 138

Toggling Green LED

• Double click on OnTapDetect() event opens Events.c module• Put Led_NegVal(Led_DeviceData); code into OnTapDetect()

function

Doubleclick

Page 140: Hands-On Workshop: Component Development Environment for ... · The macro-processor is designed to process: − Component drivers − TST files − CHG files. The generated code is

TM

© 2014 Freescale Semiconductor, Inc. | External Use

www.Freescale.com