Renesas H8SX1664 User Manual

REG10J0134-0100
Renesas Starter Kit for H8SX1664
USB Sample Code
User's Manual
RENESAS SINGLE-CHIP MICROCOMPUTER
H8SX FAMILY
Rev.1.00 Renesas Technology Europe Ltd. Revision date 08.January.2008 www.renesas.com
Table of Contents
Table of Contents..................................................................................................................................................ii
Chapter 1. Preface..................................................................................................................................................3
Chapter 2. Introduction............................................................................................................................................4
Chapter 3. Development Environment....................................................................................................................5
3.1. Sample Code Configuration.........................................................................................................................5
3.2. Target Sample Code Options .......................................................................................................................5
3.3. Host Application Software ............................................................................................................................5
Chapter 4. USB Stack (Target)................................................................................................................................6
4.1. Hardware Abstraction Layer.........................................................................................................................6
4.2. USBCore ......................................................................................................................................................7
4.3. Human Interface Device Class.....................................................................................................................8
4.4. Communication Device Class ......................................................................................................................9
4.5. Mass Storage Class...................................................................................................................................10
Chapter 5. Applicatio ns.........................................................................................................................................11
5.1. Introduction to Applications........................................................................................................................11
5.2. Human Interface Device Application ..........................................................................................................11
5.3. Communications Device Class Application................................................................................................13
5.4. Mass Storage Class Demonstration...........................................................................................................16
5.5. LibUSB .......................................................................................................................................................17
Chapter 6. Additional Information..........................................................................................................................19
ii

Chapter 1. Preface

Cautions
This document may be, wholly or partially, subject to change without notice. All rights reserved. No one is permitted to reproduce or duplicate, in any form, a part or this entire document without the written
permission of Renesas Technology Europe Limited.
Trademarks
All brand or product names used in this manual are trademarks or registered trademarks of their respective companies or organisations.
Copyright
© Renesas Technology Europe Ltd. 2007. All rights reserved. © Renesas Technology Corporation. 2007. All rights reserved. © Renesas Solutions Corporation. 2007. All rights reserved. Website:
Glossary
ADC Analog to Digital Converter USB Universal Serial Bus CPU Central Processing Unit DAC Digital to Analog Converter DMA Direct Memory Access E10A “E10A for Starter Kits” debug module FDT Flash Development Tool RSK Renesas Starter Kit
LED Light Emitting Diode LCD Liquid Crystal Display
http://www.renesas.com/
3

Chapter 2.Introduction

The RSK USB sample code provides a basis for a developer to add USB device functionality to a system. It includes sample applications for the three most common USB Device classes
Human Interface Device (HID)
Communication Device Class - Abstract Control Model (CDC-ACM)
Mass Storage Class (MSC)
In addition to the three defined USB classes a LibUSB sample is included. that a user application can utilise to access a USB device regardless of operating system. A sample using a Microsoft Windows XP host is provided.
The embedded software is available as source written in ANSI C and does not require an operating system. The host applications software is also available as source written for MS Windows using VisualC++. This manual describes the technical details of the RSK hardware. The Quick Start Guide and Tutorial Manual provide details of the software
installation and debugging environment.
Demo
HID
*
:-
LibUSB is an open source project with the aim of providing a library
CDC
Demo
MSC
Demo
LibUSB
Demo
USB Stack
Classes Samples
HID
CDC MSC
USB Core Driver
HAL
USB Hardware
Figure 1 - Embedded SW, including Layers of USB Stack
*
See specific sections for details. Tested with a USB Host PC running MS Windows XP SP2. HID and
LibUSB samples both include a PC Application.
4

Chapter 3.Development Environment

3.1.Sample Code Configuration

The Sample code is provided as a project generator with the RSK. To create the sample code project follow the instructions in the RSK Quick Start Guide.
When created the sample code will contain the source for both the Host and Target projects, including any configuration driver files.

3.2.Target Sample Code Options

When developing USB software it is useful to be able to get debug information out at runtime without stopping code from running such as when stepping in a debugger. All modules of the USB Stack software include debug messages that can be utilised in a system that supports printf. The sample Applications all support printf and the output is viewable via the serial port of the RSK. To view the serial output the following settings are required:
Baud: 19200. Data: 8 Bit. Parity: None. Stop Bits: 1. Flow: None. The level of debug message can be set using the #define VERBOSE_LEVEL. This is described in t he file u sb_com mon.h in the US BStack
directory. Note that a high level of debug messages can significantly slow down the system.

3.3.Host Application Software

To build the Microsoft Visual C++ Applications you will need to have the appropriate Windows Software Development Kit (SDK) and the Windows Driver Development Kit (DDK) installed. These kits provide access to the library functions to access USB devices and are available directly from Microsoft.
We have provided the links to the current locations for XP based downloads below however we cannot guarantee the suitability or accuracy of these links. Both must be installed to be able to build the application, we suggest installing the SDK first.
www.microsoft.com/downloads Windows SDK
Windows DDK
5

Chapter 4.USB Stack (Target)

The USB software is implemented in the form of a USB stack comprising of three layers. At the top of the stack are the USB Device Classes consisting of HID, CDC and MSC which are all described later. In the middle is a core layer (USBCore) that handles standard device requests. At the bottom is a hardware abstraction layer (HAL) that
provides a hardware independent API for the upper layers. This modular design means this software can be still be used even if developing a proprietary USB interface. For example a proprietary
module could be implemented by calling functions directly exposed by both the USBHAL API and USBCore API.

4.1.Hardware Abstraction Layer

The HAL is a hardware specific layer that provides a non-hardware specific API. The HAL supports the following transfer modes:
Control (Setup, Data IN/OUT, Status) Bulk (IN and OUT) Interrupt (IN)
Some HAL implementations may not be able to support all these modes but the H8SX1664 implementation does. Here is a list of the functions that make up the USBHAL API.
Name Description
USBHAL_Init Initialise the HAL. Register callback functions. If using the USB Core layer then this is done
automatically. USBHAL_Config_Get Get the current HAL configuration. USBHAL_Config_Set Set the current HAL configuration. USBHAL_Control_ACK Generate an ACK on the Control IN pipe. (Used following a setup packet) USBHAL_Control_IN Send data on the Control IN pipe. (Used following a setup packet) USBHAL_Control_OUT Receive data on the Control OUT pipe. (Used following a setup packet) USBHAL_Bulk_IN Send data on the Bulk IN pipe. USBHAL_Bulk_OUT Receive data on the Control OUT pipe. USBHAL_Interrupt_IN Send data on the Control IN pipe. USBHAL_Reset Reset this module. (Following an error). USBHAL_Control_Stall Stall the control pipe. (Used following a setup packet) USBHAL_Bulk_IN_Stall Stall the Bulk IN pipe. USBHAL_Bulk_OUT_Stall Stall the Bulk OUT pipe. USBHAL_Interrupt_IN_Stall Stall the Interrupt IN pipe. USBHALInterruptHandler The system must be setup so that this gets called when any USB Interrupt occurs.
The HAL module consists of the following files:-
usb_hal.c usb_hal.h. usb_common.h
6

4.2.USBCore

The USBCore layer handles standard USB requests common to all USB devices during the enumeration stage. This means that a developer can concentrate on any class or vendor specific implementation. The USBCore requires initialising with the descriptors specific to the device being implemented. It uses the USBHAL, which it initialises, to access the particular HW.
The following Get_Descriptor requests are handled:
Device Configuration String Language ID (Only a single language ID is supported and this is currently English)
Manufacturer Product Serial Number
The USBCDC API consists of a single function called ‘USBCORE_Init’. This initialises the USBCore and the HAL. In addition to passing device descriptors to this function it also requires call back functions for the following conditions:
A Setup packet has been received that this layer can’t handle. This enables a higher layer to handle class or vender specific requests. A Control Data Out has completed following a setup packet that is being handled by the layer above. The USB cable has been connected or disconnected. An unhandled error has occurred.
The HAL module consists of the following files:-
usb_core.c usb_core.h. usb_common.h
7
Loading...
+ 14 hidden pages