Designer Reference Manual USB08 Evaluation Board
222 Universal USB Device Driver (USBIO) MOTOROLA
Universal USB Device Driver (USBIO)
E.6.3 CUsbIoThread Class
The class CUsbIoThread provides basic functions needed to
implement a worker thread that performs input or ou tput ope rations on a
pipe. It includes functions that are used to start and stop the worker
thread.
The CUsbIoThread class does not implement the threads main
routine. This has to be done in a derived class. Thus, CUsbIoThread is
an universal base class that simplifies the implementation of a worker
thread that performs I/O operations on a pipe.
NOTE: The worker thread created by CUsbIoThread is a nati ve system thread.
That means it cannot be used to class MFC (Microsoft Foundation
Classes) functions. It is necessary to use PostMessage,
SendMessage or some other communication mechanism to switch over
to MFC-aware threads.
E.6.4 CUsbIoReaderClass
The class CUsbIoReader extends the CUsbIoThread class by a
specific worker thread routine that continuously send s Read req uests to
the pipe. The threads main routine gets buffers from an internal buffer
pool and submits them to the pipe using the Read function of the
CUsbIoPipe class. After all buffers are submitted the routine waits for
the first pending buffer to complete. If a buffer is completed by the
USBIO driver the virtual member function ProcessData is called with
this buffer. Within this function the data received from the pipe should be
processed. The ProcessData function has to be implemented by a
class that is derived from CUsbIoReader. After that, the buffer is put
back to the pool and the main loop is stated from the beginning.
E.6.5 CUsbIoWriter Class
The class CUsbIoWriter extends the CUsbIoThread class by a
specific worker thread routine that continuously sends Write reque sts to
the pipe. The threads main routine gets a buffer from an internal buffer
pool and calls the virtual member function ProcessBuffer to fill the