From b6674cd738cc22e61ea34cb659750ef45ce01df4 Mon Sep 17 00:00:00 2001 From: iperry Date: Fri, 25 Dec 2009 08:39:24 +0000 Subject: Fixed delayMicroseconds, changed serial interface, added an (untested) runtime check for pwm/serial collision, moved more headers around. git-svn-id: https://leaflabs.googlecode.com/svn/trunk/library@79 749a229e-a60e-11de-b98f-4500b42dc123 --- src/wiring/time.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'src/wiring/time.c') diff --git a/src/wiring/time.c b/src/wiring/time.c index 1a91b5e..164d978 100644 --- a/src/wiring/time.c +++ b/src/wiring/time.c @@ -28,7 +28,7 @@ #include "time.h" #define CYCLES_PER_MICROSECOND 72 -#define THE_SECRET_TO_LIFE_THE_UNIVERSE_AND_EVERYTHING 42 +#define FUDGE 42 extern volatile uint32_t systick_timer_millis; @@ -47,26 +47,13 @@ void delay(unsigned long ms) } -#define MAGIC 4096 -/* HZ = 1000 - * n HZ*/ + +#if 1 void delayMicroseconds(uint32_t us) { uint32_t target; uint32_t last, cur, count; - -#if 0 - asm volatile("mov r0, %[count] \n\t" -"1: \n\t" - "subs r0, r0, #1 \n\t" - "bne 1b" - : - : [count] "r" (count) - : "r0", "cc"); -#endif - -#if 1 /* fudge factor hacky hack hack for function overhead */ - target = us * CYCLES_PER_MICROSECOND - THE_SECRET_TO_LIFE_THE_UNIVERSE_AND_EVERYTHING; + target = us * CYCLES_PER_MICROSECOND - FUDGE; /* Get current count */ last = systick_get_count(); @@ -81,5 +68,5 @@ void delayMicroseconds(uint32_t us) { } last = cur; } -#endif } +#endif -- cgit v1.2.3