1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

Added setting of max RF power and initial frequency on Revo.

This commit is contained in:
Brian Webb 2013-04-06 04:28:25 +01:00
parent fef2c16f5a
commit 4564718708
5 changed files with 61 additions and 7 deletions

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

@ -65,6 +65,8 @@ ConfigRevoHWWidget::ConfigRevoHWWidget(QWidget *parent) : ConfigTaskWidget(paren
addUAVObjectToWidgetRelation("HwSettings","ComUsbBridgeSpeed",m_ui->cbMainComSpeed);
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);
}
}

View File

@ -169,9 +169,6 @@
</property>
</widget>
</item>
<item row="13" column="2">
<widget class="QComboBox" name="cbModem"/>
</item>
<item row="3" column="0">
<widget class="QComboBox" name="cbRcvr"/>
</item>
@ -375,6 +372,39 @@
</property>
</widget>
</item>
<item row="13" column="2">
<widget class="QComboBox" name="cbModem"/>
</item>
<item row="14" column="2">
<widget class="QLabel" name="lblTxPower">
<property name="text">
<string>Max Tx Power (mW)</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
</property>
</widget>
</item>
<item row="15" column="2">
<widget class="QComboBox" name="cbTxPower"/>
</item>
<item row="16" column="2">
<widget class="QLabel" name="lblInitFreq">
<property name="text">
<string>Initial Frequency (Hz)</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
</property>
</widget>
</item>
<item row="17" column="2">
<widget class="QLineEdit" name="leInitFreq">
<property name="toolTip">
<string extracomment="The initial connection frequency (Hz)"/>
</property>
</widget>
</item>
<item row="14" column="1">
<widget class="QLabel" name="lblFlexiSpeed">
<property name="text">