E.6.3 cusbiothread class, E.6.4 cusbioreaderclass, E.6.5 cusbiowriter class – Motorola USB08 User Manual

Page 222: E.6.3, Cusbiothread class, E.6.4, Cusbioreaderclass, E.6.5, Cusbiowriter class

Advertising
background image

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 output operations on a
pipe. It includes functions that are used to start and stop the worker
thread.

The

CUsbIoThread

class does not implement the thread’s 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 native 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 sends Read requests to
the pipe. The thread’s 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 requests to
the pipe. The thread’s main routine gets a buffer from an internal buffer
pool and calls the virtual member function

ProcessBuffer

to fill the

Advertising