diff --git a/arch/cpu/cc2538/dev/cc2538-rf.c b/arch/cpu/cc2538/dev/cc2538-rf.c index 23e3e11e0..cee2197e7 100644 --- a/arch/cpu/cc2538/dev/cc2538-rf.c +++ b/arch/cpu/cc2538/dev/cc2538-rf.c @@ -397,7 +397,7 @@ get_sfd_timestamp(void) } /*---------------------------------------------------------------------------*/ /* Enable or disable radio test mode emmiting modulated or unmodulated - * (carrier) signal. See datasheet page XX + * (carrier) signal. See User's Guide pages 719 and 741. */ static uint32_t prev_FRMCTRL0, prev_MDMTEST1; static uint8_t was_on; diff --git a/arch/dev/cc2420/cc2420.c b/arch/dev/cc2420/cc2420.c index 58c77e140..18b289c1d 100644 --- a/arch/dev/cc2420/cc2420.c +++ b/arch/dev/cc2420/cc2420.c @@ -1136,11 +1136,20 @@ set_send_on_cca(uint8_t enable) * (carrier) signal. See datasheet page 55. */ static uint16_t prev_MDMCTRL1, prev_DACTST; +static uint8_t was_on; static void set_test_mode(uint8_t enable, uint8_t modulated) { + radio_value_t mode; + get_value(RADIO_PARAM_POWER_MODE, &mode); + if(enable) { + if(mode == RADIO_POWER_MODE_CARRIER_ON) { + return; + } + was_on = (mode == RADIO_POWER_MODE_ON); + off(); prev_MDMCTRL1 = getreg(CC2420_MDMCTRL1); setreg(CC2420_MDMCTRL1, 0x050C); if(!modulated) { @@ -1150,12 +1159,18 @@ set_test_mode(uint8_t enable, uint8_t modulated) /* actually starts the test mode */ strobe(CC2420_STXON); } else { + if(mode != RADIO_POWER_MODE_CARRIER_ON) { + return; + } + strobe(CC2420_SRFOFF); if(!modulated) { setreg(CC2420_DACTST, prev_DACTST); } setreg(CC2420_MDMCTRL1, prev_MDMCTRL1); /* actually stops the carrier */ - strobe(CC2420_SRFOFF); + if(was_on) { + on(); + } } } /*---------------------------------------------------------------------------*/