diff --git a/cpu/cc2430/dev/cc2430_rf.c b/cpu/cc2430/dev/cc2430_rf.c index cbf997a38..fa66006f8 100644 --- a/cpu/cc2430/dev/cc2430_rf.c +++ b/cpu/cc2430/dev/cc2430_rf.c @@ -104,6 +104,7 @@ PROCESS(cc2430_rf_process, "CC2430 RF driver"); /*---------------------------------------------------------------------------*/ static uint8_t rf_initialized = 0; static uint8_t __data rf_flags; +static uint8_t rf_channel; static int on(void); /* prepare() needs our prototype */ static int off(void); /* transmit() needs our prototype */ @@ -194,9 +195,17 @@ cc2430_rf_channel_set(uint8_t channel) cc2430_rf_command(ISRXON); + rf_channel = channel; + return (int8_t) channel; } /*---------------------------------------------------------------------------*/ +uint8_t +cc2430_rf_channel_get() +{ + return rf_channel; +} +/*---------------------------------------------------------------------------*/ /** * Select RF transmit power. * diff --git a/cpu/cc2430/dev/cc2430_rf.h b/cpu/cc2430/dev/cc2430_rf.h index eecb26ead..9ef949726 100644 --- a/cpu/cc2430/dev/cc2430_rf.h +++ b/cpu/cc2430/dev/cc2430_rf.h @@ -74,6 +74,7 @@ extern const struct radio_driver cc2430_rf_driver; void cc2430_rf_command(uint8_t command); int8_t cc2430_rf_channel_set(uint8_t channel); +uint8_t cc2430_rf_channel_get(); uint8_t cc2430_rf_power_set(uint8_t new_power); void cc2430_rf_set_addr(unsigned pan, unsigned addr, const uint8_t *ieee_addr); diff --git a/cpu/cc253x/dev/cc2530-rf.h b/cpu/cc253x/dev/cc2530-rf.h index 397b952a3..9d84603d4 100644 --- a/cpu/cc253x/dev/cc2530-rf.h +++ b/cpu/cc253x/dev/cc2530-rf.h @@ -121,6 +121,7 @@ extern const struct radio_driver cc2530_rf_driver; /*---------------------------------------------------------------------------*/ int8_t cc2530_rf_channel_set(uint8_t channel); +#define cc2530_rf_channel_get() ((uint8_t)((FREQCTRL + 44) / 5)) uint8_t cc2530_rf_power_set(uint8_t new_power); void cc2530_rf_set_addr(uint16_t pan); /*---------------------------------------------------------------------------*/ diff --git a/examples/cc2530dk/border-router/border-router.c b/examples/cc2530dk/border-router/border-router.c index 50de6462a..3b6b54e88 100644 --- a/examples/cc2530dk/border-router/border-router.c +++ b/examples/cc2530dk/border-router/border-router.c @@ -39,7 +39,7 @@ #include "dev/watchdog.h" #include "dev/slip.h" #include "dev/leds.h" -#include "cc253x.h" +#include "dev/cc2530-rf.h" static uint8_t prefix_set; /*---------------------------------------------------------------------------*/ @@ -116,9 +116,9 @@ PROCESS_THREAD(border_router_process, ev, data) leds_off(LEDS_GREEN); PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); } - + cc2530_rf_channel_get(); /* We have created a new DODAG when we reach here */ - PRINTF("On Channel %u\n", (uint8_t)((FREQCTRL + 44) / 5)); + printf("On Channel %u\n", cc2530_rf_channel_get()); print_local_addresses(); diff --git a/examples/sensinode/border-router/border-router.c b/examples/sensinode/border-router/border-router.c index 8c1e4952f..fb2175c59 100644 --- a/examples/sensinode/border-router/border-router.c +++ b/examples/sensinode/border-router/border-router.c @@ -40,10 +40,6 @@ #include "dev/slip.h" #include "dev/leds.h" -#ifndef CC2430_RF_CONF_CHANNEL -#define CC2430_RF_CONF_CHANNEL 0xFF -#endif - static uint8_t prefix_set; /*---------------------------------------------------------------------------*/ PROCESS(border_router_process, "Border Router process"); @@ -123,7 +119,7 @@ PROCESS_THREAD(border_router_process, ev, data) } /* We have created a new DODAG when we reach here */ - PRINTF("On Channel %u\n", CC2430_RF_CONF_CHANNEL); + PRINTF("On Channel %u\n", cc2430_rf_channel_get()); print_local_addresses();