aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple/usb/stm32f1
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2012-07-30 23:55:27 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2012-07-31 15:04:49 -0400
commitc3ae4d18fa9b314ffb8d11cd8af3fec84bd6c278 (patch)
treee870b0093c987368a540541277d3176744167805 /libmaple/usb/stm32f1
parentd2e8ee55c568629c55b449b79417243af100cb64 (diff)
downloadlibrambutan-c3ae4d18fa9b314ffb8d11cd8af3fec84bd6c278.tar.gz
librambutan-c3ae4d18fa9b314ffb8d11cd8af3fec84bd6c278.zip
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 <mbolivar@leaflabs.com>
Diffstat (limited to 'libmaple/usb/stm32f1')
-rw-r--r--libmaple/usb/stm32f1/usb_cdcacm.c12
1 files 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);
}