Go to the documentation of this file.
71 #ifndef PERIPH_USBDEV_H
72 #define PERIPH_USBDEV_H
102 #ifndef USBDEV_EP_BUF_SPACE
103 #define USBDEV_EP_BUF_SPACE 1024
112 #ifndef USBDEV_NUM_ENDPOINTS
113 #define USBDEV_NUM_ENDPOINTS 8
283 void *value,
size_t max_len);
297 const void *value,
size_t value_len);
331 void *value,
size_t max_len);
345 const void *value,
size_t value_len);
437 void *value,
size_t max_len)
440 return dev->
driver->
get(dev, opt, value, max_len);
459 const void *value,
size_t value_len)
462 return dev->
driver->
set(dev, opt, value, value_len);
514 void *value,
size_t max_len)
538 const void *value,
size_t value_len)
usb_ep_dir_t
USB endpoint directions.
uint8_t num
Endpoint number
void(* usbdev_event_cb_t)(usbdev_t *usbdev, usbdev_event_t event)
Event callback for signaling usbdev event to upper layers.
#define assert(cond)
abort the program if assertion is false
POSIX.1-2008 compliant version of the assert macro.
usbdev_ep_event_cb_t epcb
Endpoint event callback for upper layer
usb_ep_type_t
USB endpoint types.
void(* ep_esr)(usbdev_ep_t *ep)
an endpoint's user-space event handler
static int usbdev_set(usbdev_t *dev, usbopt_t opt, const void *value, size_t value_len)
Set an option value for a given usb device.
@ USBDEV_EVENT_RESUME
USB suspend condition no longer active.
static int usbdev_ep_ready(usbdev_ep_t *ep, size_t len)
Signal data buffer ready for data transmission.
static void usbdev_esr(usbdev_t *dev)
a driver's user-space event service handler
struct usbdev_driver usbdev_driver_t
usbdev driver functions
static int usbdev_ep_set(usbdev_ep_t *ep, usbopt_ep_t opt, const void *value, size_t value_len)
Set an option value for a given usb device endpoint.
size_t len
Size of the data buffer in bytes
static void usbdev_init(usbdev_t *dev)
Initialize the USB peripheral device.
Definition of global USB peripheral and USB peripheral endpoint configuration options.
@ USBDEV_EVENT_TR_COMPLETE
Transaction completed event.
void(* init)(usbdev_t *usbdev)
Initialize the USB peripheral device.
usbdev_event_cb_t cb
Event callback supplied by upper layer
static void usbdev_ep_esr(usbdev_ep_t *ep)
an endpoint's user-space event handler
@ USBDEV_EVENT_TR_FAIL
Transaction fail event.
@ USBDEV_EVENT_SUSPEND
USB suspend condition active.
usbdev endpoint descriptor
@ USBDEV_EVENT_RESET
Line reset occurred.
usbopt_t
List of configuration settings for USB peripherals.
@ USBDEV_EVENT_ESR
Driver needs it's ESR (event service routine) handled.
usbdev_t * dev
USB device this endpoint belongs to
Definition of global compile time configuration options.
@ USBDEV_EVENT_TR_STALL
Transaction stall event.
int(* set)(usbdev_t *usbdev, usbopt_t opt, const void *value, size_t value_len)
Set an option value for a given usb device.
@ USBDEV_EVENT_HOST_CONNECT
Host connection detected.
int(* ready)(usbdev_ep_t *ep, size_t len)
Signal data buffer ready for data transmission.
void(* ep_init)(usbdev_ep_t *ep)
Initialize the USB endpoint.
usbdev_event_t
List of event types that can be send from the device driver to the upper layer.
int(* ep_set)(usbdev_ep_t *ep, usbopt_ep_t opt, const void *value, size_t value_len)
Set an option value for a given usb device endpoint.
void usbdev_init_lowlevel(void)
Low level USB peripheral driver initialization.
usbdev_t * usbdev_get_ctx(unsigned num)
Retrieve usbdev context from the peripheral.
static int usbdev_get(usbdev_t *dev, usbopt_t opt, void *value, size_t max_len)
Get an option value from a given usb device.
static int usbdev_ep_get(usbdev_ep_t *ep, usbopt_ep_t opt, void *value, size_t max_len)
Get an option value from a given usb device endpoint.
static void usbdev_ep_init(usbdev_ep_t *ep)
Initialize the USB endpoint.
usb_ep_dir_t dir
Endpoint direction
@ USBDEV_EVENT_SOF
Start of Frame received.
const struct usbdev_driver * driver
usbdev driver struct
void(* esr)(usbdev_t *dev)
a driver's user-space event service handler
int(* get)(usbdev_t *usbdev, usbopt_t opt, void *value, size_t max_len)
Get an option value from a given usb device.
usbopt_ep_t
List of configuration settings for USB peripheral endpoints.
void * context
Ptr to the thread context
uint8_t * buf
Ptr to the data buffer
@ USBDEV_EVENT_HOST_DISCONNECT
Host disconnected from the device.
void(* usbdev_ep_event_cb_t)(usbdev_ep_t *ep, usbdev_event_t event)
Event callback for signaling endpoint events to upper layers.
usbdev_ep_t *(* new_ep)(usbdev_t *dev, usb_ep_type_t type, usb_ep_dir_t dir, size_t buf_len)
Retrieve an USB endpoint of the specified type.
static usbdev_ep_t * usbdev_new_ep(usbdev_t *dev, usb_ep_type_t type, usb_ep_dir_t dir, size_t buf_len)
Retrieve an USB endpoint of the specified type.
int(* ep_get)(usbdev_ep_t *ep, usbopt_ep_t opt, void *value, size_t max_len)
Get an option value from a given usb device endpoint.
usb_ep_type_t type
Endpoint type