From 57969259ce2b6e1ebfa95611e8f64e0eef6454ef Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Tue, 3 Apr 2012 14:52:54 +0100 Subject: [PATCH] cc2x3x clock_delay(len) now delays for approx. len usecs --- cpu/cc2430/dev/clock.c | 12 ++++++------ cpu/cc253x/dev/clock.c | 7 ++++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/cpu/cc2430/dev/clock.c b/cpu/cc2430/dev/clock.c index 09e60af31..d34097c92 100644 --- a/cpu/cc2430/dev/clock.c +++ b/cpu/cc2430/dev/clock.c @@ -56,17 +56,17 @@ static volatile __data clock_time_t count = 0; /* Uptime in ticks */ static volatile __data clock_time_t seconds = 0; /* Uptime in secs */ /*---------------------------------------------------------------------------*/ /** - * One delay is about 0.6 us, so this function delays for len * 0.6 us + * Each iteration is ~1.0xy usec, so this function delays for roughly len usec */ void clock_delay(unsigned int len) { - unsigned int i; - for(i = 0; i< len; i++) { - __asm - nop - __endasm; + DISABLE_INTERRUPTS(); + while(len--) { + ASM(nop); ASM(nop); ASM(nop); + ASM(nop); ASM(nop); } + ENABLE_INTERRUPTS(); } /*---------------------------------------------------------------------------*/ /** diff --git a/cpu/cc253x/dev/clock.c b/cpu/cc253x/dev/clock.c index c67b3a93b..66f24d56c 100644 --- a/cpu/cc253x/dev/clock.c +++ b/cpu/cc253x/dev/clock.c @@ -59,15 +59,16 @@ static volatile __data clock_time_t count = 0; /* Uptime in ticks */ static volatile __data clock_time_t seconds = 0; /* Uptime in secs */ /*---------------------------------------------------------------------------*/ /** - * One delay is about 0.6 us, so this function delays for len * 0.6 us + * Each iteration is ~1.0xy usec, so this function delays for roughly len usec */ void clock_delay(unsigned int len) { - unsigned int i; - for(i = 0; i< len; i++) { + DISABLE_INTERRUPTS(); + while(len--) { ASM(nop); } + ENABLE_INTERRUPTS(); } /*---------------------------------------------------------------------------*/ /**