summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNathan Conrad <[email protected]>2019-09-16 20:25:50 -0400
committerNathan Conrad <[email protected]>2019-09-16 20:25:50 -0400
commitd341337c6a80622c22fc002b35a65b40bdf15b4b (patch)
tree1c50ecb720b6715bac2cd6a1bc80adcd40771150 /src
parent6b9783ceadf36d6507a624b8413adf9686d6e541 (diff)
Implement remote wakeup + perhaps better sleep?
Diffstat (limited to 'src')
-rw-r--r--src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
index d3cbef43c..0559a4087 100644
--- a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
+++ b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
@@ -308,6 +308,17 @@ void dcd_set_config (uint8_t rhport, uint8_t config_num)
void dcd_remote_wakeup(uint8_t rhport)
{
(void) rhport;
+ uint32_t start;
+
+ USB->CNTR |= (uint16_t)USB_CNTR_RESUME;
+ /* Wait 1 to 15 ms */
+ /* Busy loop is bad, but the osal_task_delay() isn't implemented for the "none" OSAL */
+ start = board_millis();
+ while ((board_millis() - start) < 2)
+ {
+ ;
+ }
+ USB->CNTR &= (uint16_t)(~USB_CNTR_RESUME);
}
// I'm getting a weird warning about missing braces here that I don't
@@ -538,10 +549,10 @@ static void dcd_fs_irqHandler(void) {
}
if (int_status & USB_ISTR_WKUP)
{
-
reg16_clear_bits(&USB->CNTR, USB_CNTR_LPMODE);
reg16_clear_bits(&USB->CNTR, USB_CNTR_FSUSP);
reg16_clear_bits(&USB->ISTR, USB_ISTR_WKUP);
+ dcd_event_bus_signal(0, DCD_EVENT_RESUME, true);
}
if (int_status & USB_ISTR_SUSP)
@@ -552,6 +563,7 @@ static void dcd_fs_irqHandler(void) {
/* clear of the ISTR bit must be done after setting of CNTR_FSUSP */
reg16_clear_bits(&USB->ISTR, USB_ISTR_SUSP);
+ dcd_event_bus_signal(0, DCD_EVENT_SUSPEND, true);
}
if(int_status & USB_ISTR_SOF) {