From a9b067ee93238f49e077db645414e78b6abad463 Mon Sep 17 00:00:00 2001
From: Thibaut VIARD <thibaut.viard@atmel.com>
Date: Thu, 8 May 2014 23:27:37 +0200
Subject: [PATCH]  Updating delay API

---
 cores/arduino/delay.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/cores/arduino/delay.c b/cores/arduino/delay.c
index 59189351..83427841 100644
--- a/cores/arduino/delay.c
+++ b/cores/arduino/delay.c
@@ -43,22 +43,6 @@ uint32_t micros( void )
   // a runtime multiplication and shift, saving a few cycles
 }
 
-// original function:
-// uint32_t micros( void )
-// {
-//     uint32_t ticks ;
-//     uint32_t count ;
-//
-//     SysTick->CTRL;
-//     do {
-//         ticks = SysTick->VAL;
-//         count = GetTickCount();
-//     } while (SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk);
-//
-//     return count * 1000 + (SysTick->LOAD + 1 - ticks) / (SystemCoreClock/1000000) ;
-// }
-
-
 void delay( uint32_t ms )
 {
   if ( ms == 0 )
@@ -74,6 +58,12 @@ void delay( uint32_t ms )
   } while ( _ulTickCount - start < ms ) ;
 }
 
+void SysTick_Handler( void )
+{
+  // Increment tick count each ms
+  _ulTickCount++ ;
+}
+
 #ifdef __cplusplus
 }
 #endif
-- 
GitLab