From abc478c294ff45d6afaf8b27ab8202856e1afd51 Mon Sep 17 00:00:00 2001 From: deadprogram Date: Sat, 27 Feb 2021 10:59:40 +0100 Subject: [PATCH] Revert "Allow interrupts in stm32f103xx (#1466)" as discussed in #1608 This reverts commit 3bb994da9f42118fe9cfcc8945e8ec9d3b01da27. --- src/runtime/runtime_stm32f103.go | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/src/runtime/runtime_stm32f103.go b/src/runtime/runtime_stm32f103.go index 9ecfcfd1..d1af5201 100644 --- a/src/runtime/runtime_stm32f103.go +++ b/src/runtime/runtime_stm32f103.go @@ -120,9 +120,7 @@ func sleepTicks(d timeUnit) { for d != 0 { ticks() // update timestamp ticks := uint32(d) // current scaling only supports 100 usec to 6553 msec - if !timerSleep(ticks) { - return - } + timerSleep(ticks) d -= timeUnit(ticks) } } @@ -143,8 +141,7 @@ func ticks() timeUnit { } // ticks are in microseconds -// returns false if an interrupt occured -func timerSleep(ticks uint32) bool { +func timerSleep(ticks uint32) { timerWakeup.Set(0) // STM32 timer update event period is calculated as follows: @@ -191,19 +188,10 @@ func timerSleep(ticks uint32) bool { // Enable the timer. stm32.TIM3.CR1.SetBits(stm32.TIM_CR1_CEN) -wait: - arm.Asm("wfi") - if timerWakeup.Get() != 0 { - return true + // wait till timer wakes up + for timerWakeup.Get() == 0 { + arm.Asm("wfi") } - - if hasScheduler { - return false - } else { - // keep looping until the routine exits or is interrupted - goto wait - } - } func handleTIM3(interrupt.Interrupt) {