stm32f1: Use internal functions for early USB gpio toggle
Avoid using the "low-level" library timing utilities. This is in preparation for using SysTick as part of the timer implementation. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
// This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
|
||||
#include "autoconf.h"
|
||||
#include "board/internal.h" // udelay
|
||||
#include "board/misc.h" // timer_read_time
|
||||
#include "command.h" // DECL_CONSTANT
|
||||
#include "stm32f1xx.h"
|
||||
#include "stm32f1xx_ll_system.h"
|
||||
@@ -19,6 +21,7 @@
|
||||
|
||||
DECL_CONSTANT(MCU, "stm32f103");
|
||||
|
||||
|
||||
/****************************************************************
|
||||
* dynamic memory pool
|
||||
****************************************************************/
|
||||
@@ -128,6 +131,20 @@ void io_config(void)
|
||||
LL_DBGMCU_SetTracePinAssignment(LL_DBGMCU_TRACE_NONE);
|
||||
}
|
||||
|
||||
// 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