HPM SDK
HPMicro Software Development Kit
hpm_usb_drv.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021-2025 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 (25U)
30 #define USB_PHY_DEINIT_DELAY_COUNT (5000U)
31 #define USB_HOST_FRAMELIST_SIZE (8U)
33 /*---------------------------------------------------------------------
34  * Macro Enum Declarations
35  *---------------------------------------------------------------------
36  */
40 typedef enum {
43  usb_dir_in_mask = 0x80
49 typedef enum {
59 typedef enum {
68 typedef enum {
71  usb_line_state2 = 2
77 typedef enum {
79  usb_tran_serial = 1
85 typedef enum {
99 typedef enum {
104 /*---------------------------------------------------------------------
105  * Structure Declarations
106  *---------------------------------------------------------------------
107  */
111 typedef struct __attribute__ ((packed)) {
112  union {
113  struct __attribute__ ((packed)) {
114  uint8_t recipient : 5;
115  uint8_t type : 2;
116  uint8_t direction : 1;
117  } bmRequestType_bit;
118 
119  uint8_t bmRequestType;
120  };
121 
122  uint8_t bRequest;
123  uint16_t wValue;
124  uint16_t wIndex;
125  uint16_t wLength;
127 
131 typedef struct {
132  uint8_t xfer;
133  uint8_t ep_addr;
134  uint16_t max_packet_size;
136 
137 #if defined __cplusplus
138 extern "C" {
139 #endif /* __cplusplus */
140 
141 /*---------------------------------------------------------------------
142  * Common API
143  *---------------------------------------------------------------------
144  */
145 
152 static inline uint32_t usb_get_interrupts(USB_Type *ptr)
153 {
154  return ptr->USBINTR;
155 }
156 
163 static inline void usb_enable_interrupts(USB_Type *ptr, uint32_t mask)
164 {
165  ptr->USBINTR |= mask;
166 }
167 
174 static inline void usb_disable_interrupts(USB_Type *ptr, uint32_t mask)
175 {
176  ptr->USBINTR &= ~mask;
177 }
178 
185 static inline uint32_t usb_get_status_flags(USB_Type *ptr)
186 {
187  return ptr->USBSTS;
188 }
189 
199 static inline void usb_clear_status_flags(USB_Type *ptr, uint32_t mask)
200 {
201  ptr->USBSTS = mask;
202 }
203 
209 static inline void usb_otg_enable_dpdm_wakeup(USB_Type *ptr)
210 {
212 }
213 
219 static inline void usb_otg_disable_dpdm_wakeup(USB_Type *ptr)
220 {
222 }
223 
229 static inline void usb_otg_enable_id_wakeup(USB_Type *ptr)
230 {
232 }
233 
239 static inline void usb_otg_disable_id_wakeup(USB_Type *ptr)
240 {
242 }
243 
249 static inline void usb_otg_enable_vbus_wakeup(USB_Type *ptr)
250 {
252 }
253 
259 static inline void usb_otg_disable_vbus_wakeup(USB_Type *ptr)
260 {
262 }
263 
271 {
273 }
274 
280 static inline void usb_otg_enable_wakeup_int(USB_Type *ptr)
281 {
283 }
284 
290 static inline void usb_otg_disable_wakeup_int(USB_Type *ptr)
291 {
293 }
294 
301 static inline bool usb_get_otg_wakeup_int_flag(USB_Type *ptr)
302 {
303  return (USB_TOP_STATUS_WAKEUP_INT_STATUS_GET(ptr->TOP_STATUS) != 0) ? true : false;
304 }
305 
312 static inline uint8_t usb_get_suspend_status(USB_Type *ptr)
313 {
314  return USB_PORTSC1_SUSP_GET(ptr->PORTSC1);
315 }
316 
323 static inline bool usb_get_port_reset_status(USB_Type *ptr)
324 {
325  return USB_PORTSC1_PR_GET(ptr->PORTSC1);
326 }
327 
334 static inline bool usb_get_port_ccs(USB_Type *ptr)
335 {
336  return USB_PORTSC1_CCS_GET(ptr->PORTSC1);
337 }
338 
345 static inline uint8_t usb_get_port_speed(USB_Type *ptr)
346 {
347  return USB_PORTSC1_PSPD_GET(ptr->PORTSC1);
348 }
349 
356 static inline void usb_set_port_test_mode(USB_Type *ptr, usb_test_mode_t test_mode)
357 {
358  ptr->PORTSC1 = (ptr->PORTSC1 & ~USB_PORTSC1_PTC_MASK) | USB_PORTSC1_PTC_SET(test_mode);
359 }
360 
366 static inline void usb_set_port_suspend(USB_Type *ptr)
367 {
369 }
370 
376 static inline void usb_force_port_resume(USB_Type *ptr)
377 {
379  while ((ptr->PORTSC1 & USB_PORTSC1_FPR_MASK) != 0) {
380  }
381 }
382 
389 {
391 }
392 
398 static inline void usb_phy_exit_low_power_suspend(USB_Type *ptr)
399 {
401  /* otg utmi clock detection */
402  ptr->PHY_STATUS |= USB_PHY_STATUS_UTMI_CLK_VALID_MASK; /* write 1 to clear valid status */
403  while (USB_PHY_STATUS_UTMI_CLK_VALID_GET(ptr->PHY_STATUS) == 0) { /* get utmi clock status */
404  ;
405  }
406 }
407 
414 static inline bool usb_phy_get_session_valid_flag(USB_Type *ptr)
415 {
416  return (USB_PHY_STATUS_UTMI_SESS_VALID_GET(ptr->PHY_STATUS) != 0) ? true : false;
417 }
418 
425 {
426  ptr->OTGSC |= USB_OTGSC_ASVIE_MASK;
427 }
428 
435 {
436  ptr->OTGSC &= ~USB_OTGSC_ASVIE_MASK;
437 }
438 
446 {
447  return ((ptr->OTGSC & USB_OTGSC_ASVIE_MASK) != 0);
448 }
449 
457 {
458  return (USB_OTGSC_ASVIS_SET(ptr->OTGSC) != 0) ? true : false;
459 }
460 
467 {
468  ptr->OTGSC |= USB_OTGSC_ASVIS_MASK;
469 }
470 
478 {
479  return (USB_OTGSC_ASV_GET(ptr->OTGSC) != 0) ? true : false;
480 }
481 
487 void usb_phy_deinit(USB_Type *ptr);
488 
495 void usb_phy_init(USB_Type *ptr, bool host);
496 
502 static inline uint8_t usb_phy_get_line_state(USB_Type *ptr)
503 {
505 }
506 
512 static inline void usb_phy_using_internal_vbus(USB_Type *ptr)
513 {
516 }
517 
523 static inline void usb_phy_using_external_vbus(USB_Type *ptr)
524 {
527 }
528 
534 static inline void usb_phy_disable_dp_dm_pulldown(USB_Type *ptr)
535 {
536  ptr->PHY_CTRL0 |= 0x001000E0u;
537 }
538 
544 static inline void usb_phy_enable_dp_dm_pulldown(USB_Type *ptr)
545 {
546  ptr->PHY_CTRL0 &= ~0x001000E0u;
547 }
548 
555 {
557 }
558 
559 /*---------------------------------------------------------------------
560  * Device API
561  *---------------------------------------------------------------------
562  */
563 
570 void usb_dcd_bus_reset(USB_Type *ptr, uint16_t ep0_max_packet_size);
571 
577 void usb_dcd_init(USB_Type *ptr);
578 
584 void usb_dcd_deinit(USB_Type *ptr);
585 
592 
600 
607 uint8_t usb_dcd_edpt_get_type(USB_Type *ptr, uint8_t ep_addr);
608 
615 void usb_dcd_edpt_xfer(USB_Type *ptr, uint8_t ep_idx);
616 
623 void usb_dcd_edpt_stall(USB_Type *ptr, uint8_t ep_addr);
624 
631 void usb_dcd_edpt_clear_stall(USB_Type *ptr, uint8_t ep_addr);
632 
640 bool usb_dcd_edpt_check_stall(USB_Type *ptr, uint8_t ep_addr);
641 
648 void usb_dcd_edpt_close(USB_Type *ptr, uint8_t ep_addr);
649 
655 void usb_dcd_connect(USB_Type *ptr);
656 
662 void usb_dcd_disconnect(USB_Type *ptr);
663 
670 static inline uint32_t usb_dcd_get_edpt_setup_status(USB_Type *ptr)
671 {
672  return ptr->ENDPTSETUPSTAT;
673 }
674 
681 static inline void usb_dcd_clear_edpt_setup_status(USB_Type *ptr, uint32_t mask)
682 {
683  ptr->ENDPTSETUPSTAT = mask;
684 }
685 
692 static inline void usb_dcd_set_address(USB_Type *ptr, uint8_t dev_addr)
693 {
695 }
696 
703 static inline void usb_dcd_set_edpt_list_addr(USB_Type *ptr, uint32_t addr)
704 {
706 }
707 
714 static inline uint8_t usb_dcd_get_device_addr(USB_Type *ptr)
715 {
717 }
718 
725 static inline uint32_t usb_dcd_get_edpt_complete_status(USB_Type *ptr)
726 {
727  return ptr->ENDPTCOMPLETE;
728 }
729 
736 static inline void usb_dcd_clear_edpt_complete_status(USB_Type *ptr, uint32_t mask)
737 {
738  ptr->ENDPTCOMPLETE = mask;
739 }
740 
741 /*---------------------------------------------------------------------
742  * Host API
743  *---------------------------------------------------------------------
744  */
752 bool usb_hcd_init(USB_Type *ptr, uint32_t int_mask, uint16_t framelist_size);
753 
759 void usb_hcd_port_reset(USB_Type *ptr);
760 
767 static inline void usb_hcd_set_command(USB_Type *ptr, uint32_t mask)
768 {
769  ptr->USBCMD |= mask;
770 }
771 
778 static inline uint32_t usb_hcd_get_frame_index(USB_Type *ptr)
779 {
780  return ptr->FRINDEX;
781 }
782 
789 static inline bool usb_hcd_get_port_csc(USB_Type *ptr)
790 {
791  return USB_PORTSC1_CSC_GET(ptr->PORTSC1);
792 }
793 
800 static inline void usb_hcd_set_power_ctrl_polarity(USB_Type *ptr, bool high)
801 {
802  if (high) {
804  } else {
806  }
807 }
808 
814 static inline void usb_hcd_enable_port_power(USB_Type *ptr)
815 {
817 }
818 
825 static inline void usb_hcd_set_async_list_addr(USB_Type *ptr, uint32_t addr)
826 {
828 }
829 
836 static inline void usb_hcd_set_periodic_list_addr(USB_Type *ptr, uint32_t addr)
837 {
839 }
840 
846 static inline void usb_hcd_run(USB_Type *ptr)
847 {
848  ptr->USBCMD |= USB_USBCMD_RS_MASK;
849 }
850 
856 static inline void usb_hcd_stop(USB_Type *ptr)
857 {
858  ptr->USBCMD &= ~USB_USBCMD_RS_MASK;
859 }
860 
866 static inline void usb_hcd_disable_ase_pse(USB_Type *ptr)
867 {
869  while (ptr->USBCMD & (USB_USBCMD_PSE_MASK | USB_USBCMD_ASE_MASK)) {
870  ;
871  }
872 }
873 
879 static inline void usb_hcd_enable_ase_pse(USB_Type *ptr)
880 {
882 }
883 
884 #if defined __cplusplus
885 }
886 #endif /* __cplusplus */
887 
889 #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:280
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:323
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:270
static void usb_otg_enable_vbus_wakeup(USB_Type *ptr)
Enable otg vbus change wakeup.
Definition: hpm_usb_drv.h:249
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:445
static uint8_t usb_get_port_speed(USB_Type *ptr)
Get USB port speed status.
Definition: hpm_usb_drv.h:345
static bool usb_get_otg_wakeup_int_flag(USB_Type *ptr)
Get otg wakeup status flags.
Definition: hpm_usb_drv.h:301
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:312
static void usb_otg_disable_dpdm_wakeup(USB_Type *ptr)
Disbable otg dp/dm change wakeup.
Definition: hpm_usb_drv.h:219
static void usb_otg_disable_wakeup_int(USB_Type *ptr)
Disable otg wakeup interrupt.
Definition: hpm_usb_drv.h:290
static bool usb_hcd_get_port_csc(USB_Type *ptr)
Get port connect status change.
Definition: hpm_usb_drv.h:789
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:778
static bool usb_phy_get_session_valid_flag(USB_Type *ptr)
Get phy session valid flag.
Definition: hpm_usb_drv.h:414
static void usb_hcd_set_power_ctrl_polarity(USB_Type *ptr, bool high)
Set power ctrl polarity.
Definition: hpm_usb_drv.h:800
static void usb_otgsc_enable_session_valid_chg_int(USB_Type *ptr)
enable otgsc session valid change interrupt
Definition: hpm_usb_drv.h:424
static uint32_t usb_dcd_get_edpt_setup_status(USB_Type *ptr)
Get setup status of endpoint.
Definition: hpm_usb_drv.h:670
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:398
static void usb_otgsc_disable_session_valid_chg_int(USB_Type *ptr)
disable otgsc session valid change interrupt
Definition: hpm_usb_drv.h:434
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:767
static void usb_dcd_set_edpt_list_addr(USB_Type *ptr, uint32_t addr)
Set endpoint list address.
Definition: hpm_usb_drv.h:703
static uint32_t usb_get_status_flags(USB_Type *ptr)
Get all USB status flags.
Definition: hpm_usb_drv.h:185
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:692
static void usb_phy_enter_low_power_suspend(USB_Type *ptr)
USB phy enter low power suspend.
Definition: hpm_usb_drv.h:388
static void usb_phy_using_external_vbus(USB_Type *ptr)
USB phy using external vbus.
Definition: hpm_usb_drv.h:523
static void usb_hcd_stop(USB_Type *ptr)
Stop hcd controller.
Definition: hpm_usb_drv.h:856
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:209
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:356
usb_line_state_t
USB line state.
Definition: hpm_usb_drv.h:68
usb_test_mode_t
USB test modes.
Definition: hpm_usb_drv.h:85
static void usb_otg_enable_id_wakeup(USB_Type *ptr)
Enable otg id change wakeup.
Definition: hpm_usb_drv.h:229
static void usb_hcd_run(USB_Type *ptr)
Start hcd controller.
Definition: hpm_usb_drv.h:846
usb_vbus_wakeup_source_t
USB vbus wakeup source.
Definition: hpm_usb_drv.h:99
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:836
static void usb_phy_using_internal_vbus(USB_Type *ptr)
USB phy using internal vbus.
Definition: hpm_usb_drv.h:512
static uint32_t usb_dcd_get_edpt_complete_status(USB_Type *ptr)
Get complete status of endpoint.
Definition: hpm_usb_drv.h:725
static void usb_dcd_clear_edpt_complete_status(USB_Type *ptr, uint32_t mask)
Clear complete status of endpoint.
Definition: hpm_usb_drv.h:736
bool usb_dcd_edpt_check_stall(USB_Type *ptr, uint8_t ep_addr)
Clear stall.
Definition: hpm_usb_drv.c:266
void usb_phy_deinit(USB_Type *ptr)
De-Initialize USB phy.
Definition: hpm_usb_drv.c:36
static void usb_enable_interrupts(USB_Type *ptr, uint32_t mask)
Enable interrupts.
Definition: hpm_usb_drv.h:163
static void usb_hcd_enable_ase_pse(USB_Type *ptr)
Enable hcd controller Asynchronous Schedule and Periodic Schedule.
Definition: hpm_usb_drv.h:879
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:376
static uint32_t usb_get_interrupts(USB_Type *ptr)
Get the mask of all enabled interrupts.
Definition: hpm_usb_drv.h:152
static void usb_otg_disable_id_wakeup(USB_Type *ptr)
Disbable otg id change wakeup.
Definition: hpm_usb_drv.h:239
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:334
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:456
static void usb_clear_status_flags(USB_Type *ptr, uint32_t mask)
Clear status flags.
Definition: hpm_usb_drv.h:199
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:714
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:77
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:825
static void usb_phy_disable_dp_dm_pulldown(USB_Type *ptr)
USB phy disconnect dp/dm pins pulldown resistance.
Definition: hpm_usb_drv.h:534
static void usb_otg_disable_vbus_wakeup(USB_Type *ptr)
Disbable otg vbus change wakeup.
Definition: hpm_usb_drv.h:259
usb_dir_t
USB transfer direction types.
Definition: hpm_usb_drv.h:40
usb_controller_mode_t
USB controller work modes.
Definition: hpm_usb_drv.h:59
static void usb_disable_interrupts(USB_Type *ptr, uint32_t mask)
Disable interrupts.
Definition: hpm_usb_drv.h:174
usb_xfer_type_t
USB transfer types.
Definition: hpm_usb_drv.h:49
static void usb_otgsc_clear_session_valid_chg_flag(USB_Type *ptr)
clear otgsc session valid change flag
Definition: hpm_usb_drv.h:466
static bool usb_otgsc_get_session_valid_flag(USB_Type *ptr)
Get otgsc session valid flag.
Definition: hpm_usb_drv.h:477
usb_control_request_t
Definition: hpm_usb_drv.h:126
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:681
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:544
static void usb_set_port_suspend(USB_Type *ptr)
USB set port suspend.
Definition: hpm_usb_drv.h:366
static void usb_phyctrl1_set_not_utmi_suspend(USB_Type *ptr)
Set phyctrl1 not utmi suspend.
Definition: hpm_usb_drv.h:554
static void usb_hcd_enable_port_power(USB_Type *ptr)
Enable port power.
Definition: hpm_usb_drv.h:814
static uint8_t usb_phy_get_line_state(USB_Type *ptr)
USB phy get line status.
Definition: hpm_usb_drv.h:502
static void usb_hcd_disable_ase_pse(USB_Type *ptr)
Disable hcd controller Asynchronous Schedule and Periodic Schedule.
Definition: hpm_usb_drv.h:866
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:70
@ usb_line_state2
Definition: hpm_usb_drv.h:71
@ usb_line_state0
Definition: hpm_usb_drv.h:69
@ usb_test_k_state
Definition: hpm_usb_drv.h:88
@ usb_test_se0_nak
Definition: hpm_usb_drv.h:89
@ usb_test_mode_disable
Definition: hpm_usb_drv.h:86
@ usb_test_j_state
Definition: hpm_usb_drv.h:87
@ usb_test_force_ls
Definition: hpm_usb_drv.h:93
@ usb_test_force_fs
Definition: hpm_usb_drv.h:92
@ usb_test_force_hs
Definition: hpm_usb_drv.h:91
@ usb_test_packet
Definition: hpm_usb_drv.h:90
@ usb_vbus_wakeup_session_valid
Definition: hpm_usb_drv.h:101
@ usb_vbus_wakeup_vbus_valid
Definition: hpm_usb_drv.h:100
@ usb_tran_serial
Definition: hpm_usb_drv.h:79
@ usb_tran_parallel
Definition: hpm_usb_drv.h:78
@ usb_dir_in_mask
Definition: hpm_usb_drv.h:43
@ usb_dir_in
Definition: hpm_usb_drv.h:42
@ usb_dir_out
Definition: hpm_usb_drv.h:41
@ usb_ctrl_mode_device
Definition: hpm_usb_drv.h:61
@ usb_ctrl_mode_host
Definition: hpm_usb_drv.h:62
@ usb_ctrl_mode_otg
Definition: hpm_usb_drv.h:60
@ usb_xfer_bulk
Definition: hpm_usb_drv.h:52
@ usb_xfer_interrupt
Definition: hpm_usb_drv.h:53
@ usb_xfer_isochronous
Definition: hpm_usb_drv.h:51
@ usb_xfer_control
Definition: hpm_usb_drv.h:50
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:131
uint8_t ep_addr
Definition: hpm_usb_drv.h:133
uint8_t xfer
Definition: hpm_usb_drv.h:132
uint16_t max_packet_size
Definition: hpm_usb_drv.h:134