Public Member Functions | Static Public Member Functions

mxusb::Callbacks Class Reference

#include <usb.h>

List of all members.

Public Member Functions

virtual void IRQendpoint (unsigned char epNum, Endpoint::Direction dir)
virtual void IRQstateChanged ()
virtual void IRQconfigurationChanged ()
virtual void IRQsuspend ()
virtual void IRQresume ()
virtual void IRQreset ()
virtual ~Callbacks ()

Static Public Member Functions

static void setCallbacks (Callbacks *callback)
static CallbacksIRQgetCallbacks ()

Detailed Description

By making a class that derives from this it is possible to handle USB events. Override methods for the events you need to handle. These callbacks are called from the USB interrupt handler, and therefore are subject to these restrictions:


Constructor & Destructor Documentation

mxusb::Callbacks::~Callbacks (  )  [virtual]

Destructor


Member Function Documentation

void mxusb::Callbacks::IRQconfigurationChanged (  )  [virtual]

This callback is called right before device configuration changes. It is useful for devices with multiple configurations that can be changed on the fly by the host. To get the new configuration number it is possible to call DeviceState::IRQgetConfiguration(). Don't cause context switches from here, as this callback is not always called from within an interrupt routine.

void mxusb::Callbacks::IRQendpoint ( unsigned char  epNum,
Endpoint::Direction  dir 
) [virtual]

Called when an endpoint has completed a transfer (tx or rx, depending on configuration). You can cause a context switch from within this callback, by calling Scheduler::IRQfindNextThread();

Parameters:
epNum endpoint number
dir direction, endpoint direction
static Callbacks* mxusb::Callbacks::IRQgetCallbacks (  )  [inline, static]

Must be called with interrupts disabled. When interrupts are re-enabled a thread can call setCallbacks(), so caching the result is not allowed.

Returns:
the current callbacks class registered for USB event handling
void mxusb::Callbacks::IRQreset (  )  [virtual]

Called when the hosts resets the device. You can cause a context switch from within this callback, by calling Scheduler::IRQfindNextThread();

void mxusb::Callbacks::IRQresume (  )  [virtual]

Called when the host resumes the device. You can cause a context switch from within this callback, by calling Scheduler::IRQfindNextThread();

void mxusb::Callbacks::IRQstateChanged (  )  [virtual]

Called every time the device state changes, for example from DeviceState::DEFAULT to DeviceState::ADDRESS. Don't cause context switches from here, as this callback is not always called from within an interrupt routine.

void mxusb::Callbacks::IRQsuspend (  )  [virtual]

Called when the host suspends the device. You can cause a context switch from within this callback, by calling Scheduler::IRQfindNextThread();

void mxusb::Callbacks::setCallbacks ( Callbacks callback  )  [static]

Set callbacks for USB events.

Parameters:
callback an instance of a class that derives from Callbacks, or NULL to disable the callbacks. If a previous callback was set, the object will not be deleted, so if it was allocated on the heap, user code is responsible for object deallocation.

The documentation for this class was generated from the following files: