#include <usb.h>
List of all members.
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:
- Keep execution time as low as possible, to avoid increasing interrupt latency for other interrupts
- Do not call any kernel service that has not been designed to run from within an IRQ. For example, do not printf, create threads or sleep
- Do not allow C++ exceptions to propagate through these callbacks
- Never call these callback member functions yourself, not even when interrupts are disabled.
Constructor & Destructor Documentation
mxusb::Callbacks::~Callbacks |
( |
|
) |
[virtual] |
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.
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: