armcm_timer: Unify udelay() implementation
Move the udelay() code from various arm board directories into the src/generic/armcm_timer.c code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
@@ -18,6 +18,4 @@ int is_enabled_pclock(uint32_t pclk);
|
||||
void enable_pclock(uint32_t pclk);
|
||||
void gpio_peripheral(uint32_t gpio, int func, int pullup);
|
||||
|
||||
void udelay(uint32_t usecs);
|
||||
|
||||
#endif // internal.h
|
||||
|
||||
@@ -67,20 +67,6 @@ 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)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <string.h> // memcpy
|
||||
#include "LPC17xx.h" // LPC_SC
|
||||
#include "autoconf.h" // CONFIG_SMOOTHIEWARE_BOOTLOADER
|
||||
#include "board/armcm_timer.h" // udelay
|
||||
#include "board/irq.h" // irq_disable
|
||||
#include "board/misc.h" // timer_read_time
|
||||
#include "byteorder.h" // cpu_to_le32
|
||||
|
||||
Reference in New Issue
Block a user