USB: clean disconnect
This commit is contained in:
parent
face9da9d0
commit
b04fcb7d3e
|
@ -36,8 +36,6 @@
|
|||
#include "global.h" // global utilities
|
||||
#include "usb_cdcacm.h" // USB CDC ACM header and definitions
|
||||
|
||||
#include "print.h"
|
||||
|
||||
/** maximum packet size for USB data transfer */
|
||||
#define USB_DATA_TRANSFER_SIZE 64 // 64 is the maximum for full speed devices
|
||||
|
||||
|
@ -252,18 +250,14 @@ static void usb_disconnect(void)
|
|||
rcc_periph_clock_enable(RCC_GPIOB);
|
||||
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO9);
|
||||
gpio_set(GPIOB, GPIO9);
|
||||
for (uint32_t i = 0; i < 0x2000; i++) {
|
||||
__asm__("nop");
|
||||
}
|
||||
sleep_ms(20); // pull D+ low for at least 10 ms
|
||||
gpio_clear(GPIOB, GPIO9);
|
||||
#else
|
||||
// pull USB D+ low for a short while
|
||||
rcc_periph_clock_enable(RCC_GPIOA);
|
||||
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO12);
|
||||
gpio_clear(GPIOA, GPIO12);
|
||||
for (uint32_t i = 0; i < 0x2000; i++) {
|
||||
__asm__("nop");
|
||||
}
|
||||
sleep_ms(20); // pull D+ low for at least 10 ms
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -296,7 +290,7 @@ static void usb_dfu_detach(usbd_device *usbd_dev, struct usb_setup_data *req)
|
|||
}
|
||||
|
||||
/** USB CDC ACM control callback
|
||||
* @note if transmission happens before the control setting is complete, linux echoes back the data
|
||||
* @note if transmission happens before the control setting is complete, Linux echoes back the data
|
||||
* @param[in] usbd_dev USB device descriptor
|
||||
* @param[in] req control request information
|
||||
*/
|
||||
|
@ -342,7 +336,7 @@ static int usb_cdcacm_control_request(usbd_device *usbd_dev, struct usb_setup_da
|
|||
usb_cdcacm_connecting = (0!=req->wValue); // check if terminal is open
|
||||
//bool dtr = (req->wValue & (1 << 0)) ? true : false;
|
||||
//bool rts = (req->wValue & (1 << 1)) ? true : false;
|
||||
/* this Linux cdc_acm driver requires this to be implemented
|
||||
/* the Linux cdc_acm driver requires this to be implemented
|
||||
* even though it's optional in the CDC spec, and we don't
|
||||
* advertise it in the ACM functional descriptor.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue