diff options
| author | sakumisu <[email protected]> | 2022-09-17 14:26:16 +0800 |
|---|---|---|
| committer | sakumisu <[email protected]> | 2022-09-17 14:26:16 +0800 |
| commit | 946b978053ace0caa9eefff467a266a2e37f0212 (patch) | |
| tree | 0c42d5c33143ddfe20ea28bbb6d2d9deacc07e70 | |
| parent | 0412b6b68573c881b64f83eb7c9d8576aeb6e379 (diff) | |
add bcdr register for usb connect
| -rw-r--r-- | port/fsdev/usb_dc_fsdev.c | 5 | ||||
| -rw-r--r-- | port/fsdev/usb_fsdev_reg.h | 21 |
2 files changed, 26 insertions, 0 deletions
diff --git a/port/fsdev/usb_dc_fsdev.c b/port/fsdev/usb_dc_fsdev.c index 5c64ac6e..a239e54c 100644 --- a/port/fsdev/usb_dc_fsdev.c +++ b/port/fsdev/usb_dc_fsdev.c @@ -17,6 +17,8 @@ #define USB_RAM_SIZE 512 #endif +#warning please check your PMA_ACCESS is 1 or 2 + #define USB ((USB_TypeDef *)USB_BASE) #define USB_BTABLE_SIZE (8 * USB_NUM_BIDIR_ENDPOINTS) @@ -82,6 +84,9 @@ int usb_dc_init(void) /* Set interrupt mask */ USB->CNTR = (uint16_t)winterruptmask; + /* Enabling DP Pull-UP bit to Connect internal PU resistor on USB DP line */ + USB->BCDR |= (uint16_t)USB_BCDR_DPPU; + return 0; } diff --git a/port/fsdev/usb_fsdev_reg.h b/port/fsdev/usb_fsdev_reg.h index c9f532ba..d90595b3 100644 --- a/port/fsdev/usb_fsdev_reg.h +++ b/port/fsdev/usb_fsdev_reg.h @@ -34,6 +34,10 @@ typedef struct __IO uint16_t RESERVEDB; /*!< Reserved */ __IO uint16_t BTABLE; /*!< Buffer Table address register, Address offset: 0x50 */ __IO uint16_t RESERVEDC; /*!< Reserved */ + __IO uint16_t LPMCSR; /*!< LPM Control and Status register, Address offset: 0x54 */ + __IO uint16_t RESERVEDD; /*!< Reserved */ + __IO uint16_t BCDR; /*!< Battery Charging detector register, Address offset: 0x58 */ + __IO uint16_t RESERVEDE; /*!< Reserved */ } USB_TypeDef; /******************************************************************************/ @@ -592,6 +596,23 @@ typedef struct #define USB_BTABLE_BTABLE_Msk (0x1FFFUL << USB_BTABLE_BTABLE_Pos) /*!< 0x0000FFF8 */ #define USB_BTABLE_BTABLE USB_BTABLE_BTABLE_Msk /*!< Buffer Table */ +/****************** Bits definition for USB_BCDR register *******************/ +#define USB_BCDR_BCDEN ((uint16_t)0x0001U) /*!< Battery charging detector (BCD) enable */ +#define USB_BCDR_DCDEN ((uint16_t)0x0002U) /*!< Data contact detection (DCD) mode enable */ +#define USB_BCDR_PDEN ((uint16_t)0x0004U) /*!< Primary detection (PD) mode enable */ +#define USB_BCDR_SDEN ((uint16_t)0x0008U) /*!< Secondary detection (SD) mode enable */ +#define USB_BCDR_DCDET ((uint16_t)0x0010U) /*!< Data contact detection (DCD) status */ +#define USB_BCDR_PDET ((uint16_t)0x0020U) /*!< Primary detection (PD) status */ +#define USB_BCDR_SDET ((uint16_t)0x0040U) /*!< Secondary detection (SD) status */ +#define USB_BCDR_PS2DET ((uint16_t)0x0080U) /*!< PS2 port or proprietary charger detected */ +#define USB_BCDR_DPPU ((uint16_t)0x8000U) /*!< DP Pull-up Enable */ + +/******************* Bit definition for LPMCSR register *********************/ +#define USB_LPMCSR_LMPEN ((uint16_t)0x0001U) /*!< LPM support enable */ +#define USB_LPMCSR_LPMACK ((uint16_t)0x0002U) /*!< LPM Token acknowledge enable*/ +#define USB_LPMCSR_REMWAKE ((uint16_t)0x0008U) /*!< bRemoteWake value received with last ACKed LPM Token */ +#define USB_LPMCSR_BESL ((uint16_t)0x00F0U) /*!< BESL value received with last ACKed LPM Token */ + /*!< Buffer descriptor table */ /***************** Bit definition for USB_ADDR0_TX register *****************/ #define USB_ADDR0_TX_ADDR0_TX_Pos (1U) |
