An introduction to nxpusblib March 2012
Agenda NXP USB portfolio Demo using LPC1800- Out of the Box What is nxpusblib? How to use nxpusblib? Why to use nxpusblib? Summary 2
NXP USB Portfolio
NXP MCU the only complete ARM range of Cortex-M0, Cortex-M3 and Cortex-M4 processors cost performance 8-bit 16-bit 32-bit DSP Entry level Cortex-M0 NXP ARM Cortex-M Continuum Cortex-M0 Cortex-M3 Cortex-M4 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
USB Roadmap for Cortex-M0 Full-Speed LPC134x LPC11U1x LPC11U2x 32K Flash, 6K SRAM LPC11Uxx 32K Flash, up to 10K SRAM, up to 4K EEPROM LQFP64 package offering 40-128K Flash, up to 10K SRAM, up to 4K EEPROM Small sector size (256 bytes) LQFP64 package offering Up to 64K Flash, up to 10K SRAM, up to 4K EEPROM Small sector size (256 bytes) LQFP64 package offering Low cost USB Platform for mbed Platform for LPCXpreso 5
USB Roadmap for Cortex-M3/M4 High Speed LPC4300 LPC1800 6
LPC11U00- Entry level USB Up to 32k Flash Power Profiles Up to 40 GPIOs Also TFBGA48 (4.5 x 4.5 mm) 2 SSP USB 2.0 FS Smart Card Interface 7
LPC1800 HS Demo Out-of-the-Box Experience
What is nxpusblib?
Setting up nxpusb with just 3 APIs! Setup using just 3 APIs: USB_Init () USB_Connect () Event_functions() Events. ROM drivers- HID, MSC, CDC, custom 10
On-Chip USB Rom Drivers Customer benefits: Savings of up to 4K code space API driven approach Programming via USB using Mass Storage Class Ease of use as a Virtual COM port Custom class benefits 11
nxpusblib + on-chip ROM Drivers Same API application interface with or without on-chip ROM drivers 12
USB controller Support Device Host Dual-Host Coming Soon! 13
Class Support HID VCOM Device Firmware Update (DFU*) MSC Audio Smart Card* *DFU, Smart Card Interface coming soon! 14
What is included in nxpusblib? 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 Bulk Interrupt Isochronous Supported tool chains Keil uvision 4 LPCXpresso 4 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 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 15
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
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
nxpusblib directory structure Keil workspace project file Example applications Board support packages Chip drivers USB library 18
Building nxpusblib with Keil uvision 4 Master workspace project file: \applications\examples\nxpusblib\nxpusblib_workspace.uvmpw Batch build feature Target selection 19
Building nxpusblib with LPCXpresso 1. Import all Existing Projects into the workspace 2. Set build configurations (right click->build config) 3. Click Build 20
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
How to use nxpusblib? Creating a HID project in 5 Steps!
nxpusblib Board Support Package (BSP) 23
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
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_GenericHIDDevice will also be used in this demonstration. Click on the Finish button. 25
Step 2: Configuring projects in LPCXpresso Make sure you choose the appropriate Configuration for the project you are using. 26
Step 3: Enabling the Indexer Under Windows -> Preferences, the Indexer should set the Build configuration to Use active build configuration 27
Step 4: Select the microcontroller For each project listed in the Project Explorer, change to the appropriate microcontroller 28
Step 5: (Optional) if not using BSP Since 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. Includes and Libraries GenericHID.h 29
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 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, 30
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: LPC_GPIO->DIR[0] = (1<<7); 31
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; 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 } 32
Step 10: Testing nxpusblib Use a generic HID application to send and receive data from the LPC11U14 33
Why to use nxpusblib?
Comparison with USB stacks Significant savings (~50%) using nxpusblib + on-chip ROM Limitations with USBHostLite: Supports one class only (Mass storage) 35
Best-in-Class Support from NXP team! We want to hear from you! LPCForums USB http://www.lpcware.com/forums/peripherals-forums/usb 36
Summary
Summary 38
One Stop Shop for USB! Widest range of USB controllers FS, HS Device, host and Dual host controllers Certified at USB.org! FREE USB stacks nxpusblib + other stacks On-chip ROM drivers HID, MSC, CDC, Custom class FREE PID program Launching soon! 39
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