HPM SDK
HPMicro Software Development Kit
hpm_usb_drv.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 HPMicro
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef HPM_USB_DRV_H
9 #define HPM_USB_DRV_H
10 /*---------------------------------------------------------------------
11  * Includes
12  *---------------------------------------------------------------------
13  */
14 #include "hpm_common.h"
15 #include "hpm_usb_regs.h"
16 #include "hpm_soc_feature.h"
17 
25 /*---------------------------------------------------------------------
26  * Macro Constant Declarations
27  *---------------------------------------------------------------------
28  */
29 #define USB_PHY_INIT_DELAY_COUNT (100U)
30 #define USB_HOST_FRAMELIST_SIZE (8U)
32 /*---------------------------------------------------------------------
33  * Macro Enum Declarations
34  *---------------------------------------------------------------------
35  */
39 typedef enum {
42  usb_dir_in_mask = 0x80
48 typedef enum {
58 typedef enum {
67 typedef enum {
70  usb_line_state2 = 2
76 typedef enum {
78  usb_tran_serial = 1
84 typedef enum {
98 typedef enum {
103 /*---------------------------------------------------------------------
104  * Structure Declarations
105  *---------------------------------------------------------------------
106  */
110 typedef struct __attribute__ ((packed)) {
111  union {
112  struct __attribute__ ((packed)) {
113  uint8_t recipient : 5;
114  uint8_t type : 2;
115  uint8_t direction : 1;
116  } bmRequestType_bit;
117 
118  uint8_t bmRequestType;
119  };
120 
121  uint8_t bRequest;
122  uint16_t wValue;
123  uint16_t wIndex;
124  uint16_t wLength;
126 
130 typedef struct {
131  uint8_t xfer;
132  uint8_t ep_addr;
133  uint16_t max_packet_size;
135 
136 #if defined __cplusplus
137 extern "C" {
138 #endif /* __cplusplus */
139 
140 /*---------------------------------------------------------------------
141  * Common API
142  *---------------------------------------------------------------------
143  */
144 
151 static inline uint32_t usb_get_interrupts(USB_Type *ptr)
152 {
153  return ptr->USBINTR;
154 }
155 
162 static inline void usb_enable_interrupts(USB_Type *ptr, uint32_t mask)
163 {
164  ptr->USBINTR |= mask;
165 }
166 
173 static inline void usb_disable_interrupts(USB_Type *ptr, uint32_t mask)
174 {
175  ptr->USBINTR &= ~mask;
176 }
177 
184 static inline uint32_t usb_get_status_flags(USB_Type *ptr)
185 {
186  return ptr->USBSTS;
187 }
188 
198 static inline void usb_clear_status_flags(USB_Type *ptr, uint32_t mask)
199 {
200  ptr->USBSTS = mask;
201 }
202 
208 static inline void usb_otg_enable_dpdm_wakeup(USB_Type *ptr)
209 {
211 }
212 
218 static inline void usb_otg_disable_dpdm_wakeup(USB_Type *ptr)
219 {
221 }
222 
228 static inline void usb_otg_enable_id_wakeup(USB_Type *ptr)
229 {
231 }
232 
238 static inline void usb_otg_disable_id_wakeup(USB_Type *ptr)
239 {
241 }
242 
248 static inline void usb_otg_enable_vbus_wakeup(USB_Type *ptr)
249 {
251 }
252 
258 static inline void usb_otg_disable_vbus_wakeup(USB_Type *ptr)
259 {
261 }
262 
270 {
272 }
273 
279 static inline void usb_otg_enable_wakeup_int(USB_Type *ptr)
280 {
282 }
283 
289 static inline void usb_otg_disable_wakeup_int(USB_Type *ptr)
290 {
292 }
293 
300 static inline bool usb_get_otg_wakeup_int_flag(USB_Type *ptr)
301 {
302  return (USB_TOP_STATUS_WAKEUP_INT_STATUS_GET(ptr->TOP_STATUS) != 0) ? true : false;
303 }
304 
311 static inline uint8_t usb_get_suspend_status(USB_Type *ptr)
312 {
313  return USB_PORTSC1_SUSP_GET(ptr->PORTSC1);
314 }
315 
322 static inline bool usb_get_port_reset_status(USB_Type *ptr)
323 {
324  return USB_PORTSC1_PR_GET(ptr->PORTSC1);
325 }
326 
333 static inline bool usb_get_port_ccs(USB_Type *ptr)
334 {
335  return USB_PORTSC1_CCS_GET(ptr->PORTSC1);
336 }
337 
344 static inline uint8_t usb_get_port_speed(USB_Type *ptr)
345 {
346  return USB_PORTSC1_PSPD_GET(ptr->PORTSC1);
347 }
348 
355 static inline void usb_set_port_test_mode(USB_Type *ptr, usb_test_mode_t test_mode)
356 {
357  ptr->PORTSC1 = (ptr->PORTSC1 & ~USB_PORTSC1_PTC_MASK) | USB_PORTSC1_PTC_SET(test_mode);
358 }
359 
365 static inline void usb_set_port_suspend(USB_Type *ptr)
366 {
368 }
369 
375 static inline void usb_force_port_resume(USB_Type *ptr)
376 {
378  while ((ptr->PORTSC1 & USB_PORTSC1_FPR_MASK) != 0) {
379  }
380 }
381 
388 {
390 }
391 
397 static inline void usb_phy_exit_low_power_suspend(USB_Type *ptr)
398 {
400  /* otg utmi clock detection */
401  ptr->PHY_STATUS |= USB_PHY_STATUS_UTMI_CLK_VALID_MASK; /* write 1 to clear valid status */
402  while (USB_PHY_STATUS_UTMI_CLK_VALID_GET(ptr->PHY_STATUS) == 0) { /* get utmi clock status */
403  ;
404  }
405 }
406 
413 static inline bool usb_phy_get_session_valid_flag(USB_Type *ptr)
414 {
415  return (USB_PHY_STATUS_UTMI_SESS_VALID_GET(ptr->PHY_STATUS) != 0) ? true : false;
416 }
417 
424 {
425  ptr->OTGSC |= USB_OTGSC_ASVIE_MASK;
426 }
427 
434 {
435  ptr->OTGSC &= ~USB_OTGSC_ASVIE_MASK;
436 }
437 
445 {
446  return ((ptr->OTGSC & USB_OTGSC_ASVIE_MASK) != 0);
447 }
448 
456 {
457  return (USB_OTGSC_ASVIS_SET(ptr->OTGSC) != 0) ? true : false;
458 }
459 
466 {
467  ptr->OTGSC |= USB_OTGSC_ASVIS_MASK;
468 }
469 
477 {
478  return (USB_OTGSC_ASV_GET(ptr->OTGSC) != 0) ? true : false;
479 }
480 
487 void usb_phy_init(USB_Type *ptr, bool host);
488 
494 static inline uint8_t usb_phy_get_line_state(USB_Type *ptr)
495 {
497 }
498 
504 static inline void usb_phy_using_internal_vbus(USB_Type *ptr)
505 {
508 }
509 
515 static inline void usb_phy_using_external_vbus(USB_Type *ptr)
516 {
519 }
520 
526 static inline void usb_phy_disable_dp_dm_pulldown(USB_Type *ptr)
527 {
528  ptr->PHY_CTRL0 |= 0x001000E0u;
529 }
530 
536 static inline void usb_phy_enable_dp_dm_pulldown(USB_Type *ptr)
537 {
538  ptr->PHY_CTRL0 &= ~0x001000E0u;
539 }
540 
547 {
549 }
550 
551 /*---------------------------------------------------------------------
552  * Device API
553  *---------------------------------------------------------------------
554  */
555 
562 void usb_dcd_bus_reset(USB_Type *ptr, uint16_t ep0_max_packet_size);
563 
569 void usb_dcd_init(USB_Type *ptr);
570 
576 void usb_dcd_deinit(USB_Type *ptr);
577 
584 
592 
599 uint8_t usb_dcd_edpt_get_type(USB_Type *ptr, uint8_t ep_addr);
600 
607 void usb_dcd_edpt_xfer(USB_Type *ptr, uint8_t ep_idx);
608 
615 void usb_dcd_edpt_stall(USB_Type *ptr, uint8_t ep_addr);
616 
623 void usb_dcd_edpt_clear_stall(USB_Type *ptr, uint8_t ep_addr);
624 
632 bool usb_dcd_edpt_check_stall(USB_Type *ptr, uint8_t ep_addr);
633 
640 void usb_dcd_edpt_close(USB_Type *ptr, uint8_t ep_addr);
641 
647 void usb_dcd_connect(USB_Type *ptr);
648 
654 void usb_dcd_disconnect(USB_Type *ptr);
655 
662 static inline uint32_t usb_dcd_get_edpt_setup_status(USB_Type *ptr)
663 {
664  return ptr->ENDPTSETUPSTAT;
665 }
666 
673 static inline void usb_dcd_clear_edpt_setup_status(USB_Type *ptr, uint32_t mask)
674 {
675  ptr->ENDPTSETUPSTAT = mask;
676 }
677 
684 static inline void usb_dcd_set_address(USB_Type *ptr, uint8_t dev_addr)
685 {
687 }
688 
695 static inline void usb_dcd_set_edpt_list_addr(USB_Type *ptr, uint32_t addr)
696 {
698 }
699 
706 static inline uint8_t usb_dcd_get_device_addr(USB_Type *ptr)
707 {
709 }
710 
717 static inline uint32_t usb_dcd_get_edpt_complete_status(USB_Type *ptr)
718 {
719  return ptr->ENDPTCOMPLETE;
720 }
721 
728 static inline void usb_dcd_clear_edpt_complete_status(USB_Type *ptr, uint32_t mask)
729 {
730  ptr->ENDPTCOMPLETE = mask;
731 }
732 
733 /*---------------------------------------------------------------------
734  * Host API
735  *---------------------------------------------------------------------
736  */
744 bool usb_hcd_init(USB_Type *ptr, uint32_t int_mask, uint16_t framelist_size);
745 
751 void usb_hcd_port_reset(USB_Type *ptr);
752 
759 static inline void usb_hcd_set_command(USB_Type *ptr, uint32_t mask)
760 {
761  ptr->USBCMD |= mask;
762 }
763 
770 static inline uint32_t usb_hcd_get_frame_index(USB_Type *ptr)
771 {
772  return ptr->FRINDEX;
773 }
774 
781 static inline bool usb_hcd_get_port_csc(USB_Type *ptr)
782 {
783  return USB_PORTSC1_CSC_GET(ptr->PORTSC1);
784 }
785 
792 static inline void usb_hcd_set_power_ctrl_polarity(USB_Type *ptr, bool high)
793 {
794  if (high) {
796  } else {
798  }
799 }
800 
806 static inline void usb_hcd_enable_port_power(USB_Type *ptr)
807 {
809 }
810 
817 static inline void usb_hcd_set_async_list_addr(USB_Type *ptr, uint32_t addr)
818 {
820 }
821 
828 static inline void usb_hcd_set_periodic_list_addr(USB_Type *ptr, uint32_t addr)
829 {
831 }
832 
838 static inline void usb_hcd_run(USB_Type *ptr)
839 {
840  ptr->USBCMD |= USB_USBCMD_RS_MASK;
841 }
842 
848 static inline void usb_hcd_stop(USB_Type *ptr)
849 {
850  ptr->USBCMD &= ~USB_USBCMD_RS_MASK;
851 }
852 
858 static inline void usb_hcd_disable_ase_pse(USB_Type *ptr)
859 {
861  while (ptr->USBCMD & (USB_USBCMD_PSE_MASK | USB_USBCMD_ASE_MASK)) {
862  ;
863  }
864 }
865 
871 static inline void usb_hcd_enable_ase_pse(USB_Type *ptr)
872 {
874 }
875 
876 #if defined __cplusplus
877 }
878 #endif /* __cplusplus */
879 
881 #endif /* HPM_USB_DRV_H */
#define USB_PORTSC1_CSC_GET(x)
Definition: hpm_usb_regs.h:1475
#define USB_PORTSC1_CCS_GET(x)
Definition: hpm_usb_regs.h:1495
#define USB_ASYNCLISTADDR_ASYBASE_MASK
Definition: hpm_usb_regs.h:967
#define USB_OTG_CTRL0_OTG_WKDPDMCHG_EN_MASK
Definition: hpm_usb_regs.h:1994
#define USB_PHY_STATUS_LINE_STATE_GET(x)
Definition: hpm_usb_regs.h:2224
#define USB_PHY_STATUS_UTMI_CLK_VALID_MASK
Definition: hpm_usb_regs.h:2212
#define USB_PHY_CTRL1_UTMI_OTG_SUSPENDM_MASK
Definition: hpm_usb_regs.h:2192
#define USB_OTG_CTRL0_OTG_WAKEUP_INT_ENABLE_MASK
Definition: hpm_usb_regs.h:2059
#define USB_PHY_CTRL0_VBUS_VALID_OVERRIDE_MASK
Definition: hpm_usb_regs.h:2133
#define USB_OTG_CTRL0_OTG_VBUS_SOURCE_SEL_SET(x)
Definition: hpm_usb_regs.h:2032
#define USB_DEVICEADDR_USBADR_SET(x)
Definition: hpm_usb_regs.h:918
#define USB_OTG_CTRL0_OTG_VBUS_SOURCE_SEL_MASK
Definition: hpm_usb_regs.h:2030
#define USB_PHY_CTRL0_VBUS_VALID_OVERRIDE_EN_MASK
Definition: hpm_usb_regs.h:2170
#define USB_OTGSC_ASVIS_MASK
Definition: hpm_usb_regs.h:1541
#define USB_OTGSC_ASVIE_MASK
Definition: hpm_usb_regs.h:1504
#define USB_USBCMD_RS_MASK
Definition: hpm_usb_regs.h:442
#define USB_PHY_STATUS_UTMI_SESS_VALID_GET(x)
Definition: hpm_usb_regs.h:2251
#define USB_PHY_CTRL0_SESS_VALID_OVERRIDE_MASK
Definition: hpm_usb_regs.h:2124
#define USB_OTG_CTRL0_OTG_POWER_MASK_MASK
Definition: hpm_usb_regs.h:2068
#define USB_PERIODICLISTBASE_BASEADR_MASK
Definition: hpm_usb_regs.h:952
#define USB_OTGSC_ASVIS_SET(x)
Definition: hpm_usb_regs.h:1543
#define USB_PORTSC1_PP_MASK
Definition: hpm_usb_regs.h:1289
#define USB_DEVICEADDR_USBADR_GET(x)
Definition: hpm_usb_regs.h:919
#define USB_PORTSC1_PTC_SET(x)
Definition: hpm_usb_regs.h:1269
#define USB_OTGSC_ASV_GET(x)
Definition: hpm_usb_regs.h:1581
#define USB_USBCMD_PSE_MASK
Definition: hpm_usb_regs.h:390
#define USB_PORTSC1_PTC_MASK
Definition: hpm_usb_regs.h:1267
#define USB_PORTSC1_PHCD_MASK
Definition: hpm_usb_regs.h:1201
#define USB_PORTSC1_FPR_MASK
Definition: hpm_usb_regs.h:1391
#define USB_PORTSC1_PSPD_GET(x)
Definition: hpm_usb_regs.h:1166
#define USB_OTG_CTRL0_OTG_ID_WAKEUP_EN_MASK
Definition: hpm_usb_regs.h:2021
#define USB_PHY_STATUS_UTMI_CLK_VALID_GET(x)
Definition: hpm_usb_regs.h:2215
#define USB_USBCMD_ASE_MASK
Definition: hpm_usb_regs.h:374
#define USB_PORTSC1_SUSP_MASK
Definition: hpm_usb_regs.h:1365
#define USB_DEVICEADDR_USBADRA_MASK
Definition: hpm_usb_regs.h:938
#define USB_PORTSC1_PR_GET(x)
Definition: hpm_usb_regs.h:1341
#define USB_OTG_CTRL0_OTG_VBUS_WAKEUP_EN_MASK
Definition: hpm_usb_regs.h:2012
#define USB_ENDPTLISTADDR_EPBASE_MASK
Definition: hpm_usb_regs.h:980
#define USB_PHY_CTRL0_SESS_VALID_OVERRIDE_EN_MASK
Definition: hpm_usb_regs.h:2161
#define USB_PORTSC1_SUSP_GET(x)
Definition: hpm_usb_regs.h:1368
#define USB_TOP_STATUS_WAKEUP_INT_STATUS_GET(x)
Definition: hpm_usb_regs.h:2205
static void usb_otg_enable_wakeup_int(USB_Type *ptr)
Enable otg wakeup interrupt.
Definition: hpm_usb_drv.h:279
bool usb_hcd_init(USB_Type *ptr, uint32_t int_mask, uint16_t framelist_size)
Initialize controller to host mode.
Definition: hpm_usb_drv.c:306
static bool usb_get_port_reset_status(USB_Type *ptr)
Get USB reset status.
Definition: hpm_usb_drv.h:322
static void usb_otg_set_vbus_wakeup_source(USB_Type *ptr, usb_vbus_wakeup_source_t src)
Set otg vbus wakeup source.
Definition: hpm_usb_drv.h:269
static void usb_otg_enable_vbus_wakeup(USB_Type *ptr)
Enable otg vbus change wakeup.
Definition: hpm_usb_drv.h:248
static bool usb_otgsc_session_valid_chg_int_is_enable(USB_Type *ptr)
check otgsc session valid change interrupt is enable
Definition: hpm_usb_drv.h:444
static uint8_t usb_get_port_speed(USB_Type *ptr)
Get USB port speed status.
Definition: hpm_usb_drv.h:344
static bool usb_get_otg_wakeup_int_flag(USB_Type *ptr)
Get otg wakeup status flags.
Definition: hpm_usb_drv.h:300
void usb_dcd_edpt_close(USB_Type *ptr, uint8_t ep_addr)
Close a specified endpoint.
Definition: hpm_usb_drv.c:274
static uint8_t usb_get_suspend_status(USB_Type *ptr)
Get USB suspend status.
Definition: hpm_usb_drv.h:311
static void usb_otg_disable_dpdm_wakeup(USB_Type *ptr)
Disbable otg dp/dm change wakeup.
Definition: hpm_usb_drv.h:218
static void usb_otg_disable_wakeup_int(USB_Type *ptr)
Disable otg wakeup interrupt.
Definition: hpm_usb_drv.h:289
static bool usb_hcd_get_port_csc(USB_Type *ptr)
Get port connect status change.
Definition: hpm_usb_drv.h:781
void usb_dcd_connect(USB_Type *ptr)
Connect by enabling internal pull-up resistor on D+/D-.
Definition: hpm_usb_drv.c:190
void usb_dcd_edpt_stall(USB_Type *ptr, uint8_t ep_addr)
Stall endpoint.
Definition: hpm_usb_drv.c:248
static uint32_t usb_hcd_get_frame_index(USB_Type *ptr)
Get frame index.
Definition: hpm_usb_drv.h:770
static bool usb_phy_get_session_valid_flag(USB_Type *ptr)
Get phy session valid flag.
Definition: hpm_usb_drv.h:413
static void usb_hcd_set_power_ctrl_polarity(USB_Type *ptr, bool high)
Set power ctrl polarity.
Definition: hpm_usb_drv.h:792
static void usb_otgsc_enable_session_valid_chg_int(USB_Type *ptr)
enable otgsc session valid change interrupt
Definition: hpm_usb_drv.h:423
static uint32_t usb_dcd_get_edpt_setup_status(USB_Type *ptr)
Get setup status of endpoint.
Definition: hpm_usb_drv.h:662
void usb_dcd_deinit(USB_Type *ptr)
Deinitialize controller to device.
Definition: hpm_usb_drv.c:166
static void usb_phy_exit_low_power_suspend(USB_Type *ptr)
USB phy exit low power suspend.
Definition: hpm_usb_drv.h:397
static void usb_otgsc_disable_session_valid_chg_int(USB_Type *ptr)
disable otgsc session valid change interrupt
Definition: hpm_usb_drv.h:433
static void usb_hcd_set_command(USB_Type *ptr, uint32_t mask)
Initialize controller to host modeHost set command register.
Definition: hpm_usb_drv.h:759
static void usb_dcd_set_edpt_list_addr(USB_Type *ptr, uint32_t addr)
Set endpoint list address.
Definition: hpm_usb_drv.h:695
static uint32_t usb_get_status_flags(USB_Type *ptr)
Get all USB status flags.
Definition: hpm_usb_drv.h:184
void usb_dcd_bus_reset(USB_Type *ptr, uint16_t ep0_max_packet_size)
USB device bus reset.
Definition: hpm_usb_drv.c:94
static void usb_dcd_set_address(USB_Type *ptr, uint8_t dev_addr)
Set address.
Definition: hpm_usb_drv.h:684
static void usb_phy_enter_low_power_suspend(USB_Type *ptr)
USB phy enter low power suspend.
Definition: hpm_usb_drv.h:387
static void usb_phy_using_external_vbus(USB_Type *ptr)
USB phy using external vbus.
Definition: hpm_usb_drv.h:515
static void usb_hcd_stop(USB_Type *ptr)
Stop hcd controller.
Definition: hpm_usb_drv.h:848
uint8_t usb_dcd_edpt_get_type(USB_Type *ptr, uint8_t ep_addr)
get a specified endpoint type
Definition: hpm_usb_drv.c:231
static void usb_otg_enable_dpdm_wakeup(USB_Type *ptr)
Enable otg dp/dm change wakeup.
Definition: hpm_usb_drv.h:208
static void usb_set_port_test_mode(USB_Type *ptr, usb_test_mode_t test_mode)
Set port test control mode.
Definition: hpm_usb_drv.h:355
usb_line_state_t
USB line state.
Definition: hpm_usb_drv.h:67
usb_test_mode_t
USB test modes.
Definition: hpm_usb_drv.h:84
static void usb_otg_enable_id_wakeup(USB_Type *ptr)
Enable otg id change wakeup.
Definition: hpm_usb_drv.h:228
static void usb_hcd_run(USB_Type *ptr)
Start hcd controller.
Definition: hpm_usb_drv.h:838
usb_vbus_wakeup_source_t
USB vbus wakeup source.
Definition: hpm_usb_drv.h:98
void usb_phy_init(USB_Type *ptr, bool host)
Initialize USB phy.
Definition: hpm_usb_drv.c:62
static void usb_hcd_set_periodic_list_addr(USB_Type *ptr, uint32_t addr)
Set periodic list address.
Definition: hpm_usb_drv.h:828
static void usb_phy_using_internal_vbus(USB_Type *ptr)
USB phy using internal vbus.
Definition: hpm_usb_drv.h:504
static uint32_t usb_dcd_get_edpt_complete_status(USB_Type *ptr)
Get complete status of endpoint.
Definition: hpm_usb_drv.h:717
static void usb_dcd_clear_edpt_complete_status(USB_Type *ptr, uint32_t mask)
Clear complete status of endpoint.
Definition: hpm_usb_drv.h:728
bool usb_dcd_edpt_check_stall(USB_Type *ptr, uint8_t ep_addr)
Clear stall.
Definition: hpm_usb_drv.c:266
static void usb_enable_interrupts(USB_Type *ptr, uint32_t mask)
Enable interrupts.
Definition: hpm_usb_drv.h:162
static void usb_hcd_enable_ase_pse(USB_Type *ptr)
Enable hcd controller Asynchronous Schedule and Periodic Schedule.
Definition: hpm_usb_drv.h:871
void usb_hcd_port_reset(USB_Type *ptr)
Initialize controller to host modeHost Reset port.
Definition: hpm_usb_drv.c:358
static void usb_force_port_resume(USB_Type *ptr)
USB force port resume.
Definition: hpm_usb_drv.h:375
static uint32_t usb_get_interrupts(USB_Type *ptr)
Get the mask of all enabled interrupts.
Definition: hpm_usb_drv.h:151
static void usb_otg_disable_id_wakeup(USB_Type *ptr)
Disbable otg id change wakeup.
Definition: hpm_usb_drv.h:238
void usb_dcd_edpt_xfer(USB_Type *ptr, uint8_t ep_idx)
Submit a transfer.
Definition: hpm_usb_drv.c:240
static bool usb_get_port_ccs(USB_Type *ptr)
Get USB current connect status.
Definition: hpm_usb_drv.h:333
void usb_dcd_edpt_open(USB_Type *ptr, usb_endpoint_config_t *config)
Open an endpoint.
Definition: hpm_usb_drv.c:219
static bool usb_otgsc_get_session_valid_chg_flag(USB_Type *ptr)
get otgsc session valid change flag
Definition: hpm_usb_drv.h:455
static void usb_clear_status_flags(USB_Type *ptr, uint32_t mask)
Clear status flags.
Definition: hpm_usb_drv.h:198
void usb_dcd_disconnect(USB_Type *ptr)
Disconnect by disabling internal pull-up resistor on D+/D-.
Definition: hpm_usb_drv.c:196
static uint8_t usb_dcd_get_device_addr(USB_Type *ptr)
Get device address.
Definition: hpm_usb_drv.h:706
void usb_dcd_remote_wakeup(USB_Type *ptr)
Wakeup from host.
Definition: hpm_usb_drv.c:301
usb_transceiver_t
USB transceiver.
Definition: hpm_usb_drv.h:76
static void usb_hcd_set_async_list_addr(USB_Type *ptr, uint32_t addr)
Get port connect status changeSet async list address.
Definition: hpm_usb_drv.h:817
static void usb_phy_disable_dp_dm_pulldown(USB_Type *ptr)
USB phy disconnect dp/dm pins pulldown resistance.
Definition: hpm_usb_drv.h:526
static void usb_otg_disable_vbus_wakeup(USB_Type *ptr)
Disbable otg vbus change wakeup.
Definition: hpm_usb_drv.h:258
usb_dir_t
USB transfer direction types.
Definition: hpm_usb_drv.h:39
usb_controller_mode_t
USB controller work modes.
Definition: hpm_usb_drv.h:58
static void usb_disable_interrupts(USB_Type *ptr, uint32_t mask)
Disable interrupts.
Definition: hpm_usb_drv.h:173
usb_xfer_type_t
USB transfer types.
Definition: hpm_usb_drv.h:48
static void usb_otgsc_clear_session_valid_chg_flag(USB_Type *ptr)
clear otgsc session valid change flag
Definition: hpm_usb_drv.h:465
static bool usb_otgsc_get_session_valid_flag(USB_Type *ptr)
Get otgsc session valid flag.
Definition: hpm_usb_drv.h:476
usb_control_request_t
Definition: hpm_usb_drv.h:125
static void usb_dcd_clear_edpt_setup_status(USB_Type *ptr, uint32_t mask)
Clear the setup status of all specified endpoints.
Definition: hpm_usb_drv.h:673
void usb_dcd_edpt_clear_stall(USB_Type *ptr, uint8_t ep_addr)
Clear stall.
Definition: hpm_usb_drv.c:256
static void usb_phy_enable_dp_dm_pulldown(USB_Type *ptr)
USB phy connect dp/dm pins pulldown resistance.
Definition: hpm_usb_drv.h:536
static void usb_set_port_suspend(USB_Type *ptr)
USB set port suspend.
Definition: hpm_usb_drv.h:365
static void usb_phyctrl1_set_not_utmi_suspend(USB_Type *ptr)
Set phyctrl1 not utmi suspend.
Definition: hpm_usb_drv.h:546
static void usb_hcd_enable_port_power(USB_Type *ptr)
Enable port power.
Definition: hpm_usb_drv.h:806
static uint8_t usb_phy_get_line_state(USB_Type *ptr)
USB phy get line status.
Definition: hpm_usb_drv.h:494
static void usb_hcd_disable_ase_pse(USB_Type *ptr)
Disable hcd controller Asynchronous Schedule and Periodic Schedule.
Definition: hpm_usb_drv.h:858
void usb_dcd_init(USB_Type *ptr)
Initialize controller to device mode.
Definition: hpm_usb_drv.c:122
@ usb_line_state1
Definition: hpm_usb_drv.h:69
@ usb_line_state2
Definition: hpm_usb_drv.h:70
@ usb_line_state0
Definition: hpm_usb_drv.h:68
@ usb_test_k_state
Definition: hpm_usb_drv.h:87
@ usb_test_se0_nak
Definition: hpm_usb_drv.h:88
@ usb_test_mode_disable
Definition: hpm_usb_drv.h:85
@ usb_test_j_state
Definition: hpm_usb_drv.h:86
@ usb_test_force_ls
Definition: hpm_usb_drv.h:92
@ usb_test_force_fs
Definition: hpm_usb_drv.h:91
@ usb_test_force_hs
Definition: hpm_usb_drv.h:90
@ usb_test_packet
Definition: hpm_usb_drv.h:89
@ usb_vbus_wakeup_session_valid
Definition: hpm_usb_drv.h:100
@ usb_vbus_wakeup_vbus_valid
Definition: hpm_usb_drv.h:99
@ usb_tran_serial
Definition: hpm_usb_drv.h:78
@ usb_tran_parallel
Definition: hpm_usb_drv.h:77
@ usb_dir_in_mask
Definition: hpm_usb_drv.h:42
@ usb_dir_in
Definition: hpm_usb_drv.h:41
@ usb_dir_out
Definition: hpm_usb_drv.h:40
@ usb_ctrl_mode_device
Definition: hpm_usb_drv.h:60
@ usb_ctrl_mode_host
Definition: hpm_usb_drv.h:61
@ usb_ctrl_mode_otg
Definition: hpm_usb_drv.h:59
@ usb_xfer_bulk
Definition: hpm_usb_drv.h:51
@ usb_xfer_interrupt
Definition: hpm_usb_drv.h:52
@ usb_xfer_isochronous
Definition: hpm_usb_drv.h:50
@ usb_xfer_control
Definition: hpm_usb_drv.h:49
Definition: hpm_usb_regs.h:12
__RW uint32_t OTG_CTRL0
Definition: hpm_usb_regs.h:50
__RW uint32_t PHY_CTRL1
Definition: hpm_usb_regs.h:53
__RW uint32_t PHY_STATUS
Definition: hpm_usb_regs.h:56
__RW uint32_t FRINDEX
Definition: hpm_usb_regs.h:23
__RW uint32_t USBCMD
Definition: hpm_usb_regs.h:20
__RW uint32_t DEVICEADDR
Definition: hpm_usb_regs.h:26
__RW uint32_t ENDPTLISTADDR
Definition: hpm_usb_regs.h:31
__RW uint32_t PERIODICLISTBASE
Definition: hpm_usb_regs.h:27
__RW uint32_t USBINTR
Definition: hpm_usb_regs.h:22
__RW uint32_t ENDPTCOMPLETE
Definition: hpm_usb_regs.h:48
__RW uint32_t PORTSC1
Definition: hpm_usb_regs.h:40
__RW uint32_t PHY_CTRL0
Definition: hpm_usb_regs.h:52
__RW uint32_t ENDPTSETUPSTAT
Definition: hpm_usb_regs.h:44
__RW uint32_t USBSTS
Definition: hpm_usb_regs.h:21
__RW uint32_t OTGSC
Definition: hpm_usb_regs.h:42
__RW uint32_t TOP_STATUS
Definition: hpm_usb_regs.h:55
__RW uint32_t ASYNCLISTADDR
Definition: hpm_usb_regs.h:30
Endpoint config structure.
Definition: hpm_usb_drv.h:130
uint8_t ep_addr
Definition: hpm_usb_drv.h:132
uint8_t xfer
Definition: hpm_usb_drv.h:131
uint16_t max_packet_size
Definition: hpm_usb_drv.h:133