cc2420 return to last state when disabling carrier

Made cc2420 follow the same logic as cc2538 when
disabling the unmodulated carrier. Now they both
return to the state they were in before the carrier
was enabled.
This commit is contained in:
Carlos Pérez Penichet 2018-10-26 16:28:20 +02:00
parent c6770112af
commit a906f03a25
2 changed files with 17 additions and 2 deletions

View File

@ -397,7 +397,7 @@ get_sfd_timestamp(void)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Enable or disable radio test mode emmiting modulated or unmodulated /* 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 uint32_t prev_FRMCTRL0, prev_MDMTEST1;
static uint8_t was_on; static uint8_t was_on;

View File

@ -1136,11 +1136,20 @@ set_send_on_cca(uint8_t enable)
* (carrier) signal. See datasheet page 55. * (carrier) signal. See datasheet page 55.
*/ */
static uint16_t prev_MDMCTRL1, prev_DACTST; static uint16_t prev_MDMCTRL1, prev_DACTST;
static uint8_t was_on;
static void static void
set_test_mode(uint8_t enable, uint8_t modulated) set_test_mode(uint8_t enable, uint8_t modulated)
{ {
radio_value_t mode;
get_value(RADIO_PARAM_POWER_MODE, &mode);
if(enable) { if(enable) {
if(mode == RADIO_POWER_MODE_CARRIER_ON) {
return;
}
was_on = (mode == RADIO_POWER_MODE_ON);
off();
prev_MDMCTRL1 = getreg(CC2420_MDMCTRL1); prev_MDMCTRL1 = getreg(CC2420_MDMCTRL1);
setreg(CC2420_MDMCTRL1, 0x050C); setreg(CC2420_MDMCTRL1, 0x050C);
if(!modulated) { if(!modulated) {
@ -1150,12 +1159,18 @@ set_test_mode(uint8_t enable, uint8_t modulated)
/* actually starts the test mode */ /* actually starts the test mode */
strobe(CC2420_STXON); strobe(CC2420_STXON);
} else { } else {
if(mode != RADIO_POWER_MODE_CARRIER_ON) {
return;
}
strobe(CC2420_SRFOFF);
if(!modulated) { if(!modulated) {
setreg(CC2420_DACTST, prev_DACTST); setreg(CC2420_DACTST, prev_DACTST);
} }
setreg(CC2420_MDMCTRL1, prev_MDMCTRL1); setreg(CC2420_MDMCTRL1, prev_MDMCTRL1);
/* actually stops the carrier */ /* actually stops the carrier */
strobe(CC2420_SRFOFF); if(was_on) {
on();
}
} }
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/