mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-16 02:33:28 +00:00
This reverts commit 3bb994da9f.
This commit is contained in:
@@ -120,9 +120,7 @@ func sleepTicks(d timeUnit) {
|
|||||||
for d != 0 {
|
for d != 0 {
|
||||||
ticks() // update timestamp
|
ticks() // update timestamp
|
||||||
ticks := uint32(d) // current scaling only supports 100 usec to 6553 msec
|
ticks := uint32(d) // current scaling only supports 100 usec to 6553 msec
|
||||||
if !timerSleep(ticks) {
|
timerSleep(ticks)
|
||||||
return
|
|
||||||
}
|
|
||||||
d -= timeUnit(ticks)
|
d -= timeUnit(ticks)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,8 +141,7 @@ func ticks() timeUnit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ticks are in microseconds
|
// ticks are in microseconds
|
||||||
// returns false if an interrupt occured
|
func timerSleep(ticks uint32) {
|
||||||
func timerSleep(ticks uint32) bool {
|
|
||||||
timerWakeup.Set(0)
|
timerWakeup.Set(0)
|
||||||
|
|
||||||
// STM32 timer update event period is calculated as follows:
|
// STM32 timer update event period is calculated as follows:
|
||||||
@@ -191,19 +188,10 @@ func timerSleep(ticks uint32) bool {
|
|||||||
// Enable the timer.
|
// Enable the timer.
|
||||||
stm32.TIM3.CR1.SetBits(stm32.TIM_CR1_CEN)
|
stm32.TIM3.CR1.SetBits(stm32.TIM_CR1_CEN)
|
||||||
|
|
||||||
wait:
|
// wait till timer wakes up
|
||||||
arm.Asm("wfi")
|
for timerWakeup.Get() == 0 {
|
||||||
if timerWakeup.Get() != 0 {
|
arm.Asm("wfi")
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if hasScheduler {
|
|
||||||
return false
|
|
||||||
} else {
|
|
||||||
// keep looping until the routine exits or is interrupted
|
|
||||||
goto wait
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleTIM3(interrupt.Interrupt) {
|
func handleTIM3(interrupt.Interrupt) {
|
||||||
|
|||||||
Reference in New Issue
Block a user