void configure_radio(modulation_t mod){
#if defined USE_SI4460 || defined USE_SX127X
    if(mod == MODULATION_CW){
        hw_radio_continuous_tx(&tx_cfg, true);
    } else {
        hw_radio_continuous_tx(&tx_cfg, false);
    }

#elif defined USE_CC1101

    hw_radio_set_rx(&tx_cfg, NULL, NULL); // we 'misuse' hw_radio_set_rx to configure the channel (using the public API)
    hw_radio_set_idle(); // go straight back to idle

    /* Configure */
    cc1101_interface_write_single_patable(current_eirp_level);
    //cc1101_interface_write_single_reg(0x08, 0x22); // PKTCTRL0 random PN9 mode + disable data whitening
    cc1101_interface_write_single_reg(0x08, 0x22); // PKTCTRL0 disable data whitening, continious preamble
    if(mod == MODULATION_CW) {
      cc1101_interface_write_single_reg(0x12, 0x30); // MDMCFG2
    } else {
      cc1101_interface_write_single_reg(0x12, 0x12); // MDMCFG2
    }

    cc1101_interface_strobe(0x32); // strobe calibrate
#endif
}
Пример #2
0
static void configure_eirp(const eirp_t eirp)
{
    if(eirp != current_eirp)
    {
        current_eirp = eirp;
        cc1101_interface_write_single_patable(0xC0); // TODO only 10 dBm supported for now
    }
}
void change_eirp(){
#if defined USE_SI4460
    ezradio_set_property(0x22, 0x01, 0x01, current_eirp_level);
#elif defined USE_CC1101
    cc1101_interface_write_single_patable(current_eirp_level);
#endif
#ifdef HAS_LCD
    char string[10] = "";
    sprintf(string, "ptx %3x", current_eirp_level);
    lcd_write_string(string);
#endif
}
void start()
{
    hw_rx_cfg_t rx_cfg;
    rx_cfg.channel_id.channel_header.ch_coding = PHY_CODING_PN9;
    rx_cfg.channel_id.channel_header.ch_class = current_channel_class;
    rx_cfg.channel_id.channel_header.ch_freq_band = current_channel_band;
    rx_cfg.channel_id.center_freq_index = channel_indexes[current_channel_indexes_index];

#ifdef HAS_LCD
    char string[10] = "";
    char rate;
    char band[3];
    switch(current_channel_class)
    {
        case PHY_CLASS_LO_RATE: rate = 'L'; break;
        case PHY_CLASS_NORMAL_RATE: rate = 'N'; break;
        case PHY_CLASS_HI_RATE: rate = 'H'; break;
    }

    switch(current_channel_band)
    {
        case PHY_BAND_433: strncpy(band, "433", sizeof(band)); break;
        case PHY_BAND_868: strncpy(band, "868", sizeof(band)); break;
        case PHY_BAND_915: strncpy(band, "915", sizeof(band)); break;
    }

    sprintf(string, "%.3s%c-%i", band, rate, rx_cfg.channel_id.center_freq_index),
    lcd_write_string(string);
#endif

    hw_radio_set_rx(&rx_cfg, NULL, &rssi_valid_cb); // we 'misuse' hw_radio_set_rx to configure the channel (using the public API)
    hw_radio_set_idle(); // go straight back to idle

    cc1101_interface_write_single_reg(0x08, 0x22); // PKTCTRL0 random PN9 mode + disable data whitening
    //cc1101_interface_write_single_reg(0x12, 0x30); // MDMCFG2: use OOK modulation to clearly view centre freq on spectrum analyzer, comment for GFSK
    cc1101_interface_write_single_patable(0xc0); // 10dBm TX EIRP
    cc1101_interface_strobe(0x35); // strobe TX
}