Microchip® Advanced Software Framework

udd.h File Reference

Common API for USB Device Drivers (UDD)

Copyright (c) 2009-2018 Microchip Technology Inc. and its subsidiaries.

#include "usb_protocol.h"
#include "udc_desc.h"

Data Structures

struct  udd_ctrl_request_t
 Global variable to give and record information of the setup request management. More...
 

Macros

#define Udd_setup_is_in()   (USB_REQ_DIR_IN == (udd_g_ctrlreq.req.bmRequestType & USB_REQ_DIR_MASK))
 Return true if the setup request udd_g_ctrlreq indicates IN data transfer. More...
 
#define Udd_setup_is_out()   (USB_REQ_DIR_OUT == (udd_g_ctrlreq.req.bmRequestType & USB_REQ_DIR_MASK))
 Return true if the setup request udd_g_ctrlreq indicates OUT data transfer. More...
 
#define Udd_setup_recipient()   (udd_g_ctrlreq.req.bmRequestType & USB_REQ_RECIP_MASK)
 Return the recipient of the SETUP request udd_g_ctrlreq. More...
 
#define Udd_setup_type()   (udd_g_ctrlreq.req.bmRequestType & USB_REQ_TYPE_MASK)
 Return the type of the SETUP request udd_g_ctrlreq. More...
 

Typedefs

typedef void(* udd_callback_halt_cleared_t )(void)
 End of halt callback function type. More...
 
typedef void(* udd_callback_trans_t )(udd_ep_status_t status, iram_size_t nb_transfered, udd_ep_id_t ep)
 End of transfer callback function type. More...
 
typedef uint8_t udd_ep_id_t
 Endpoint identifier. More...
 

Enumerations

enum  udd_ep_status_t {
  UDD_EP_TRANSFER_OK = 0,
  UDD_EP_TRANSFER_ABORT = 1
}
 Endpoint transfer status Returned in parameters of callback register via udd_ep_run routine. More...
 

Functions

void udd_attach (void)
 Attach device to the bus when possible. More...
 
void udd_detach (void)
 Detaches the device from the bus. More...
 
void udd_disable (void)
 Disables the USB Device mode. More...
 
void udd_enable (void)
 Enables the USB Device mode. More...
 
uint16_t udd_get_frame_number (void)
 Returns the current start of frame number. More...
 
uint16_t udd_get_micro_frame_number (void)
 Returns the current micro start of frame number. More...
 
uint8_t udd_getaddress (void)
 Returns the USB address of device. More...
 
bool udd_include_vbus_monitoring (void)
 Authorizes the VBUS event. More...
 
bool udd_is_high_speed (void)
 Test whether the USB Device Controller is running at high speed or not. More...
 
void udd_send_remotewakeup (void)
 The USB driver sends a resume signal called Upstream Resume. More...
 
void udd_set_address (uint8_t address)
 Changes the USB address of device. More...
 
void udd_set_setup_payload (uint8_t *payload, uint16_t payload_size)
 Load setup payload. More...
 
Endpoint Management

The following functions allow drivers to create and remove endpoints, as well as set, clear and query their "halted" and "wedged" states.

bool udd_ep_alloc (udd_ep_id_t ep, uint8_t bmAttributes, uint16_t MaxEndpointSize)
 Configures and enables an endpoint. More...
 
void udd_ep_free (udd_ep_id_t ep)
 Disables an endpoint. More...
 
bool udd_ep_is_halted (udd_ep_id_t ep)
 Check if the endpoint ep is halted. More...
 
bool udd_ep_set_halt (udd_ep_id_t ep)
 Set the halted state of the endpoint ep. More...
 
bool udd_ep_clear_halt (udd_ep_id_t ep)
 Clear the halted state of the endpoint ep. More...
 
bool udd_ep_wait_stall_clear (udd_ep_id_t ep, udd_callback_halt_cleared_t callback)
 Registers a callback to call when endpoint halt is cleared. More...
 
bool udd_ep_run (udd_ep_id_t ep, bool b_shortpacket, uint8_t *buf, iram_size_t buf_size, udd_callback_trans_t callback)
 Allows to receive or send data on an endpoint. More...
 
void udd_ep_abort (udd_ep_id_t ep)
 Aborts transfer on going on endpoint. More...
 
High speed test mode management

The following functions allow the device to jump to a specific test mode required in high speed mode.

void udd_test_mode_j (void)
 
void udd_test_mode_k (void)
 
void udd_test_mode_se0_nak (void)
 
void udd_test_mode_packet (void)
 
UDC callbacks to provide for UDD

The following callbacks are used by UDD.

bool udc_process_setup (void)
 Decodes and manages a setup request. More...
 
void udc_reset (void)
 Reset the UDC. More...
 
void udc_sof_notify (void)
 To signal that a SOF is occurred. More...
 

Variables

udd_ctrl_request_t udd_g_ctrlreq
 Global variable to give and record information of the set up request management. More...