diff --git a/cpu/cc2430/8051def.h b/cpu/cc2430/8051def.h index a1fa15e80..ce6bc3357 100644 --- a/cpu/cc2430/8051def.h +++ b/cpu/cc2430/8051def.h @@ -14,6 +14,11 @@ #include +/* This port no longer implements the legacy clock_delay. Hack its usages + * outta the way till it gets phased out completely + * NB: This also overwrites the prototype so delay_usec() is declared twice */ +#define clock_delay(t) clock_delay_usec(t) + /* * lint - style defines to help syntax parsers with sdcc-specific 8051 code * They don't interfere with actual compilation diff --git a/cpu/cc2430/dev/cc2430_rf.c b/cpu/cc2430/dev/cc2430_rf.c index 3e53a0f31..cbf997a38 100644 --- a/cpu/cc2430/dev/cc2430_rf.c +++ b/cpu/cc2430/dev/cc2430_rf.c @@ -126,7 +126,7 @@ cc2430_rf_command(uint8_t command) case ISTXON: fifo_count = RXFIFOCNT; RFST = command; - clock_delay(2); + clock_delay_usec(2); if(fifo_count != RXFIFOCNT) { RFST = ISFLUSHRX; RFST = ISFLUSHRX; @@ -430,7 +430,7 @@ transmit(unsigned short transmit_len) cc2430_rf_command(ISTXON); counter = 0; while(!(RFSTATUS & TX_ACTIVE) && (counter++ < 3)) { - clock_delay(10); + clock_delay_usec(6); } if(!(RFSTATUS & TX_ACTIVE)) { diff --git a/cpu/cc2430/dev/clock.c b/cpu/cc2430/dev/clock.c index ac64ac300..92867e8b3 100644 --- a/cpu/cc2430/dev/clock.c +++ b/cpu/cc2430/dev/clock.c @@ -59,11 +59,11 @@ static volatile __data clock_time_t seconds = 0; /* Uptime in secs */ * Each iteration is ~1.0xy usec, so this function delays for roughly len usec */ void -clock_delay(unsigned int len) +clock_delay_usec(uint16_t len) { DISABLE_INTERRUPTS(); while(len--) { - ASM(nop); ASM(nop); ASM(nop); + ASM(nop); ASM(nop); ASM(nop); ASM(nop); } ENABLE_INTERRUPTS(); diff --git a/cpu/cc253x/8051def.h b/cpu/cc253x/8051def.h index a8cc59a81..72945ca31 100644 --- a/cpu/cc253x/8051def.h +++ b/cpu/cc253x/8051def.h @@ -19,6 +19,11 @@ #include "dev/watchdog.h" #define watchdog_stop() watchdog_periodic() +/* This port no longer implements the legacy clock_delay. Hack its usages + * outta the way till it gets phased out completely + * NB: This also overwrites the prototype so delay_usec() is declared twice */ +#define clock_delay(t) clock_delay_usec(t) + /* * lint - style defines to help syntax parsers with sdcc-specific 8051 code * They don't interfere with actual compilation diff --git a/cpu/cc253x/dev/cc2530-rf.c b/cpu/cc253x/dev/cc2530-rf.c index 6adacc22c..f33d3ce37 100644 --- a/cpu/cc253x/dev/cc2530-rf.c +++ b/cpu/cc253x/dev/cc2530-rf.c @@ -287,7 +287,7 @@ transmit(unsigned short transmit_len) counter = 0; while(!(FSMSTAT1 & FSMSTAT1_TX_ACTIVE) && (counter++ < 3)) { - clock_delay(10); + clock_delay_usec(6); } if(!(FSMSTAT1 & FSMSTAT1_TX_ACTIVE)) { diff --git a/cpu/cc253x/dev/clock.c b/cpu/cc253x/dev/clock.c index dfcbc1c79..08a32f031 100644 --- a/cpu/cc253x/dev/clock.c +++ b/cpu/cc253x/dev/clock.c @@ -62,7 +62,7 @@ static volatile __data clock_time_t seconds = 0; /* Uptime in secs */ * Each iteration is ~1.0xy usec, so this function delays for roughly len usec */ void -clock_delay(unsigned int len) +clock_delay_usec(uint16_t len) { DISABLE_INTERRUPTS(); while(len--) { diff --git a/examples/cc2530dk/timer-test.c b/examples/cc2530dk/timer-test.c index 65f641fc0..7d9844676 100644 --- a/examples/cc2530dk/timer-test.c +++ b/examples/cc2530dk/timer-test.c @@ -16,14 +16,14 @@ #include /*---------------------------------------------------------------------------*/ -#define TEST_CLOCK_DELAY 1 -#define TEST_RTIMER 1 -#define TEST_ETIMER 1 -#define TEST_CLOCK_SECONDS 1 +#define TEST_CLOCK_DELAY_USEC 1 +#define TEST_RTIMER 1 +#define TEST_ETIMER 1 +#define TEST_CLOCK_SECONDS 1 /*---------------------------------------------------------------------------*/ static struct etimer et; -#if TEST_CLOCK_DELAY +#if TEST_CLOCK_DELAY_USEC static rtimer_clock_t start_count, end_count, diff; #endif @@ -64,16 +64,16 @@ PROCESS_THREAD(clock_test_process, ev, data) PROCESS_YIELD(); -#if TEST_CLOCK_DELAY - printf("Clock delay test, (10,000 x i) cycles:\n"); +#if TEST_CLOCK_DELAY_USEC + printf("clock_delay_usec test, (10,000 x i) usec:\n"); i = 1; while(i < 7) { start_count = RTIMER_NOW(); - clock_delay(10000 * i); + clock_delay_usec(10000 * i); end_count = RTIMER_NOW(); diff = end_count - start_count; - printf("Delayed %u = %u rtimer ticks = ~%u us\n", 10000 * i, diff, - diff * 64); + printf("Requested: %u usec, Real: %u rtimer ticks = ~%u us\n", + 10000 * i, diff, diff * 64); i++; } #endif diff --git a/examples/sensinode/energy-scan/energy-scan.c b/examples/sensinode/energy-scan/energy-scan.c index bb73f18a1..7f90e593a 100644 --- a/examples/sensinode/energy-scan/energy-scan.c +++ b/examples/sensinode/energy-scan/energy-scan.c @@ -76,7 +76,7 @@ PROCESS_THREAD(energy_scan, ev, data) while(1) { cmax = RSSI_BASE; cc2430_rf_channel_set(channel); - clock_delay(200); + clock_delay_usec(200); for(j = 0; j < RSSI_SAMPLES; j++) { t0 = RTIMER_NOW(); diff --git a/examples/sensinode/timer-test.c b/examples/sensinode/timer-test.c index 65f641fc0..7d9844676 100644 --- a/examples/sensinode/timer-test.c +++ b/examples/sensinode/timer-test.c @@ -16,14 +16,14 @@ #include /*---------------------------------------------------------------------------*/ -#define TEST_CLOCK_DELAY 1 -#define TEST_RTIMER 1 -#define TEST_ETIMER 1 -#define TEST_CLOCK_SECONDS 1 +#define TEST_CLOCK_DELAY_USEC 1 +#define TEST_RTIMER 1 +#define TEST_ETIMER 1 +#define TEST_CLOCK_SECONDS 1 /*---------------------------------------------------------------------------*/ static struct etimer et; -#if TEST_CLOCK_DELAY +#if TEST_CLOCK_DELAY_USEC static rtimer_clock_t start_count, end_count, diff; #endif @@ -64,16 +64,16 @@ PROCESS_THREAD(clock_test_process, ev, data) PROCESS_YIELD(); -#if TEST_CLOCK_DELAY - printf("Clock delay test, (10,000 x i) cycles:\n"); +#if TEST_CLOCK_DELAY_USEC + printf("clock_delay_usec test, (10,000 x i) usec:\n"); i = 1; while(i < 7) { start_count = RTIMER_NOW(); - clock_delay(10000 * i); + clock_delay_usec(10000 * i); end_count = RTIMER_NOW(); diff = end_count - start_count; - printf("Delayed %u = %u rtimer ticks = ~%u us\n", 10000 * i, diff, - diff * 64); + printf("Requested: %u usec, Real: %u rtimer ticks = ~%u us\n", + 10000 * i, diff, diff * 64); i++; } #endif diff --git a/platform/cc2530dk/contiki-main.c b/platform/cc2530dk/contiki-main.c index 5767f3fe4..512472bd4 100644 --- a/platform/cc2530dk/contiki-main.c +++ b/platform/cc2530dk/contiki-main.c @@ -343,7 +343,7 @@ main(void) CC_NON_BANKED * On occasion the XOSC is reported stable when in reality it's not. * We need to wait for a safeguard of 64us or more before selecting it */ - clock_delay(10); + clock_delay_usec(65); while(CLKCONCMD & CLKCONCMD_OSC); /* Wait till it's happened */ } #endif /* LPM_MODE==LPM_MODE_PM2 */ diff --git a/platform/sensinode/contiki-sensinode-main.c b/platform/sensinode/contiki-sensinode-main.c index 905695526..d059c24f2 100644 --- a/platform/sensinode/contiki-sensinode-main.c +++ b/platform/sensinode/contiki-sensinode-main.c @@ -371,7 +371,7 @@ main(void) * On occasion the XOSC is reported stable when in reality it's not. * We need to wait for a safeguard of 64us or more before selecting it */ - clock_delay(10); + clock_delay_usec(65); while(CLKCON & OSC); /* Wait till it's happened */ } #endif /* LPM_MODE==LPM_MODE_PM2 */