Embed Inc PIC 18F USB Framework
Last updated 22 Feb 2008
The Embed Inc PIC 18F USB Framework is a comprehensive set of code for
developing full speed USB devices using the PIC 18F USB-capable
parts. Features of the framework include:
- Driver for the PIC USB hardware written in assembler.
- Simple put-byte and get-byte application interface for each USB
endpoint in use. Additional control routines are also exported
depending on endpoint configuration.
- Hardware ping-pong buffering with triple software buffers for
each endpoint.
- Endpoints selection, transfer mode, and buffer size are defined
in a separate include file. The PIC hardware driver
automatically configures itself with assembly time logic to the
configuration specified in the include file.
- Separate endpoint 0 command processing module that handles system
enumeration requests and special requests from the private host
driver.
- Static enumeration data is defined in a separate include file to
simplify customization.
- No interrupts are used by the PIC USB routines, so can be used by
applications that require low interrupt latency. Instead of
interrupts, two routines must be called periodically by the
application, one for general USB service and the other for endpoint 0
command processing.
- Custom Windows kernel mode device driver.
- U1EX example PIC application that runs on the USBProg PIC programmer.
- Example U1EX low level host library.
- TEST_U1EX and U1EX_LIST example host applications.
- Built in capability to handle multiple compatible devices
connected to the USB. Applications can enumerate all devices,
and select a particular one using the user-settable name in each
device.
- Source code for all of the above except the Windows kernel mode
driver is included in the free distribution.
- Copyright that allows the PIC USB code to be used for personal
projects or evaluation without fee in most cases. See the
copyright notice at the start of each file for details.
To get the framework, go to the software downloads
page and install the PIC 18F USB Framework release. The
framework includes the U1EX PIC example application that runs on a USBProg instead of its normal
firmware, and the TEST_U1EX and U1EX_LIST host programs. All source
code is in the SOURCE > USB directory within the software installation
directory. The PIC source code uses the Embed Inc PIC development environment.
Some key files are listed below. See their comments or
documentation files for the details.
U1EX_USB.ASPIC
-
Low level driver for the PIC USB hardware. This driver uses
software triple buffering with hardware ping-pong buffering. It
exports simple put-byte and get-byte subroutines for application use,
along with additional control routines per endpoint depending on
configuration.
U1EX_USB.INS.ASPIC
-
Include file that defines the endpoints in use, their transfer modes, and
their buffer sizes. All the remaining code automatically configures
itself accordingly using assembly-time logic.
U1EX_USB0.ASPIC
-
Endpoint 0 command processor. Endpoint 0 is reserved for
communication with the operating system and the custom driver, and
includes the USB enumeration handshaking. This module is a clean
client of the low level USB driver in the USB module.
U1EX_USB0.INS.ASPIC
-
Include file used by the USB0 module to define the static data returned to
the host during enumeration.
U1EX_xxx.ASPIC
-
Other source modules of the U1EX example USB PIC application. This
application uses USB endpoint 1 to implement a bi-directional stream of
bytes for communicating with the host application.
U1EX_xxx.PAS
-
Host source code of the example library that provides basic I/O services
to the application level.
TEST_UIEX.EXE
-
Test program that provides a command line interface for communicating with
the U1EX example device. Individual bytes can be sent and received,
with some higher level commands and interpretation of the received byte
stream included. For example, the command LED ON turns
on the LED on the target unit.
U1EX_LIST
-
Program to enumerate all the U1EX devices connected to the USB.