USB EndPoint 0

The file UsbBase.fth contains an (almost) hardware independent USB code base. The hardware layer files, UsbHwxxxx.fth provide a standard interface that isolates hardware from the base layer. Class drivers such as MscDrv.fth should be compiled after the core layer and can reference the hardware layer. After the class files have been compiled, compile UsbEP0.fth, which contains the USB control and initialisation code using endpoint 0.

Setup operations

: RTD?          \ -- flag
Is this a request to the device? If so return true.

: RTI?          \ -- flag
Is this a request to the device? If so return true.

: doEP0SuStd    \ --
Handle the EP0 REQUEST_TYPE_STANDARD setup operations.

: doEP0ClassRTI \ --
Handle the class REQUEST_TO_INTERFACE operations.

: doEP0SuClass  \ --
Handle the EP0 REQUEST_TYPE_CLASS setup operations.

Despatch

: doEP0setup    \ --
Perform the EP0 SETUP operations.

: doEP0out      \ --
Perform the EP0 OUT (to device) operations.

: doEP0in       \ --
Perform the EP0 IN (to host) operations.

: doEP0         \ event --
The despatcher for the actions of endpoint 0.

USB system initialisation

As of November 2010, start up of the USB code is performed by startUSBsys ( -- ), which can be found in UsbEP0.fth. startUSBsys uses conditional compilation to produce a start up word that initialises all the required classes. Please use startUSBsys as your USB start up word from now on.

: StartCDC      \ --
Start the USB and CDC systems. Used for CDC only devices. NOW OBSOLETE - see startUSBsys below.

: StartMSC      \ --
Initialise MSC and start USB. NOW OBSOLETE - see startUSBsys below.

: StartCompo    \ --
Start the USB CDC and MSC systems. Used for composite devices. NOW OBSOLETE - see startUSBsys below.

: startUSBsys   \ --
Initialise all the selected USB components and then start the USB connection.