usb_cdc: Add support for detecting a USB level Arduino bootloader request

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2018-12-05 21:22:34 -05:00
parent c6065e29a6
commit b84ecebf8f
6 changed files with 33 additions and 0 deletions

View File

@ -178,6 +178,11 @@ usb_set_configure(void)
UEIENX = 1<<TXINE;
}
void
usb_request_bootloader(void)
{
}
#if CONFIG_MACH_at90usb1286
#define UHWCON_Init ((1<<UIMOD) | (1<<UVREGE))
#define PLLCSR_Init ((1<<PLLP2) | (1<<PLLP0) | (1<<PLLE))

View File

@ -402,6 +402,15 @@ usb_req_set_configuration(struct usb_ctrlrequest *req)
}
static struct usb_cdc_line_coding line_coding;
static uint8_t line_control_state;
static void
check_reboot(void)
{
if (line_coding.dwDTERate == 1200 && !(line_control_state & 0x01))
// A baud of 1200 is an Arduino style request to enter the bootloader
usb_request_bootloader();
}
static void
usb_req_set_line_coding(struct usb_ctrlrequest *req)
@ -412,6 +421,7 @@ usb_req_set_line_coding(struct usb_ctrlrequest *req)
return;
}
usb_do_xfer(&line_coding, sizeof(line_coding), UX_READ);
check_reboot();
}
static void
@ -432,7 +442,9 @@ usb_req_set_line(struct usb_ctrlrequest *req)
usb_do_stall();
return;
}
line_control_state = req->wValue;
usb_do_xfer(NULL, 0, UX_SEND);
check_reboot();
}
static void

View File

@ -21,6 +21,7 @@ int_fast8_t usb_send_ep0_progmem(const void *data, uint_fast8_t len);
void usb_stall_ep0(void);
void usb_set_address(uint_fast8_t addr);
void usb_set_configure(void);
void usb_request_bootloader(void);
// usb_cdc.c
void usb_notify_bulk_in(void);

View File

@ -241,6 +241,11 @@ usb_set_configure(void)
usb_irq_enable();
}
void
usb_request_bootloader(void)
{
}
void
usbserial_init(void)
{

View File

@ -168,6 +168,11 @@ usb_set_configure(void)
USB_DEVICE_EPINTENSET_TRCPT0 | USB_DEVICE_EPINTENSET_TRCPT1);
}
void
usb_request_bootloader(void)
{
}
void
usbserial_init(void)
{

View File

@ -211,6 +211,11 @@ usb_set_configure(void)
{
}
void
usb_request_bootloader(void)
{
}
/****************************************************************
* Setup and interrupts