diff options
author | iperry <iperry@749a229e-a60e-11de-b98f-4500b42dc123> | 2009-12-25 08:39:24 +0000 |
---|---|---|
committer | iperry <iperry@749a229e-a60e-11de-b98f-4500b42dc123> | 2009-12-25 08:39:24 +0000 |
commit | b6674cd738cc22e61ea34cb659750ef45ce01df4 (patch) | |
tree | bfee2ae84883c32871ee13a6e0f346f144263cf6 /src/wiring/time.c | |
parent | 3bb04834ffd3f90dc9015997ea11a56d9d150099 (diff) | |
download | librambutan-b6674cd738cc22e61ea34cb659750ef45ce01df4.tar.gz librambutan-b6674cd738cc22e61ea34cb659750ef45ce01df4.zip |
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
Diffstat (limited to 'src/wiring/time.c')
-rw-r--r-- | src/wiring/time.c | 23 |
1 files changed, 5 insertions, 18 deletions
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 |