Create an USB Application Using CMSIS-Driver. Klaus Koschinsky Senior Field Applications Engineer

Similar documents
Component-based Software Development for Microcontrollers. Zhang Zheng FAE, ARM China

Getting Started with MDK. Create Applications with µvision for ARM Cortex -M Microcontrollers

ARM TrustZone for ARMv8-M for software engineers

MDK-ARM Version 5. ULINK Debug Adapters. Microcontroller Development Kit.

MDK-Professional Middleware Components. MDK-ARM Microcontroller Development Kit MDK-ARM Version 5. USB Host and Device. Middleware Pack.

MDK-ARM. Microcontroller Development Kit

5/11/2012 CMSIS-RTOS. Niall Cooling Feabhas Limited CMSIS. Cortex Microcontroller Software Interface Standard.

Kinetis SDK Release Notes for the TWR-K24F120M Tower System Module

Migrate RTX to CMSIS-RTOS

Freescale Kinetis Software Development Kit Release Notes

Kinetis SDK v Release Notes for KV5x Derivatives

Kinetis SDK v Release Notes for the MK21DA5 and MKW24D5 Devices

Arm TrustZone Armv8-M Primer

Hands-On Workshop: ARM mbed

STM32 Cortex-M3 STM32F STM32L STM32W

GET STARTED FAST WITH THIS COMPREHENSIVE ENABLEMENT OFFERING FOR LPC800 MCUS

RENESAS SYNERGY PLATFORM

Getting Started with MCUXpresso SDK CMSIS Packs

SN32F100 Series QUICK START. SN32F100 Series SN32F107 SN32F108 SN32F109. SONiX TECHNOLOGY CO., LTD Page 1 Version 3.1

Lab 3b: Scheduling Multithreaded Applications with RTX & uvision

Migrating to Cortex-M3 Microcontrollers: an RTOS Perspective

Designing, developing, debugging ARM Cortex-A and Cortex-M heterogeneous multi-processor systems

Bringing the benefits of Cortex-M processors to FPGA

mbed Hello World! Introduction to mbed

STM3220G-SK/KEI. Keil starter kit for STM32F2 series microcontrollers (STM32F207IG MCU) Features. Description

Developing a Camera Application with i.mx RT Series

Hands-On Workshop: Developing with the Kinetis Software Development Kit

Developing a simple UVC device based on i.mx RT1050

UM1853 User manual. STM32CubeF1 Nucleo demonstration firmware. Introduction

mbed OS Update Sam Grove Technical Lead, mbed OS June 2017 ARM 2017

Getting started with the X-CUBE-IKA02A1 multifunctional software expansion for STM32Cube

Heterogeneous multi-processing with Linux and the CMSIS-DSP library

CODE TIME TECHNOLOGIES. Abassi RTOS. CMSIS Version 3.0 RTOS API

AT-501 Cortex-A5 System On Module Product Brief

UM2204. Getting started with STM32CubeH7 for STM32H7 Series. User manual. Introduction

STM32L4R9I-EVAL. Evaluation board with STM32L4R9AI MCU. Features

STM32F7 series ARM Cortex -M7 powered Releasing your creativity

Implementing Secure Software Systems on ARMv8-M Microcontrollers

STM32SnippetsL0. STM32L0xx Snippets firmware package. Features. Description

Getting started with the STSW-BCNKT01 software package for STEVAL-BCNKT01V1 based on STM32Cube

Getting started with X-CUBE-LED channel LED driver software expansion based on LED1642GW for STM32Cube

Zilog Real-Time Kernel

Tutorial. How to use Keil µvision with Spansion templates Spansion Inc.

RZ Embedded Microprocessors

Hands-On Workshop: ARM mbed : From Rapid Prototyping to Production

ASF4 API Reference Manual

SEAMLESS INTEGRATION OF COMMUNICATION PROTOCOLS

Quick Start Guide. TWR-VF65GS10 For Vybrid Controller Solutions Based on ARM Cortex -A5 and Cortex-M4 Processors with the DS-5 Toolchain TOWER SYSTEM

NXP LPC4300: Cortex -M4/M0 Hands-On Lab

μez Software Quickstart Guide

ZiLOG Real-Time Kernel Version 1.2.0

TI-RTOS overview. Nick Lethaby, TI-RTOS and IoT Ecosystem. May 2015

STM32F7 series ARM Cortex -M7 powered Releasing your creativity

32F412GDISCOVERY. Discovery kit with STM32F412ZG MCU. Features. Description

Experiment 1. Development Platform. Ahmad Khayyat, Hazem Selmi, Saleh AlSaleh

Software Design Challenges for heterogenic SOC's

STM32H7x3I-EVAL. Evaluation board with STM32H7x3XI MCUs. Data brief. Features

μez Software Quickstart Guide

S32 SDK for Power Architecture Release Notes Version EAR

Keil TM MDK-ARM Quick Start for. Holtek s HT32 Series Microcontrollers

Kinetis KE1xF512 MCUs

The Next Steps in the Evolution of ARM Cortex-M

3 2-bit ARM Cortex TM -M3 based

L2 - C language for Embedded MCUs

Freescale MQX RTOS TWR-K64F120M Release Notes

EMBEDDED SYSTEMS WITH ROBOTICS AND SENSORS USING ERLANG

UM2045 User manual. Getting started with the X-CUBE-NFC3 near field communication transceiver software expansion for STM32Cube.

Kinetis KV5x Real-Time Control MCUs with Ethernet Up to 1 MB Flash and 256 KB SRAM

2-bit ARM Cortex TM -M3 based Microcontroller FM3 Family MB9A130 Series

Getting Started with FreeRTOS BSP for i.mx 7Dual

Getting started with the X-CUBE-NFC5 high performance HF reader / NFC initiator IC software expansion for STM32Cube

STM32L100C-Discovery Board Projects

ASF4 API Reference Manual

ECE254 Lab3 Tutorial. Introduction to MCB1700 Hardware Programming. Irene Huang

UM QN908x Quick Start. Document information. QN908x, Quick Start, Development Kit, QN9080 DK, QN9080 Development Kit

User Manual. LPC-StickView V3.0. for LPC-Stick (LPC2468) LPC2478-Stick LPC3250-Stick. Contents

Key Benefits. SAM S70 and E70 Devices

Freescale MQX RTOS for Kinetis SDK Release Notes version beta

Designing with STM32F2x & STM32F4

AN207 Building Mbed OS projects with Keil uvision

Kinetis SDK Freescale Freedom FRDM-KL03Z Platform User s Guide

IoT and Security: ARM v8-m Architecture. Robert Boys Product Marketing DSG, ARM. Spring 2017: V 3.1

Getting Started with DS-MDK. Create Applications for Heterogeneous ARM Cortex -A/Cortex-M Devices

Copyright 2016 Xilinx

TN0132 Technical note

Getting started with the software package for STEVAL-STLKT01V1 based on STM32Cube

USB / Ethernet Production Ready Module

32F469IDISCOVERY. Discovery kit with STM32F469NI MCU. Features. Description

User Manual Rev. 0. Freescale Semiconductor Inc. FRDMKL02ZUM

AN4624 Application note

Cortex-M Processors and the Internet of Things (IoT)

ARM mbed mbed OS mbed Cloud

CMPE3D02/SMD02 Embedded Systems

REAL TIME OPERATING SYSTEM PROGRAMMING-I: VxWorks

NXP Unveils Its First ARM Cortex -M4 Based Controller Family

Microcontroller basics

TEVATRON TECHNOLOGIES PVT. LTD Embedded! Robotics! IoT! VLSI Design! Projects! Technical Consultancy! Education! STEM! Software!

EDBG. Description. Programmers and Debuggers USER GUIDE

Lab 3a: Scheduling Tasks with uvision and RTX

Getting started with the STM32 Nucleo pack for USB Type-C and Power Delivery with the Nucleo-F072RB board and the STUSB1602

Transcription:

Create an USB Application Using CMSIS-Driver Klaus Koschinsky Senior Field Applications Engineer 1

Contents Project Overview CMSIS Technical Overview Development Tools Project Creation (Demo) 2

Create a USB Application Requirements Read data from a USB Memory Stick Display these data [to a display] Software Features USB Host Stack File System Graphic User Interface Provide a update button [on a touch screen] Touch Screen Support Implementation easy to expand for further feature requests Software Concept (RTOS Kernel) Drivers for Peripherals Scalable to different hardware 3

Software Stack for the USB Application Application Code Run-Time Environment Real Time OS Peripheral HAL (Device Specific) MDK Professional Middleware Graphics File System USB Host CMSIS-Driver: USB Host, I 2 C, SPI CMSIS-CORE MCU ARM Cortex -M Other Peripherals USB Host Controller Communication Peripherals Ready-to-use made Software Components to reduce application development time Run-Time Environment must be easy to combine, to configure, and to adapt for the MCU hardware/peripherals and for the application specific requirements Embedded Applications need access to all levels of the system 4

Target Hardware for the USB Application Evaluation Kit for Cortex-M Microcontroller 5 Discovery kit for STM32F429ZI MCU

6

7 CMSIS Technical Overview

Software Complexity The Challenge Well-known issues that drive software development costs Increasing product requirements that are implemented by software Hardware problems tend to become compensated by software Hardware uses defined interfaces that simplify re-use Software components are hard to integrate Software Standards and Software Components are key for productivity! 8

Cortex Microcontroller Standard (CMSIS) Vendor-independent Standard for hardware manufacturers and tool vendors Common Software layers and interfaces for all Cortex-M processor based devices CMSIS-CORE API for Cortex-M processor and core peripherals CMSIS-DSP DSP Math Library with more than 60 functions CMSIS-SVD XML system view description for peripheral debugging CMSIS-RTOS API for RTOS integration CMSIS-DAP Firmware for Debug Access Port CMSIS-DRIVER API for peripheral driver interfaces CMSIS-PACK XML description for software components, device parameters, board support 9

CMSIS-CORE Consistent API for Cortex-M processor core and device peripherals core_<cpu>.h CMSIS CPU & Core Access core_cminstr.h CPU Instruction Access core_cm4_simd.h SIMD Instruction Access (Cortex-M4 only) core_cmfunc.h Core Peripheral Functions startup_<device>.s CMSIS Device Startup Interrupt Vectors system_<device>.c CMSIS System & Clock Configuration <device>.h CMSIS Device Peripheral Access system_<device>.h CMSIS System & Clock Configuration 10 User Application #include <device>.h main() {... } CMSIS-CORE Device Files (Silicon Vendor) User Program CMSIS-CORE Standard Files (ARM)

CMSIS-CORE - Example #include <device.h> // File name depends on device used void SysTick_Handler (void) { // SysTick Interrupt Handler ; // Add user code here } void TIM1_UP_IRQHandler (void) { // Timer Interrupt Handler ; // Add user code here } void timer1_init(int frequency) { // Set up Timer (device specific) NVIC_SetPriority (TIM1_UP_IRQn, 1); // Set Timer priority NVIC_EnableIRQ (TIM1_UP_IRQn); // Enable Timer Interrupt } 11 // The processor clock is initialized by CMSIS startup + system file void main (void) { // user application starts here if (SysTick_Config (SystemCoreClock / 1000)) { : // Handle Error } timer1_init (); // setup device-specific timer while (1) {} // Endless Loop (the Super-Loop) } // BOLD: CMSIS Features

CMSIS-RTOS Generic RTOS Interface for Cortex-M Microcontrollers Implementation Based on RTX: 6KB memory foot print Includes Source Code under Open Source License (BSD) 12

CMSIS-RTOS: Mail Queue Memory Pool with Message Passing Thread or ISR can exchange data A single data owner at a time Mailbox FIFO for multiple messages Thread or ISR On overruns: forces task switch or error notification Deterministic time behavior (independent from current load) Timeout prevents from application hang-up put Mail Queue...... memory blocks get Thread or ISR extern osmailqid mailbox1; void job1 (void) { // Thread 1 struct msg *message; } message = osmailalloc (mailbox1, 12); // fill message content osmailput (mailbox1, message); timeout osmailqdef (mail1, 20, struct msg); osmailqid mailbox1; void job2 (void) { // Thread 2 osevent msg; mailbox1 = osmailcreate(osmailq (mail1), osthreadgetid ()); while (1) { msg = osmailget (mailbox1, 100); // process message content osmailfree (mailbox1, msg); timeout } } 13

Files for CMSIS-RTOS Layer RTOS_config.c CMSIS RTOS Configuration cmsis_os.h CMSIS Standard RTOS Interface RTOS.LIB CMSIS Compliant RTOS Library User Application #include cmsis_os.h main() {... } User Program CMSIS-RTOS Files (RTOS Vendor) 14

CMSIS-RTOS Example #include "cmsis_os.h" // CMSIS-RTOS header file void job1 (void const *argument) { // thread function 'job1' while (1) { : // execute some code osdelay (10); // delay execution for 10 milliseconds } } osthreaddef(job1, ospriorityabovenormal, 1, 0); // define job1 as thread function void job2 (void const *argument) { // thread function 'job2' while (1) { : // execute some code osdelay (20); // delay execution for 20 milliseconds } } osthreaddef(job2, osprioritynormal, 1, 0); // define job2 as thread function int main (void) { // program execution starts here oskernelinitialize (); // initialize RTOS kernel : // setup and initialize peripherals osthreadcreate (osthread(job1)); osthreadcreate (osthread(job2)); oskernelstart (); // start kernel with job1 execution } 15 // BOLD: CMSIS-RTOS Features

CMSIS-DSP Library Over 60 functions for various data types C Source Code, optimized for all Cortex-M based devices For CMSIS compliant C Compilers (ARM/Keil, IAR, GCC) 16

CMSIS-DAP Debug Access Port Firmware (typical use case: low-cost Starter Kits) Standard debug connection over USB to a MCU Cost reduction and multiple tool support on evaluation kits Running on all major development environments (MDK, DS-5, IAR, etc.) USB CMSIS-DAP Debug FW On Cortex-M MCU Main Cortex-based MCU or SoC Low-cost evaluation board 17

CMSIS-SVD System View Description for Peripherals Purpose Peripheral Views in debugger CMSIS Core device header files Scope } consistency Formalized description of the Programmer s View Covering peripherals, registers, bit fields and bit values Format Defined by written specification and XML Schema Validated for semantic consistency 18

CMSIS-Pack: Ready-to-Use Components Delivery Mechanism for software components, device parameters, and evaluation boards Variant Device Family Pack CMSIS Pack Middleware Pack Board Support Pack In-house Software Pack Source Silicon Vendor, Tool Vendor ARM Silicon Vendor, Tool Vendor, 3rd Party Board Vendor Tool User Use Case Deploy support for new MCU families Standard delivery of CMSIS components Simplify integration of pre-build middleware Support of evaluation boards with interfaces and example projects Supply and update software components within a company 19

CMSIS-Driver: Ready-to-Use Peripheral I/O API Interfaces Peripheral Driver Interfaces for Middleware and User Applications CMSIS-Driver USB Device Driver USART Driver Ethernet PHY Ethernet MAC SPI Driver MCI Driver NAND Flash Driver USB Host Driver RTE_Device.h Configuration File For generic USB device communication Universal Synchronous Asynchronous Receiver/Transmitter driver. Interface to Ethernet PHY Interface to Ethernet MAC Serial Peripheral Interface Bus driver Memory Card Interface for SD/MMC memory NAND Flash Memory interface driver For generic USB host communication Central driver configuration file (implementation specific) 20

CMSIS-Driver: Interfaces Attributes and Functions common in all CMSIS-Drivers Each CMSIS-Driver defines an Access Struct for calling the various driver functions Each peripheral (that is accessed via a CMSIS-Driver) has one Driver Instance Depending on the device a CMSIS-Driver implementation may support several Driver Instances Driver Functions: GetVersion: can be called at any time to obtain version information of the driver interface. GetCapabilities: can be called at any time to obtain capabilities of the driver interface. Initialize: must be called first. Initializes the software resources used by the interface. SignalEvent: is an optional callback function that is registered with the Initialize function. PowerControl: Controls the power profile of the peripheral and may be called after Initialize. Uninitialize: It will free all software resources used by the interface. Control: Function to configure communication parameters or execute control functions. Additional functions are specific to each driver interface (for example Send, Receive) 21

CMSIS-Driver: SPI: Functions and Access The CMSIS-Driver functions for each peripheral type are in a access structure: typedef struct _ARM_DRIVER_SPI { ARM_DRIVER_VERSION (*GetVersion) (void); ARM_SPI_CAPABILITIES (*GetCapabilities) (void); int32_t (*Initialize) (ARM_SPI_SignalEvent_t cb_event); int32_t (*Uninitialize) (void); int32_t (*PowerControl) (ARM_POWER_STATE state); int32_t (*Send) (const void *data, uint32_t num); int32_t (*Receive) (void *data, uint32_t num); int32_t (*Transfer) (const void *data_out, void *data_in, uint32_t num); uint32_t (*GetTxCount) (void); uint32_t (*GetRxCount) (void); int32_t (*Control) (uint32_t control, uint32_t arg); ARM_SPI_STATUS (*GetStatus) (void); } const ARM_DRIVER_SPI; Several peripherals of the same type use multiple instances of the driver access struct. The name of each driver instance reflects the name of the peripheral. ARM_DRIVER_SPI Driver_SPI1; // access functions for SPI1 interface ARM_DRIVER_SPI Driver_SPI2; // access functions for SPI2 interface ARM_DRIVER_SPI Driver_SPI3; // access functions for SPI3 interface 22

CMSIS-Driver: Non-Blocking Data Transmit Functions Driver Driver uses ISR or DMA to start data transfer using the peripheral. Once data transfer is started, the _Send function returns. Peripheral continues reading the transfer buffer. Once finished, the transfer complete event is signaled using the _SignalEvent callback. Application Code _Send Middleware fills a transfer buffer with data and calls the _Send function. Middleware continues execution or waits for the transfer complete event. Note that the transfer buffer cannot be refilled since it is still processed. _GetCount During data transfer, the number of sent items can be monitored. Middleware may partially fill the transfer buffer. _SignalEvent _Send Now, middleware can completely fill the transfer buffer and initiate the next _Send. Time 23

CMSIS-Driver Example #include "Driver_SPI.h" extern ARM_DRIVER_SPI Driver_SPI0; // SPI Driver void myspi_callback(uint32_t event) { switch (event) { case ARM_SPI_EVENT_TRANSFER_COMPLETE: ossignalset(tid_myspi_thread, 0x01); break; // Success : } const uint8_t testdata_out[8] = { 0, 1, 2, 3, 4, 5, 6, 7 }; // Test data buffers void myspi_thread(void const* arg) { } ARM_DRIVER_SPI* SPIdrv = &Driver_SPI0; SPIdrv->Initialize(mySPI_callback); SPIdrv->PowerControl(ARM_POWER_FULL); // Initialize the SPI driver // Power up the SPI peripheral SPIdrv->Control(ARM_SPI_MODE_MASTER ARM_SPI_CPOL1_CPHA1 ARM_SPI_MSB_LSB ARM_SPI_SS_MASTER_SW ARM_SPI_DATA_BITS(8), 10000000); // Configure the SPI to Master, 8-bit mode @10000 kbits/sec SPIdrv->Control(ARM_SPI_CONTROL_SS, ARM_SPI_SS_ACTIVE); while (1) { SPIdrv->Send(testdata_out, sizeof(testdata_in)); evt = ossignalwait(0x01, 100); : // Activate Slave Select to enable the connected SPI chip // Transmit some data // Wait for event: Transfer Complete // BOLD: CMSIS-Driver Feature 24

CMSIS-Driver Microcontroller Device Software Packs Middleware Startup/System Control Structs USB USB Controller USB Device Driver USBD0 USB Device Rx1/Tx1 USART USART Driver USART1 Ethernet Ethernet PHY Ethernet PHY ETH_PHY0 TCP/IP Networking Ethernet MAC Ethernet MAC ETH_MAC0 SPI1 SPI2 SPI #1 SPI #2 SPI Driver SPI1 SPI2 Graphics SDIO0 SDIO MCI Driver MCI0 File System I/O Memory Controller NAND Flash Driver NAND0 USB USB Controller USB Host Driver USBH0 USB Host 25 RTE_Device.h Configuration File

Files for CMSIS-Driver Layer USBD0_device.c CMSIS-Driver compliant Peripheral Driver Driver_USB.h CMSIS Standard Driver Interface Driver_Common.h CMSIS Standard Driver Interface RTE_Device.h Device Configuration File (Common for all drivers) User Application #include Driver_USB.h main() {... } CMSIS-Driver Device-Specific Files User Program CMSIS-Driver API Definition Files (ARM) 26

Development Tools for our Project 27

MDK Professional Best-in-class C/C++ Compiler Co-developed with ARM processors Proven in thousands of projects Pre-emptive Deterministic Source included EHCI/OHCI Interface Host & OTG mode Low & Full Speed ARM C/C++ Compiler µvision Project Manager, Editor & Debugger CMSIS-RTOS RTX USB Host Network File System Integrated Development Environment for edit, debug, and trace Tight integration of all MDK components Optimized for MCU systems Extensive protocol support Feature-rich applications Extensive media support FAT 12/16/32 Standard driver class support small memory footprint Low, Full, and High Speed USB Device Graphics Widget Library included Touch screen support Low level drivers 28

ULINKpro Debug and Trace Adapter JTAG SWD SWO 100 Mpbs ETM Streaming www.keil.com/coresight ULINKpro Cortex-M processors with up to 200 MHz Serial Wire Trace Capturing up to 100 Mbit/sec (Manchester Mode) ETM Trace Capturing up to 800 Mbit/sec Virtually un-limited Trace Buffer Unique Streaming Trace feature supports Code Coverage and Performance Analysis 29

Middleware: Network Add TCP/IP network connectivity via Ethernet or Serial Extensive range of service applications included Designed for Cortex-M devices with small memory footprint 30

Middleware: Graphic Add a graphical user interface (GUI) to an application quickly Compatible with hundreds of display controllers Touch-screen support for many TFT LCDs 31

Middleware: USB Host USB Host Component Class HID Human Interface Device MSC Mass Storage CORE USB Host Driver USBH High-Speed Full-Speed Connect common USB devices easily Support for various popular microcontroller host controllers High performance and small footprint USB 1.1 Low Speed (1.5 Mbit/s) and Full Speed (12 Mbit/s) Supports USB Flash drives and card storage devices 32

Middleware: USB Device USB Device Component Class HID Human Interface Device CDC Communication Device MSC Mass Storage ADC Audio Device CORE USB Device Driver USBD High-Speed Full-Speed Standard USB Device classes supported Plug N Play: No need to develop a driver for Windows or Linux hosts USB 1.1 Low Speed (1.5 Mbit/s) and Full Speed (12 Mbit/s) 33

Middleware: File System File System Component Drive RAM NAND Flash NOR Flash USB MSC Mass Storage Memory Card SD/SDHC/MMC CORE Variants: Long File Names Short File Names Driver NAND Flash NOR Flash MCI SPI Enable applications to work with locally stored data Storage devices: ROM, RAM, Flash, and SD/MMC/SDHC/eMMC FAT32 file system supported Simultaneous access to multiple storage devices 34

Web Portal for Software Packs 35

36 Project Creation

Keil MDK Workflow using Software Packs Install Select Configure Implement Download relevant Software Packs from Web Portal Choose device and select required middleware Setup parameters of the Run-Time Environment Use code templates for faster software development 37

Incremental Steps to Create the USB Application 1. Create Project for the STM32F429 Evaluation Board 2. Add and configure CMSIS-Core and CMSIS-RTOS for a simple blinky application 3. Add and configure USB Host middleware component Connect this component to the USB Host CMSIS-Driver Add and Configure Flash File System middleware component for USB Storage Connect the file system to the USB Host middleware component 4. Add and Configure Graphical User Interface Connect the LCD driver to SPI CMSIS-Driver 5. Create the dialog that is displayed 6. Add and Configure Touch Screen Interface Connect this component to the I 2 C CMSIS-Driver 38

Lets Do It! Demo Time 39

Thank You The trademarks featured in this presentation are registered and/or unregistered trademarks of ARM Limited (or its subsidiaries) in the EU and/or elsewhere. All rights reserved. Any other marks featured may be trademarks of their respective owners 40