USBwiz User Manual Rev.2.27 Date: April 20, 2009 User Manual Document Information Information Description Abstract This document covers complete information about USBwiz, specifications, tutorials, and references.
GHI Electronics,LLC USBwiz User Manual Table of Contents Table of Contents 1.Introduction....................................................................................................................................................3 1.1.Example applications.............................................................................................................................3 1.2.Key features........................................................................................................
GHI Electronics,LLC USBwiz User Manual Introduction 1. Introduction USBwiz is an optimized solution for easy interfacing almost any embedded system to USB hosting with a vast variety of USB drivers such as Printer Driver, HID Driver (mice, keyboards and joysticks), CDC Driver (modems, cellphone), USB-to-Serial device Drivers ( FTDI, Silabs, Prolific) and Mass Storage Driver (Thumb Drives, memory readers, ..
GHI Electronics,LLC USBwiz User Manual Introduction ● ● ● ● ● 40 to 50 mA, power consumption Single supply 3.3V 5V tolerant I/O pins -40˚C to +85˚C temperature operating range Lead free 1.3. USBwiz Circuit Boards USBwiz-OEM: USBwiz-OEM board contains USBwiz chipset and the other needed circuitry. key features: ● Fully assembled and tested ● Can be mounted to almost any case using 90 degrees brackets ● Standard .
GHI Electronics,LLC USBwiz User Manual Introduction Thanks to USBwiz chip, through RS232, UART, SPI or I2C interfaces you can access many USB devices, including USB memory drives. Also, you can read/write files from the any formatted SD or MMC card. The board comes with the D-SUB25 connector to access all USBwiz's functionality. Look at the schematics for more details.
GHI Electronics,LLC USBwiz User Manual USBwiz Architecture 2. USBwiz Architecture USBwiz is a single chip that performs all work needed for USB hosting and FAT file system. USBwiz connects to a USB host (ISP1160) on one side and to your product on the other side (PIC, AVR…etc.) Using simple commands over I2C, SPI or UART (serial), you can use almost any USB device on the market. If the device falls under a supported USB class, no USB knowledge is necessary, USBwiz does the work.
GHI Electronics,LLC USBwiz User Manual USBwiz Architecture 2.1. Block Diagram SD/MMC SPI Dirver FAT File System Controller Master System AVR, PIC ...etc UART,SPI or I2C Human-friendly Commander SPI SD/MMC USB-to-Serial Driver USB port0 ISP1160 CDC Driver Data bus USB Host Controller Printer Driver USB Host driver HID Driver USB Driver Mass Storage Driver Mass Storage Device HID...Keyboard, mouse,,joystick..etc USB to Serial FTDI,Silabs,Prolific.
GHI Electronics,LLC USBwiz User Manual USBwiz Architecture 2.3. Commander USBwiz uses LPC2134 UART, SPI or I2C to let the user communicate with boot loader, Commander. All commands are entered in ASCII characters. We chose to use ASCII to simplify troubleshooting and to allow humans to enter commands easily. Main function of Commander is to provide user with simple tool to control USBwiz to get the full use of its functions. 2.4. FAT File System USBwiz can connect to two kinds of storage media types.
GHI Electronics,LLC USBwiz User Manual USBwiz Architecture 2.6. Supported USB Client Classes The USB organization defines many classes for different USB devices. This means all USB devices of a certain type; keyboards for example, should run the same way. This is the reason why you do not need to install drivers when connecting a keyboard to your PC. Your operating system includes the “USB class drivers”. USBwiz comes with many USB class drivers.
GHI Electronics,LLC USBwiz User Manual Pin-Out and Description 3. Pin-Out and Description The following table includes brief description about USBwiz chip pinouts: Pin Name Description 1 UH_RD# 2 3 4 5 6 7 8 9 10 11 12 13 UH_WR# RTXC1 D11 RTXC2 VSS V3A D10 MISC UH_RESET# A0 D9 ACTIVITY_LED 14 15 16 17 18 19 MISC1 SD_DET D8 SD_CS# VSS UART_TX Read strobe. Used for USB host chip (must have a pull-up resistor on this pin or UH_CS#) Write strobe.
GHI Electronics,LLC USBwiz User Manual Pin-Out and Description Pin 22 23 24 25 26 27 28 Name I2C_SCL VCC RTCK/DBG# VSS I2C_SDA MMC/SD_SCK MODE0 29 MMC/SD_MISO 30 31 32 MMC/SD_MOSI SD_WP MODE1 33 34 35 36 37 38 39 40 41 D0 D1 D2 D15 D3 D4 D5 D14 D6/BL# 42 43 44 45 46 47 48 49 50 51 52 53 VSS V3 D13 D7 UH_IRQ SPI_SCK D12 VBAT VSS V3 TMS SPI_MISO Rev.2.27 Description The SCL line for I2C bus 3.
GHI Electronics,LLC USBwiz User Manual Pin-Out and Description Pin Name Description 54 UART_RTS SPI_MOSI In UART mode, this pin is Ready To Send Signal. In SPI mode, this pin is data input to USBwiz on SPI bus. 55 56 57 UART_CTS SPI_SSEL# TCK USBwiz_RESET# 58 UH_CS# 59 60 61 62 63 64 VSSA TDI XTAL2 XTAL1 VREF TDO In UART mode, this pin is Clear To Send Signal. Select line for USBwiz in SPI mode Leave unconnected Reset signal for USBwiz. USBwiz reset is required after power up. Chip Select.
GHI Electronics,LLC USBwiz User Manual Communication Interface selection 4. Communication Interface selection 4.1. Selecting an Interface USBwiz uses UART, SPI or I2C to communicate with any external microcontroller. At power up, USBwiz samples MODE0 and MODE1 to determine what interface to use. The MODE pins have a built in pull up resistors to default the pin to 1. Do not connect these pins to VCC, leave unconnected for 1 or connect to GND for 0.
GHI Electronics,LLC USBwiz User Manual Communication Interface selection pins for handshaking. SPI_SSEL, SPI_SCK, SPI_MISO, and SPI_MOSI are the standard SPI pins where SSEL is used for Slave Select, SCK is the Serial Clock (7Mhz running and 1.75Mhz for boot loader,) MISO is the data line going from USBwiz to your microcontroller, and MOSI is the data line going from your microcontroller to USBwiz. The other two pins are used for handshaking, they are DATARDY and BUSY.
GHI Electronics,LLC USBwiz User Manual Communication Interface selection ● SCK is idle high ● SCK is lower that 7Mhz. (1.75 in boot loader) ● Data is shifted out MSB first ● Data is shifted on the rising edge For further details and timing diagrams, consult LPC2134 datasheet and manual from NXP Semiconductor. 4.4. I2C Interface Mode Four pins are needed for I2C communication. The USER_I2C_SCL and USER_I2C_SDA are the two I2C bus lines.
GHI Electronics,LLC USBwiz User Manual Getting Started with USBwiz 5. Getting Started with USBwiz The following chapter give simple steps to get USBwiz working for first time user and that is through UART interface. All you need: ● USBwiz OEM board ● RS232 adapter connected to UART Tx/Rx and connected to PC COMx ● PC COMx access through a terminal program ● USBwiz latest firmware Step-by-Step: 1. confirm that all hardware connections are made: Rev.2.
GHI Electronics,LLC USBwiz User Manual Getting Started with USBwiz Other options are using USB to UART modules or cables. You will have a virtual COM port on your PC that communicates with USBwiz. Examples are UM232R and TTL-232R from FTDI. 2. Open COM port using a terminal program, for example TeraTerm, and ensure the baud rate is 9600, 8 data bits, 1 stop bit and no handshaking. 3. Select to receive a line end with the line feeds (LF+CR), because USBwiz only sends CR.
GHI Electronics,LLC USBwiz User Manual Getting Started with USBwiz 4. Reset the chip and you will get the GHI electronics banner similar to the following: GHI Electronics, LLC -----------------------------Boot Loader x.xx USBwiz(TM) x.xx !00 5. To update firmware, please refer to boot loader section in this document. Rev.2.27 Page 18 of 64 www.ghielectronics.
GHI Electronics,LLC USBwiz User Manual Getting Started with USBwiz μPICFAT™ Development Board For even easier and faster startup, GHI offers a development system for μALFAT and USBwiz. This is the component that provides power and communication to μALFAT/USBwiz. It also provides the serial interface to your computer, and contains the PIC micro controller PIC18F453 that will be used to interface to μALFAT/USBwiz. Complete with a programming port for direct interface to the ICD 2™ programmer.
GHI Electronics,LLC USBwiz User Manual 1. USBwiz Functions 6. 1. USBwiz Functions 6.1. Commander The commands and response in USBwiz are made in a way where they can be understood and read by a human and can be easily parsed by any simple 8-bit micro. Each command is 2 characters. Some commands take parameters and others don’t. For example, VR command doesn’t take any parameters and it returns the version number. On the other hand, MD requires parameter to run.
GHI Electronics,LLC USBwiz User Manual 1. USBwiz Functions MD USBWIZ CD USBWIZ Create “USBWIZ” folder Change the current folder access to “USBWIZ” folder Files USBwiz allows you to open up to 4 files at the same time using file handles. This is not how many files USBwiz can open on a drive. USBwiz can open thousand of files same as your PC. Handles are used for fast access to a file. If a user needs to log data to 2 files at the same time, “VOLTAGE.LOG” and “CURRENT.LOG” file handles become very useful.
GHI Electronics,LLC USBwiz User Manual 1. USBwiz Functions Keyboard Most keyboards return 8 bytes in the HID report which are decoded as follows: First byte is the modifier byte: (When the bit is set, the associated button is pressed) Modifier Key Left CTRL Left SHIFT Left ALT Left GUI Right CTRL Right SHIFT Right ALT Right GUI Bit Order 0 1 2 3 4 5 6 7 Key array bytes follows with each byte represent a pressed key. Thus, several pressed keys can be reported at the same time.
GHI Electronics,LLC USBwiz User Manual 1.
GHI Electronics,LLC USBwiz User Manual 1.
GHI Electronics,LLC USBwiz User Manual 1. USBwiz Functions 7A 7B 7C 7D 7E 7F 80 81 82 83 84 85 86 8A 8B 8C 8D 8E 8F 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F A0 A1 A2 A3 A4 A5-CF B0 B1 B2 B3 B4 B5 B6 B7 Rev.2.
GHI Electronics,LLC USBwiz User Manual 1.
GHI Electronics,LLC USBwiz User Manual 1. USBwiz Functions Example: This example is taken from USB HID specifications.
GHI Electronics,LLC USBwiz User Manual 1. USBwiz Functions 6.5. USB Printers USBwiz Printer driver support those that have interface with unidirectional protocol. The way USB printers work is very similar to Parallel port printers. But instead of the data going over the Parallel port, it is transferred over USB. This means that the application needs to know what data/scripts to be sent to the printer.
GHI Electronics,LLC USBwiz User Manual 1. USBwiz Functions UP 0 Now you can preform any printer commands, such as reset. PR 0 The actual print command PP, will accept up to 255 bytes of data for every transfer. You can safely call the PP more than once. PP 0>4 Get Printer Status Command PS is used to Get Printer Standard Status Byte which is identical to status byte that is usually returned from Parallel Port printers. 6.6. USB Serial Devices USBwiz supports many serial USB devices.
GHI Electronics,LLC USBwiz User Manual 1.
GHI Electronics,LLC USBwiz User Manual 1.
GHI Electronics,LLC USBwiz User Manual 1. USBwiz Functions Rev.2.27 Page 32 of 64 www.ghielectronics.
GHI Electronics,LLC USBwiz User Manual USBwiz Command Set 7. USBwiz Command Set All commands below are entered in ASCII. We choose to use ASCII to simplify troubleshooting and to allow humans to enter commands easily. A special case is when accessing the data inside or outside a file. When writing/reading to/from a file or USB Pipe, USBwiz will use any kind of data. Basically, what you send is what goes on the file. It doesn’t have to be ASCII.
GHI Electronics,LLC USBwiz User Manual USBwiz Command Set Command Description Command Description ZF Resize File DF Delete File IF Find File or Folder ND Rename File or Folder UH Register USB Human Interface Device HR Read HID Report UP Register USB Printer PR Reset USB Printer PS Get USB Printer Status PP Send Data to USB Printer to print US Register Serial Communication Device SR Read Serial Device SW Write to Serial Device EV Enable Events SK Store Key CK Check Key T
GHI Electronics,LLC USBwiz User Manual USBwiz Command Set further commands. ● Some commands have multiple error codes !xx, usually, the first error code denotes the command is accepted and then it is processed. Another error code is sent when the command has finished processing successfully.
GHI Electronics,LLC USBwiz User Manual USBwiz Command Set IT - Initialize Real Time Clock USBwiz has a built in real time clock that is used to save the date on the created files. Users need to specify if USBwiz will be running the RTC using the same oscillator as USBwiz or separate 32Khz oscillator and a battery. The advantage of running the RTC on a 32Khz oscillator and battery is that it will not loose the time when losing the main power source of USBwiz.
GHI Electronics,LLC USBwiz User Manual USBwiz Command Set Example 1 Example 2 GTF !00 01/20/2006-06:21:04 !00 GTX !00 $34210000 !00 Get time in formatted ASCII format. Get time in DWORD HEX. VR - Get Version Number It prints the version number of USBwiz firmware. Note that this version is not same or related to the version number of the boot loader nor the OEM boards we offer. Format Example VR M Major number USBwizM.
GHI Electronics,LLC USBwiz User Manual USBwiz Command Set EE - Enable/Disable Echo To echo the sent data to USBwiz. Format EEh !00 h can be 0 to disable echo and 1 to enable echo Example EE1 !00 Enables echo RS - Read Sector Format Example RSmsssssss !00 512 Bytes is returned in HEX mode and (512*2 in ASCII mode) !00 RSH0 Read Sector from the current File System Media m Returned data mode. H for HEX and A for ASCII.
GHI Electronics,LLC USBwiz User Manual USBwiz Command Set Format Example FMd !00 $mm !00 FMd>l Mount File System for device d d can be S for SD, 0 for USB 0 or 1 for USB 1 mm Max available LUN on device, ($00) in most cases. Mount File System for device d and LUN l FM d>>2 Mount File system on the second primary partition of device d.
GHI Electronics,LLC USBwiz User Manual USBwiz Command Set UM - Register USB Mass Storage USB Memory register command. Use it in case you need to read or write sectors from a USB memory that doesn't have FAT file system. This command is not needed if FM command is used.
GHI Electronics,LLC USBwiz User Manual USBwiz Command Set NF - Get Next Directory Entry This command will print out the Directory Entry “File or Folder” and increments the Files and Folders list pointer. Format Example NF !00 NNNNNNNN.EEEAA ssssssss !00 NF !00 TEST0001.TXT00 0000FE23 !00 NF !00 TEST0002.
GHI Electronics,LLC USBwiz User Manual USBwiz Command Set subdirectories. Format Example RDfoldername !00 RDMYFOLDER !00 Remove the folder with name MYFOLDER OF - Open a file for read, write or append To open a file for read, write or append in the current Folder, use OF command. The command require a file handle and the access mode. Open Modes are: ● ‘R’ Open for read, requires the file to already exist in the current media and the current accessed folder.
GHI Electronics,LLC USBwiz User Manual USBwiz Command Set CF - Close File Handle This command issues a flush file (FF – Command) automatically and then closes the file handle. Afterwards, the handle will available for future use. Format CFn !00 Close File handle n RF - Read from File After opening a file, any amount of data can be read using this command. To read more data, send another RF command and so on.
GHI Electronics,LLC USBwiz User Manual USBwiz Command Set all of them must be sent; if an error occurs while writing, USBwiz still expects all bytes before producing the final error code. If any data is written to a file, the file must be flushed (FF command) or closed (CF command) when done. Otherwise, the file and/or the file system might get corrupted.
GHI Electronics,LLC USBwiz User Manual USBwiz Command Set and the other for write, this command allows copying data from a file to another even if they were opened in different storage media devices.
GHI Electronics,LLC USBwiz User Manual USBwiz Command Set PF - Seek File This command changes the file pointer position. File must be opened in read mode. Format Example PFn>ssssssss !00 PF1>10 !00 n File Handle ssssssss HEX DWORD new position Set file pointer at the 16th byte in file FP - Get Current File Pointer Position This command gets the current sector address and the position in that sector of file pointer. File must be opened in read mode.
GHI Electronics,LLC USBwiz User Manual USBwiz Command Set Example IFTEST.TXT !00 $00000F34$00$34210000 !00 File has been found and its size is 3892 bytes with no special attributes. Last modification time is 00:00:00 date is 1/1/2006 * File Attributes are one byte Standard Attribute Structure in FAT system. 7 6 Reserved 5 Archive 4 Folder 3 Volume ID 2 System 1 Hidden 0 Read Only ** Time and Date structure is a 32-bits standard structure used in FAT system.
GHI Electronics,LLC USBwiz User Manual USBwiz Command Set HR - Read HID Report This command read HID Report data. It also returns HID Report Size. Format HRp !00 $nn Report’s data !00 p the port number nn HID Report Size Report data are in ASCII Hexadecimal UP - Register USB Printer USBwiz has an internal p0rinter driver that can support up to 2 printers. This command must be used before accessing printers.
GHI Electronics,LLC USBwiz User Manual USBwiz Command Set PP - Send Data to USB Printer to print Format Example PPp>ss !00 Data to Print !00 PP1>C !00 HelloWorld! !00 p is the USB port number ss data size, max of 255 bytes Send C bytes to USB port 1 US - Register Serial Communication Device USBwiz has an internal Serial Driver. This command must be used before accessing these devices.
GHI Electronics,LLC USBwiz User Manual USBwiz Command Set Example Data to device !00 SW0>3 !00 AT !00 Write 3 bytes to serial device on port 0 Send AT followed by carriage return (0x0D) EV - Enable Events USBwiz can detect SD card and USB devices insert and removal. All events are returned with % symbol proceeding the event number. Appendix lists all events.
GHI Electronics,LLC USBwiz User Manual USBwiz Command Set CK - Check Key Checking the stored key: 1. The user application will generate a random 8 bytes and then encrypt them using XTEA algorithm against the "secret key" that was used above 2. The user application will keep the original values and will send the new encrypted values to USBwiz to the Check Key command"CK xxxxxxxxxxxxxxxx" 3. USBwiz will decrypt the incoming data using the "secret key” and send it back to the application. 4.
GHI Electronics,LLC USBwiz User Manual USBwiz Command Set TF - Print File This command transfers a file from a connected storage media to a printer. This commands simply reads the file contents and send them to the registered printer. Format TFP>H>FileName !00 !00 Example TF0>0>PIC.PRN !00 !00 P: Register printer port number H: A free file handle to use FileName: Name of the file to transfer.
GHI Electronics,LLC USBwiz User Manual USBwiz Command Set !00 assign handle number 0 to it. UR - Release USB Device Handle (Raw Command) Releases the device handle, so it can be used by other connected/re-connected devices. Format Example URh !00 UR0 !00 h USB device handle 0, 1, 2 Release handle 0 LD - Load USB Descriptor (Raw Command) Loads a device/configuration descriptor into USBwiz internal buffer.
GHI Electronics,LLC USBwiz User Manual USBwiz Command Set SC - Set Configuration (Raw Command) Set USB configuration. Format Example SCh>n h USB device handle 0, 1, 2 !00 n Configuration number. First configuration is 1 not 0. 0 is not configured. SC0>1 !00 FI - Find Interface (Raw Command) Searches for an interface in the loaded configuration descriptor(LD command) in the internal buffer with a specific criteria.
GHI Electronics,LLC USBwiz User Manual USBwiz Command Set Example FE0302 !00 $07 07058103 04000A !00 00 Setup 01 Output 02 Input 07 is fixed Find an endpoint in the previous interface with interrupt transfer and input direction. FD - Find Descriptor (Raw Command) Searches for a descriptor in the loaded configuration descriptor(LD command) in the internal buffer with a specific criteria.
GHI Electronics,LLC USBwiz User Manual USBwiz Command Set Example SSh>ttrrvvvviiiilll !00 USBwiz sends the received data from USB device !00 SSh>ttrrvvvviiiilll !00 USBwiz reads data from the user !00 SS0>0806010000000012 !00 USBwiz reads data from the user !00 In Data-stage Out Data-stage OP - Open USB Pipe (Raw Command) This command opens a pipe to the found endpoint (FE command).
GHI Electronics,LLC USBwiz User Manual USBwiz Command Set WP - Write Pipe (Raw Command) Format Example Rev.2.27 WPp>ss !00 User sends ss bytes !00 WP1>10 !00 1234567890abc def !00 p Pipe handle ss size of data to write Write 0x10 bytes to pipe 1 Page 57 of 64 www.ghielectronics.
GHI Electronics,LLC USBwiz User Manual USBwiz Boot Loader 8. USBwiz Boot Loader 8.1. General Description The boot loader is used to update the firmware of USBwiz. The firmware is the code that sits inside the USBwiz chip and does all the work. When there is a new firmware release, you can simply download the file from our website and, using simple commands, you can load it on USBwiz. At power up, USBwiz boot loader takes control and checks the mode pins (MODE0 and MODE1).
GHI Electronics,LLC USBwiz User Manual USBwiz Boot Loader version number of the boot loader may not match the version number of USBwiz. Important Note: USBwiz chips come with no firmware on them. 8.3. Firmware Update The easiest way to update USBwiz is by placing the new firmware on a SD card or a USB mass storage device. Then, connect the media to USBwiz and send the boot loader (BL) command to load the new firmware.
GHI Electronics,LLC USBwiz User Manual Error Codes Error Codes Value (HEX) 00 01 02 03 04 05 09 10 11 12 13 14 15 16 21 22 23 24 25 31 32 33 34 35 40 41 42 43 44 45 46 47 48 49 4A 4B 4C Rev.2.27 Description Operation has passed successfully. Failed to read sector from SD/MMC media. For example, The media was removed Failed to write sector to SD/MMC media. For example, The media was removed Failed to erase sector on SD/MMC media. For example, The media was removed Failed to initialize SD/MMC media.
GHI Electronics,LLC USBwiz User Manual Error Codes Value (HEX) 4D 4E 4F 50 51 52 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 81 82 83 84 85 86 90 Rev.2.27 Description This is not an error. Indicated the end of the file/folder list. Failed to read valid data from media. Try to format the media on PC* File handle is already used. Should close it first. Reached the end of the file. New size can't be zero. The new file name already exists.
GHI Electronics,LLC USBwiz User Manual Error Codes Value (HEX) Description 91 USB Mass Storage device uses unsupported protocol. 92 USB Mass Storage device uses unsupported subclass. 93 USB Mass Storage command failed* 94 USB Mass Storage command failed* 95 USB Mass Storage device not found. A1 Unknown command. A2 Command string is too long* A3 Invalid name. A4 Invalid number. A5 Failed to complete the write request. A7 Failed to initialize the media. A8 The requested command has incorrect parameters.
GHI Electronics,LLC USBwiz User Manual USBwiz Events USBwiz Events Value (HEX) Description 01 SD inserted. 02 SD removed. 20 Failed to initialize ISP1160. 30 USB port 0 device inserted. 31 USB port 0 device removed. 32 USB port 1 device inserted. 33 USB port 1 device removed. Rev.2.27 Page 63 of 64 www.ghielectronics.
GHI Electronics,LLC USBwiz User Manual DISCLAIMER DISCLAIMER IN NO EVENT SHALL GHI ELECTRONICS, LLC.