AT90USBxxx Dual role demonstration with file system
Use of this program is subject to Atmel's End User License Agreement.
Please read file lic_page for copyright notice.
This embedded application source code illustrates how to implement a dual role application with the AT90USBxxx controller.
As the AT90USBxxx implements a device/host usb controller, the embedded application can operates in one of the following usb operating modes:
- USB device
- USB reduced host controller
This source code is usable with the following compilers:
- IAR Embedded Workbench (5.11A and higher)
- AVRGCC (WinAVR 20080411 and higher).
Support for other compilers may required modifications or attention for:
- compiler.h file
- special registers declaration file
- interrupt subroutines declarations
- V2.0.8
USB Device:
- Class MSC:
- Add MSC compliance with Linux 2.4 kernel
USB Host:
- Class MSC:
- Add read/write USB command for large block
Ushell:
- Add new command to perform transfer
- Fix and enable history of Ushell
FileSystem:
- Fix bug in routine which check the end of cluster list
- Fix format FAT32
- Improve format time
- V2.0.7
MAJOR changes :
- Add feature "firmware upgrade via U-Disk" (for IAR compiler only), See AppNote AVR916
- New ushell
Other changes
USB DEVICE Stack:
- Class MSC:
- Improve MSC compliance
- Add write Protect Management under MAC OS
- Detach behavior in mode self power
USB HOST Stack:
- Improve Device MSC detection
- Improve Write protection detection on device MSC
- V2.0.6
USB Stack - Host mode :
- improve behavior of MS driver with HUB
- Update MS driver to support the write mode with sector sizes other than 512 bytes (see USB_SUPPORT_MS_SECTOR_WR_MAX)
- Fix read routine with a U-Disk sector !=512B
USB Stack - Device mode :
- Fix bug in MSC driver to support Vista and Windows Seven
File System:
- V2.0.5
USB Stack:
- Fix bug on stall management with dual banks
- Improve device disconnection detection in USB host mode
- Fix bug about back drive voltage on D+ after VBus disconnect (USB Certification)
- New MS driver for USB host:
- support multi LUN like multi card reader
- fix bug in case of different plug
- improve disconnection detection
- support disk with sector size different of 512B (read only)
File System:
- Fix bug on feature get free space on FAT32
- Fix bug in case of memory full during a path creation
- Fix bug in case of mode "nav_single" (file or dir) enable
- Add cmd, get partition size
- V2.0.4
USB Stack :
- improve USB chap9 & MSC compliance
- Fix USB constant about Device Status
- Add a new sub class for MassStorage
New watchdog driver
DataFlash driver :
- Fix bug in I/O initialization routine
File System :
- Split write command during copy file to support bad U-Disk
- Update short name creation routine for more compliant with FAT32 white paper
- improve ushell_task.c behavior
- V2.0.3
- Move VBus interrupt to VBus pooling
- V2.0.2
Improvemnt:
- Add three possibilities for SN on USB (No SN/Constant SN/Unique SN)
- Add dual bank in USB host mode
- Add the switch USB mode by software (no use HW reset)
- Improvement ushell task
- Create a generic copy routine
- V2.0.1
Fix:
- write command on host ms (Remove SOF flag test in host_write_10_ram) New:
- Add USBKEY driver in package
- Add modify generic defines from board driver
- Add USB Write Protection management on DataFlash
- V2.0.0
By default the demonstration is preconfigured for dual role USB application. It means that the code generated allows to operate as a device or a host depending on the USB ID pin:
- Attached to a mini B plug (ID pin unconnected) the application will be used in the device operating mode. Thus the application can be connected to a system host (PC) to operate as USB Device Mass Storage (removable drive).
- Attached to a mini A plug (ID pin tied to ground) the application operates in reduced host mode. This mode allows to connect a USB mass storage device
- In both modes, the STK525 can be connected to a serial terminal, where the user can acess a simple command line interperter (ushell) to perform file system access. To use the simple shell application, connect the STK525 to a serial terminal emulator (like Hyperterminal under windows systems). The serial port settings are:
- 57600 bauds
- 8bits data, no parity
- no flow control To use the application, the SK525 should be configured to be self powered (see STK525 hardware manual).
Connect the STK525 to a PC host system with a miniB (STK525 side) to plugA (PC host) cable
- A removable drive allows to read/write files on the on-board data flash memory.
- Connected to a USB Mass Storage Device (MSD), files can be exchange with the on-board data flash disk and the MSD.
- The right direction of the joystick allows to read the content of a MSD "OUT" directory and to write it to an on-board data flash "IN" directory.
- The left direction of the joystick allows to write the content of an on-board data flash "OUT" directory to a MSD "IN" directory.
Connected to a serial terminal emulator the Usheel command line interpreter allows to:
- Navigate in the file system (both on-board dataflash and a USB mass storage device connected to the USB host interface). The following commands are supported:
- a: , b: ... goto selected drive
- cd dirname
- ls
- touch filename
- append filename
- mark: bookmark current directory
- cp filename: copy filename to bookmark
- rm filename: erase file or empty directory
- format drivename, with drivename: a, b...
- deltree dirname
- cat filename
- cd..
- mount disk(a,b,..)
- mkdir dirname
- disk: get number of drives
- goto: goto bookmark
- df: get free space information
- cat filename
- rm*: rm *
- Get information about the connected device and misc commands
- lsusb
- suspend: suspend USB bus activity
- resume: resume USB bus activity
- reboot: reset the application
For more information about File System module see File System
As illustrated in the figure bellow, the application entry point is located is the main.c file. The main function first performs the initialization of a scheduler module and then runs it in an infinite loop. The scheduler is a simple infinite loop calling all its tasks defined in the conf_scheduler.h file. No real time schedule is performed, when a task ends, the scheduler calls the next task defined in the configuration file (conf_scheduler.h).
The sample dual role application is based on several different tasks:
- The usb_task (usb_task.c associated source file), is the task performing the USB low level enumeration process in device or host mode. Once this task has detected that the usb connection is fully operationnal, it updates different status flags that can be check within the high level application tasks.
- The storage task performs SCSI bulk only protocol decoding and performs flash memory access.
- The host_ms_task manages the Device Mass Storage interfaceconnected
- The ushell_task manages the terminal commands process
Generated on Wed Sep 23 09:37:09 2009 for ATMEL by
1.5.3