SAMV71 Xplained Ultra Software Package 1.5

USBH_HAL.c File Reference

USB host driver Compliance with common driver UHD. More...

#include "conf_usb_host.h"
#include "board.h"
#include "USBHDriver.h"
#include "USBH.h"
#include <string.h>
#include <stdlib.h>
#include "sleepmgr.h"

Go to the source code of this file.

Data Structures

struct  uhd_ctrl_request_t
 Structure to store the high level setup request. More...
struct  USBH_PipeJob_t
 Structure definition to store registered jobs on a pipe. More...

Defines

#define UHD_USB_INT_LEVEL   5
#define USB_HOST_MAX_EP   9
#define UHD_PIPE_USED(pipe)   (USB_HOST_MAX_EP >= pipe)
#define UHD_PIPE_DMA_SUPPORTED
#define UHD_PIPE_FIFO_SUPPORTED
#define UHC_MODE_CHANGE(arg)
#define UHC_SOF_EVENT()
#define UHC_VBUS_CHANGE(b_present)
#define UHC_VBUS_ERROR()
#define UHD_ISOCHRONOUS_NB_BANK   2
#define UHD_BULK_NB_BANK   2
#define UHD_INTERRUPT_NB_BANK   1

Functions

void USBHS_Handler (void)
void USBH_HAL_EnableUsbHost (void)
 Enables the USB host mode Start the ID pin management if the ID pin is available.
void USBH_HAL_DisableUsb (bool b_id_stop)
 Disables the USB host mode.
USBH_Speed_t USBH_HAL_GetSpeed (void)
 Returns the speed of connected device.
uint16_t USBH_HAL_GetFrameNum (void)
 Returns the current Start Of Frame (SOF) number.
uint16_t USBH_HAL_GetMicroFrameNum (void)
 Returns the current micro start of frame number.
void USBH_HAL_Reset (uhd_callback_reset_t callback)
 Enables the Reset state on the USB line.
void USBH_HAL_Suspend (void)
 Enables the suspend state on the USB line. The SUSPEND state is enable when SOF are disabled on USB line.
bool USBH_HAL_IsSuspended (void)
 Test if the suspend state is enabled on the USB line.
void USBH_HAL_Resume (void)
 Enables the IDLE state on the USB line. The IDLE state is enable when SOF are present on USB line. A Downstream Resume signal can be sent.
bool USBH_HAL_SetupReq (uint8_t add, USBGenericRequest *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. Note: Request timeout is 5s.
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 USBH_HAL_ConfigureControlPipe (uint8_t add, uint16_t ep_size)
 Configures and enables a control endpoint 0.
bool USBH_HAL_ConfigurePipe (uint8_t add, USBEndpointDescriptor *ep_desc)
 Configures and enables an endpoint.
void USBH_HAL_FreePipe (uint8_t add, uint8_t endp)
 Disables an endpoint or all endpoint of a device.
bool USBH_HAL_RunEndpoint (uint8_t add, uint8_t endp, bool b_shortpacket, uint8_t *buf, uint32_t buf_size, uint16_t timeout, uhd_callback_trans_t callback)
 Allows to receive or send data on an endpoint.
void USBH_HAL_AbortEndPoint (uint8_t add, uint8_t endp)
 Aborts an on-going transfer on an endpoint.

Power management



enum  uhd_uotghs_state_enum {
  UHD_STATE_OFF = 0, UHD_STATE_WAIT_ID_HOST = 1, UHD_STATE_NO_VBUS = 2, UHD_STATE_DISCONNECT = 3,
  UHD_STATE_SUSPEND = 4, UHD_STATE_IDLE = 5
}
 

States of USBHS interface.


Control endpoint low level management routine.

This function performs control endpoint management. It handles the SETUP/DATA/HANDSHAKE phases of a control transaction.



enum  uhd_ctrl_request_phase_t {
  UHD_CTRL_REQ_PHASE_SETUP = 0, UHD_CTRL_REQ_PHASE_DATA_OUT = 1, UHD_CTRL_REQ_PHASE_DATA_IN = 2, UHD_CTRL_REQ_PHASE_ZLP_IN = 3,
  UHD_CTRL_REQ_PHASE_ZLP_OUT = 4
}
 

Bit definitions to store setup request state machine.

More...
struct uhd_ctrl_request_tuhd_ctrl_request_first
 Entry points of setup request list.
struct uhd_ctrl_request_tuhd_ctrl_request_last
volatile uint16_t uhd_ctrl_request_timeout
 Remaining time for on-going setup request (No request on-going if equal 0).
uint16_t uhd_ctrl_nb_trans
 Number of transfered byte on DATA phase of current setup request.
uhd_ctrl_request_phase_t uhd_ctrl_request_phase

Detailed Description

USB host driver Compliance with common driver UHD.

Definition in file USBH_HAL.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines