Unmodulated carrier transmission for cc2420
Modified the cc2420 driver to enable the radio test mode to emit unmodulated carriers (tones). A carrier can be enabled using the normal radio driver API: NETSTACK_CONF_RADIO.set_value( RADIO_PARAM_POWER_MODE, RADIO_POWER_MODE_CARRIER_ON); Once enabled, the carrier can be disabled like this: NETSTACK_CONF_RADIO.set_value( RADIO_PARAM_POWER_MODE, RADIO_POWER_MODE_CARRIER_OFF);
This commit is contained in:
parent
37e9027807
commit
feb1513b46
@ -114,6 +114,7 @@ PROCESS(cc2420_process, "CC2420 driver");
|
||||
#define CORR_THR(n) (((n) & 0x1f) << 6)
|
||||
#define FIFOP_THR(n) ((n) & 0x7f)
|
||||
#define RXBPF_LOCUR (1 << 13);
|
||||
#define TX_MODE (3 << 2)
|
||||
|
||||
int cc2420_on(void);
|
||||
int cc2420_off(void);
|
||||
@ -135,6 +136,8 @@ static void set_poll_mode(uint8_t enable);
|
||||
static void set_send_on_cca(uint8_t enable);
|
||||
static void set_auto_ack(uint8_t enable);
|
||||
|
||||
static void set_test_mode(uint8_t enable, uint8_t modulated);
|
||||
|
||||
signed char cc2420_last_rssi;
|
||||
uint8_t cc2420_last_correlation;
|
||||
|
||||
@ -156,7 +159,11 @@ get_value(radio_param_t param, radio_value_t *value)
|
||||
}
|
||||
switch(param) {
|
||||
case RADIO_PARAM_POWER_MODE:
|
||||
*value = receive_on ? RADIO_POWER_MODE_ON : RADIO_POWER_MODE_OFF;
|
||||
if ((getreg(CC2420_MDMCTRL1) & TX_MODE) & 0x08) {
|
||||
*value = RADIO_POWER_MODE_CARRIER_ON;
|
||||
} else {
|
||||
*value = receive_on ? RADIO_POWER_MODE_ON : RADIO_POWER_MODE_OFF;
|
||||
}
|
||||
return RADIO_RESULT_OK;
|
||||
case RADIO_PARAM_CHANNEL:
|
||||
*value = cc2420_get_channel();
|
||||
@ -237,6 +244,11 @@ set_value(radio_param_t param, radio_value_t value)
|
||||
cc2420_off();
|
||||
return RADIO_RESULT_OK;
|
||||
}
|
||||
if(value == RADIO_POWER_MODE_CARRIER_ON ||
|
||||
value == RADIO_POWER_MODE_CARRIER_OFF) {
|
||||
set_test_mode((value == RADIO_POWER_MODE_CARRIER_ON), 0);
|
||||
return RADIO_RESULT_OK;
|
||||
}
|
||||
return RADIO_RESULT_INVALID_VALUE;
|
||||
case RADIO_PARAM_CHANNEL:
|
||||
if(value < 11 || value > 26) {
|
||||
@ -1120,3 +1132,30 @@ set_send_on_cca(uint8_t enable)
|
||||
send_on_cca = enable;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Enable or disable radio test mode emmiting modulated or unmodulated
|
||||
* (carrier) signal. See datasheet page 55.
|
||||
*/
|
||||
static uint16_t prev_MDMCTRL1, prev_DACTST;
|
||||
|
||||
static void
|
||||
set_test_mode(uint8_t enable, uint8_t modulated)
|
||||
{
|
||||
if (enable) {
|
||||
prev_MDMCTRL1 = getreg(CC2420_MDMCTRL1);
|
||||
setreg(CC2420_MDMCTRL1, 0x050C);
|
||||
if (!modulated) {
|
||||
prev_DACTST = getreg(CC2420_DACTST);
|
||||
setreg(CC2420_DACTST, 0x1800);
|
||||
}
|
||||
/* actually starts the test mode */
|
||||
strobe(CC2420_STXON);
|
||||
} else {
|
||||
if (!modulated) {
|
||||
setreg(CC2420_DACTST, prev_DACTST);
|
||||
}
|
||||
setreg(CC2420_MDMCTRL1, prev_MDMCTRL1);
|
||||
/* actually stops the carrier */
|
||||
strobe(CC2420_SRFOFF);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -196,7 +196,9 @@ enum {
|
||||
/* Radio power modes */
|
||||
enum {
|
||||
RADIO_POWER_MODE_OFF,
|
||||
RADIO_POWER_MODE_ON
|
||||
RADIO_POWER_MODE_ON,
|
||||
RADIO_POWER_MODE_CARRIER_ON,
|
||||
RADIO_POWER_MODE_CARRIER_OFF
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user