Adjust cc2x3x ports to the new clock API

This commit is contained in:
George Oikonomou 2012-04-30 13:30:34 +01:00
parent efd6d12831
commit 1f7171f943
11 changed files with 39 additions and 29 deletions

View file

@ -14,6 +14,11 @@
#include <stdint.h> #include <stdint.h>
/* 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 * lint - style defines to help syntax parsers with sdcc-specific 8051 code
* They don't interfere with actual compilation * They don't interfere with actual compilation

View file

@ -126,7 +126,7 @@ cc2430_rf_command(uint8_t command)
case ISTXON: case ISTXON:
fifo_count = RXFIFOCNT; fifo_count = RXFIFOCNT;
RFST = command; RFST = command;
clock_delay(2); clock_delay_usec(2);
if(fifo_count != RXFIFOCNT) { if(fifo_count != RXFIFOCNT) {
RFST = ISFLUSHRX; RFST = ISFLUSHRX;
RFST = ISFLUSHRX; RFST = ISFLUSHRX;
@ -430,7 +430,7 @@ transmit(unsigned short transmit_len)
cc2430_rf_command(ISTXON); cc2430_rf_command(ISTXON);
counter = 0; counter = 0;
while(!(RFSTATUS & TX_ACTIVE) && (counter++ < 3)) { while(!(RFSTATUS & TX_ACTIVE) && (counter++ < 3)) {
clock_delay(10); clock_delay_usec(6);
} }
if(!(RFSTATUS & TX_ACTIVE)) { if(!(RFSTATUS & TX_ACTIVE)) {

View file

@ -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 * Each iteration is ~1.0xy usec, so this function delays for roughly len usec
*/ */
void void
clock_delay(unsigned int len) clock_delay_usec(uint16_t len)
{ {
DISABLE_INTERRUPTS(); DISABLE_INTERRUPTS();
while(len--) { while(len--) {
ASM(nop); ASM(nop); ASM(nop); ASM(nop); ASM(nop);
ASM(nop); ASM(nop); ASM(nop); ASM(nop);
} }
ENABLE_INTERRUPTS(); ENABLE_INTERRUPTS();

View file

@ -19,6 +19,11 @@
#include "dev/watchdog.h" #include "dev/watchdog.h"
#define watchdog_stop() watchdog_periodic() #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 * lint - style defines to help syntax parsers with sdcc-specific 8051 code
* They don't interfere with actual compilation * They don't interfere with actual compilation

View file

@ -287,7 +287,7 @@ transmit(unsigned short transmit_len)
counter = 0; counter = 0;
while(!(FSMSTAT1 & FSMSTAT1_TX_ACTIVE) && (counter++ < 3)) { while(!(FSMSTAT1 & FSMSTAT1_TX_ACTIVE) && (counter++ < 3)) {
clock_delay(10); clock_delay_usec(6);
} }
if(!(FSMSTAT1 & FSMSTAT1_TX_ACTIVE)) { if(!(FSMSTAT1 & FSMSTAT1_TX_ACTIVE)) {

View file

@ -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 * Each iteration is ~1.0xy usec, so this function delays for roughly len usec
*/ */
void void
clock_delay(unsigned int len) clock_delay_usec(uint16_t len)
{ {
DISABLE_INTERRUPTS(); DISABLE_INTERRUPTS();
while(len--) { while(len--) {

View file

@ -16,14 +16,14 @@
#include <stdio.h> #include <stdio.h>
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#define TEST_CLOCK_DELAY 1 #define TEST_CLOCK_DELAY_USEC 1
#define TEST_RTIMER 1 #define TEST_RTIMER 1
#define TEST_ETIMER 1 #define TEST_ETIMER 1
#define TEST_CLOCK_SECONDS 1 #define TEST_CLOCK_SECONDS 1
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static struct etimer et; static struct etimer et;
#if TEST_CLOCK_DELAY #if TEST_CLOCK_DELAY_USEC
static rtimer_clock_t start_count, end_count, diff; static rtimer_clock_t start_count, end_count, diff;
#endif #endif
@ -64,16 +64,16 @@ PROCESS_THREAD(clock_test_process, ev, data)
PROCESS_YIELD(); PROCESS_YIELD();
#if TEST_CLOCK_DELAY #if TEST_CLOCK_DELAY_USEC
printf("Clock delay test, (10,000 x i) cycles:\n"); printf("clock_delay_usec test, (10,000 x i) usec:\n");
i = 1; i = 1;
while(i < 7) { while(i < 7) {
start_count = RTIMER_NOW(); start_count = RTIMER_NOW();
clock_delay(10000 * i); clock_delay_usec(10000 * i);
end_count = RTIMER_NOW(); end_count = RTIMER_NOW();
diff = end_count - start_count; diff = end_count - start_count;
printf("Delayed %u = %u rtimer ticks = ~%u us\n", 10000 * i, diff, printf("Requested: %u usec, Real: %u rtimer ticks = ~%u us\n",
diff * 64); 10000 * i, diff, diff * 64);
i++; i++;
} }
#endif #endif

View file

@ -76,7 +76,7 @@ PROCESS_THREAD(energy_scan, ev, data)
while(1) { while(1) {
cmax = RSSI_BASE; cmax = RSSI_BASE;
cc2430_rf_channel_set(channel); cc2430_rf_channel_set(channel);
clock_delay(200); clock_delay_usec(200);
for(j = 0; j < RSSI_SAMPLES; j++) { for(j = 0; j < RSSI_SAMPLES; j++) {
t0 = RTIMER_NOW(); t0 = RTIMER_NOW();

View file

@ -16,14 +16,14 @@
#include <stdio.h> #include <stdio.h>
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#define TEST_CLOCK_DELAY 1 #define TEST_CLOCK_DELAY_USEC 1
#define TEST_RTIMER 1 #define TEST_RTIMER 1
#define TEST_ETIMER 1 #define TEST_ETIMER 1
#define TEST_CLOCK_SECONDS 1 #define TEST_CLOCK_SECONDS 1
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static struct etimer et; static struct etimer et;
#if TEST_CLOCK_DELAY #if TEST_CLOCK_DELAY_USEC
static rtimer_clock_t start_count, end_count, diff; static rtimer_clock_t start_count, end_count, diff;
#endif #endif
@ -64,16 +64,16 @@ PROCESS_THREAD(clock_test_process, ev, data)
PROCESS_YIELD(); PROCESS_YIELD();
#if TEST_CLOCK_DELAY #if TEST_CLOCK_DELAY_USEC
printf("Clock delay test, (10,000 x i) cycles:\n"); printf("clock_delay_usec test, (10,000 x i) usec:\n");
i = 1; i = 1;
while(i < 7) { while(i < 7) {
start_count = RTIMER_NOW(); start_count = RTIMER_NOW();
clock_delay(10000 * i); clock_delay_usec(10000 * i);
end_count = RTIMER_NOW(); end_count = RTIMER_NOW();
diff = end_count - start_count; diff = end_count - start_count;
printf("Delayed %u = %u rtimer ticks = ~%u us\n", 10000 * i, diff, printf("Requested: %u usec, Real: %u rtimer ticks = ~%u us\n",
diff * 64); 10000 * i, diff, diff * 64);
i++; i++;
} }
#endif #endif

View file

@ -343,7 +343,7 @@ main(void) CC_NON_BANKED
* On occasion the XOSC is reported stable when in reality it's not. * 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 * 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 */ while(CLKCONCMD & CLKCONCMD_OSC); /* Wait till it's happened */
} }
#endif /* LPM_MODE==LPM_MODE_PM2 */ #endif /* LPM_MODE==LPM_MODE_PM2 */

View file

@ -371,7 +371,7 @@ main(void)
* On occasion the XOSC is reported stable when in reality it's not. * 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 * 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 */ while(CLKCON & OSC); /* Wait till it's happened */
} }
#endif /* LPM_MODE==LPM_MODE_PM2 */ #endif /* LPM_MODE==LPM_MODE_PM2 */