From ff9ceb65d2c5033e80aaa795b508cdff6356b14b Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 1 Apr 2020 20:56:46 +0700 Subject: doc update --- docs/porting.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs/porting.md') diff --git a/docs/porting.md b/docs/porting.md index deb1b9efb..ccafa7999 100644 --- a/docs/porting.md +++ b/docs/porting.md @@ -6,7 +6,7 @@ data transactions on different endpoints. Porting is the process of adding low-l the rest of the common stack. Once the low-level is implemented, it is very easy to add USB support for the microcontroller to other projects, especially those already using TinyUSB such as CircuitPython. -Below are instructions on how to get the cdc_msc_hid device example running on a new microcontroller. Doing so includes adding the common code necessary for other uses while minimizing other extra code. Whenever you see a phrase or word in <> it should be replaced. +Below are instructions on how to get the cdc_msc device example running on a new microcontroller. Doing so includes adding the common code necessary for other uses while minimizing other extra code. Whenever you see a phrase or word in <> it should be replaced. ## Register defs @@ -19,7 +19,7 @@ Once this is done, create a directory in `hw/bsp/` for the spec ## Build Now that those directories are in place, we can start our iteration process to get the example building successfully. To build, run from the root of TinyUSB: -`make -C examples/device/cdc_msc_hid BOARD=` +`make -C examples/device/cdc_msc BOARD=` Unless, you've read ahead, this will fail miserably. Now, lets get it to fail less by updating the files in the board directory. The code in the board's directory is responsible for setting up the microcontroller's clocks and pins so that USB works. TinyUSB itself only operates on the USB peripheral. The board directory also includes information what files are needed to build the example. -- cgit v1.3.1 From 715c4dbbf8fe7c6bb83013df626a201928704b30 Mon Sep 17 00:00:00 2001 From: Nathan Conrad Date: Wed, 8 Apr 2020 11:51:33 -0400 Subject: stm32fsdev: Implement dcd_connect. --- docs/porting.md | 6 ++++++ src/device/dcd.h | 8 ++++---- src/device/usbd.c | 1 + src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c | 24 ++++++++++++++++++------ src/portable/template/dcd_template.c | 14 ++++++++++++++ test/test/device/msc/test_msc_device.c | 1 + test/test/device/usbd/test_usbd.c | 1 + 7 files changed, 45 insertions(+), 10 deletions(-) (limited to 'docs/porting.md') diff --git a/docs/porting.md b/docs/porting.md index deb1b9efb..7d7d4cdb1 100644 --- a/docs/porting.md +++ b/docs/porting.md @@ -62,6 +62,8 @@ All of the code for the low-level device API is in `src/portable//CNTR |= USB_CNTR_RESETM | USB_CNTR_SOFM | USB_CNTR_ESOFM | USB_CNTR_CTRM | USB_CNTR_SUSPM | USB_CNTR_WKUPM; dcd_handle_bus_reset(); + + // Data-line pull-up is left disconnected. +} - // And finally enable pull-up, which may trigger the RESET IRQ if the host is connected. - // (if this MCU has an internal pullup) +// Define only on MCU with internal pull-up so BSP can override (needed on MCU without internal pull-up) #if defined(USB_BCDR_DPPU) - USB->BCDR |= USB_BCDR_DPPU; -#else - // FIXME: callback to the user to ask them to twiddle a GPIO to disable/enable D+??? -#endif +TU_ATTR_WEAK +void dcd_disconnect(uint8_t rhport) +{ + (void) rhport; + USB->BCDR &= ~(USB_BCDR_DPPU); +} + +TU_ATTR_WEAK +void dcd_connect(uint8_t rhport) +{ + (void) rhport; + USB->BCDR |= USB_BCDR_DPPU; } +#endif + // Enable device interrupt void dcd_int_enable (uint8_t rhport) { diff --git a/src/portable/template/dcd_template.c b/src/portable/template/dcd_template.c index 102910509..d29c98e55 100644 --- a/src/portable/template/dcd_template.c +++ b/src/portable/template/dcd_template.c @@ -45,6 +45,20 @@ void dcd_init (uint8_t rhport) (void) rhport; } +#if HAS_INTERNAL_PULLUP +// Enable internal D+/D- pullup +void dcd_connect(uint8_t rhport) TU_ATTR_WEAK +{ + (void) rhport; +} + +// Disable internal D+/D- pullup +void dcd_disconnect(uint8_t rhport) TU_ATTR_WEAK +{ + (void) rhport; +} +#endif + // Enable device interrupt void dcd_int_enable (uint8_t rhport) { diff --git a/test/test/device/msc/test_msc_device.c b/test/test/device/msc/test_msc_device.c index 095c28170..62a36d3e3 100644 --- a/test/test/device/msc/test_msc_device.c +++ b/test/test/device/msc/test_msc_device.c @@ -199,6 +199,7 @@ void setUp(void) if ( !tusb_inited() ) { dcd_init_Expect(rhport); + dcd_connect_Expect(rhport); tusb_init(); } diff --git a/test/test/device/usbd/test_usbd.c b/test/test/device/usbd/test_usbd.c index 06372b2e4..1bb32c1e5 100644 --- a/test/test/device/usbd/test_usbd.c +++ b/test/test/device/usbd/test_usbd.c @@ -127,6 +127,7 @@ void setUp(void) { mscd_init_Expect(); dcd_init_Expect(rhport); + dcd_connect_Expect(rhport); tusb_init(); } } -- cgit v1.3.1 From 5bd9d14fc14d9130d7d879800bd46e4ca08e3d5f Mon Sep 17 00:00:00 2001 From: Nathan Conrad Date: Fri, 10 Apr 2020 10:23:56 -0400 Subject: stm32fsdev: set dcd_connect API definitions to strong, Modify documentation. --- docs/porting.md | 4 ++-- src/device/dcd.h | 4 ++-- src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'docs/porting.md') diff --git a/docs/porting.md b/docs/porting.md index 7d7d4cdb1..d3408aebd 100644 --- a/docs/porting.md +++ b/docs/porting.md @@ -62,7 +62,7 @@ All of the code for the low-level device API is in `src/portable//BCDR &= ~(USB_BCDR_DPPU); } -TU_ATTR_WEAK +// Enable internal D+ PU void dcd_connect(uint8_t rhport) { (void) rhport; -- cgit v1.3.1