diff options
| author | Ha Thach <[email protected]> | 2020-04-11 15:49:34 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-04-11 15:49:34 +0700 |
| commit | 04a06ec40147f1f44cfee0567667cc97bbe900ee (patch) | |
| tree | e1efa890fa3ceb93e15244ba6e6df3e61c701910 /src/device | |
| parent | 4748b349a2812fb2e08f7dfd04866afd50acb98f (diff) | |
| parent | 13a3081d308828ae6e4b9a40bb8ac7bf5b0e424c (diff) | |
Merge branch 'master' into refactor-irqhandler
Diffstat (limited to 'src/device')
| -rw-r--r-- | src/device/dcd.h | 6 | ||||
| -rw-r--r-- | src/device/usbd.c | 3 | ||||
| -rw-r--r-- | src/device/usbd.h | 14 |
3 files changed, 22 insertions, 1 deletions
diff --git a/src/device/dcd.h b/src/device/dcd.h index dbdc19dd3..f4e6edb95 100644 --- a/src/device/dcd.h +++ b/src/device/dcd.h @@ -106,6 +106,12 @@ void dcd_set_config (uint8_t rhport, uint8_t config_num); // Wake up host void dcd_remote_wakeup(uint8_t rhport); +// Connect or disconnect D+/D- line pull-up resistor. +// Defined in dcd source if MCU has internal pull-up. +// Otherwise, may be defined in BSP. +void dcd_connect(uint8_t rhport) TU_ATTR_WEAK; +void dcd_disconnect(uint8_t rhport) TU_ATTR_WEAK; + //--------------------------------------------------------------------+ // Endpoint API //--------------------------------------------------------------------+ diff --git a/src/device/usbd.c b/src/device/usbd.c index ddd99d7f1..2adac429c 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -332,6 +332,7 @@ bool tud_init (void) // Init device controller driver dcd_init(TUD_OPT_RHPORT); + tud_connect(); dcd_int_enable(TUD_OPT_RHPORT); return true; @@ -421,7 +422,7 @@ void tud_task (void) uint8_t const epnum = tu_edpt_number(ep_addr); uint8_t const ep_dir = tu_edpt_dir(ep_addr); - TU_LOG2(" Endpoint: 0x%02X, Bytes: %ld\r\n", ep_addr, event.xfer_complete.len); + TU_LOG2(" Endpoint: 0x%02X, Bytes: %u\r\n", ep_addr, (unsigned int) event.xfer_complete.len); _usbd_dev.ep_status[epnum][ep_dir].busy = false; diff --git a/src/device/usbd.h b/src/device/usbd.h index 2bb9821ed..6b31d8113 100644 --- a/src/device/usbd.h +++ b/src/device/usbd.h @@ -65,6 +65,20 @@ static inline bool tud_ready(void) // Remote wake up host, only if suspended and enabled by host bool tud_remote_wakeup(void); +static inline bool tud_disconnect(void) +{ + TU_VERIFY(dcd_disconnect); + dcd_disconnect(TUD_OPT_RHPORT); + return true; +} + +static inline bool tud_connect(void) +{ + TU_VERIFY(dcd_connect); + dcd_connect(TUD_OPT_RHPORT); + return true; +} + // Carry out Data and Status stage of control transfer // - If len = 0, it is equivalent to sending status only // - If len > wLength : it will be truncated |
