Post on 24-Oct-2021
transcript
External Use
TM
Hands-On Workshop: Xtrinsic
Intelligent Sensing Framework
(ISF) on Kinetis MCUs
FTF-SDS-F0006
A P R . 2 0 1 4
Margaret Nadworny | SSD Software Manager
TM
External Use 1
From the Brochure
• The Xtrinsic Intelligent Sensing Framework (ISF) is a
comprehensive and robust runtime framework providing open
sensor hub capability for Xtrinsic intelligent sensors
• This hands-on workshop explains how ISF can be used on the
Kinetis platform to easily add Freescale sensors to obtain sensor
data for custom sensor algorithms
TM
External Use 2
Agenda
• Talk about the FRDM-KL25Z and
FRDM-FXS-MULTI hardware
• Short introduction to ISF
• Hands-on FXAS21000 Gyro application
TM
External Use 3
Get to Know the FRDM-KL25Z
The Freescale Freedom development platform is a set of software and hardware tools for evaluation and development. It is ideal for rapid prototyping of microcontroller-based applications. The Freescale Freedom KL25Z hardware, FRDM-KL25Z, is a simple, yet sophisticated design featuring a Kinetis L Series microcontroller, the industry’s first microcontroller built on the ARM® Cortex™-M0+ core.
Features:
• MKL25Z128VLK4 MCU – 48 MHz, 128 KB Flash, 16 KB SRAM, USB OTG (FS), 80 LQFP
• Capacitive touch slider, MMA8451Q accelerometer, Tri-color LED
• Flexible power supply options – USB, coin cell battery, external source
• Easy access to MCU I/O
• Battery-ready, power-measurement access points
• Form factor compatible with Arduino ™ R3 pin layout
• OpenSDA debug interface
− Mass storage device flash programming interface (default)
• No tool installation required to evaluate demo apps
− P&E Debug interface provides run-control debugging and compatibility with IDE tools
− CMSIS-DAP interface: ARM standard for embedded debug interface
TM
External Use 4
Get to Know the FRDM-FXS-MULTI
• MMA8652FC accelerometer • MPL3115A2 pressure sensor
• FXAS21000 gyroscope • FXOS8700CQ 6-axis sensor
• MAG3110 3-axis magnetometer • MMA9553L sensing platform
Freescale's Freedom Development Platform for Multiple Xtrinsic Sensors, the FRDM-FXS-MULTI, is a sensor expansion board that includes:
Features: • Cost effective (starting at $30.00 USD) • Small size (approximately 81 mm x 52 mm x 2 mm) • Arduino™ footprint-compatible with support for sensor
expansion boards • Easy access to the MCU I/O pins
Software Enablement and Support: • Freescale Xtrinsic Sensor Fusion Toolbox for Android
(download for $0 USD with license) • Magnetic calibration code • 3-axis tilt • 6-axis sensor (magnetometer and accelerometer) using
Xtrinsic eCompass software • 6-axis capability (accelerometer and gyroscope) • 9-axis capability (accelerometer, gyroscope and
magnetometer) • Virtual gyroscope and offset compensated angular rates
TM
External Use 5
Anatomy of a Typical Embedded Sensor Application
Things an Embedded Sensor Application has to know how to do:
• Send/Receive I2C messages
• Register map/configuration for each particular sensor
• Schedule periodic processing
• Control the power modes
• Handle Interrupt Vector Table
• Configure board peripherals
• Compute useful outputs (Application Code)
• Send and receive host messages (USB, UART)
• Understand the host application-level protocol
• Stack pointer management/Context switching
• Implement concurrency mechanisms (mutex, semaphore, etc.)
• Perform Boot-up board initialization
Monolithic Application
High-level code
Low-level code
High-level code
Low-level code
TM
External Use 6
But What is at the Heart of an Embedded App?
Things it has to know how to do:
• Send/Receive I2C messages
• Register map/Configuration for each particular sensor
• Schedule periodic processing
• Control the power modes
• Handle Interrupt Vector Table
• Configure board peripherals
• Compute useful outputs (Application Code)
• Send and receive host messages (USB, UART)
• Understand the host application-level protocol
• Stack pointer management/Context switching
• Implement concurrency mechanisms (mutex, semaphore, etc.)
• Perform Boot-up board initialization
The rest is just stuff you have to do
to get it all to work
Monolithic Application
High-level code
Low-level code
High-level code
Low-level code
TM
External Use 7
You Only Want to Write This Stuff Once
• Compute useful outputs (Application Code)
• Send/Receive I2C messages
• Register map/Configuration for each particular sensor
• Schedule periodic processing
• Control the power modes
• Handle Interrupt Vector Table
• Configure board peripherals
• Send and receive host messages (USB, UART)
• Understand the host application-level protocol
• Stack pointer management/Context switching
• Implement concurrency mechanisms (mutex,
semaphore, etc.)
• Perform Boot-up board initialization
One Approach:
High-level code
Low-level code
Reuse this stuff
over and over
Defined Interface
Application
Code
TM
External Use 8
ISF is Designed to Make Your Life Easier What does it do for you?
Functionality ISF Component
• Send/Receive I2C messages I2C protocol Adapter
• Register map/Configuration for each
particular sensor
Sensor Adapters
• Schedule Periodic Processing Bus Manager
• Control the power modes Power Management
• Handle Interrupt Vector Table System Utilities
• Configure board peripherals Device Control
• Compute useful outputs (Application Code) This is the only thing you do want to write
• Send and receive host messages (USB,
UART)
Command Interpreter
• Understand the host application-level protocol Host Proxy
• Stack pointer management/Context switching Task Scheduler
• Implement concurrency mechanisms (mutex,
semaphore, etc)
Synchronization
• Send external interrupts to host Host Interrupt Control
• Perform Boot-up board initialization Powerup/Boot
I2C
AccelMagGyro
Bus
Mgmt
Power
Mgmt
Sys Util
Device
CtrlMem Map
Cmd
Interp
Host
Proxy
Scheduler
Sync
Host
Int Ctrl
PwrUp
Boot
Embedded Apps
UserUserUser
TM
External Use 9
The ISF Architecture Brick E
mb
ed
de
d In
tellig
en
t S
en
so
r E
nv
iro
nm
en
tEmbedded
Services
Integrated
Services
System
Services
OS
Services
Hardware
Abstraction
Embedded AppsContext/IntentGesturesSignal Proc
Device Mgmt
Comm Sensor Fusion Sensor Mgmt
Appl Support
Cmd
Interp
Host
Proxy
Host
Int Ctrl
Device
Msg’ing
I2CSPIGPIO
Device
Ctrl
PwrUp
Boot
Power
Mgmt
Calibration Accel
Scheduler
Sync
Tmr/Clk
Timer
Abstr
Sync
Abstr
Mem
Mgmt
UserUserUser
UserUserUserUserUserUser
Sys Util
Mem Map
Jolt
Config
Mgmt
Filters
Pattern
Recognition
PedometerContext Det Intent Mgmt
Sleep/Wake
Low G
Hi G P/L
Status
Mgmt
Tap
Pulse
Compass
Events
Sensor
Mgr
MagGyro
TempExtrn
Tilt
9 axis
fusion
Bus
Mgmt
Gesture
MgrAuto S/W
Test
Support
Digital
Sensor
Abstr
6 axis
fusion
TM
External Use 10
ISF is Composable – Use Only What You Need
Component Sensor App1 Sensor App2 Sensor App3 Sensor App4
I2C protocol Adapter Sensor Adapters Sensor Manager Bus Manager Power Management System Utilities Device Control Command Interpreter Host Proxy Task Scheduler (MQXTM) Synchronization (MQXTM) Host Interrupt Control Powerup/Boot
TM
External Use 11
ISF High-Level Design Goals
• Faster time to market
• Allow application developers to focus on their real areas of
expertise
• We want developers to get the highest bang-for-the-buck
How?
• Abstracting the details that developers do not want to deal with
• Do this for work at all levels up and down the stack
TM
External Use 12
Xtrinsic Intelligent Sensing Framework (ISF)
Intelligent Sensing
Framework
Sensor Manager
MQX RTOS
Power
Manager
Device
Messaging
Command Interpreter
Host Proxy
Hardware
Intelligent Sensor Hardware
ISF Abstraction
Interfaces
ISF Bus Protocol
Extensions
Embedded ApplicationEmbedded Application
Embedded Applications
Pub/Sub Event-Based
Sensor Data
Sensor Abstraction Interface
Internal
Sensor
Adapter
Bus
Manager
Host
Processor
- OR -
Sensor Data
Updates
Sensor
Configuration
I/O Buffers
Simplified
Power
Mgmt APIs
ISF Sensor
Extensions
Customer
Developed
Other Freescale
SW
Protocol DriverProtocol Driver
I2C Protocol
Driver
External
Sensor
External
Sensor
External
Sensor
LEGEND:
INT_OUT
ISF Components
Registered Callbacks
Sensor AdapterSensor AdapterSensor
Adapter
Main Sensor Data
Flow
Main Host
Interface Flow
TM
External Use 13
Main Sensor Flow
• Using The Sensor
Manager Interface
for Sensor Data
Sensor Manager
Embedded Applications
Pub/Sub Event-Based
Sensor Data
Sensor Abstraction Interface
Sensor Data
Updates
Sensor
Configuration
I2C Protocol
Driver
Sensor
Adapter
Device
Messaging
Bus
Manager
TM
External Use 14
Command Interpreter Host Processor
Embedded Applications I/O Buffers
Registered Callbacks
INT_OUT
Main Host Interface Flow
• Make outputs available
to the Host Processor
TM
External Use 15
Command Interpreter Host Processor
Embedded Applications I/O Buffers
Registered Callbacks
INT_OUT
Main Host Interface Flow
• React to data from the
Host Processor
TM
External Use 16
Command Interpreter Host Processor
Embedded Applications I/O Buffers
Registered Callbacks
INT_OUT
Main Host Interface Flow
• ISF Training Module 5 provides an example project that explains
the use of the Command Interpreter
TM
External Use 17
Power Management Interface
• Set the Power Mode
Power
Manager
Intelligent Sensor Hardware
Embedded
Applications
Simplified
Power
Mgmt APIs
TM
External Use 18
The ISF Installation Directory Structure
• This gets installed on your
computer via the ISF
website Installer
− ISF1P1KL25Z_INSTALLER
• Additional Sensor
Adapters get added in as
they are installed:
− lib_fsl_fxas21000_i2cspi_3d_gyro.a
− lib_fsl_mag3110_i2c_3D_mag.a
− lib_fsl_ml3115_i2C_1D_press.a
− libfsl_fxos87000_i2cspi_6D_AccMag.a
C:\Program Files\Freescale\ ISF_Kinetis\ISF_R1p1
TM
External Use 19
A Typical CodeWarriorTM Project with ISF
• FXAS21000_Project
isf_sensor_configuration.c
isf_sensor_configuration.h
HOST_CMD_README.txt
CodeWarrior and
Processor Expert
(Pex) Files
Project source code:
FXAS21000_Project.c
Doc
Documentation
Generated Code
Include Files
MQXLITE
Project Settings
Sources
app
ISF
Include
Source
All Include files
Project-Specific
ISF/System
Configuration Code
TM
External Use 20
ISF Overall Development Flow
• Pick a Project Template/Example to start from
− Example Embedded App projects
− Sensor Adapter template project
− Training Module Projects
• Modify ISF Configuration as necessary
− Add/Remove sensors
− Add/Remove ISF Components
• Update Project Properties to match
− Include Paths, Link Libraries
• Add your own embedded app logic
• Compile/Execute
TM
External Use 21
ISF Training Modules
• Module 1 - Installing Necessary Software
• Module 2 - Installing an ISF binary
• Module 3 - Building an ISF Application
• Module 4 - Modifying an ISF Application
• Module 5 - Using the ISF Command Interpreter
• Module 6 - Adding an External Sensor
TM
External Use 22
An ISF Software Reference Manual is Available
ISF1P195K_SW_REFERENCE_RM
TM
External Use 23
An HTML ISF API Reference Manual is Available
ISF1P1KL25Z_API_REFERENCE_RM
TM
External Use 24
New Freescale Sensor Community
community.freescale.com/community/sensors
• Forum for customers and Freescale experts to exchange technical
information about Freescale solutions
− In this vibrant, best-in-class environment, you can share sensor design ideas and
tips, ask and answer technical questions, and receive input on just about any
sensor design topic
− Technical support with fellow design engineers and Freescale experts
TM
External Use 25
HANDS-ON TRAINING
Building a small gyro application on the
FRDM-KL25Z and the
FRDM-FXS-MULTI Sensor Expansion
Board
TM
External Use 26
What is Needed
For this class, your computers have been pre-installed with:
Base for ISF development on KL25Z:
• CodeWarrior 10.5
• ISF1P1KL25Z- Base framework for application development on the
FRDM-KL25Z
Sensor Adapter:
• ISF1P1_KL25Z FXAS21000_ADAPTER_LIB - ISF component to manage
the Freescake FXAS21000 Gyro
Demo Project:
• FXAS21000_Project - The CodeWarrior project for this session
Gyro Demo PC GUI App:
• FXAS21000 Demo - Graphical display application for gyro data
TM
External Use 27
The Application
What are we going to do?
Create an application that subscribes to gyro data and sends it to the
PC for graphical display
TM
External Use 28
The FRDMKL25Z + Sensor Expansion Board Setup
Serial Comms
KL25Z
PC
Gyro
I2C
USB To PC using
the OpenSDA
TM
External Use 29
ISF Overall Development Flow
1. Pick a Project Template/Example to start from:
− Example Embedded App projects
− Sensor Adapter template project
− Training Module Projects
2. Modify ISF Configuration as necessary
− Add/Remove sensors
− Add/Remove ISF Components
3. Add your own embedded app logic
4. Compile/Execute
TM
External Use 30
A Typical ISF User Application Structure
Part of Template
Included by example in
Template
Placeholder in Template
Includes, Defines, and Prototypes
Main_task
Initialization code
Sensor subscription code
Main Loop
Wait for sensor data
Set sensor settings
Call Subscribe
Begin Sensor Data
Retrieve sensor data
Use sensor data
Shutdown/Cleanup code
ISF provides some
Template/Example
projects to get started
The first is the
FXAS21000 Project
used in this workshop
TM
External Use 31
General Approach is to Start with an Example
Project and Modify it
Types of changes we’d want to make for this app:
1. Update the sensor configuration to include the FXAS21000
2. Subscribe to gyro data
3. Send data to the PC using the ISF Command Interpreter
whenever new data is available
TM
External Use 32
Configuring Available Sensors
• Define the sensors available in the system
• This changes a little more often than the
channels configuration
• A default system configuration for FXLC95000
is provided
• It is recommended that you copy and
customize these files for each application
you write to include the sensors you need
for your application
Example Applications
/…/Sources/ISF/
Include/isf_sensor_configuration.h
Example Applications/…/Sources/ISF/Source/isf_sensor_configuration.c
TM
External Use 33
Describe the CI interface for this App
For each sensor, there is a corresponding embedded application provided.
For each embedded app, there is a README.txt file provided to explain some of the commands provided by the embedded application.
(Sensor Name)_Project_HOST_CMD_README.txt
FXAS21000_Project_HOST_CMD_README.txt
| FXAS21000_EMBEDDED_APP P R O J E C T A P P L I C A T I O N I D s
+-----------+------------------------------+----------------------------------------------------------------------------+
| APP ID | NAME | DESCRIPTION |
+-----------+------------------------------+----------------------------------------------------------------------------+
| 0 | Device Info | ISF Built-in: Returns Device Information |
|------------+------------------------------+----------------------------------------------------------------------------+
| 1 | ISF Mailbox App | ISF Built-in: Manages Quick-Read Mailbox configuration |
+-----------+------------------------------+----------------------------------------------------------------------------+
| 2 | FXAS21000_App | FXAS21000 application |
|------------+------------------------------+----------------------------------------------------------------------------+
0x7E 0x02 0x00 0x00 0x7E
0x7E => Start and end of a data packet
0x02 => Number of bytes in the data packet
TM
External Use 34
Describe the CI interface for this App (Continued)
| FXAS21000_EMBEDDED_APP P R O J E C T A P P L I C A T I O N I D s Reset the application
(CI_CMD_RESET_APP)
+-----------+------------------------------+----------------------------------------------------------------------------+ Reset : 0x7E 0x04 0x02
0x06 0x00 0x00 0x7E
| APP ID | NAME | DESCRIPTION |
+-----------+------------------------------+----------------------------------------------------------------------------+
| 0 | Device Info | ISF Built-in: Returns Device Information |
|------------+------------------------------+----------------------------------------------------------------------------+
| 1 | ISF Mailbox App | ISF Built-in: Manages Quick-Read Mailbox configuration |
+-----------+------------------------------+----------------------------------------------------------------------------+
| 2 | FXAS21000_App | FXAS21000 application |
|------------+------------------------------+----------------------------------------------------------------------------+
Write application configuration (CI_CMD_WRITE_CONFIG)
State Unsubscribed : 0x7E 0x05 0x02 0x02 0x00 0x01 0x00 0x7E
State Subscribed : 0x7E 0x05 0x02 0x02 0x00 0x01 0x01 0x7E
State Oneshot : 0x7E 0x05 0x02 0x02 0x00 0x01 0x02 0x7E
State Streaming : 0x7E 0x05 0x02 0x02 0x00 0x01 0x03 0x7E
TM
External Use 35
Compiling & Linking => Build Project
• Open CodeWarrior 10.5 in Workspace:
…..\workspace_ISFonKL25Z
• Find the FXAS21000 Project − Start Menu > All Programs > Freescale > Xtrinsic ISF
v1.1 Kinetis KL25Z > Example Applications
− Copy it into a new directory (to avoid corruption)
• Inside the directory, locate the .project file and copy it into the CodeWarrior window
• Right Click on the Project Name
• Select “Clean Project”
• Then select “Build Project”
Right-click
TM
External Use 36
Executable: hex File to S19 File
• One of the files generated in the FLASH
directory is: FXAS21000_Project.hex
TM
External Use 37
Make Sure the Hardware is Ready
Green and Orange “Power” LEDs USB Cable Connected to PC
(from the bottom, OpenSDA)
TM
External Use 38
Connect the Boards to the PC
Once you plug in the Freedom Board, it shows up as a new
device on the PC:
TM
External Use 39
Identify the Executable Image
Locate the .hex file in Windows Explorer, right click, and copy it
Copy it into the FRDM-KL25Z Directory
The firmware has been loaded onto the board ----
TM
External Use 40
Move the Executable Image onto the Board
Paste it into the FRDM-KL25Z Directory.
The executable/image is now running on the board.
TM
External Use 41
Run the PC GUI AKA FXAS21000 Demo GUI
From the Start Menu, click on
“All Programs” > Freescale Demos > FXAS21000 Demo
Make sure the
PC GUI is
talking to the
board. Expect
a COMi port
number with
a check box.
OK to click the
big green
START button.
TM
External Use 42
Run the PC GUI AKA FXAS21000 Demo GUI
Rotate the board in 3 axes -
TM
External Use 43
Questions and Answers
TM
External Use 44
Backup
TM
External Use 45
Sensor Manager
Embedded Applications
Pub/Sub Event-Based
Sensor Data
Sensor Abstraction Interface
Sensor Data
Updates
Sensor
Configuration
I2C Protocol
Driver
Sensor
Adapter
Device
Messaging
Bus
Manager
What Makes It All Work?
Main Sensor Flow Deep-Dive
TM
External Use 46
SM Design Goals
Sensor Manager
Embedded Applications
Pub/Sub Event-Based
Sensor Data
Sensor Abstraction Interface
Sensor Data
Updates
Sensor
Configuration
I2C Protocol
Driver
Sensor
Adapter
Device
Messaging
Bus
Manager
• Just wants sensor data
• Doesn’t need to understand specifics of sensor
control or configuration
• Knows sensor control
• Doesn’t need to understand specifics of sensor
configuration
• Knows sensor configuration
• Doesn’t need to understand specifics of channel
communications or periodic timing
• Knows periodic timers and bus serialization
• Doesn’t need to know what is done in each
registered callback
Knows channel communications
Doesn’t need to understand specific bus
protocols
Knows specific bus
protocols
TM
© 2014 Freescale Semiconductor, Inc. | External Use
www.Freescale.com