File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -120,7 +120,9 @@ func sleepTicks(d timeUnit) {
120120 for d != 0 {
121121 ticks () // update timestamp
122122 ticks := uint32 (d ) // current scaling only supports 100 usec to 6553 msec
123- timerSleep (ticks )
123+ if ! timerSleep (ticks ) {
124+ return
125+ }
124126 d -= timeUnit (ticks )
125127 }
126128}
@@ -141,7 +143,8 @@ func ticks() timeUnit {
141143}
142144
143145// ticks are in microseconds
144- func timerSleep (ticks uint32 ) {
146+ // returns false if an interrupt occured
147+ func timerSleep (ticks uint32 ) bool {
145148 timerWakeup .Set (0 )
146149
147150 // STM32 timer update event period is calculated as follows:
@@ -188,10 +191,19 @@ func timerSleep(ticks uint32) {
188191 // Enable the timer.
189192 stm32 .TIM3 .CR1 .SetBits (stm32 .TIM_CR1_CEN )
190193
191- // wait till timer wakes up
192- for timerWakeup .Get () == 0 {
193- arm .Asm ("wfi" )
194+ wait:
195+ arm .Asm ("wfi" )
196+ if timerWakeup .Get () != 0 {
197+ return true
194198 }
199+
200+ if hasScheduler {
201+ return false
202+ } else {
203+ // keep looping until the routine exits or is interrupted
204+ goto wait
205+ }
206+
195207}
196208
197209func handleTIM3 (interrupt.Interrupt ) {
You can’t perform that action at this time.
0 commit comments