Microchip® Advanced Software Framework

uhd.h File Reference

Common API for USB Host Drivers (UHD)

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

#include "usb_protocol.h"

Typedefs

typedef void(* uhd_callback_reset_t )(void)
 End of reset callback function type. More...
 
typedef void(* uhd_callback_setup_end_t )(usb_add_t add, uhd_trans_status_t status, uint16_t payload_trans)
 End of setup callback function type. More...
 
typedef bool(* uhd_callback_setup_run_t )(usb_add_t add, uint8_t **payload, uint16_t *payload_size)
 Data setup transfer callback function type. More...
 
typedef void(* uhd_callback_trans_t )(usb_add_t add, usb_ep_t ep, uhd_trans_status_t status, iram_size_t nb_transfered)
 End of transfer callback function type. More...
 

Enumerations

enum  uhd_speed_t {
  UHD_SPEED_LOW = 0,
  UHD_SPEED_FULL = 1,
  UHD_SPEED_HIGH = 2
}
 Device speed. More...
 
enum  uhd_trans_status_t {
  UHD_TRANS_NOERROR = 0,
  UHD_TRANS_DISCONNECT,
  UHD_TRANS_CRC,
  UHD_TRANS_DT_MISMATCH,
  UHD_TRANS_STALL,
  UHD_TRANS_NOTRESPONDING,
  UHD_TRANS_PIDFAILURE,
  UHD_TRANS_TIMEOUT,
  UHD_TRANS_ABORTED
}
 Endpoint transfer status The status field is updated after each transaction attempt, whether successful or not. More...
 

Functions

void uhd_disable (bool b_id_stop)
 Disables the USB host mode. More...
 
void uhd_enable (void)
 Enables the USB host mode Start the ID pin management if the ID pin is available. More...
 
uint16_t uhd_get_frame_number (void)
 Returns the current Start Of Frame (SOF) number. More...
 
uint16_t uhd_get_microframe_number (void)
 Returns the current micro start of frame number. More...
 
uhd_speed_t uhd_get_speed (void)
 Returns the speed of connected device. More...
 
bool uhd_is_suspend (void)
 Test if the suspend state is enabled on the USB line. More...
 
void uhd_resume (void)
 Enables the IDLE state on the USB line. More...
 
void uhd_send_reset (uhd_callback_reset_t callback)
 Enables the Reset state on the USB line. More...
 
bool uhd_setup_request (usb_add_t add, usb_setup_req_t *req, uint8_t *payload, uint16_t payload_size, uhd_callback_setup_run_t callback_run, uhd_callback_setup_end_t callback_end)
 Add a setup request in the control endpoint setup queue. More...
 
void uhd_suspend (void)
 Enables the suspend state on the USB line. More...
 
bool uhd_suspend_lpm (bool b_remotewakeup, uint8_t hird)
 Enables the suspend L1 state on the USB line. 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 uhd_ep0_alloc (usb_add_t add, uint8_t ep_size)
 Configures and enables a control endpoint 0. More...
 
bool uhd_ep_alloc (usb_add_t add, usb_ep_desc_t *ep_desc, uhd_speed_t speed)
 Configures and enables an endpoint. More...
 
void uhd_ep_free (usb_add_t add, usb_ep_t endp)
 Disables an endpoint or all endpoint of a device. More...
 
bool uhd_ep_run (usb_add_t add, usb_ep_t endp, bool b_shortpacket, uint8_t *buf, iram_size_t buf_size, uint16_t timeout, uhd_callback_trans_t callback)
 Allows to receive or send data on an endpoint. More...
 
void uhd_ep_abort (usb_add_t add, usb_ep_t endp)
 Aborts an on-going transfer on an endpoint. More...
 
High speed test mode management

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

void uhd_test_mode_j (void)
 
void uhd_test_mode_k (void)
 
void uhd_test_mode_se0_nak (void)
 
void uhd_test_mode_packet (void)
 
UHC callbacks to provide for UHD

The following callbacks are used by UHD.

void uhc_start (void)
 Starts the host mode. More...
 
void uhc_stop (bool b_id_stop)
 Stops the host mode. More...
 
void uhc_notify_connection (bool b_plug)
 Notify device connection or disconnection. More...
 
void uhc_notify_sof (bool b_micro)
 Notify each start of frame sent by driver. More...
 
void uhc_notify_resume (void)
 Notify that a resume bus occurs A resume can occur after a downstream or an upstream resume. More...
 
void uhc_notify_resume_lpm (void)
 Notify that a resume bus occurs after a L1 state A resume can occur after a downstream or an upstream resume. More...