An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1....

41
An introduction to “nxpUSBlib” March 2012

Transcript of An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1....

Page 1: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

An introduction to “nxpUSBlib”

March 2012

Page 2: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

NXP USB portfolio

Demo using LPC1800- “Out of the Box”

“What” is nxpusblib?

“How” to use nxpusblib?

Agenda

“Why” to use nxpusblib?

Summary

2

Page 3: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

NXP USB Portfolio NXP USB Portfolio

Page 4: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

8-bit 16-bit 32-bit DSP

cost performance

NXP MCU – the only complete ARM range of Cortex-M0, Cortex-M3 and Cortex-M4 processors

NXP ARM Cortex-M Continuum

Cortex-M4Cortex-M3Cortex-M0

Entry level

Cortex-M0

Fully featured

Cortex-M4

True 8/16-bit

replacement- low power, low cost, more performance

High performance for

communication and

control- USB, Ethernet, CAN, and much more

Advanced Digital

Signal control- Floating point unit- Dual-core options

Over 250 different ARM based microcontrollers available!!

4

Page 5: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

USB Roadmap for Cortex-M0Full-Speed

LPC11Uxx

LPC11U2x 40-128K Flash, up

to 10K SRAM, up

to 4K EEPROM

LPC134x

Up to 64K Flash, up

to 10K SRAM, up to

4K EEPROM

Small sector size

(256 bytes)

LQFP64 package

32K Flash, up to

10K SRAM, up to

4K EEPROM

LQFP64 package

offering

Platform for mbed

32K Flash, 6K SRAM

Low cost USB

Platform for

LPCXpreso

LPC11U1xSmall sector size

(256 bytes)

LQFP64 package

offering

LQFP64 package

offering

5

Page 6: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

USB Roadmap for Cortex-M3/M4High Speed

LPC1800

LPC4300

LPC1800

6

Page 7: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

LPC11U00- Entry level USB

USB 2.0 FS

2 SSP

Power Profiles

Up to 40 GPIOs

Up to 32k Flash

Also TFBGA48 (4.5 x 4.5 mm)

USB 2.0 FS

Smart Card

Interface

7

Page 8: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

LPC1800 HS Demo“Out-of-the-Box Experience” “Out-of-the-Box Experience”

Page 9: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

“What” is nxpusblib?“What” is nxpusblib?

Page 10: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

Setting up nxpUSB with just 3 APIs!

Setup using just 3 APIs:

• USB_Init ()

• USB_Connect ()

• Event_functions()

Events……

.

10

ROM drivers-HID, MSC, CDC, custom

……

.

Page 11: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

On-Chip USB Rom Drivers

Customer benefits:– Savings of up to 4K

code space

– API driven approach

– Programming via USB

using Mass Storage

11

using Mass Storage

Class

– Ease of use as a Virtual

COM port

– Custom class benefits

Page 12: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

nxpUSBlib + on-chip ROM Drivers

12

Same API application interface with or without

on-chip ROM drivers

Page 13: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

USB controller Support

Device

Host

13

Host

Dual-Host

Coming Soon!

Page 14: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

Class Support

HIDVCOM

Device Firmware Update (DFU*)

14

Audio

MSC

Smart Card*

Update (DFU*)

*DFU, Smart Card Interface coming soon!

Page 15: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

Supported controllers– Full speed, device mode controller

(dedicated buffers)

– Full speed, host and device mode

controller (shared buffers)

– High speed, host and device mode

controller

Supported transfer types– Control

What is included in nxpUSBlib?

Supported boards– LPCXpresso LPC11U14, LPC1769 and

Rev B base board

– Hitex LPC1850/4350 Evaluation Board

(rev A4)

– NGX LPC4330-Xplorer

– Element 14 LPC4350 gaming board

– Embedded Artists

Included examples– Control

– Bulk

– Interrupt

– Isochronous

Supported tool chains– Keil uVision 4

– LPCXpresso 4

15

Included examples– Audio output host and device

– Keyboard host and device

– Mass storage host and device

– Mouse device

– VCOM device

ROM drivers– HS: LPC1800, LPC4300

– FS: LPC11U00, LPC1300

Page 16: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

Where to get nxpUSBlib?

nxpUSBlib website:http://www.lpcware.com/content/project/nxpusblib

Latest version of nxpUSBlib

Links to development board vendors

Links to compilers/debuggers and other tools

Build and configuration documentation

16

Page 17: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

What is available in the download?

One zip file:– Full source to a complete USB stack

– 10 example applications

– Android Accessory project from

Embedded Artists

– Project files for uVision4 and

LPCXpresso 4

– Documentation

17

Page 18: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

nxpUSBlib directory structure

Keil workspace project file

Example applications

18

Board support packages

Chip drivers

USB library

Page 19: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

Building nxpUSBlib with Keil uVision 4

Master workspace project file:

\applications\examples\nxpUSBlib\nxpUSBlib_workspace.uvmpw

Batch build feature Target selection

19

Page 20: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

Building nxpUSBlib with LPCXpresso

1. Import all “Existing Projects” into the workspace

2. Set build configurations

(right click->build config)

3. Click Build

20

Page 21: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

Configuring nxpUSBlib (With ROM Drivers)

\libraries\nxpUSBLib\nxpUSBlibConfig.h

/* This option effects only on high speed parts that need to test full speed activities */

#define USB_FORCED_FULLSPEED 0

/* Define USE_USB_ROM_STACK = 1 to use MCU's internal ROM stack, 0 if otherwise */

#define USE_USB_ROM_STACK 0

21

Page 22: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

“How” to use nxpUSBlib? “How” to use nxpUSBlib? Creating a HID project in 5 Steps!

Page 23: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

nxpUSBlib Board Support Package (BSP)

23

Page 24: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

Using nxpUSBlib for “your” application

Objectives:We would like to send one byte to the USB hardware to turn on/off an LED using P0.7, and we also need to read the state of a button (P0.1).The hardware will be an LPC11U14 LPCXpresso board plugged into an NGX base board.

24

Page 25: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

Step 1: Selecting projects in LPCXpresso

When we read nxpUSBlib into the LPCXpresso IDE, we are presented with the entire library, so we need to choose which we will need for our project.The CDL and nxpUSBlib are required for all projects.Example_GenericHIDDevicewill also be used in this

25

will also be used in this demonstration.Click on the Finish button.

Page 26: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

Step 2: Configuring projects in LPCXpresso

Make sure you choose the appropriate Configuration for the project you are using.

26

Page 27: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

Step 3: Enabling the Indexer

Under Windows -> Preferences, the Indexer should set the Build configuration to “Use active build configuration”

27

Page 28: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

Step 4: Select the microcontroller

For each project listed in the Project Explorer, change to the appropriate microcontroller

28

Page 29: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

Step 5: (Optional) if not using BSPSince we are creating our own project (not using the BSP included in

nxpUSBlib) we can remove the references to the BSP in the

Example_GenericHIDDevice project.

29

Includes and Libraries

GenericHID.h

Page 30: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

Step 6: Customizing the Generic HID example

Now that we have the IDE environment set up for creating our HID project, we need to make a few modifications.The default Report Size, as defined in the Descriptors.h file is 8 bytes. We are only going to use one byte, so this can be changed to 1.

/** Size in bytes of the Generic HID reports. */

#define GENERIC_REPORT_SIZE 1

30

In most situations, you will probably want to change the Product ID, and sometimes the Vendor ID. These values can be found in the Descriptors.c file.

.VendorID = 0x1FC9, /* NXP */

.ProductID = 0x204F,

Page 31: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

Step 8: Customizing the Generic HID example

In the GenericHID.c file:1. All references to the LEDs_SetAllLEDs function can be commented out since these are part of the BSP.c file

2. The bsp_init(), LEDs_Init(), sei() and USB_Connect() can be commented out.

3. We need to add the following to the main(void) to initialize P0.7 to be an output to drive the LED:

31

P0.7 to be an output to drive the LED:LPC_GPIO->DIR[0] |= (1<<7);

Page 32: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

Step 9: Customizing the Generic HID example

The two callback functions are used to send/receive data from the USB host. These two functions are found in the GenericHID.c file

void CALLBACK_HID_Device_ProcessHIDReport(…) {

uint8_t* Data = (uint8_t*)ReportData;

if (Data[0] & 0x01)

LPC_GPIO->SET[0] = (1<<7); // set P0.7 high

else

LPC_GPIO->CLR[0] = (1<<7); // set P0.7 low

*ReportSize = GENERIC_REPORT_SIZE;

32

*ReportSize = GENERIC_REPORT_SIZE;

return false;

}

CALLBACK_HID_Device_CreateHIDReport(…) {

uint8_t* Data = (uint8_t*)ReportData;

if (LPC_GPIO->PIN[0] & 0x02)

Data[0] = 1; // return “1” if not pressed”

else

Data[0] = 0; // return “0” if not pressed”

}

Page 33: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

Step 10: Testing nxpUSBlib

Use a generic HID application to send and receive data from the LPC11U14

33

Page 34: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

“Why” to use nxpUSBlib?“Why” to use nxpUSBlib?

Page 35: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

Comparison with USB stacks

35

Significant savings (~50%) using nxpUSBlib + on-chip ROM

Limitations with USBHostLite: Supports one class only (Mass storage)

Page 36: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

Best-in-Class Support from NXP team!

LPCForumsWe want to hear from you!

36

http://www.lpcware.com/forums/peripherals-forums/usb

USB

hear from you!

Page 37: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

SummarySummary

Page 38: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

Summary

38

Page 39: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

Widest range of USB controllers– FS, HS

– Device, host and Dual host controllers

– Certified at USB.org!

FREE USB stacks – nxpUSBlib + other stacks

One Stop Shop for USB!

– nxpUSBlib + other stacks

On-chip ROM drivers– HID, MSC, CDC, Custom class

FREE PID program – Launching soon!

39

Page 40: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks

Where to get started?

www.nxp.com/microcontrollers

– MCU homepage

www.nxp.com/lpczone

– Product updates and training

www.nxp.com/lpcxpresso– Low-cost development

www.lpcware.com– Download nxpUSBlib!

40

Page 41: An introduction to “nxpUSBlib” · PDF fileBuilding nxpUSBlib with LPCXpresso 1. ... commented out since these are part of the BSP.c ... – Certified at USB.org! FREE USB stacks