Public Member Functions | Static Public Member Functions

mxusb::EndpointZeroCallbacks Class Reference

#include <ep0.h>

Inherited by mxusb::DefaultEndpointZeroCallbacks.

List of all members.

Public Member Functions

virtual bool IRQsetup (const Setup *setup)=0
virtual bool IRQendOfOutDataStage (const Setup *setup)
virtual ~EndpointZeroCallbacks ()

Static Public Member Functions

static void IRQsetDataBuffer (unsigned char *data)
static void setCallbacks (EndpointZeroCallbacks *callback)
static EndpointZeroCallbacksIRQgetCallbacks ()

Detailed Description

By making a class that derives from this it is possible to handle class and vendor specific request on the default control pipe (endpoint zero). These callbacks are called from the USB interrupt handler, and therefore are subject to these restrictions:

Constructor & Destructor Documentation

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


Member Function Documentation

bool mxusb::EndpointZeroCallbacks::IRQendOfOutDataStage ( const Setup setup  )  [virtual]

This callback is called after an expected setup request is received (IRQsetup() callback called, and user code returned true), and the data stage is completed. If there is no data stage (setup.wLenght==0) or the request was of IN (device to host) type, then this callback won't be called. If no IN transaction with data stage is expected as valid, there is no need to override this member function.

setup the same setup request passed to the previous IRQsetup() call
true if the data received in the buffer was correct. In this case the status stage of the transaction will be ACKed, otherwise a STALL will be returned to the host.
static EndpointZeroCallbacks* mxusb::EndpointZeroCallbacks::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.

the current callbacks class registered for USB event handling
void mxusb::EndpointZeroCallbacks::IRQsetDataBuffer ( unsigned char *  data  )  [static]

Set data buffer for setup requests that require it. It is meant to be called from within IRQsetup() if setup.wLength>0. Other uses may produce undefined behaviour. Do not allocate the buffer on the stack, since it will be accessed after IRQsetup() returns.

data data to send to the host, if the setup transaction is of type IN, else pointer to an empty buffer that will be filled by the host. Buffer length must be at least setup.wLength.
virtual bool mxusb::EndpointZeroCallbacks::IRQsetup ( const Setup setup  )  [pure virtual]

This callback is called when a class or vendor request is received on endpoint zero. If setup.wLength>0, a data stage is required and in this case the callback must either return false or call IRQsetDataBuffer() to set up the buffer used for the data stage.

setup the associated setup request
if this is an expected request for the device being built, return true. This means the request will be accepted, otherwise return false and the request will be STALLed.
void mxusb::EndpointZeroCallbacks::setCallbacks ( EndpointZeroCallbacks callback  )  [static]

Set callbacks for USB nonstandard requests on endpoint zero.

callback an instance of a class that derives from EndpoinZeroCallbacks, 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: