From 2bf044442eae7dbdaff91051d2c135b4aa51f1b2 Mon Sep 17 00:00:00 2001 From: Dave Hylands Date: Sat, 23 Aug 2014 12:21:12 -0700 Subject: Add support for pyb.micros() by using the systick timer. I also removed trailing spaces from modpyb.c which affected a couple of lines technically not part of this patch. Tested using: https://github.com/dhylands/upy-examples/blob/master/micros_test.py which eventually fails due to wraparound issues (I could fix the test to compensate but didn't bother) --- stmhal/stm32f4xx_it.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'stmhal/stm32f4xx_it.c') diff --git a/stmhal/stm32f4xx_it.c b/stmhal/stm32f4xx_it.c index 5fa7f8289..4bd13c05c 100644 --- a/stmhal/stm32f4xx_it.c +++ b/stmhal/stm32f4xx_it.c @@ -174,6 +174,11 @@ void PendSV_Handler(void) { */ void SysTick_Handler(void) { HAL_IncTick(); + + // Read the systick control regster. This has the side effect of clearing + // the COUNTFLAG bit, which makes the logic in sys_tick_get_microseconds + // work properly. + SysTick->CTRL; } /******************************************************************************/ -- cgit v1.2.3