Loading...
Searching...
No Matches

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 <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include "assert.h"
#include "periph_conf.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_CPU_DMA_REQUIREMENTS
 USBDEV endpoint buffer CPU-specific requirements.
 
#define usbdev_ep_buf_t   USBDEV_CPU_DMA_REQUIREMENTS uint8_t
 Instantiation type for usbdev endpoint buffers.
 
#define USBDEV_CPU_SET_ADDR_AFTER_STATUS   1
 USBDEV specific requirement for setting the device address.
 
#define USBDEV_NUM_ENDPOINTS   8
 Number of USB IN and OUT endpoints allocated.
 

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.
 
typedef void(* usbdev_ep_event_cb_t) (usbdev_ep_t *ep, usbdev_event_t event)
 Event callback for signaling endpoint events to upper layers.
 
typedef struct usbdev_driver usbdev_driver_t
 usbdev driver functions
 

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
}
 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.
 
usbdev_tusbdev_get_ctx (unsigned num)
 Retrieve usbdev context from the peripheral.
 
static void usbdev_init (usbdev_t *dev)
 Initialize the USB peripheral device.
 
static usbdev_ep_tusbdev_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 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_set (usbdev_t *dev, usbopt_t opt, const void *value, size_t value_len)
 Set an option value for a given usb device.
 
static void usbdev_esr (usbdev_t *dev)
 a driver's user-space event service handler
 
static void usbdev_ep0_stall (usbdev_t *dev)
 Stall both OUT and IN packets on endpoint 0 until a setup packet is received.
 
static void usbdev_ep_init (usbdev_ep_t *ep)
 Initialize the USB endpoint.
 
static void usbdev_ep_stall (usbdev_ep_t *ep, bool enable)
 Enable or disable the stall condition on the USB endpoint.
 
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 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 void usbdev_ep_esr (usbdev_ep_t *ep)
 an endpoint's user-space event handler
 
static int usbdev_ep_xmit (usbdev_ep_t *ep, uint8_t *buf, size_t len)
 Submit a buffer for a USB endpoint transmission.