From c3ae4d18fa9b314ffb8d11cd8af3fec84bd6c278 Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Mon, 30 Jul 2012 23:55:27 -0400 Subject: usb_cdcacm.c: Resolve TODO and improve comments. The disc pin code was copy-pasted when the CDC ACM pieces were extracted from the rest of the USB code, and I didn't really understand what was going on when I moved it over. Having checked the spec, the comments can be safely improved. Signed-off-by: Marti Bolivar --- libmaple/usb/stm32f1/usb_cdcacm.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libmaple/usb/stm32f1/usb_cdcacm.c b/libmaple/usb/stm32f1/usb_cdcacm.c index 6a8235e..edd4b98 100644 --- a/libmaple/usb/stm32f1/usb_cdcacm.c +++ b/libmaple/usb/stm32f1/usb_cdcacm.c @@ -393,17 +393,19 @@ USER_STANDARD_REQUESTS User_Standard_Requests = { */ void usb_cdcacm_enable(gpio_dev *disc_dev, uint8 disc_bit) { - /* Present ourselves to the host */ + /* Present ourselves to the host. Writing 0 to "disc" pin must + * pull USB_DP pin up while leaving USB_DM pulled down by the + * transceiver. See USB 2.0 spec, section 7.1.7.3. */ gpio_set_mode(disc_dev, disc_bit, GPIO_OUTPUT_PP); - gpio_write_bit(disc_dev, disc_bit, 0); // presents us to the host + gpio_write_bit(disc_dev, disc_bit, 0); - /* initialize USB peripheral */ + /* Initialize the USB peripheral. */ usb_init_usblib(USBLIB, ep_int_in, ep_int_out); } void usb_cdcacm_disable(gpio_dev *disc_dev, uint8 disc_bit) { - // These are just guesses about how to do this, but it seems to work. - // TODO: verify this with USB spec + /* Turn off the interrupt and signal disconnect (see e.g. USB 2.0 + * spec, section 7.1.7.3). */ nvic_irq_disable(NVIC_USB_LP_CAN_RX0); gpio_write_bit(disc_dev, disc_bit, 1); } -- cgit v1.2.3