/* Change Current mode / status to RX */
void cc1101_enter_rx_mode(void)
{
- cc1101_send_cmd(CC1101_CMD(state_idle));
+ uint8_t status = (cc1101_read_status() & CC1101_STATE_MASK);
+ if (status != CC1101_STATE_RX) {
+ if ((status != CC1101_STATE_FSTON) && (status != CC1101_STATE_TX)) {
+ cc1101_send_cmd(CC1101_CMD(state_idle));
+ }
+ }
cc1101_send_cmd(CC1101_CMD(state_rx));
}
static uint8_t cc1101_enter_tx_mode(void)
{
- uint8_t status = 0;
- status = (cc1101_read_status() & CC1101_STATE_MASK);
+ uint8_t status = (cc1101_read_status() & CC1101_STATE_MASK);
if (status != CC1101_STATE_TX) {
- cc1101_send_cmd(CC1101_CMD(state_idle));
+ if ((status != CC1101_STATE_FSTON) && (status != CC1101_STATE_RX)) {
+ cc1101_send_cmd(CC1101_CMD(state_idle));
+ }
cc1101_send_cmd(CC1101_CMD(state_tx));
}
/* Wait until chip is in Tx state */
/* Frequency synthesizer control - 0x0B .. 0x0C - FSCTRL1..0 */
CC1101_REGS(freq_synth_ctrl[0]), 0x0C, /* Used for ?? IF: 304.6875 KHz */
+ CC1101_REGS(freq_synth_ctrl[1]), 0x00, /* Reset value */
/* Carrier Frequency control - FREQ2..0 : Fcarrier == 867.999939 MHz */
CC1101_REGS(freq_control[0]), 0x21, /* 0x216276 == Fcarrier * 2^16 / Fxtal */
CC1101_REGS(freq_control[1]), 0x62, /* == approx(868 MHz) * 65536 / 26 MHz */
CC1101_REGS(freq_control[2]), 0x76,
- /* Modem configuration - MDMCFG4..0 */
+ /* Modem configuration - MDMCFG4..0 - 0x10 .. 0x14 */
/* MDMCFG4..3 : RX filterbandwidth = 541.666667 kHz and Datarate = 249.938965 kBaud */
CC1101_REGS(modem_config[0]), 0x2D,
CC1101_REGS(modem_config[1]), 0x3B,
/* Modem deviation : DEVIATN */
CC1101_REGS(modem_deviation), 0x62, /* Deviation = 127 kHz */
- /* Front End Rx/Tx config : use defaults */
-// CC1101_REGS(front_end_rx_cfg), 0x56,
-// CC1101_REGS(front_end_tx_cfg), 0x10,
- /* Main Radio Control State Machine Configuration - MCSM2..0 */
- CC1101_REGS(radio_stm[1]), 0x3F, /* CCA mode if RSSI below threshold, Stay in RX, Go to RX */
+ /* Main Radio Control State Machine Configuration - MCSM2..0 - 0x16 .. 0x18 */
+ CC1101_REGS(radio_stm[0]), 0x07, /* Use default */
+ CC1101_REGS(radio_stm[1]), 0x3F, /* CCA mode if RSSI below threshold unless Rx, Stay in RX, Go to RX */
CC1101_REGS(radio_stm[2]), 0x18, /* PO timeout 149-155us, Auto calibrate from idle to rx/tx */
/* Frequency Offset Compensation configuration - FOCCFG */
CC1101_REGS(agc_ctrl[1]), 0x00, /* LNA 2 gain decr first, Carrier sense relative threshold disabled */
CC1101_REGS(agc_ctrl[2]), 0xB0, /* Medium settings, 24 samples wait time, normal op. */
+ /* Wake on radio : use defaults */
+
+ /* Front End Rx/Tx config */
+ CC1101_REGS(front_end_rx_cfg), 0xB6,
+ CC1101_REGS(front_end_tx_cfg), 0x10,
+
/* Frequency synthesizer calibration - 0x23 .. 0x26 - FSCAL3..0 */
CC1101_REGS(freq_synth_cal[0]), 0xEA,
CC1101_REGS(freq_synth_cal[1]), 0x2A,