HPM SDK
HPMicro Software Development Kit
hpm_usb_drv.h File Reference
#include "hpm_common.h"
#include "hpm_usb_regs.h"
#include "hpm_soc_feature.h"

Go to the source code of this file.

Data Structures

struct  usb_endpoint_config_t
 Endpoint config structure. More...
 

Macros

#define USB_PHY_INIT_DELAY_COUNT   (16U)
 
#define USB_HOST_FRAMELIST_SIZE   (8U)
 

Enumerations

enum  usb_dir_t { usb_dir_out = 0 , usb_dir_in = 1 , usb_dir_in_mask = 0x80 }
 USB transfer direction types. More...
 
enum  usb_xfer_type_t { usb_xfer_control = 0 , usb_xfer_isochronous , usb_xfer_bulk , usb_xfer_interrupt }
 USB transfer types. More...
 
enum  usb_controller_mode_t { usb_ctrl_mode_otg = 0 , usb_ctrl_mode_device = 2 , usb_ctrl_mode_host = 3 }
 USB controller work modes. More...
 
enum  usb_line_state_t { usb_line_state0 = 0 , usb_line_state1 = 1 , usb_line_state2 = 2 }
 USB line state. More...
 
enum  usb_transceiver_t { usb_tran_parallel = 0 , usb_tran_serial = 1 }
 USB transceiver. More...
 

Functions

static uint32_t usb_get_interrupts (USB_Type *ptr)
 Get the mask of all enabled interrupts. More...
 
static void usb_enable_interrupts (USB_Type *ptr, uint32_t mask)
 Enable interrupts. More...
 
static uint32_t usb_get_status_flags (USB_Type *ptr)
 Get all USB status flags. More...
 
static void usb_clear_status_flags (USB_Type *ptr, uint32_t mask)
 Clear status flags. More...
 
static uint8_t usb_get_suspend_status (USB_Type *ptr)
 Get USB suspend status. More...
 
static bool usb_get_port_reset_status (USB_Type *ptr)
 Get USB reset status. More...
 
static bool usb_get_port_ccs (USB_Type *ptr)
 Get USB current connect status. More...
 
static uint8_t usb_get_port_speed (USB_Type *ptr)
 Get USB port speed status. More...
 
void usb_phy_init (USB_Type *ptr)
 Initialize USB phy. More...
 
static uint8_t usb_phy_get_line_state (USB_Type *ptr)
 USB phy get line status. More...
 
static void usb_phy_using_internal_vbus (USB_Type *ptr)
 USB phy using internal vbus. More...
 
static void usb_phy_using_external_vbus (USB_Type *ptr)
 USB phy using external vbus. More...
 
static void usb_phy_disable_dp_dm_pulldown (USB_Type *ptr)
 USB phy disconnect dp/dm pins pulldown resistance. More...
 
static void usb_phy_enable_dp_dm_pulldown (USB_Type *ptr)
 USB phy connect dp/dm pins pulldown resistance. More...
 
void usb_dcd_bus_reset (USB_Type *ptr, uint16_t ep0_max_packet_size)
 USB device bus reset. More...
 
void usb_dcd_init (USB_Type *ptr)
 Initialize controller to device mode. More...
 
void usb_dcd_deinit (USB_Type *ptr)
 Deinitialize controller to device. More...
 
void usb_dcd_remote_wakeup (USB_Type *ptr)
 Wakeup from host. More...
 
void usb_dcd_edpt_open (USB_Type *ptr, usb_endpoint_config_t *config)
 Open an endpoint. More...
 
uint8_t usb_dcd_edpt_get_type (USB_Type *ptr, uint8_t ep_addr)
 get a specified endpoint type More...
 
void usb_dcd_edpt_xfer (USB_Type *ptr, uint8_t ep_idx)
 Submit a transfer. More...
 
void usb_dcd_edpt_stall (USB_Type *ptr, uint8_t ep_addr)
 Stall endpoint. More...
 
void usb_dcd_edpt_clear_stall (USB_Type *ptr, uint8_t ep_addr)
 Clear stall. More...
 
bool usb_dcd_edpt_check_stall (USB_Type *ptr, uint8_t ep_addr)
 Clear stall. More...
 
void usb_dcd_edpt_close (USB_Type *ptr, uint8_t ep_addr)
 Close a specified endpoint. More...
 
void usb_dcd_connect (USB_Type *ptr)
 Connect by enabling internal pull-up resistor on D+/D-. More...
 
void usb_dcd_disconnect (USB_Type *ptr)
 Disconnect by disabling internal pull-up resistor on D+/D-. More...
 
static uint32_t usb_dcd_get_edpt_setup_status (USB_Type *ptr)
 Get setup status of endpoint. More...
 
static void usb_dcd_clear_edpt_setup_status (USB_Type *ptr, uint32_t mask)
 Clear the setup status of all specified endpoints. More...
 
static void usb_dcd_set_address (USB_Type *ptr, uint8_t dev_addr)
 Set address. More...
 
static void usb_dcd_set_edpt_list_addr (USB_Type *ptr, uint32_t addr)
 Set endpoint list address. More...
 
static uint8_t usb_dcd_get_device_addr (USB_Type *ptr)
 Get device address. More...
 
static uint32_t usb_dcd_get_edpt_complete_status (USB_Type *ptr)
 Get complete status of endpoint. More...
 
static void usb_dcd_clear_edpt_complete_status (USB_Type *ptr, uint32_t mask)
 Clear complete status of endpoint. More...
 
bool usb_hcd_init (USB_Type *ptr, uint32_t int_mask, uint16_t framelist_size)
 Initialize controller to host mode. More...
 
void usb_hcd_port_reset (USB_Type *ptr)
 Initialize controller to host modeHost Reset port. More...
 
static void usb_hcd_set_command (USB_Type *ptr, uint32_t mask)
 Initialize controller to host modeHost set command register. More...
 
static uint32_t usb_hcd_get_frame_index (USB_Type *ptr)
 Get frame index. More...
 
static bool usb_hcd_get_port_csc (USB_Type *ptr)
 Get port connect status change. More...
 
static void usb_hcd_set_power_ctrl_polarity (USB_Type *ptr, bool high)
 Set power ctrl polarity. More...
 
static void usb_hcd_enable_port_power (USB_Type *ptr)
 Enable port power. More...
 
static void usb_hcd_set_async_list_addr (USB_Type *ptr, uint32_t addr)
 Get port connect status changeSet async list address. More...
 
static void usb_hcd_set_periodic_list_addr (USB_Type *ptr, uint32_t addr)
 Set periodic list address. More...
 
static void usb_hcd_run (USB_Type *ptr)
 Start hcd controller. More...
 
static void usb_hcd_stop (USB_Type *ptr)
 Stop hcd controller. More...
 

Variables

 usb_control_request_t