lpc176x: force minimum usb disconnect time
Fixes GitHub Issue #1499. Resolves USB hang by forcing a minimum USB disconnection time at boot. Signed-off-by: Matt Baker <baker.matt.j@gmail.com>
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "LPC17xx.h" // NVIC_SystemReset
|
||||
#include "command.h" // DECL_CONSTANT
|
||||
#include "sched.h" // sched_main
|
||||
#include "board/misc.h" // timer_read_time
|
||||
|
||||
DECL_CONSTANT_STR("MCU", "lpc176x");
|
||||
|
||||
@@ -66,6 +67,20 @@ command_reset(uint32_t *args)
|
||||
}
|
||||
DECL_COMMAND_FLAGS(command_reset, HF_IN_SHUTDOWN, "reset");
|
||||
|
||||
// Implement simple early-boot delay mechanism
|
||||
void
|
||||
udelay(uint32_t usecs)
|
||||
{
|
||||
if (!(CoreDebug->DEMCR & CoreDebug_DEMCR_TRCENA_Msk)) {
|
||||
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
|
||||
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
|
||||
}
|
||||
|
||||
uint32_t end = timer_read_time() + timer_from_us(usecs);
|
||||
while (timer_is_before(timer_read_time(), end))
|
||||
;
|
||||
}
|
||||
|
||||
// Main entry point
|
||||
int
|
||||
main(void)
|
||||
|
||||
Reference in New Issue
Block a user