diff --git a/flight/targets/boards/revolution/board_hw_defs.c b/flight/targets/boards/revolution/board_hw_defs.c index 3a7cf115f..63b784f09 100644 --- a/flight/targets/boards/revolution/board_hw_defs.c +++ b/flight/targets/boards/revolution/board_hw_defs.c @@ -1092,6 +1092,53 @@ static const struct pios_usart_cfg pios_usart_hkosd_flexi_cfg = { }, }; +static const struct pios_usart_cfg pios_usart_rcvrport_cfg = { + .regs = USART6, + .remap = GPIO_AF_USART6, + .init = { + .USART_BaudRate = 57600, + .USART_WordLength = USART_WordLength_8b, + .USART_Parity = USART_Parity_No, + .USART_StopBits = USART_StopBits_1, + .USART_HardwareFlowControl = USART_HardwareFlowControl_None, + .USART_Mode = USART_Mode_Rx | USART_Mode_Tx, + }, + .irq = { + .init = { + .NVIC_IRQChannel = USART6_IRQn, + .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID, + .NVIC_IRQChannelSubPriority = 0, + .NVIC_IRQChannelCmd = ENABLE, + }, + }, + + .tx = { + // * 7: PC6 = TIM8 CH1, USART6 TX + .gpio = GPIOC, + .init = { + .GPIO_Pin = GPIO_Pin_6, + .GPIO_Speed = GPIO_Speed_2MHz, + .GPIO_Mode = GPIO_Mode_AF, + .GPIO_OType = GPIO_OType_PP, + .GPIO_PuPd = GPIO_PuPd_UP + }, + .pin_source = GPIO_PinSource6, + }, + + .rx = { + // * 8: PC7 = TIM8 CH2, USART6 RX + .gpio = GPIOC, + .init = { + .GPIO_Pin = GPIO_Pin_7, + .GPIO_Speed = GPIO_Speed_2MHz, + .GPIO_Mode = GPIO_Mode_AF, + .GPIO_OType = GPIO_OType_PP, + .GPIO_PuPd = GPIO_PuPd_UP + }, + .pin_source = GPIO_PinSource7, + } +}; + #if defined(PIOS_INCLUDE_COM) #include diff --git a/flight/targets/boards/revolution/firmware/pios_board.c b/flight/targets/boards/revolution/firmware/pios_board.c index 9f66deb6d..b1c418dae 100644 --- a/flight/targets/boards/revolution/firmware/pios_board.c +++ b/flight/targets/boards/revolution/firmware/pios_board.c @@ -880,25 +880,33 @@ void PIOS_Board_Init(void) case HWSETTINGS_RM_RCVRPORT_PPM: case HWSETTINGS_RM_RCVRPORT_PPMOUTPUTS: case HWSETTINGS_RM_RCVRPORT_PPMPWM: + case HWSETTINGS_RM_RCVRPORT_PPMTELEMETRY: #if defined(PIOS_INCLUDE_PPM) + PIOS_Board_configure_ppm(&pios_ppm_cfg); + if (hwsettings_rcvrport == HWSETTINGS_RM_RCVRPORT_PPMOUTPUTS) { // configure servo outputs and the remaining 5 inputs as outputs pios_servo_cfg = &pios_servo_cfg_out_in_ppm; } - PIOS_Board_configure_ppm(&pios_ppm_cfg); - // enable pwm on the remaining channels if (hwsettings_rcvrport == HWSETTINGS_RM_RCVRPORT_PPMPWM) { PIOS_Board_configure_pwm(&pios_pwm_ppm_cfg); } + if (hwsettings_rcvrport == HWSETTINGS_RM_RCVRPORT_PPMTELEMETRY) { + PIOS_Board_configure_com(&pios_usart_rcvrport_cfg, PIOS_COM_TELEM_RF_RX_BUF_LEN, PIOS_COM_TELEM_RF_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_telem_rf_id); + } + break; #endif /* PIOS_INCLUDE_PPM */ case HWSETTINGS_RM_RCVRPORT_OUTPUTS: // configure only the servo outputs pios_servo_cfg = &pios_servo_cfg_out_in; break; + case HWSETTINGS_RM_RCVRPORT_TELEMETRY: + PIOS_Board_configure_com(&pios_usart_rcvrport_cfg, PIOS_COM_TELEM_RF_RX_BUF_LEN, PIOS_COM_TELEM_RF_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_telem_rf_id); + break; } diff --git a/ground/openpilotgcs/src/plugins/config/configrevohwwidget.cpp b/ground/openpilotgcs/src/plugins/config/configrevohwwidget.cpp index 902716058..ae224bd6c 100644 --- a/ground/openpilotgcs/src/plugins/config/configrevohwwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configrevohwwidget.cpp @@ -65,6 +65,8 @@ ConfigRevoHWWidget::ConfigRevoHWWidget(QWidget *parent) : ConfigTaskWidget(paren addWidgetBinding("HwSettings", "GPSSpeed", m_ui->cbMainGPSSpeed); addWidgetBinding("HwSettings", "ComUsbBridgeSpeed", m_ui->cbMainComSpeed); + addWidgetBinding("HwSettings", "TelemetrySpeed", m_ui->cbRcvrTelemSpeed); + // Add Gps protocol configuration addWidgetBinding("GPSSettings", "DataProtocol", m_ui->cbMainGPSProtocol); addWidgetBinding("GPSSettings", "DataProtocol", m_ui->cbFlexiGPSProtocol); @@ -95,6 +97,7 @@ void ConfigRevoHWWidget::setupCustomCombos() connect(m_ui->cbFlexi, SIGNAL(currentIndexChanged(int)), this, SLOT(flexiPortChanged(int))); connect(m_ui->cbMain, SIGNAL(currentIndexChanged(int)), this, SLOT(mainPortChanged(int))); + connect(m_ui->cbRcvr, SIGNAL(currentIndexChanged(int)), this, SLOT(rcvrPortChanged(int))); } void ConfigRevoHWWidget::refreshWidgetsValues(UAVObject *obj) @@ -105,6 +108,7 @@ void ConfigRevoHWWidget::refreshWidgetsValues(UAVObject *obj) usbVCPPortChanged(0); mainPortChanged(0); flexiPortChanged(0); + rcvrPortChanged(0); m_refreshing = false; } @@ -196,6 +200,10 @@ void ConfigRevoHWWidget::flexiPortChanged(int index) if (m_ui->cbMain->currentIndex() == HwSettings::RM_MAINPORT_TELEMETRY) { m_ui->cbMain->setCurrentIndex(HwSettings::RM_MAINPORT_DISABLED); } + if (m_ui->cbRcvr->currentIndex() == HwSettings::RM_RCVRPORT_PPMTELEMETRY + || m_ui->cbRcvr->currentIndex() == HwSettings::RM_RCVRPORT_TELEMETRY) { + m_ui->cbRcvr->setCurrentIndex(HwSettings::RM_RCVRPORT_DISABLED); + } break; case HwSettings::RM_FLEXIPORT_GPS: // Add Gps protocol configuration @@ -247,6 +255,10 @@ void ConfigRevoHWWidget::mainPortChanged(int index) if (m_ui->cbFlexi->currentIndex() == HwSettings::RM_FLEXIPORT_TELEMETRY) { m_ui->cbFlexi->setCurrentIndex(HwSettings::RM_FLEXIPORT_DISABLED); } + if (m_ui->cbRcvr->currentIndex() == HwSettings::RM_RCVRPORT_PPMTELEMETRY + || m_ui->cbRcvr->currentIndex() == HwSettings::RM_RCVRPORT_TELEMETRY) { + m_ui->cbRcvr->setCurrentIndex(HwSettings::RM_RCVRPORT_DISABLED); + } break; case HwSettings::RM_MAINPORT_GPS: // Add Gps protocol configuration @@ -279,6 +291,30 @@ void ConfigRevoHWWidget::mainPortChanged(int index) } } +void ConfigRevoHWWidget::rcvrPortChanged(int index) +{ + Q_UNUSED(index); + + switch (m_ui->cbRcvr->currentIndex()) { + case HwSettings::RM_RCVRPORT_TELEMETRY: + case HwSettings::RM_RCVRPORT_PPMTELEMETRY: + m_ui->lblRcvrSpeed->setVisible(true); + m_ui->cbRcvrTelemSpeed->setVisible(true); + + if (m_ui->cbFlexi->currentIndex() == HwSettings::RM_FLEXIPORT_TELEMETRY) { + m_ui->cbFlexi->setCurrentIndex(HwSettings::RM_FLEXIPORT_DISABLED); + } + if (m_ui->cbMain->currentIndex() == HwSettings::RM_FLEXIPORT_TELEMETRY) { + m_ui->cbMain->setCurrentIndex(HwSettings::RM_FLEXIPORT_DISABLED); + } + break; + default: + m_ui->lblRcvrSpeed->setVisible(false); + m_ui->cbRcvrTelemSpeed->setVisible(false); + break; + } +} + void ConfigRevoHWWidget::openHelp() { QDesktopServices::openUrl(QUrl(tr("http://wiki.openpilot.org/x/GgDBAQ"), QUrl::StrictMode)); diff --git a/ground/openpilotgcs/src/plugins/config/configrevohwwidget.h b/ground/openpilotgcs/src/plugins/config/configrevohwwidget.h index abb079839..436982fef 100644 --- a/ground/openpilotgcs/src/plugins/config/configrevohwwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configrevohwwidget.h @@ -57,6 +57,7 @@ private slots: void usbHIDPortChanged(int index); void flexiPortChanged(int index); void mainPortChanged(int index); + void rcvrPortChanged(int index); void openHelp(); }; diff --git a/ground/openpilotgcs/src/plugins/config/configrevohwwidget.ui b/ground/openpilotgcs/src/plugins/config/configrevohwwidget.ui index 71fe01a23..f199499cb 100644 --- a/ground/openpilotgcs/src/plugins/config/configrevohwwidget.ui +++ b/ground/openpilotgcs/src/plugins/config/configrevohwwidget.ui @@ -121,9 +121,9 @@ 0 - 0 - 810 - 665 + -87 + 789 + 847 @@ -139,6 +139,45 @@ 12 + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -192,81 +231,100 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - 0 - 0 - - + + + - USB HID Function + Protocol + + + Qt::PlainText + + + Qt::AlignCenter + + + + + + + + + + + + + Qt::Horizontal + + + + 80 + 10 + + + + + + + + Speed Qt::AlignBottom|Qt::AlignHCenter - - + + - Qt::Horizontal + Qt::Vertical QSizePolicy::Fixed - 50 - 10 + 20 + 20 - - + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 13 + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 13 + + + + + + Qt::Horizontal @@ -281,17 +339,201 @@ - - + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 13 + + + + + + + + 0 + + + + + true + + + + + + + + + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 90 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 120 + 10 + + + + + + + + + 0 + 0 + + - Protocol + Receiver Port - Qt::AlignCenter + Qt::AlignBottom|Qt::AlignHCenter - + + + + + 0 + 0 + + + + Sonar Port + + + Qt::AlignBottom|Qt::AlignHCenter + + + + + + + Speed + + + Qt::AlignBottom|Qt::AlignHCenter + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 120 + 10 + + + + + + + + + + + false + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 70 + 10 + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + Main Port + + + Qt::AlignBottom|Qt::AlignHCenter + + + + + + + + + + Flexi Port + + + Qt::AlignBottom|Qt::AlignHCenter + + + + @@ -322,28 +564,12 @@ - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - + 0 - + true @@ -358,64 +584,8 @@ - - - - - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 70 - 10 - - - - - - - - Flexi Port - - - Qt::AlignBottom|Qt::AlignHCenter - - - - - - - false - - - - - - - - - - Main Port - - - Qt::AlignBottom|Qt::AlignHCenter - - - - - - - true - - - - - + + Qt::Horizontal @@ -430,13 +600,80 @@ - - + + + + Protocol + + + Qt::AlignCenter + + - - + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 50 + 10 + + + - + + + + + + + + + 0 + 0 + + + + Speed + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + + + + + + + Qt::Vertical + + + + 0 + 50 + + + + + + + + + + true + + + + @@ -452,71 +689,10 @@ - - - - - 0 - 0 - - - - Sonar Port - - - Qt::AlignBottom|Qt::AlignHCenter - - - - - - - - 0 - 0 - - - - Receiver Port - - - Qt::AlignBottom|Qt::AlignHCenter - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 25 - - - + + - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 120 - 10 - - - - - @@ -532,177 +708,25 @@ - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 120 - - - + + - - + + + + + 0 + 0 + + - Speed + USB HID Function Qt::AlignBottom|Qt::AlignHCenter - - - - 0 - - - - - true - - - - - - - - - - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 120 - 10 - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 13 - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 13 - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 13 - - - - - - - - Qt::Horizontal - - - - 80 - 10 - - - - - - - - Speed - - - Qt::AlignBottom|Qt::AlignHCenter - - - - - - - Protocol - - - Qt::PlainText - - - Qt::AlignCenter - - - - - - - - - @@ -908,8 +932,8 @@ Beware of not locking yourself out! - + diff --git a/shared/uavobjectdefinition/hwsettings.xml b/shared/uavobjectdefinition/hwsettings.xml index 09b79d388..a190a1b47 100644 --- a/shared/uavobjectdefinition/hwsettings.xml +++ b/shared/uavobjectdefinition/hwsettings.xml @@ -12,7 +12,7 @@ - +