From 4564718708080b21352b3f325a09d7860b63aee5 Mon Sep 17 00:00:00 2001 From: Brian Webb Date: Sat, 6 Apr 2013 04:28:25 +0100 Subject: [PATCH] Added setting of max RF power and initial frequency on Revo. --- flight/Modules/PipXtreme/pipxtrememod.c | 1 - flight/PiOS/Common/pios_rfm22b.c | 8 +++-- flight/targets/RevoMini/System/pios_board.c | 10 ++++++ .../src/plugins/config/configrevohwwidget.cpp | 13 ++++++- .../src/plugins/config/configrevohwwidget.ui | 36 +++++++++++++++++-- 5 files changed, 61 insertions(+), 7 deletions(-) diff --git a/flight/Modules/PipXtreme/pipxtrememod.c b/flight/Modules/PipXtreme/pipxtrememod.c index 5aaed3831..729333a75 100644 --- a/flight/Modules/PipXtreme/pipxtrememod.c +++ b/flight/Modules/PipXtreme/pipxtrememod.c @@ -47,7 +47,6 @@ // Private constants #define SYSTEM_UPDATE_PERIOD_MS 1000 -#define LED_BLINK_RATE_HZ 5 #if defined(PIOS_SYSTEM_STACK_SIZE) #define STACK_SIZE_BYTES PIOS_SYSTEM_STACK_SIZE diff --git a/flight/PiOS/Common/pios_rfm22b.c b/flight/PiOS/Common/pios_rfm22b.c index 1378336ce..beddb1e08 100644 --- a/flight/PiOS/Common/pios_rfm22b.c +++ b/flight/PiOS/Common/pios_rfm22b.c @@ -559,8 +559,8 @@ int32_t PIOS_RFM22B_Init(uint32_t *rfm22b_id, uint32_t spi_id, uint32_t slave_nu rfm22b_dev->stats.rx_seq = 0; // Initialize the frequencies. - PIOS_RFM22B_SetFrequencyRange(*rfm22b_id, RFM22B_NOMINAL_CARRIER_FREQUENCY, RFM22B_NOMINAL_CARRIER_FREQUENCY, RFM22B_FREQUENCY_HOP_STEP_SIZE); PIOS_RFM22B_SetInitialFrequency(*rfm22b_id, RFM22B_DEFAULT_FREQUENCY); + PIOS_RFM22B_SetFrequencyRange(*rfm22b_id, RFM22B_DEFAULT_FREQUENCY, RFM22B_DEFAULT_FREQUENCY, RFM22B_FREQUENCY_HOP_STEP_SIZE); // Initialize the bindings. for (uint32_t i = 0; i < OPLINKSETTINGS_BINDINGS_NUMELEM; ++i) { @@ -1361,6 +1361,10 @@ static bool rfm22_ready_to_send(struct pios_rfm22b_dev *rfm22b_dev) if (rfm22b_dev->prev_tx_packet || rfm22b_dev->send_ppm || rfm22b_dev->send_status) return true; + // Are we not connected yet? + if (!rfm22_isConnected(rfm22b_dev)) + return true; + // Is there some data ready to sent? PHPacketHandle dp = &rfm22b_dev->data_packet; if (dp->header.data_size > 0) @@ -2519,7 +2523,7 @@ static enum pios_rfm22b_event rfm22_init(struct pios_rfm22b_dev *rfm22b_dev) rfm22_write(rfm22b_dev, RFM22_xtal_osc_load_cap, rfm22b_dev->cfg.RFXtalCap); // Initialize the frequency and datarate to te default. - rfm22_setNominalCarrierFrequency(rfm22b_dev, RFM22B_DEFAULT_FREQUENCY, RFM22B_DEFAULT_FREQUENCY, RFM22B_FREQUENCY_HOP_STEP_SIZE); + rfm22_setNominalCarrierFrequency(rfm22b_dev, rfm22b_dev->init_frequency, rfm22b_dev->init_frequency, RFM22B_FREQUENCY_HOP_STEP_SIZE); rfm22_setDatarate(rfm22b_dev, RFM22B_DEFAULT_RX_DATARATE, true); return RFM22B_EVENT_INITIALIZED; diff --git a/flight/targets/RevoMini/System/pios_board.c b/flight/targets/RevoMini/System/pios_board.c index 3f5f66962..98c9067f9 100644 --- a/flight/targets/RevoMini/System/pios_board.c +++ b/flight/targets/RevoMini/System/pios_board.c @@ -631,6 +631,10 @@ void PIOS_Board_Init(void) { #if defined(PIOS_INCLUDE_RFM22B) uint8_t hwsettings_radioport; HwSettingsRadioPortGet(&hwsettings_radioport); + uint8_t hwsettings_maxrfpower; + HwSettingsMaxRFPowerGet(&hwsettings_maxrfpower); + uint32_t hwsettings_deffreq; + HwSettingsDefaultFrequencyGet(&hwsettings_deffreq); switch (hwsettings_radioport) { case HWSETTINGS_RADIOPORT_DISABLED: break; @@ -642,6 +646,12 @@ void PIOS_Board_Init(void) { if (PIOS_RFM22B_Init(&pios_rfm22b_id, PIOS_RFM22_SPI_PORT, pios_rfm22b_cfg->slave_num, pios_rfm22b_cfg)) { PIOS_Assert(0); } + + // Set the modem parameters and reinitilize the modem. + PIOS_RFM22B_SetInitialFrequency(pios_rfm22b_id, hwsettings_deffreq); + PIOS_RFM22B_SetTxPower(pios_rfm22b_id, hwsettings_maxrfpower); + PIOS_RFM22B_Reinit(pios_rfm22b_id); + #ifdef PIOS_INCLUDE_RFM22B_COM uint8_t *rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_RFM22B_RF_RX_BUF_LEN); uint8_t *tx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_RFM22B_RF_TX_BUF_LEN); diff --git a/ground/openpilotgcs/src/plugins/config/configrevohwwidget.cpp b/ground/openpilotgcs/src/plugins/config/configrevohwwidget.cpp index 6564819a7..bd96ca5ee 100644 --- a/ground/openpilotgcs/src/plugins/config/configrevohwwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configrevohwwidget.cpp @@ -64,7 +64,9 @@ ConfigRevoHWWidget::ConfigRevoHWWidget(QWidget *parent) : ConfigTaskWidget(paren addUAVObjectToWidgetRelation("HwSettings","GPSSpeed",m_ui->cbMainGPSSpeed); addUAVObjectToWidgetRelation("HwSettings","ComUsbBridgeSpeed",m_ui->cbMainComSpeed); - addUAVObjectToWidgetRelation("HwSettings","RadioPort",m_ui->cbModem); + addUAVObjectToWidgetRelation("HwSettings", "RadioPort", m_ui->cbModem); + addUAVObjectToWidgetRelation("HwSettings", "MaxRFPower", m_ui->cbTxPower); + addUAVObjectToWidgetRelation("HwSettings", "DefaultFrequency", m_ui->leInitFreq); connect(m_ui->cchwHelp,SIGNAL(clicked()),this,SLOT(openHelp())); @@ -288,6 +290,15 @@ void ConfigRevoHWWidget::modemPortChanged(int index) if(m_ui->cbFlexi->currentIndex() == HwSettings::RM_FLEXIPORT_TELEMETRY) { m_ui->cbFlexi->setCurrentIndex(HwSettings::RM_FLEXIPORT_DISABLED); } + m_ui->lblTxPower->setVisible(true); + m_ui->cbTxPower->setVisible(true); + m_ui->lblInitFreq->setVisible(true); + m_ui->leInitFreq->setVisible(true); + } else { + m_ui->lblTxPower->setVisible(false); + m_ui->cbTxPower->setVisible(false); + m_ui->lblInitFreq->setVisible(false); + m_ui->leInitFreq->setVisible(false); } } diff --git a/ground/openpilotgcs/src/plugins/config/configrevohwwidget.ui b/ground/openpilotgcs/src/plugins/config/configrevohwwidget.ui index 199d2e817..fb81114bd 100644 --- a/ground/openpilotgcs/src/plugins/config/configrevohwwidget.ui +++ b/ground/openpilotgcs/src/plugins/config/configrevohwwidget.ui @@ -169,9 +169,6 @@ - - - @@ -375,6 +372,39 @@ + + + + + + + Max Tx Power (mW) + + + Qt::AlignBottom|Qt::AlignHCenter + + + + + + + + + + Initial Frequency (Hz) + + + Qt::AlignBottom|Qt::AlignHCenter + + + + + + + + + +