Definitions low-level USB driver interface. More...

Detailed Description

Definitions low-level USB driver interface.

Author
Koen Zandberg koen@.nosp@m.berg.nosp@m.zand..nosp@m.net

Definition in file usbdev.h.

#include <stdint.h>
#include <stddef.h>
#include "assert.h"
#include "usb.h"
#include "usb/usbopt.h"
+ Include dependency graph for usbdev.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  usbdev
 usbdev device descriptor More...
 
struct  usbdev_ep
 usbdev endpoint descriptor More...
 
struct  usbdev_driver
 usbdev driver functions More...
 

Macros

#define USBDEV_EP_BUF_SPACE   1024
 Statically allocated buffer space for endpoints. More...
 
#define USBDEV_NUM_ENDPOINTS   8
 Number of USB IN and OUT endpoints allocated. More...
 

Typedefs

typedef struct usbdev usbdev_t
 usbdev_t forward declaration
 
typedef struct usbdev_ep usbdev_ep_t
 usbdev_ep_t forward declaration
 
typedef void(* usbdev_event_cb_t) (usbdev_t *usbdev, usbdev_event_t event)
 Event callback for signaling usbdev event to upper layers. More...
 
typedef void(* usbdev_ep_event_cb_t) (usbdev_ep_t *ep, usbdev_event_t event)
 Event callback for signaling endpoint events to upper layers. More...
 
typedef struct usbdev_driver usbdev_driver_t
 usbdev driver functions More...
 

Enumerations

enum  usbdev_event_t {
  USBDEV_EVENT_ESR = 1, USBDEV_EVENT_HOST_CONNECT, USBDEV_EVENT_HOST_DISCONNECT, USBDEV_EVENT_RESET,
  USBDEV_EVENT_SOF, USBDEV_EVENT_SUSPEND, USBDEV_EVENT_RESUME, USBDEV_EVENT_TR_COMPLETE,
  USBDEV_EVENT_TR_STALL, USBDEV_EVENT_TR_FAIL
}
 List of event types that can be send from the device driver to the upper layer. More...
 

Functions

void usbdev_init_lowlevel (void)
 Low level USB peripheral driver initialization. More...
 
usbdev_tusbdev_get_ctx (unsigned num)
 Retrieve usbdev context from the peripheral. More...
 
static void usbdev_init (usbdev_t *dev)
 Initialize the USB peripheral device. More...
 
static usbdev_ep_tusbdev_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. More...
 
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. More...
 
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. More...
 
static void usbdev_esr (usbdev_t *dev)
 a driver's user-space event service handler More...
 
static void usbdev_ep_init (usbdev_ep_t *ep)
 Initialize the USB endpoint. More...
 
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. More...
 
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. More...
 
static void usbdev_ep_esr (usbdev_ep_t *ep)
 an endpoint's user-space event handler More...
 
static int usbdev_ep_ready (usbdev_ep_t *ep, size_t len)
 Signal data buffer ready for data transmission. More...