aboutsummaryrefslogtreecommitdiffstats
path: root/src/stm32f1
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2019-06-09 20:26:30 -0400
committerKevin O'Connor <kevin@koconnor.net>2019-06-09 20:27:57 -0400
commit700e35c6ac74a64719fbc38fe66386dd422613f3 (patch)
tree2a829c04c12f3b6393d842f1835c2f8f8df023dc /src/stm32f1
parent97840f9851772ffbcc99b8e33c82b0af4770baa8 (diff)
downloadkutter-700e35c6ac74a64719fbc38fe66386dd422613f3.tar.gz
kutter-700e35c6ac74a64719fbc38fe66386dd422613f3.tar.xz
kutter-700e35c6ac74a64719fbc38fe66386dd422613f3.zip
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>
Diffstat (limited to 'src/stm32f1')
-rw-r--r--src/stm32f1/internal.h2
-rw-r--r--src/stm32f1/main.c14
-rw-r--r--src/stm32f1/usbserial.c1
3 files changed, 1 insertions, 16 deletions
diff --git a/src/stm32f1/internal.h b/src/stm32f1/internal.h
index e509927b..4c4394fd 100644
--- a/src/stm32f1/internal.h
+++ b/src/stm32f1/internal.h
@@ -10,6 +10,4 @@
extern GPIO_TypeDef *const digital_regs[];
extern uint32_t const digital_pins[];
-void udelay(uint32_t usecs);
-
#endif // internal.h
diff --git a/src/stm32f1/main.c b/src/stm32f1/main.c
index 258578da..d9bdbb24 100644
--- a/src/stm32f1/main.c
+++ b/src/stm32f1/main.c
@@ -131,20 +131,6 @@ 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)
diff --git a/src/stm32f1/usbserial.c b/src/stm32f1/usbserial.c
index 7eeb3421..3bdf86a8 100644
--- a/src/stm32f1/usbserial.c
+++ b/src/stm32f1/usbserial.c
@@ -6,6 +6,7 @@
#include <string.h> // NULL
#include "autoconf.h" // CONFIG_STM_FLASH_START_2000
+#include "board/armcm_timer.h" // udelay
#include "board/gpio.h" // gpio_out_setup
#include "board/io.h" // writeb
#include "board/irq.h" // irq_disable