75#ifndef PERIPH_USBDEV_H
76#define PERIPH_USBDEV_H
83#include "periph_conf.h"
106#ifndef USBDEV_CPU_DMA_REQUIREMENTS
107#define USBDEV_CPU_DMA_REQUIREMENTS
126#define usbdev_ep_buf_t USBDEV_CPU_DMA_REQUIREMENTS uint8_t
138#ifndef USBDEV_CPU_SET_ADDR_AFTER_STATUS
139#define USBDEV_CPU_SET_ADDR_AFTER_STATUS 1
148#ifndef USBDEV_NUM_ENDPOINTS
149#define USBDEV_NUM_ENDPOINTS 8
312 void *value,
size_t max_len);
326 const void *value,
size_t value_len);
385 void *value,
size_t max_len);
399 const void *value,
size_t value_len);
499 void *value,
size_t max_len)
502 return dev->
driver->
get(dev, opt, value, max_len);
521 const void *value,
size_t value_len)
524 return dev->
driver->
set(dev, opt, value, value_len);
615 void *value,
size_t max_len)
639 const void *value,
size_t value_len)
POSIX.1-2008 compliant version of the assert macro.
#define assert(cond)
abort the program if assertion is false
void usbdev_init_lowlevel(void)
Low level USB peripheral driver initialization.
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.
static usbdev_ep_t * usbdev_new_ep(usbdev_t *dev, usb_ep_type_t type, usb_ep_dir_t dir, size_t size)
Retrieve an USB endpoint of the specified type.
static void usbdev_init(usbdev_t *dev)
Initialize the USB peripheral device.
usbdev_event_t
List of event types that can be send from the device driver to the upper layer.
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.
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.
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 void usbdev_ep0_stall(usbdev_t *dev)
Stall both OUT and IN packets on endpoint 0 until a setup packet is received.
usbdev_t * usbdev_get_ctx(unsigned num)
Retrieve usbdev context from the peripheral.
static void usbdev_ep_stall(usbdev_ep_t *ep, bool enable)
Enable or disable the stall condition on the USB endpoint.
void(* usbdev_ep_event_cb_t)(usbdev_ep_t *ep, usbdev_event_t event)
Event callback for signaling endpoint events to upper layers.
void(* usbdev_event_cb_t)(usbdev_t *usbdev, usbdev_event_t event)
Event callback for signaling usbdev event to upper layers.
static void usbdev_esr(usbdev_t *dev)
a driver's user-space event service handler
static int usbdev_ep_xmit(usbdev_ep_t *ep, uint8_t *buf, size_t len)
Submit a buffer for a USB endpoint transmission.
struct usbdev_driver usbdev_driver_t
usbdev driver functions
static void usbdev_ep_esr(usbdev_ep_t *ep)
an endpoint's user-space event handler
@ USBDEV_EVENT_SUSPEND
USB suspend condition active.
@ USBDEV_EVENT_TR_STALL
Transaction stall event.
@ USBDEV_EVENT_ESR
Driver needs it's ESR (event service routine) handled.
@ USBDEV_EVENT_HOST_DISCONNECT
Host disconnected from the device.
@ USBDEV_EVENT_RESUME
USB suspend condition no longer active.
@ USBDEV_EVENT_HOST_CONNECT
Host connection detected.
@ USBDEV_EVENT_TR_COMPLETE
Transaction completed event.
@ USBDEV_EVENT_RESET
Line reset occurred.
@ USBDEV_EVENT_SOF
Start of Frame received.
usbopt_t
List of configuration settings for USB peripherals.
usbopt_ep_t
List of configuration settings for USB peripheral endpoints.
usb_ep_dir_t
USB endpoint directions.
usb_ep_type_t
USB endpoint types.
int(* set)(usbdev_t *usbdev, usbopt_t opt, const void *value, size_t value_len)
Set an option value for a given usb device.
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(* ep_init)(usbdev_ep_t *ep)
Initialize the USB endpoint.
void(* ep_stall)(usbdev_ep_t *ep, bool enable)
Enable or disable the stall condition on the USB endpoint.
int(* xmit)(usbdev_ep_t *ep, uint8_t *buf, size_t len)
Transmit a data buffer.
void(* init)(usbdev_t *usbdev)
Initialize the USB peripheral device.
void(* esr)(usbdev_t *dev)
a driver's user-space event service handler
void(* ep_esr)(usbdev_ep_t *ep)
an endpoint's user-space event handler
void(* ep0_stall)(usbdev_t *usbdev)
Stall both OUT and IN packets on endpoint 0 until a setup packet is received.
usbdev_ep_t *(* new_ep)(usbdev_t *dev, usb_ep_type_t type, usb_ep_dir_t dir, size_t size)
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.
int(* get)(usbdev_t *usbdev, usbopt_t opt, void *value, size_t max_len)
Get an option value from a given usb device.
usbdev endpoint descriptor
usbdev_t * dev
USB device this endpoint belongs to
uint8_t num
Endpoint number
size_t len
Endpoint configured max transfer size in bytes.
usb_ep_dir_t dir
Endpoint direction
usb_ep_type_t type
Endpoint type
usbdev_ep_event_cb_t epcb
Endpoint event callback for upper layer
void * context
Ptr to the thread context
usbdev_event_cb_t cb
Event callback supplied by upper layer
const struct usbdev_driver * driver
usbdev driver struct
Definition of global compile time configuration options.
Definition of global USB peripheral and USB peripheral endpoint configuration options.