From b7acee57236e65ddda7622a453e60b9f1478fd67 Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Sun, 10 Sep 2017 17:28:08 +0200 Subject: [PATCH] Allow USB mode selection on USB connect (#5193) Allow all USB modes to be compiled in at the same time --- .../src/firmwares/opentx/opentxeeprom.cpp | 3 +- .../src/firmwares/opentx/opentxinterface.cpp | 4 - companion/src/generaledit/generalsetup.cpp | 36 +- companion/src/generaledit/generalsetup.h | 1 + companion/src/generaledit/generalsetup.ui | 2057 +++++++++-------- companion/src/radiodata.h | 1 + radio/src/datastructs.h | 3 +- radio/src/debug.h | 12 +- radio/src/gui/128x64/radio_setup.cpp | 9 +- radio/src/gui/212x64/radio_setup.cpp | 5 + radio/src/gui/212x64/view_statistics.cpp | 7 - radio/src/gui/480x272/radio_setup.cpp | 6 + radio/src/keys.h | 2 +- radio/src/main_arm.cpp | 58 +- radio/src/opentx.cpp | 2 - radio/src/opentx.h | 6 + radio/src/serial.cpp | 14 +- .../targets/common/arm/stm32/CMakeLists.txt | 58 +- .../common/arm/stm32/serial2_driver.cpp | 26 +- .../targets/common/arm/stm32/usb_driver.cpp | 44 +- .../src/targets/common/arm/stm32/usb_driver.h | 51 + .../src/targets/common/arm/stm32/usbd_conf.h | 5 +- .../src/targets/common/arm/stm32/usbd_desc.c | 176 +- .../src/targets/common/arm/stm32/usbd_usr.cpp | 15 +- radio/src/targets/horus/board.h | 15 +- radio/src/targets/simu/simpgmspace.cpp | 2 + radio/src/targets/taranis/board.h | 14 +- radio/src/targets/taranis/diskio.cpp | 9 +- radio/src/tasks_arm.cpp | 2 +- .../Class/cdc/src/usbd_cdc_core.c | 9 +- .../Class/msc/inc/usbd_msc_core.h | 2 +- radio/src/translations.cpp | 5 + radio/src/translations.h | 8 +- radio/src/translations/cz.h.txt | 7 + radio/src/translations/de.h.txt | 7 + radio/src/translations/en.h.txt | 7 + radio/src/translations/es.h.txt | 7 + radio/src/translations/fi.h.txt | 7 + radio/src/translations/fr.h.txt | 7 + radio/src/translations/it.h.txt | 7 + radio/src/translations/nl.h.txt | 7 + radio/src/translations/pl.h.txt | 7 + radio/src/translations/pt.h.txt | 7 + radio/src/translations/se.h.txt | 7 + radio/util/fwoptions.py | 10 - 45 files changed, 1515 insertions(+), 1239 deletions(-) create mode 100644 radio/src/targets/common/arm/stm32/usb_driver.h diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 0e6d3fe0c..647b4f751 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -3703,7 +3703,8 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, Board::Type if (version >= 218) { internalField.Append(new BoolField<1>(this, generalData.jitterFilter)); internalField.Append(new BoolField<1>(this, generalData.disableRssiPoweroffAlarm)); - internalField.Append(new SpareBitsField<5>(this)); + internalField.Append(new UnsignedField<2>(this, generalData.usbMode)); + internalField.Append(new SpareBitsField<3>(this)); } else { internalField.Append(new SpareBitsField<7>(this)); diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index 003d79144..39af035d7 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -1133,10 +1133,6 @@ void addOpenTxFrskyOptions(OpenTxFirmware * firmware) firmware->addOption("lua", QObject::tr("Support for Lua model scripts")); firmware->addOption("luac", QObject::tr("Enable Lua compiler")); firmware->addOption("bindopt", QObject::tr("Enable bindings options")); - Option usb_options[] = {{"massstorage", QObject::tr("Instead of Joystick emulation, USB connection is Mass Storage (as in the Bootloader)")}, - {"cli", QObject::tr("Instead of Joystick emulation, USB connection is Command Line Interface")}, - {NULL}}; - firmware->addOptions(usb_options); } void addOpenTxTaranisOptions(OpenTxFirmware * firmware) diff --git a/companion/src/generaledit/generalsetup.cpp b/companion/src/generaledit/generalsetup.cpp index 265bb5b2a..c990c8895 100644 --- a/companion/src/generaledit/generalsetup.cpp +++ b/companion/src/generaledit/generalsetup.cpp @@ -27,8 +27,8 @@ ui(new Ui::GeneralSetup) { ui->setupUi(this); - QLabel * pmsl[] = {ui->ro_label,ui->ro1_label,ui->ro2_label,ui->ro3_label,ui->ro4_label,ui->ro5_label,ui->ro6_label,ui->ro7_label,ui->ro8_label, NULL}; - QSlider * tpmsld[] = {ui->chkSA, ui->chkSB, ui->chkSC, ui->chkSD, ui->chkSE, ui->chkSF, ui->chkSG, ui->chkSH, NULL}; + QLabel *pmsl[] = {ui->ro_label, ui->ro1_label, ui->ro2_label, ui->ro3_label, ui->ro4_label, ui->ro5_label, ui->ro6_label, ui->ro7_label, ui->ro8_label, NULL}; + QSlider *tpmsld[] = {ui->chkSA, ui->chkSB, ui->chkSC, ui->chkSD, ui->chkSE, ui->chkSF, ui->chkSG, ui->chkSH, NULL}; if (IS_TARANIS(firmware->getBoard())) { ui->contrastSB->setMinimum(0); @@ -44,27 +44,27 @@ ui(new Ui::GeneralSetup) switchstate >>= 2; ui->chkSE->setValue(switchstate & 0x3); switchstate >>= 2; - ui->chkSF->setValue((switchstate & 0x3)/2); + ui->chkSF->setValue((switchstate & 0x3) / 2); switchstate >>= 2; ui->chkSG->setValue(switchstate & 0x3); switchstate >>= 2; ui->chkSH->setValue(switchstate & 0x3); } else { - for (int i=0; pmsl[i]; i++) { + for (int i = 0; pmsl[i]; i++) { pmsl[i]->hide(); } - for (int i=0; tpmsld[i]; i++) { + for (int i = 0; tpmsld[i]; i++) { tpmsld[i]->hide(); } this->layout()->removeItem(ui->TaranisReadOnlyUnlock); } } else { - for (int i=0; pmsl[i]; i++) { + for (int i = 0; pmsl[i]; i++) { pmsl[i]->hide(); } - for (int i=0; tpmsld[i]; i++) { + for (int i = 0; tpmsld[i]; i++) { tpmsld[i]->hide(); } this->layout()->removeItem(ui->TaranisReadOnlyUnlock); @@ -112,10 +112,10 @@ ui(new Ui::GeneralSetup) ui->varioVolume_SL->setValue(generalSettings.varioVolume); ui->bgVolume_SL->setValue(generalSettings.backgroundVolume); ui->wavVolume_SL->setValue(generalSettings.wavVolume); - ui->varioP0_SB->setValue(700+(generalSettings.varioPitch*10)); + ui->varioP0_SB->setValue(700 + (generalSettings.varioPitch * 10)); updateVarioPitchRange(); - ui->varioPMax_SB->setValue(700+(generalSettings.varioPitch*10)+1000+(generalSettings.varioRange*10)); - ui->varioR0_SB->setValue(500+(generalSettings.varioRepeat*10)); + ui->varioPMax_SB->setValue(700 + (generalSettings.varioPitch * 10) + 1000 + (generalSettings.varioRange * 10)); + ui->varioR0_SB->setValue(500 + (generalSettings.varioRepeat * 10)); } if (!firmware->getCapability(HasFAIMode)) { @@ -152,6 +152,14 @@ ui(new Ui::GeneralSetup) ui->adjustRTC->hide(); } + if (IS_STM32(firmware->getBoard())){ + ui->usbModeCB->setCurrentIndex(generalSettings.usbMode); + } + else { + ui->usbModeLabel->hide(); + ui->usbModeCB->hide(); + } + if (!firmware->getCapability(OptrexDisplay)) { ui->label_displayType->hide(); ui->displayTypeCB->setDisabled(true); @@ -332,6 +340,14 @@ void GeneralSetupPanel::on_backlightswCB_currentIndexChanged(int index) } } +void GeneralSetupPanel::on_usbModeCB_currentIndexChanged(int index) +{ + if (!lock) { + generalSettings.usbMode = ui->usbModeCB->currentIndex(); + emit modified(); + } +} + void GeneralSetupPanel::on_backlightColor_SL_valueChanged() { if (!lock) { diff --git a/companion/src/generaledit/generalsetup.h b/companion/src/generaledit/generalsetup.h index d4183cddf..80a63d027 100644 --- a/companion/src/generaledit/generalsetup.h +++ b/companion/src/generaledit/generalsetup.h @@ -59,6 +59,7 @@ class GeneralSetupPanel : public GeneralPanel void on_hapticmodeCB_currentIndexChanged(int index); void on_hapticLengthCB_currentIndexChanged(int index); void on_backlightswCB_currentIndexChanged(int index); + void on_usbModeCB_currentIndexChanged(int index); void on_backlightColor_SL_valueChanged(); void on_mavbaud_CB_currentIndexChanged(int index); void on_voiceLang_CB_currentIndexChanged(int index); diff --git a/companion/src/generaledit/generalsetup.ui b/companion/src/generaledit/generalsetup.ui index 8c8dc1b0f..fd17611ad 100644 --- a/companion/src/generaledit/generalsetup.ui +++ b/companion/src/generaledit/generalsetup.ui @@ -6,7 +6,7 @@ 0 0 - 806 + 809 801 @@ -1121,8 +1121,74 @@ p, li { white-space: pre-wrap; } QLayout::SetDefaultConstraint - - + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Warnings</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">These will define startup warnings.</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Throttle warning - will alert if the throttle is not at idle during startup</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Switch warning - will alert if switches are not in their defaul position</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Memory warning - will alert if there's not a lot of memory left</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Silent mode warning - will alert you if the beeper is set to quiet (0)</p></body></html> + + + + + + true + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + RSSI Poweroff Warning + + + + + + + + 0 + 0 + + + + + 0 + 22 + + @@ -1130,51 +1196,970 @@ p, li { white-space: pre-wrap; } - Mode selection: + Beeper volume -Mode 1: - Left stick: Elevator, Rudder - Right stick: Throttle, Aileron - -Mode 2: - Left stick: Throttle, Rudder - Right stick: Elevator, Aileron - -Mode 3: - Left stick: Elevator, Aileron - Right stick: Throttle, Rudder - -Mode 4: - Left stick: Throttle, Aileron - Right stick: Elevator, Rudder - - +0 - Quiet. No beeps at all. +1 - No Keys. Normal beeps but menu keys do not beep. +2 - Normal. +3 - Loud. +4 - Extra loud. - + + + Quiet + + + + + Alarms Only + + + + + No Keys + + + + + All + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Beeper Mode + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + X-Short + + + + + Short + + + + + Normal + + + + + Long + + + + + X-Long + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Beeper Length + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Haptic Mode + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Measurement Units + + + + + + + + 0 + 0 + + + + Play Delay (switch mid position) + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + X-Short + + + + + Short + + + + + Normal + + + + + Long + + + + + X-Long + + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Warnings</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">These will define startup warnings.</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Throttle warning - will alert if the throttle is not at idle during startup</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Switch warning - will alert if switches are not in their defaul position</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Memory warning - will alert if there's not a lot of memory left</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Silent mode warning - will alert you if the beeper is set to quiet (0)</p></body></html> + + + + + + true + + + + + + + + hh° (N/S) mm' ss''.dd + + + + + NMEA + + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 16777215 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Warnings</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">These will define startup warnings.</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Throttle warning - will alert if the throttle is not at idle during startup</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Switch warning - will alert if switches are not in their defaul position</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Memory warning - will alert if there's not a lot of memory left</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Silent mode warning - will alert you if the beeper is set to quiet (0)</p></body></html> + + + + + + true + + + + + + + + 4800 Baud + + + + + 9600 Baud + + + + + 14400 Baud + + + + + 19200 Baud + + + + + 38400 Baud + + + + + 57600 Baud + + + + + 76800 Baud + + + + + 115200 Baud + + + + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + Show splash screen on startup + + + Show splash screen on startup + + + + + + + + + + + 0 + 0 + + + + + --- + + + + + 2s + + + + + 3s + + + + + 4s + + + + + 6s + + + + + 8s + + + + + 10s + + + + + 15s + + + + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + + + + + + If not zero will sound beeps if the transmitter has been left without inputs for the specified number of minutes. + + + min + + + 120 + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + Standard + + + + + Optrex + + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + + + + + + Battery warning voltage. +This is the threashhold where the battery warning sounds. + +Acceptable values are 5v..10v + + + + + + V + + 1 + + 4.000000000000000 + + + 12.000000000000000 + + + 0.100000000000000 + + + 9.600000000000000 + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + + + + + + + + + 10 + + + 45 + + + 25 + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + -2 + + + 2 + + + 1 + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + + 0 + 22 + + - Mode 1 (RUD ELE THR AIL) + Quiet - Mode 2 (RUD THR ELE AIL) + Only Alarms - Mode 3 (AIL ELE THR RUD) + No Keys - Mode 4 (AIL THR ELE RUD) + All + + + + + 0 + 0 + + + + MAVLink Baud Rate + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Haptic Length + + + + + + + + 0 + 0 + + + + + 20 + 0 + + + + + + + Battery Warning + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + "No Sound" Warning + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + LCD Display Type + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Haptic Strength + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Battery Meter Range + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + + + Contrast + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Show Splash Screen on Startup + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Low EEPROM Warning + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Inactivity Timer + + + + + + + + + Min + + + + + + + v + + + 1 + + + 4.000000000000000 + + + 16.000000000000000 + + + 0.100000000000000 + + + 9.000000000000000 + + + + + + + Max + + + + + + + v + + + 1 + + + 4.000000000000000 + + + 16.000000000000000 + + + 0.100000000000000 + + + 12.000000000000000 + + + + + + + + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">LCD Screen Contrast</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Values can be 20-45</span></p></body></html> + + + ms + + + 0 + + + 1000 + + + 10 + + + 0 + + + + + + + GPS Coordinates + + + + + + + + 0 + 0 + + + + Default Channel Order + + + + + + + + Metric + + + + + Imperial + + + + + + + + Stick Mode + + + @@ -1311,49 +2296,8 @@ Mode 4: - - - - Stick Mode - - - - - - - - Metric - - - - - Imperial - - - - - - - - - 0 - 0 - - - - Default Channel Order - - - - - - - GPS Coordinates - - - - - + + @@ -1361,993 +2305,80 @@ Mode 4: - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">LCD Screen Contrast</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Values can be 20-45</span></p></body></html> - - - ms - - - 0 - - - 1000 - - - 10 - - - 0 - - - - - - - - - Min - - - - - - - v - - - 1 - - - 4.000000000000000 - - - 16.000000000000000 - - - 0.100000000000000 - - - 9.000000000000000 - - - - - - - Max - - - - - - - v - - - 1 - - - 4.000000000000000 - - - 16.000000000000000 - - - 0.100000000000000 - - - 12.000000000000000 - - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Low EEPROM Warning - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Inactivity Timer - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Show Splash Screen on Startup - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - - - Contrast - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Battery Meter Range - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Haptic Strength - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - LCD Display Type - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - "No Sound" Warning - - - - - - - - 0 - 0 - - - - - 20 - 0 - - - - - - - Battery Warning - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Haptic Length - - - - - - - - 0 - 0 - - - - MAVLink Baud Rate - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - Quiet - - - - - Only Alarms - - - - - No Keys - - - - - All - - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - -2 - - - 2 - - - 1 - - - Qt::Horizontal - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - - - - - - - - - 10 - - - 45 - - - 25 - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - - - - - - Battery warning voltage. -This is the threashhold where the battery warning sounds. + Mode selection: -Acceptable values are 5v..10v +Mode 1: + Left stick: Elevator, Rudder + Right stick: Throttle, Aileron + +Mode 2: + Left stick: Throttle, Rudder + Right stick: Elevator, Aileron + +Mode 3: + Left stick: Elevator, Aileron + Right stick: Throttle, Rudder + +Mode 4: + Left stick: Throttle, Aileron + Right stick: Elevator, Rudder + + - - - - - V - - + 1 - - 4.000000000000000 - - - 12.000000000000000 - - - 0.100000000000000 - - - 9.600000000000000 - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - Standard + Mode 1 (RUD ELE THR AIL) - Optrex - - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - - - - - - If not zero will sound beeps if the transmitter has been left without inputs for the specified number of minutes. - - - min - - - 120 - - - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Show splash screen on startup - - - Show splash screen on startup - - - - - - - - - - - 0 - 0 - - - - - --- - - - - - 2s - - - - - 3s - - - - - 4s - - - - - 6s - - - - - 8s - - - - - 10s - - - - - 15s - - - - - - - - - - - 4800 Baud + Mode 2 (RUD THR ELE AIL) - 9600 Baud + Mode 3 (AIL ELE THR RUD) - 14400 Baud + Mode 4 (AIL THR ELE RUD) - - - 19200 Baud - - - - - 38400 Baud - - - - - 57600 Baud - - - - - 76800 Baud - - - - - 115200 Baud - - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 16777215 - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Warnings</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">These will define startup warnings.</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Throttle warning - will alert if the throttle is not at idle during startup</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Switch warning - will alert if switches are not in their defaul position</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Memory warning - will alert if there's not a lot of memory left</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Silent mode warning - will alert you if the beeper is set to quiet (0)</p></body></html> - - - - - - true - - - - - - - - hh° (N/S) mm' ss''.dd - - - - - NMEA - - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Warnings</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">These will define startup warnings.</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Throttle warning - will alert if the throttle is not at idle during startup</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Switch warning - will alert if switches are not in their defaul position</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Memory warning - will alert if there's not a lot of memory left</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Silent mode warning - will alert you if the beeper is set to quiet (0)</p></body></html> - - - - - - true - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - X-Short - - - - - Short - - - - - Normal - - - - - Long - - - - - X-Long - - - - - - - - - 0 - 0 - - - - Play Delay (switch mid position) - - - - - - - Measurement Units - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - + - Haptic Mode + USB Mode - - - - - 0 - 0 - - - - - 0 - 0 - - - - Beeper Length - - - - - - - - 0 - 0 - - - - - 0 - 22 - - + + - X-Short + Ask on Connect - Short + Joystick (HID) - Normal + USB Mass Storage - Long + USB Serial (CDC) - - - X-Long - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Beeper Mode - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - - - - - - Beeper volume - -0 - Quiet. No beeps at all. -1 - No Keys. Normal beeps but menu keys do not beep. -2 - Normal. -3 - Loud. -4 - Extra loud. - - - - Quiet - - - - - Alarms Only - - - - - No Keys - - - - - All - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - RSSI Poweroff Warning - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Warnings</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">These will define startup warnings.</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Throttle warning - will alert if the throttle is not at idle during startup</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Switch warning - will alert if switches are not in their defaul position</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Memory warning - will alert if there's not a lot of memory left</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Silent mode warning - will alert you if the beeper is set to quiet (0)</p></body></html> - - - - - - true - diff --git a/companion/src/radiodata.h b/companion/src/radiodata.h index 6aea0bb1e..578e55a8b 100644 --- a/companion/src/radiodata.h +++ b/companion/src/radiodata.h @@ -1184,6 +1184,7 @@ class GeneralSettings { BeeperMode beeperMode; bool disableAlarmWarning; bool disableRssiPoweroffAlarm; + unsigned int usbMode; BeeperMode hapticMode; unsigned int stickMode; // TODO enum int timezone; diff --git a/radio/src/datastructs.h b/radio/src/datastructs.h index 92daf4f7a..6e377bc57 100644 --- a/radio/src/datastructs.h +++ b/radio/src/datastructs.h @@ -897,7 +897,8 @@ PACK(struct TrainerData { NOBACKUP(uint8_t imperial:1); \ NOBACKUP(uint8_t jitterFilter:1); /* 0 - active */\ NOBACKUP(uint8_t disableRssiPoweroffAlarm:1); \ - NOBACKUP(uint8_t spareExtraArm:5); \ + NOBACKUP(uint8_t USBMode:2); \ + NOBACKUP(uint8_t spareExtraArm:3); \ NOBACKUP(char ttsLanguage[2]); \ NOBACKUP(int8_t beepVolume:4); \ NOBACKUP(int8_t wavVolume:4); \ diff --git a/radio/src/debug.h b/radio/src/debug.h index 2a0030cc5..ce4e9c9f8 100644 --- a/radio/src/debug.h +++ b/radio/src/debug.h @@ -34,6 +34,8 @@ extern "C" { #endif +uint8_t serial2TracesEnabled(); + #if defined(SIMU) typedef void (*traceCallbackFunc)(const char * text); extern traceCallbackFunc traceCallback; @@ -41,14 +43,10 @@ extern "C" { #elif defined(SEMIHOSTING) #include #define debugPrintf(...) printf(__VA_ARGS__) -#elif defined(DEBUG) && defined(CLI) && defined(USB_SERIAL) - #define debugPrintf(...) do { if (cliTracesEnabled) serialPrintf(__VA_ARGS__); } while(0) #elif defined(DEBUG) && defined(CLI) - uint8_t serial2TracesEnabled(); - #define debugPrintf(...) do { if (serial2TracesEnabled() && cliTracesEnabled) serialPrintf(__VA_ARGS__); } while(0) -#elif defined(DEBUG) && defined(CPUARM) && !defined(PCBX7) - uint8_t serial2TracesEnabled(); - #define debugPrintf(...) do { if (serial2TracesEnabled()) serialPrintf(__VA_ARGS__); } while(0) + #define debugPrintf(...) do { if (cliTracesEnabled) serialPrintf(__VA_ARGS__); } while(0) +#elif defined(DEBUG) && defined(CPUARM) && defined(SERIAL2) + #define debugPrintf(...) do { serialPrintf(__VA_ARGS__); } while(0) #else #define debugPrintf(...) #endif diff --git a/radio/src/gui/128x64/radio_setup.cpp b/radio/src/gui/128x64/radio_setup.cpp index d4c56c49a..17b608ebb 100644 --- a/radio/src/gui/128x64/radio_setup.cpp +++ b/radio/src/gui/128x64/radio_setup.cpp @@ -107,6 +107,7 @@ enum MenuRadioSetupItems { IF_FAI_CHOICE(ITEM_SETUP_FAI) CASE_MAVLINK(ITEM_MAVLINK_BAUD) CASE_CPUARM(ITEM_SETUP_SWITCHES_DELAY) + CASE_STM32(ITEM_SETUP_USB_MODE) ITEM_SETUP_RX_CHANNEL_ORD, ITEM_SETUP_STICK_MODE_LABELS, ITEM_SETUP_STICK_MODE, @@ -141,7 +142,7 @@ void menuRadioSetup(event_t event) } #endif - MENU(STR_MENURADIOSETUP, menuTabGeneral, MENU_RADIO_SETUP, HEADER_LINE+ITEM_SETUP_MAX, { HEADER_LINE_COLUMNS CASE_RTCLOCK(2) CASE_RTCLOCK(2) CASE_BATTGRAPH(1) LABEL(SOUND), CASE_AUDIO(0) CASE_BUZZER(0) CASE_VOICE(0) CASE_CPUARM(0) CASE_CPUARM(0) CASE_CPUARM(0) 0, CASE_AUDIO(0) CASE_VARIO_CPUARM(LABEL(VARIO)) CASE_VARIO_CPUARM(0) CASE_VARIO_CPUARM(0) CASE_VARIO_CPUARM(0) CASE_VARIO_CPUARM(0) CASE_HAPTIC(LABEL(HAPTIC)) CASE_HAPTIC(0) CASE_HAPTIC(0) CASE_HAPTIC(0) 0, LABEL(ALARMS), 0, CASE_CAPACITY(0) CASE_PCBSKY9X(0) 0, 0, 0, CASE_CPUARM(0) IF_ROTARY_ENCODERS(0) LABEL(BACKLIGHT), 0, 0, CASE_CPUARM(0) CASE_PWM_BACKLIGHT(0) CASE_PWM_BACKLIGHT(0) 0, CASE_SPLASH_PARAM(0) CASE_GPS(0) CASE_CPUARM(0) CASE_GPS(0) CASE_PXX(0) CASE_CPUARM(0) CASE_CPUARM(0) IF_FAI_CHOICE(0) CASE_MAVLINK(0) CASE_CPUARM(0) 0, COL_TX_MODE, 0, 1/*to force edit mode*/}); + MENU(STR_MENURADIOSETUP, menuTabGeneral, MENU_RADIO_SETUP, HEADER_LINE+ITEM_SETUP_MAX, { HEADER_LINE_COLUMNS CASE_RTCLOCK(2) CASE_RTCLOCK(2) CASE_BATTGRAPH(1) LABEL(SOUND), CASE_AUDIO(0) CASE_BUZZER(0) CASE_VOICE(0) CASE_CPUARM(0) CASE_CPUARM(0) CASE_CPUARM(0) 0, CASE_AUDIO(0) CASE_VARIO_CPUARM(LABEL(VARIO)) CASE_VARIO_CPUARM(0) CASE_VARIO_CPUARM(0) CASE_VARIO_CPUARM(0) CASE_VARIO_CPUARM(0) CASE_HAPTIC(LABEL(HAPTIC)) CASE_HAPTIC(0) CASE_HAPTIC(0) CASE_HAPTIC(0) 0, LABEL(ALARMS), 0, CASE_CAPACITY(0) CASE_PCBSKY9X(0) 0, 0, 0, CASE_CPUARM(0) IF_ROTARY_ENCODERS(0) LABEL(BACKLIGHT), 0, 0, CASE_CPUARM(0) CASE_PWM_BACKLIGHT(0) CASE_PWM_BACKLIGHT(0) 0, CASE_SPLASH_PARAM(0) CASE_GPS(0) CASE_CPUARM(0) CASE_GPS(0) CASE_PXX(0) CASE_CPUARM(0) CASE_CPUARM(0) IF_FAI_CHOICE(0) CASE_MAVLINK(0) CASE_STM32(0) 0, COL_TX_MODE, 0, 1/*to force edit mode*/}); if (event == EVT_ENTRY) { reusableBuffer.generalSettings.stickMode = g_eeGeneral.stickMode; @@ -564,7 +565,11 @@ void menuRadioSetup(event_t event) if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.switchesDelay, -15, 100-15); break; #endif - +#if defined(STM32) + case ITEM_SETUP_USB_MODE: + g_eeGeneral.USBMode = editChoice(RADIO_SETUP_2ND_COLUMN, y, STR_USBMODE, STR_USBMODES, g_eeGeneral.USBMode, USB_UNSELECTED_MODE, USB_MAX_MODE, attr, event); + break; +#endif case ITEM_SETUP_RX_CHANNEL_ORD: lcdDrawTextAlignedLeft(y, STR_RXCHANNELORD); // RAET->AETR for (uint8_t i=1; i<=4; i++) { diff --git a/radio/src/gui/212x64/radio_setup.cpp b/radio/src/gui/212x64/radio_setup.cpp index 1172b1652..c534c4d96 100644 --- a/radio/src/gui/212x64/radio_setup.cpp +++ b/radio/src/gui/212x64/radio_setup.cpp @@ -88,6 +88,7 @@ enum MenuRadioSetupItems { IF_FAI_CHOICE(ITEM_SETUP_FAI) CASE_MAVLINK(ITEM_MAVLINK_BAUD) ITEM_SETUP_SWITCHES_DELAY, + ITEM_SETUP_USB_MODE, ITEM_SETUP_RX_CHANNEL_ORD, ITEM_SETUP_STICK_MODE_LABELS, ITEM_SETUP_STICK_MODE, @@ -478,6 +479,10 @@ void menuRadioSetup(event_t event) if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.switchesDelay, -15, 100-15); break; + case ITEM_SETUP_USB_MODE: + g_eeGeneral.USBMode = editChoice(RADIO_SETUP_2ND_COLUMN, y, STR_USBMODE, STR_USBMODES, g_eeGeneral.USBMode, USB_UNSELECTED_MODE, USB_MAX_MODE, attr, event); + break; + case ITEM_SETUP_RX_CHANNEL_ORD: lcdDrawTextAlignedLeft(y, STR_RXCHANNELORD); // RAET->AETR for (uint8_t i=1; i<=4; i++) { diff --git a/radio/src/gui/212x64/view_statistics.cpp b/radio/src/gui/212x64/view_statistics.cpp index d8b1d5bd6..37a9fa248 100644 --- a/radio/src/gui/212x64/view_statistics.cpp +++ b/radio/src/gui/212x64/view_statistics.cpp @@ -92,13 +92,6 @@ void menuStatisticsView(event_t event) #define MENU_DEBUG_Y_USB (5*FH) #define MENU_DEBUG_Y_RTOS (6*FH) -#if defined(USB_SERIAL) - extern uint16_t usbWraps; - extern uint16_t charsWritten; - extern "C" volatile uint32_t APP_Rx_ptr_in; - extern "C" volatile uint32_t APP_Rx_ptr_out; -#endif - void menuStatisticsDebug(event_t event) { TITLE(STR_MENUDEBUG); diff --git a/radio/src/gui/480x272/radio_setup.cpp b/radio/src/gui/480x272/radio_setup.cpp index 5afa8c8f5..8aaab2bfb 100644 --- a/radio/src/gui/480x272/radio_setup.cpp +++ b/radio/src/gui/480x272/radio_setup.cpp @@ -76,6 +76,7 @@ enum menuRadioSetupItems { IF_FAI_CHOICE(ITEM_SETUP_FAI) // CASE_MAVLINK(ITEM_MAVLINK_BAUD) ITEM_SETUP_SWITCHES_DELAY, + ITEM_SETUP_USB_MODE, ITEM_SETUP_RX_CHANNEL_ORD, ITEM_SETUP_STICK_MODE, ITEM_SETUP_MAX @@ -460,6 +461,11 @@ bool menuRadioSetup(event_t event) if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.switchesDelay, -15, 100-15); break; + case ITEM_SETUP_USB_MODE: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_USBMODE); + g_eeGeneral.USBMode = editChoice(RADIO_SETUP_2ND_COLUMN, y, STR_USBMODES, g_eeGeneral.USBMode, USB_UNSELECTED_MODE, USB_MAX_MODE, attr, event); + break; + case ITEM_SETUP_RX_CHANNEL_ORD: { lcdDrawText(MENUS_MARGIN_LEFT, y, STR_RXCHANNELORD); // RAET->AETR diff --git a/radio/src/keys.h b/radio/src/keys.h index c50c52857..eed19a8e2 100644 --- a/radio/src/keys.h +++ b/radio/src/keys.h @@ -2,7 +2,7 @@ * Copyright (C) OpenTX * * Based on code named - * th9x - http://code.google.com/p/th9x + * th9x - http://code.google.com/p/th9x * er9x - http://code.google.com/p/er9x * gruvin9x - http://code.google.com/p/gruvin9x * diff --git a/radio/src/main_arm.cpp b/radio/src/main_arm.cpp index 35a165174..e9ef03021 100644 --- a/radio/src/main_arm.cpp +++ b/radio/src/main_arm.cpp @@ -24,20 +24,49 @@ uint8_t currentSpeakerVolume = 255; uint8_t requiredSpeakerVolume = 255; uint8_t mainRequestFlags = 0; +#if defined(STM32) +void onUSBConnectMenu(const char *result) +{ + if (result == STR_USB_MASS_STORAGE) { + setSelectedUsbMode(USB_MASS_STORAGE_MODE); + } + else if (result == STR_USB_JOYSTICK) { + setSelectedUsbMode(USB_JOYSTICK_MODE); + } + else if (result == STR_USB_SERIAL) { + setSelectedUsbMode(USB_SERIAL_MODE); + } +} +#endif + void handleUsbConnection() { #if defined(STM32) && !defined(SIMU) - if (!usbStarted() && usbPlugged()) { + if (!usbStarted() && usbPlugged() && !(getSelectedUsbMode() == USB_UNSELECTED_MODE)) { usbStart(); -#if defined(USB_MASS_STORAGE) - opentxClose(false); - usbPluggedIn(); -#endif + if (getSelectedUsbMode() == USB_MASS_STORAGE_MODE) { + opentxClose(false); + usbPluggedIn(); + } + } + if (!usbStarted() && usbPlugged() && getSelectedUsbMode() == USB_UNSELECTED_MODE) { + if((g_eeGeneral.USBMode == 0) && (popupMenuNoItems == 0)) { + POPUP_MENU_ADD_ITEM(STR_USB_JOYSTICK); + POPUP_MENU_ADD_ITEM(STR_USB_MASS_STORAGE); + POPUP_MENU_ADD_ITEM(STR_USB_SERIAL); + POPUP_MENU_START(onUSBConnectMenu); + } + if (g_eeGeneral.USBMode != USB_UNSELECTED_MODE) { + setSelectedUsbMode(g_eeGeneral.USBMode); + } } if (usbStarted() && !usbPlugged()) { usbStop(); -#if defined(USB_MASS_STORAGE) && !defined(EEPROM) - opentxResume(); + if (getSelectedUsbMode() == USB_MASS_STORAGE_MODE) { + opentxResume(); + } +#if !defined(BOOT) + setSelectedUsbMode(USB_UNSELECTED_MODE); #endif } #endif // defined(STM32) && !defined(SIMU) @@ -402,12 +431,10 @@ void perMain() return; } #endif - -#if defined(PCBHORUS) - // TODO if it is OK on HORUS it could be ported to all other boards - // But in this case it's needed to define sdMount for all boards, because sdInit also initializes the SD mutex - static uint32_t sdcard_present_before = SD_CARD_PRESENT(); - uint32_t sdcard_present_now = SD_CARD_PRESENT(); + +#if defined(STM32) + static bool sdcard_present_before = SD_CARD_PRESENT(); + bool sdcard_present_now = SD_CARD_PRESENT(); if (sdcard_present_now && !sdcard_present_before) { sdMount(); } @@ -421,9 +448,9 @@ void perMain() return; } #endif - + #if defined(USB_MASS_STORAGE) - if (usbPlugged()) { + if (usbPlugged() && getSelectedUsbMode() == USB_MASS_STORAGE_MODE) { // disable access to menus lcdClear(); menuMainView(0); @@ -459,4 +486,3 @@ void perMain() gpsWakeup(); #endif } - diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index d347b8a7c..e01174667 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1996,9 +1996,7 @@ void opentxResume() menuHandlers[0] = menuMainView; sdMount(); - storageReadAll(); - #if defined(PCBHORUS) loadTheme(); loadFontCache(); diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 021ad088d..997360afc 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -50,6 +50,12 @@ #define IF_CPUARM(x) #endif +#if defined(STM32) + #define CASE_STM32(x) x, +#else + #define CASE_STM32(x) +#endif + #if defined(VARIO) && defined(CPUARM) #define CASE_VARIO_CPUARM(x) x, #else diff --git a/radio/src/serial.cpp b/radio/src/serial.cpp index 7e32e8b85..e7548f234 100644 --- a/radio/src/serial.cpp +++ b/radio/src/serial.cpp @@ -2,7 +2,7 @@ * Copyright (C) OpenTX * * Based on code named - * th9x - http://code.google.com/p/th9x + * th9x - http://code.google.com/p/th9x * er9x - http://code.google.com/p/er9x * gruvin9x - http://code.google.com/p/gruvin9x * @@ -25,12 +25,12 @@ #define PRINTF_BUFFER_SIZE 128 -void serialPutc(char c) -{ -#if defined(USB_SERIAL) - usbSerialPutc(c); -#elif defined(SERIAL2) - serial2Putc(c); +void serialPutc(char c) { + if (getSelectedUsbMode() == USB_SERIAL_MODE) + usbSerialPutc(c); +#if defined(SERIAL2) + if (serial2TracesEnabled()) + serial2Putc(c); #endif } diff --git a/radio/src/targets/common/arm/stm32/CMakeLists.txt b/radio/src/targets/common/arm/stm32/CMakeLists.txt index 41f17c387..da031b0c6 100644 --- a/radio/src/targets/common/arm/stm32/CMakeLists.txt +++ b/radio/src/targets/common/arm/stm32/CMakeLists.txt @@ -1,8 +1,6 @@ set(LUA "NO" CACHE STRING "Lua scripts (YES/NO/NO_MODEL_SCRIPTS)") set_property(CACHE LUA PROPERTY STRINGS YES NO NO_MODEL_SCRIPTS) set(LUA_SCRIPT_LOAD_MODE "" CACHE STRING "Script loading mode and compilation flags [btTxcd] (see loadScript() API docs). Blank for default ('bt' on radio, 'T' on SIMU/DEBUG builds)") -set(USB "JOYSTICK" CACHE STRING "USB option (JOYSTICK/MASSSTORAGE/SERIAL)") -set_property(CACHE USB PROPERTY STRINGS JOYSTICK MASSSTORAGE SERIAL) option(LUA_COMPILER "Pre-compile and save Lua scripts" OFF) set(ARCH ARM) @@ -38,36 +36,32 @@ set(FIRMWARE_TARGET_SRC ../common/arm/stm32/usbd_usr.cpp ../common/arm/stm32/usb_driver.cpp ) -if(USB STREQUAL SERIAL) - add_definitions(-DUSB_SERIAL) - set(FIRMWARE_TARGET_SRC - ${FIRMWARE_TARGET_SRC} - ../common/arm/stm32/usbd_cdc.cpp - ) - set(STM32USB_SRC - ${STM32USB_SRC} - STM32_USB_Device_Library/Class/cdc/src/usbd_cdc_core.c - ) -elseif(USB STREQUAL MASSSTORAGE) - add_definitions(-DUSB_MASS_STORAGE) - set(STM32USB_SRC - ${STM32USB_SRC} - STM32_USB_Device_Library/Class/msc/src/usbd_msc_data.c - STM32_USB_Device_Library/Class/msc/src/usbd_msc_scsi.c - STM32_USB_Device_Library/Class/msc/src/usbd_msc_bot.c - STM32_USB_Device_Library/Class/msc/src/usbd_msc_core.c - ) - set(FIRMWARE_TARGET_SRC - ${FIRMWARE_TARGET_SRC} - ../common/arm/stm32/usbd_storage_msd.cpp - ) -else() - add_definitions(-DUSB_JOYSTICK) - set(FIRMWARE_TARGET_SRC - ${FIRMWARE_TARGET_SRC} - ../common/arm/stm32/usbd_hid_joystick.c - ) -endif() +add_definitions(-DUSB_SERIAL) +set(FIRMWARE_TARGET_SRC + ${FIRMWARE_TARGET_SRC} + ../common/arm/stm32/usbd_cdc.cpp + ) +set(STM32USB_SRC + ${STM32USB_SRC} + STM32_USB_Device_Library/Class/cdc/src/usbd_cdc_core.c + ) +add_definitions(-DUSB_MASS_STORAGE) +set(STM32USB_SRC + ${STM32USB_SRC} + STM32_USB_Device_Library/Class/msc/src/usbd_msc_data.c + STM32_USB_Device_Library/Class/msc/src/usbd_msc_scsi.c + STM32_USB_Device_Library/Class/msc/src/usbd_msc_bot.c + STM32_USB_Device_Library/Class/msc/src/usbd_msc_core.c + ) +set(FIRMWARE_TARGET_SRC + ${FIRMWARE_TARGET_SRC} + ../common/arm/stm32/usbd_storage_msd.cpp + ) +add_definitions(-DUSB_JOYSTICK) +set(FIRMWARE_TARGET_SRC + ${FIRMWARE_TARGET_SRC} + ../common/arm/stm32/usbd_hid_joystick.c + ) if(GVARS) set(GUI_SRC ${GUI_SRC} diff --git a/radio/src/targets/common/arm/stm32/serial2_driver.cpp b/radio/src/targets/common/arm/stm32/serial2_driver.cpp index 68027ee30..a5c67b51e 100644 --- a/radio/src/targets/common/arm/stm32/serial2_driver.cpp +++ b/radio/src/targets/common/arm/stm32/serial2_driver.cpp @@ -91,7 +91,7 @@ void serial2Init(unsigned int mode, unsigned int protocol) case UART_MODE_TELEMETRY_MIRROR: uart3Setup(FRSKY_SPORT_BAUDRATE, false); break; -#if !defined(USB_SERIAL) && (defined(DEBUG) || defined(CLI)) +#if defined(DEBUG) || defined(CLI) case UART_MODE_DEBUG: uart3Setup(DEBUG_BAUDRATE, false); break; @@ -153,19 +153,21 @@ extern "C" void SERIAL_USART_IRQHandler(void) } } -#if !defined(USB_SERIAL) && defined(CLI) - // Receive - uint32_t status = SERIAL_USART->SR; - while (status & (USART_FLAG_RXNE | USART_FLAG_ERRORS)) { - uint8_t data = SERIAL_USART->DR; - if (!(status & USART_FLAG_ERRORS)) { - switch (serial2Mode) { - case UART_MODE_DEBUG: - cliRxFifo.push(data); - break; +#if defined(CLI) + if (!(getSelectedUsbMode() == USB_SERIAL_MODE)) { + // Receive + uint32_t status = SERIAL_USART->SR; + while (status & (USART_FLAG_RXNE | USART_FLAG_ERRORS)) { + uint8_t data = SERIAL_USART->DR; + if (!(status & USART_FLAG_ERRORS)) { + switch (serial2Mode) { + case UART_MODE_DEBUG: + cliRxFifo.push(data); + break; + } } + status = SERIAL_USART->SR; } - status = SERIAL_USART->SR; } #endif } diff --git a/radio/src/targets/common/arm/stm32/usb_driver.cpp b/radio/src/targets/common/arm/stm32/usb_driver.cpp index 445b8afab..2403ee9bd 100644 --- a/radio/src/targets/common/arm/stm32/usb_driver.cpp +++ b/radio/src/targets/common/arm/stm32/usb_driver.cpp @@ -2,7 +2,7 @@ * Copyright (C) OpenTX * * Based on code named - * th9x - http://code.google.com/p/th9x + * th9x - http://code.google.com/p/th9x * er9x - http://code.google.com/p/er9x * gruvin9x - http://code.google.com/p/gruvin9x * @@ -31,6 +31,21 @@ extern "C" { #include "debug.h" static bool usbDriverStarted = false; +#if defined(BOOT) +static usbMode selectedUsbMode = USB_MASS_STORAGE_MODE; +#else +static usbMode selectedUsbMode = USB_UNSELECTED_MODE; +#endif + +int getSelectedUsbMode() +{ + return selectedUsbMode; +} + +void setSelectedUsbMode(int mode) +{ + selectedUsbMode = usbMode (mode); +} int usbPlugged() { @@ -70,16 +85,23 @@ void usbInit() void usbStart() { -#if defined(USB_JOYSTICK) - // initialize USB as HID device - USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_HID_cb, &USR_cb); -#elif defined(USB_SERIAL) - // initialize USB as CDC device (virtual serial port) - USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_CDC_cb, &USR_cb); -#elif defined(USB_MASS_STORAGE) - // initialize USB as MSC device - USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_MSC_cb, &USR_cb); + switch (getSelectedUsbMode()) { +#if !defined(BOOT) + case USB_JOYSTICK_MODE: + // initialize USB as HID device + USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_HID_cb, &USR_cb); + break; + case USB_SERIAL_MODE: + // initialize USB as CDC device (virtual serial port) + USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_CDC_cb, &USR_cb); + break; #endif + default: + case USB_MASS_STORAGE_MODE: + // initialize USB as MSC device + USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_MSC_cb, &USR_cb); + break; + } usbDriverStarted = true; } @@ -89,7 +111,7 @@ void usbStop() USBD_DeInit(&USB_OTG_dev); } -uint8_t usbStarted() +bool usbStarted() { return usbDriverStarted; } diff --git a/radio/src/targets/common/arm/stm32/usb_driver.h b/radio/src/targets/common/arm/stm32/usb_driver.h new file mode 100644 index 000000000..38bb31d3d --- /dev/null +++ b/radio/src/targets/common/arm/stm32/usb_driver.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) OpenTX + * + * Based on code named + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef OPENTX_USB_DRIVER_H +#define OPENTX_USB_DRIVER_H + +// USB driver +enum usbMode { + USB_UNSELECTED_MODE, + USB_JOYSTICK_MODE, + USB_SERIAL_MODE, + USB_MASS_STORAGE_MODE, + USB_MAX_MODE=USB_MASS_STORAGE_MODE +}; + +int usbPlugged(); +void usbInit(); +void usbStart(); +void usbStop(); +bool usbStarted(); +int getSelectedUsbMode(); +void setSelectedUsbMode(int mode); + +void usbSerialPutc(uint8_t c); + +// Used in view_statistics.cpp +#if defined(USB_SERIAL) + extern uint16_t usbWraps; + extern uint16_t charsWritten; + extern volatile uint32_t APP_Rx_ptr_in; + extern volatile uint32_t APP_Rx_ptr_out; +#endif + +#endif diff --git a/radio/src/targets/common/arm/stm32/usbd_conf.h b/radio/src/targets/common/arm/stm32/usbd_conf.h index f9294ee71..7feff433f 100644 --- a/radio/src/targets/common/arm/stm32/usbd_conf.h +++ b/radio/src/targets/common/arm/stm32/usbd_conf.h @@ -2,7 +2,7 @@ * Copyright (C) OpenTX * * Based on code named - * th9x - http://code.google.com/p/th9x + * th9x - http://code.google.com/p/th9x * er9x - http://code.google.com/p/er9x * gruvin9x - http://code.google.com/p/gruvin9x * @@ -27,7 +27,7 @@ #define USBD_CFG_MAX_NUM 1 #define USBD_ITF_MAX_NUM 1 -#define USB_MAX_STR_DESC_SIZ 64 +#define USB_MAX_STR_DESC_SIZ 64 #define USBD_SELF_POWERED @@ -61,4 +61,3 @@ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ - diff --git a/radio/src/targets/common/arm/stm32/usbd_desc.c b/radio/src/targets/common/arm/stm32/usbd_desc.c index 09b805de0..527a6c0f5 100644 --- a/radio/src/targets/common/arm/stm32/usbd_desc.c +++ b/radio/src/targets/common/arm/stm32/usbd_desc.c @@ -2,7 +2,7 @@ * Copyright (C) OpenTX * * Based on code named - * th9x - http://code.google.com/p/th9x + * th9x - http://code.google.com/p/th9x * er9x - http://code.google.com/p/er9x * gruvin9x - http://code.google.com/p/gruvin9x * @@ -29,27 +29,30 @@ #include "usbd_req.h" #include "usb_regs.h" + +#include "usb_driver.h" + /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY * @{ */ -/** @defgroup USBD_DESC +/** @defgroup USBD_DESC * @brief USBD descriptors module * @{ - */ + */ /** @defgroup USBD_DESC_Private_TypesDefinitions * @{ - */ + */ /** * @} - */ + */ /** @defgroup USBD_DESC_Private_Defines * @{ - */ + */ #define USBD_VID 0x0483 @@ -59,31 +62,29 @@ #if defined(BOOT) - #define USBD_PID 0x5720 - #define USBD_PRODUCT_FS_STRING USB_NAME " Bootloader" - #define USBD_CONFIGURATION_FS_STRING "MSC Config" - #define USBD_INTERFACE_FS_STRING "MSC Interface" -#elif defined(USB_JOYSTICK) - #define USBD_PID 0x5710 - #define USBD_PRODUCT_FS_STRING USB_NAME " Joystick" - #define USBD_CONFIGURATION_FS_STRING "HID Config" - #define USBD_INTERFACE_FS_STRING "HID Interface" -#elif defined(USB_SERIAL) - #define USBD_PID 0x5740 // do not change, this ID is used by the ST USB driver for Windows - #define USBD_PRODUCT_FS_STRING USB_NAME " Serial Port" - #define USBD_CONFIGURATION_FS_STRING "VSP Config" - #define USBD_INTERFACE_FS_STRING "VSP Interface" -#elif defined(USB_MASS_STORAGE) - #define USBD_PID 0x5720 - #define USBD_PRODUCT_FS_STRING USB_NAME " Mass Storage" - #define USBD_CONFIGURATION_FS_STRING "MSC Config" - #define USBD_INTERFACE_FS_STRING "MSC Interface" + #define USBD_MSC_PRODUCT_FS_STRING USB_NAME " Bootloader" +#else + #define USBD_MSC_PRODUCT_FS_STRING USB_NAME " Mass Storage" #endif +#define USBD_MSC_PID 0x5720 +#define USBD_MSC_CONFIGURATION_FS_STRING "MSC Config" +#define USBD_MSC_INTERFACE_FS_STRING "MSC Interface" + +#define USBD_HID_PID 0x5710 +#define USBD_HID_PRODUCT_FS_STRING USB_NAME " Joystick" +#define USBD_HID_CONFIGURATION_FS_STRING "HID Config" +#define USBD_HID_INTERFACE_FS_STRING "HID Interface" + +#define USBD_CDC_PID 0x5740 // do not change, this ID is used by the ST USB driver for Windows +#define USBD_CDC_PRODUCT_FS_STRING USB_NAME " Serial Port" +#define USBD_CDC_CONFIGURATION_FS_STRING "VSP Config" +#define USBD_CDC_INTERFACE_FS_STRING "VSP Interface" + const USBD_DEVICE USR_desc = { USBD_USR_DeviceDescriptor, - USBD_USR_LangIDStrDescriptor, + USBD_USR_LangIDStrDescriptor, USBD_USR_ManufacturerStrDescriptor, USBD_USR_ProductStrDescriptor, USBD_USR_SerialStrDescriptor, @@ -91,28 +92,6 @@ const USBD_DEVICE USR_desc = USBD_USR_InterfaceStrDescriptor, }; -/* USB Standard Device Descriptor */ -__ALIGN_BEGIN const uint8_t USBD_DeviceDesc[USB_SIZ_DEVICE_DESC] __ALIGN_END = -{ - USB_SIZ_DEVICE_DESC, /*bLength */ - USB_DEVICE_DESCRIPTOR_TYPE, /*bDescriptorType*/ - 0x00, /*bcdUSB */ - 0x02, - 0x00, /*bDeviceClass*/ - 0x00, /*bDeviceSubClass*/ - 0x00, /*bDeviceProtocol*/ - USB_OTG_MAX_EP0_SIZE, /*bMaxPacketSize*/ - LOBYTE(USBD_VID), /*idVendor*/ - HIBYTE(USBD_VID), /*idVendor*/ - LOBYTE(USBD_PID), /*idVendor*/ - HIBYTE(USBD_PID), /*idVendor*/ - 0x00, /*bcdDevice rel. 2.00*/ - 0x02, - USBD_IDX_MFC_STR, /*Index of manufacturer string*/ - USBD_IDX_PRODUCT_STR, /*Index of product string*/ - USBD_IDX_SERIAL_STR, /*Index of serial number string*/ - USBD_CFG_MAX_NUM /*bNumConfigurations*/ -}; /* USB_DeviceDescriptor */ /* USB Standard Device Descriptor */ __ALIGN_BEGIN const uint8_t USBD_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALIGN_END = @@ -132,16 +111,16 @@ __ALIGN_BEGIN const uint8_t USBD_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] /* USB Standard Device Descriptor */ __ALIGN_BEGIN const uint8_t USBD_LangIDDesc[USB_SIZ_STRING_LANGID] __ALIGN_END = { - USB_SIZ_STRING_LANGID, - USB_DESC_TYPE_STRING, + USB_SIZ_STRING_LANGID, + USB_DESC_TYPE_STRING, LOBYTE(USBD_LANGID_STRING), - HIBYTE(USBD_LANGID_STRING), + HIBYTE(USBD_LANGID_STRING), }; __ALIGN_BEGIN uint8_t USBD_StrDesc[USB_MAX_STR_DESC_SIZ] __ALIGN_END ; // modified by OpenTX /* -* @brief USBD_USR_DeviceDescriptor +* @brief USBD_USR_DeviceDescriptor * return the device descriptor * @param speed : current device speed * @param length : pointer to data length variable @@ -149,13 +128,50 @@ __ALIGN_BEGIN uint8_t USBD_StrDesc[USB_MAX_STR_DESC_SIZ] __ALIGN_END ; // modifi */ uint8_t * USBD_USR_DeviceDescriptor( uint8_t speed , uint16_t *length) { + int pid=0; + + switch (getSelectedUsbMode()) { + case USB_JOYSTICK_MODE: + pid = USBD_HID_PID; + break; + case USB_SERIAL_MODE: + pid = USBD_CDC_PID; + break; + case USB_MASS_STORAGE_MODE: + pid = USBD_MSC_PID; + break; + } + + /* USB Standard Device Descriptor */ + __ALIGN_BEGIN const uint8_t USBD_DeviceDesc[USB_SIZ_DEVICE_DESC] __ALIGN_END = + { + USB_SIZ_DEVICE_DESC, /*bLength */ + USB_DEVICE_DESCRIPTOR_TYPE, /*bDescriptorType*/ + 0x00, /*bcdUSB */ + 0x02, + 0x00, /*bDeviceClass*/ + 0x00, /*bDeviceSubClass*/ + 0x00, /*bDeviceProtocol*/ + USB_OTG_MAX_EP0_SIZE, /*bMaxPacketSize*/ + LOBYTE(USBD_VID), /*idVendor*/ + HIBYTE(USBD_VID), /*idVendor*/ + LOBYTE(pid), /*idVendor*/ + HIBYTE(pid), /*idVendor*/ + 0x00, /*bcdDevice rel. 2.00*/ + 0x02, + USBD_IDX_MFC_STR, /*Index of manufacturer string*/ + USBD_IDX_PRODUCT_STR, /*Index of product string*/ + USBD_IDX_SERIAL_STR, /*Index of serial number string*/ + USBD_CFG_MAX_NUM /*bNumConfigurations*/ + }; /* USB_DeviceDescriptor */ + *length = sizeof(USBD_DeviceDesc); memcpy(USBD_StrDesc, USBD_DeviceDesc, *length); return USBD_StrDesc; } /** -* @brief USBD_USR_LangIDStrDescriptor +* @brief USBD_USR_LangIDStrDescriptor * return the LangID string descriptor * @param speed : current device speed * @param length : pointer to data length variable @@ -163,14 +179,14 @@ uint8_t * USBD_USR_DeviceDescriptor( uint8_t speed , uint16_t *length) */ uint8_t * USBD_USR_LangIDStrDescriptor( uint8_t speed , uint16_t *length) { - *length = sizeof(USBD_LangIDDesc); + *length = sizeof(USBD_LangIDDesc); memcpy(USBD_StrDesc, USBD_LangIDDesc, *length); return USBD_StrDesc; } /** -* @brief USBD_USR_ProductStrDescriptor +* @brief USBD_USR_ProductStrDescriptor * return the product string descriptor * @param speed : current device speed * @param length : pointer to data length variable @@ -178,12 +194,23 @@ uint8_t * USBD_USR_LangIDStrDescriptor( uint8_t speed , uint16_t *length) */ uint8_t * USBD_USR_ProductStrDescriptor( uint8_t speed , uint16_t *length) { - USBD_GetString ((uint8_t*)USBD_PRODUCT_FS_STRING, USBD_StrDesc, length); + switch (getSelectedUsbMode()) { + case USB_JOYSTICK_MODE: + USBD_GetString ((uint8_t*)USBD_HID_PRODUCT_FS_STRING, USBD_StrDesc, length); + break; + case USB_SERIAL_MODE: + USBD_GetString ((uint8_t*)USBD_CDC_PRODUCT_FS_STRING, USBD_StrDesc, length); + break; + case USB_MASS_STORAGE_MODE: + USBD_GetString ((uint8_t*)USBD_MSC_PRODUCT_FS_STRING, USBD_StrDesc, length); + break; + } + return USBD_StrDesc; } /** -* @brief USBD_USR_ManufacturerStrDescriptor +* @brief USBD_USR_ManufacturerStrDescriptor * return the manufacturer string descriptor * @param speed : current device speed * @param length : pointer to data length variable @@ -196,7 +223,7 @@ uint8_t * USBD_USR_ManufacturerStrDescriptor( uint8_t speed , uint16_t *length) } /** -* @brief USBD_USR_SerialStrDescriptor +* @brief USBD_USR_SerialStrDescriptor * return the serial number string descriptor * @param speed : current device speed * @param length : pointer to data length variable @@ -209,7 +236,7 @@ uint8_t * USBD_USR_SerialStrDescriptor( uint8_t speed , uint16_t *length) } /** -* @brief USBD_USR_ConfigStrDescriptor +* @brief USBD_USR_ConfigStrDescriptor * return the configuration string descriptor * @param speed : current device speed * @param length : pointer to data length variable @@ -217,13 +244,23 @@ uint8_t * USBD_USR_SerialStrDescriptor( uint8_t speed , uint16_t *length) */ uint8_t * USBD_USR_ConfigStrDescriptor( uint8_t speed , uint16_t *length) { - USBD_GetString ((uint8_t *)USBD_CONFIGURATION_FS_STRING, USBD_StrDesc, length); - return USBD_StrDesc; + switch (getSelectedUsbMode()) { + case USB_JOYSTICK_MODE: + USBD_GetString ((uint8_t*)USBD_HID_CONFIGURATION_FS_STRING, USBD_StrDesc, length); + break; + case USB_SERIAL_MODE: + USBD_GetString ((uint8_t*)USBD_CDC_CONFIGURATION_FS_STRING, USBD_StrDesc, length); + break; + case USB_MASS_STORAGE_MODE: + USBD_GetString ((uint8_t*)USBD_MSC_CONFIGURATION_FS_STRING, USBD_StrDesc, length); + break; + } + return USBD_StrDesc; } /** -* @brief USBD_USR_InterfaceStrDescriptor +* @brief USBD_USR_InterfaceStrDescriptor * return the interface string descriptor * @param speed : current device speed * @param length : pointer to data length variable @@ -231,9 +268,18 @@ uint8_t * USBD_USR_ConfigStrDescriptor( uint8_t speed , uint16_t *length) */ uint8_t * USBD_USR_InterfaceStrDescriptor( uint8_t speed , uint16_t *length) { - USBD_GetString ((uint8_t*)USBD_INTERFACE_FS_STRING, USBD_StrDesc, length); - return USBD_StrDesc; + switch (getSelectedUsbMode()) { + case USB_JOYSTICK_MODE: + USBD_GetString ((uint8_t*)USBD_HID_INTERFACE_FS_STRING, USBD_StrDesc, length); + break; + case USB_SERIAL_MODE: + USBD_GetString ((uint8_t*)USBD_CDC_INTERFACE_FS_STRING, USBD_StrDesc, length); + break; + case USB_MASS_STORAGE_MODE: + USBD_GetString ((uint8_t*)USBD_MSC_INTERFACE_FS_STRING, USBD_StrDesc, length); + break; + } + return USBD_StrDesc; } /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ - diff --git a/radio/src/targets/common/arm/stm32/usbd_usr.cpp b/radio/src/targets/common/arm/stm32/usbd_usr.cpp index 20fc57b5d..f367348ff 100644 --- a/radio/src/targets/common/arm/stm32/usbd_usr.cpp +++ b/radio/src/targets/common/arm/stm32/usbd_usr.cpp @@ -2,7 +2,7 @@ * Copyright (C) OpenTX * * Based on code named - * th9x - http://code.google.com/p/th9x + * th9x - http://code.google.com/p/th9x * er9x - http://code.google.com/p/er9x * gruvin9x - http://code.google.com/p/gruvin9x * @@ -35,9 +35,9 @@ const USBD_Usr_cb_TypeDef USR_cb = USBD_USR_DeviceConfigured, USBD_USR_DeviceSuspended, USBD_USR_DeviceResumed, - + USBD_USR_DeviceConnected, - USBD_USR_DeviceDisconnected, + USBD_USR_DeviceDisconnected, }; } @@ -69,10 +69,10 @@ void USBD_USR_DeviceReset (uint8_t speed) */ void USBD_USR_DeviceConfigured (void) { - + } /** -* @brief Displays the message on LCD on device suspend event +* @brief Displays the message on LCD on device suspend event * @param None * @retval None */ @@ -112,9 +112,10 @@ void USBD_USR_DeviceConnected (void) */ void USBD_USR_DeviceDisconnected (void) { -#if !defined(BOOT) && defined(USB_MASS_STORAGE) && defined(EEPROM) +#if !defined(BOOT) && defined(EEPROM) // TODO is it really needed if we didn't write the EEPROM? - NVIC_SystemReset(); +// if (getSelectedUsbMode() == USB_MASS_STORAGE_MODE) +// NVIC_SystemReset(); #endif } diff --git a/radio/src/targets/horus/board.h b/radio/src/targets/horus/board.h index 55adb10bb..9d91a4e4a 100644 --- a/radio/src/targets/horus/board.h +++ b/radio/src/targets/horus/board.h @@ -22,6 +22,7 @@ #define _BOARD_HORUS_H_ #include "stddef.h" +#include "stdbool.h" #if defined(__cplusplus) && !defined(SIMU) extern "C" { @@ -62,6 +63,7 @@ extern "C" { #pragma clang diagnostic pop #endif +#include "usb_driver.h" #if !defined(SIMU) #include "usbd_cdc_core.h" @@ -218,7 +220,7 @@ enum EnumKeys KEY_RIGHT = KEY_TELEM, KEY_RADIO, KEY_LEFT = KEY_RADIO, - + TRM_BASE, TRM_LH_DWN = TRM_BASE, TRM_LH_UP, @@ -233,7 +235,7 @@ enum EnumKeys TRM_RS_DWN, TRM_RS_UP, TRM_LAST = TRM_RS_UP, - + NUM_KEYS }; @@ -447,14 +449,7 @@ void backlightEnable(uint8_t dutyCycle); #define BACKLIGHT_DISABLE() backlightEnable(unexpectedShutdown ? 100 : g_eeGeneral.blOffBright) #define isBacklightEnabled() true -// USB driver -int usbPlugged(); -void usbInit(); -void usbStart(); -void usbStop(); -uint8_t usbStarted(); -void usbSerialPutc(uint8_t c); -#if defined(USB_JOYSTICK) && !defined(SIMU) +#if !defined(SIMU) void usbJoystickUpdate(); #endif #if defined(PCBX12S) diff --git a/radio/src/targets/simu/simpgmspace.cpp b/radio/src/targets/simu/simpgmspace.cpp index c5abe9bca..425155cc9 100644 --- a/radio/src/targets/simu/simpgmspace.cpp +++ b/radio/src/targets/simu/simpgmspace.cpp @@ -645,6 +645,8 @@ uint32_t pwrPressed() #if defined(STM32) void pwrInit() { } int usbPlugged() { return false; } +int getSelectedUsbMode() { return USB_JOYSTICK_MODE; } +void setSelectedUsbMode(int mode) {} void USART_DeInit(USART_TypeDef* ) { } ErrorStatus RTC_SetTime(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_TimeStruct) { return SUCCESS; } ErrorStatus RTC_SetDate(uint32_t RTC_Format, RTC_DateTypeDef* RTC_DateStruct) { return SUCCESS; } diff --git a/radio/src/targets/taranis/board.h b/radio/src/targets/taranis/board.h index 3a266afff..09b9af3ad 100644 --- a/radio/src/targets/taranis/board.h +++ b/radio/src/targets/taranis/board.h @@ -22,6 +22,7 @@ #define _BOARD_H_ #include "stddef.h" +#include "stdbool.h" #if defined(__cplusplus) && !defined(SIMU) extern "C" { @@ -71,6 +72,7 @@ extern "C" { #pragma clang diagnostic pop #endif +#include "usb_driver.h" #if !defined(SIMU) #include "usbd_cdc_core.h" #include "usbd_msc_core.h" @@ -157,13 +159,14 @@ uint32_t sdGetSpeed(void); #define sdInit() #define sdMount() #define sdDone() +#define SD_CARD_PRESENT() true #else void sdInit(void); void sdMount(void); void sdDone(void); void sdPoll10ms(void); uint32_t sdMounted(void); -#define SD_CARD_PRESENT() (~SD_GPIO_PRESENT->IDR & SD_GPIO_PIN_PRESENT) +#define SD_CARD_PRESENT() ((SD_GPIO_PRESENT->IDR & SD_GPIO_PIN_PRESENT)==0) #endif // Flash Write driver @@ -453,14 +456,7 @@ uint8_t isBacklightEnabled(void); #define BACKLIGHT_ENABLE() backlightEnable(g_eeGeneral.backlightBright) #endif -// USB driver -int usbPlugged(); -void usbInit(); -void usbStart(); -void usbStop(); -uint8_t usbStarted(); -void usbSerialPutc(uint8_t c); -#if defined(USB_JOYSTICK) && !defined(SIMU) +#if !defined(SIMU) void usbJoystickUpdate(); #endif #define USB_NAME "FrSky Taranis" diff --git a/radio/src/targets/taranis/diskio.cpp b/radio/src/targets/taranis/diskio.cpp index ad51be819..8043f85a8 100644 --- a/radio/src/targets/taranis/diskio.cpp +++ b/radio/src/targets/taranis/diskio.cpp @@ -993,13 +993,18 @@ void sdInit(void) void sdInit(void) { TRACE("sdInit"); - + ioMutex = CoCreateMutex(); - if (ioMutex >= CFG_MAX_MUTEX ) { + if (ioMutex >= CFG_MAX_MUTEX) { //sd error return; } + sdMount(); +} +void sdMount() +{ + TRACE("sdMount"); if (f_mount(&g_FATFS_Obj, "", 1) == FR_OK) { // call sdGetFreeSectors() now because f_getfree() takes a long time first time it's called sdGetFreeSectors(); diff --git a/radio/src/tasks_arm.cpp b/radio/src/tasks_arm.cpp index 25c368a6f..0dcc6b064 100644 --- a/radio/src/tasks_arm.cpp +++ b/radio/src/tasks_arm.cpp @@ -138,7 +138,7 @@ void mixerTask(void * pdata) uint32_t now = CoGetOSTime(); bool run = false; -#if defined(USB_JOYSTICK) && !defined(SIMU) +#if !defined(SIMU) && defined(STM32) if ((now - lastRunTime) >= (usbStarted() ? 5 : 10)) { // run at least every 20ms (every 10ms if USB is active) #else if ((now - lastRunTime) >= 10) { // run at least every 20ms diff --git a/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.2.0/Libraries/STM32_USB_Device_Library/Class/cdc/src/usbd_cdc_core.c b/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.2.0/Libraries/STM32_USB_Device_Library/Class/cdc/src/usbd_cdc_core.c index f9f8e8e9f..87fbf3fd0 100644 --- a/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.2.0/Libraries/STM32_USB_Device_Library/Class/cdc/src/usbd_cdc_core.c +++ b/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.2.0/Libraries/STM32_USB_Device_Library/Class/cdc/src/usbd_cdc_core.c @@ -436,7 +436,7 @@ __ALIGN_BEGIN const uint8_t usbd_cdc_OtherCfgDesc[USB_CDC_CONFIG_DESC_SIZ] __AL uint8_t usbd_cdc_Init (void *pdev, uint8_t cfgidx) { - uint8_t *pbuf; + //uint8_t *pbuf; APP_Rx_ptr_in = 0; // modified by OpenTX APP_Rx_ptr_out = 0; // modified by OpenTX @@ -462,10 +462,11 @@ uint8_t usbd_cdc_Init (void *pdev, CDC_CMD_EP, CDC_CMD_PACKET_SZE, USB_OTG_EP_INT); - - pbuf = (uint8_t *)USBD_DeviceDesc; + + /* schwabe: We don't provide direct to this, but our usb descriptor has always the same values (02 and 00) */ + /*pbuf = (uint8_t *)USBD_DeviceDesc; pbuf[4] = DEVICE_CLASS_CDC; - pbuf[5] = DEVICE_SUBCLASS_CDC; + pbuf[5] = DEVICE_SUBCLASS_CDC; */ /* Initialize the Interface physical components */ APP_FOPS.pIf_Init(); diff --git a/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.2.0/Libraries/STM32_USB_Device_Library/Class/msc/inc/usbd_msc_core.h b/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.2.0/Libraries/STM32_USB_Device_Library/Class/msc/inc/usbd_msc_core.h index 8b339001c..cc3a9e414 100644 --- a/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.2.0/Libraries/STM32_USB_Device_Library/Class/msc/inc/usbd_msc_core.h +++ b/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.2.0/Libraries/STM32_USB_Device_Library/Class/msc/inc/usbd_msc_core.h @@ -61,7 +61,7 @@ * @{ */ -extern const USBD_Class_cb_TypeDef USBD_MSC_cb; // modified my OpenTX +extern const USBD_Class_cb_TypeDef USBD_MSC_cb; // modified by OpenTX /** * @} */ diff --git a/radio/src/translations.cpp b/radio/src/translations.cpp index f7c860932..0c3e72fd3 100644 --- a/radio/src/translations.cpp +++ b/radio/src/translations.cpp @@ -102,6 +102,7 @@ const pm_char STR_OPEN9X[] PROGMEM = #endif #if defined(PXX) || defined(CPUARM) ISTR(COUNTRYCODES) + ISTR(USBMODES) ISTR(VFAILSAFE) #endif #if defined(CPUARM) @@ -385,6 +386,7 @@ const pm_char STR_INTERNALRF[] PROGMEM = TR_INTERNALRF; const pm_char STR_EXTERNALRF[] PROGMEM = TR_EXTERNALRF; const pm_char STR_SPORT_OUT[] PROGMEM = TR_SPORT_OUT; const pm_char STR_COUNTRYCODE[] PROGMEM = TR_COUNTRYCODE; +const pm_char STR_USBMODE[] PROGMEM = TR_USBMODE; const pm_char STR_FAILSAFE[] PROGMEM = TR_FAILSAFE; const pm_char STR_FAILSAFESET[] PROGMEM = TR_FAILSAFESET; const pm_char STR_HOLD[] PROGMEM = TR_HOLD; @@ -457,6 +459,9 @@ const pm_char STR_RESET_TIMER3[] PROGMEM = TR_RESET_TIMER3; const pm_char STR_RESET_TELEMETRY[] PROGMEM = TR_RESET_TELEMETRY; const pm_char STR_STATISTICS[] PROGMEM = TR_STATISTICS; const pm_char STR_ABOUT_US[] PROGMEM = TR_ABOUT_US; +const pm_char STR_USB_JOYSTICK[] PROGMEM = TR_USB_JOYSTICK; +const pm_char STR_USB_MASS_STORAGE[] PROGMEM = TR_USB_MASS_STORAGE; +const pm_char STR_USB_SERIAL[] PROGMEM = TR_USB_SERIAL; const pm_char STR_SETUP_SCREENS[] PROGMEM = TR_SETUP_SCREENS; const pm_char STR_MONITOR_SCREENS[] PROGMEM = TR_MONITOR_SCREENS; #endif diff --git a/radio/src/translations.h b/radio/src/translations.h index 196e701a9..41e0016f6 100644 --- a/radio/src/translations.h +++ b/radio/src/translations.h @@ -207,11 +207,12 @@ extern const pm_char STR_OPEN9X[]; #define OFS_VBEEPCOUNTDOWN (OFS_VUNITSSYSTEM + sizeof(TR_VUNITSSYSTEM)) #define OFS_VVARIOCENTER (OFS_VBEEPCOUNTDOWN + sizeof(TR_VBEEPCOUNTDOWN)) #define OFS_COUNTRYCODES (OFS_VVARIOCENTER + sizeof(TR_VVARIOCENTER)) + #define OFS_USBMODES (OFS_COUNTRYCODES + sizeof(TR_COUNTRYCODES)) #else #define OFS_COUNTRYCODES (OFS_VLCD) #endif #if defined(PXX) || defined(CPUARM) - #define OFS_VFAILSAFE (OFS_COUNTRYCODES + sizeof(TR_COUNTRYCODES)) + #define OFS_VFAILSAFE (OFS_USBMODES + sizeof(TR_USBMODES)) #define OFS_VTRAINERMODES (OFS_VFAILSAFE + sizeof(TR_VFAILSAFE)) #else #define OFS_VFAILSAFE (OFS_COUNTRYCODES) @@ -340,6 +341,7 @@ extern const pm_char STR_OPEN9X[]; #if defined(PXX) || defined(CPUARM) #define STR_COUNTRYCODES (STR_OPEN9X + OFS_COUNTRYCODES) + #define STR_USBMODES (STR_OPEN9X + OFS_USBMODES) #define STR_VFAILSAFE (STR_OPEN9X + OFS_VFAILSAFE) #endif @@ -632,6 +634,7 @@ extern const pm_char STR_NONE[]; extern const pm_char STR_MENUSENSOR[]; extern const pm_char STR_SENSOR[]; extern const pm_char STR_COUNTRYCODE[]; +extern const pm_char STR_USBMODE[]; extern const pm_char STR_DISABLE_INTERNAL[]; #endif @@ -703,6 +706,9 @@ extern const pm_char STR_PERSISTENT_MAH[]; extern const pm_char STR_RESET_TELEMETRY[]; extern const pm_char STR_STATISTICS[]; extern const pm_char STR_ABOUT_US[]; + extern const pm_char STR_USB_JOYSTICK[]; + extern const pm_char STR_USB_MASS_STORAGE[]; + extern const pm_char STR_USB_SERIAL[]; extern const pm_char STR_SETUP_SCREENS[]; extern const pm_char STR_MONITOR_SCREENS[]; #endif diff --git a/radio/src/translations/cz.h.txt b/radio/src/translations/cz.h.txt index 085f4a196..20f348a0b 100644 --- a/radio/src/translations/cz.h.txt +++ b/radio/src/translations/cz.h.txt @@ -92,6 +92,9 @@ #define LEN_COUNTRYCODES TR("\002", "\010") #define TR_COUNTRYCODES TR("US""JP""EU", "Amerika\0""Japonsko""Evropa\0 ") +#define LEN_USBMODES TR("\006", "\010") +#define TR_USBMODES TR("Ask\0 ""Joyst\0""SDCard""Debug\0", "Ask\0 ""Joystick""Storage\0""Debug\0 ") + #define LEN_TARANIS_PROTOCOLS "\004" #define TR_TARANIS_PROTOCOLS "Vyp\0""PPM\0""XJT\0""DSM2""CRSF""MULT""R9M\0" @@ -996,6 +999,7 @@ #define TR_MENUSENSOR "SENZOR" #define TR_SENSOR "SENZOR" #define TR_COUNTRYCODE "Kód regionu" +#define TR_USBMODE "USB Mode" #define TR_VOICELANG "Jazyk hlasu" #define TR_UNITSSYSTEM "Jednotky" #define TR_EDIT "Upravit" @@ -1013,6 +1017,9 @@ #define TR_RESET_TELEMETRY "Telemetrii" #define TR_STATISTICS "Statistika" #define TR_ABOUT_US "O nás" +#define TR_USB_JOYSTICK "USB Joystick (HID)" +#define TR_USB_MASS_STORAGE "USB mass storage" +#define TR_USB_SERIAL "USB Serial (Debug)" #define TR_SETUP_SCREENS "Setup screens" #define TR_MONITOR_SCREENS "Monitory" #define TR_AND_SWITCH "AND Spínač" diff --git a/radio/src/translations/de.h.txt b/radio/src/translations/de.h.txt index e51533b92..a0b33a0dd 100644 --- a/radio/src/translations/de.h.txt +++ b/radio/src/translations/de.h.txt @@ -98,6 +98,9 @@ #define LEN_COUNTRYCODES TR("\002", "\007") #define TR_COUNTRYCODES TR("US""JP""EU", "Amerika""Japan\0 ""Europa\0") +#define LEN_USBMODES TR("\006", "\010") +#define TR_USBMODES TR("Ask\0 ""Joyst\0""SDCard""Debug\0", "Ask\0 ""Joystick""Storage\0""Debug\0 ") + #define LEN_TARANIS_PROTOCOLS "\004" #define TR_TARANIS_PROTOCOLS "AUS\0""PPM\0""XJT\0""DSM?""CRSF""MULT""R9M\0" @@ -1018,6 +1021,7 @@ #define TR_MENUSENSOR "SENSOR" #define TR_SENSOR "SENSOR" #define TR_COUNTRYCODE "Landescode" +#define TR_USBMODE "USB Mode" #define TR_VOICELANG "Sprach-Ansage" #define TR_UNITSSYSTEM "Einheiten" #define TR_EDIT "Zeile Editieren" @@ -1035,6 +1039,9 @@ #define TR_RESET_TELEMETRY "Reset Telemetrie" #define TR_STATISTICS "Statistik Timer Gas" #define TR_ABOUT_US "Die Programmierer" +#define TR_USB_JOYSTICK "USB Joystick (HID)" +#define TR_USB_MASS_STORAGE "USB mass storage" +#define TR_USB_SERIAL "USB Serial (Debug)" #define TR_SETUP_SCREENS "Setup Hautbildschirme" #define TR_MONITOR_SCREENS "Monitore Mischer Kanal Logik" #define TR_AND_SWITCH "UND Schalt" //UND mit weiterem Schaltern diff --git a/radio/src/translations/en.h.txt b/radio/src/translations/en.h.txt index db5bd9b5a..4122fea02 100644 --- a/radio/src/translations/en.h.txt +++ b/radio/src/translations/en.h.txt @@ -98,6 +98,9 @@ #define LEN_COUNTRYCODES TR("\002", "\007") #define TR_COUNTRYCODES TR("US""JP""EU", "America""Japan\0 ""Europe\0") +#define LEN_USBMODES TR("\006", "\010") +#define TR_USBMODES TR("Ask\0 ""Joyst\0""SDCard""Debug\0", "Ask\0 ""Joystick""Storage\0""Debug\0 ") + #define LEN_TARANIS_PROTOCOLS "\004" #define TR_TARANIS_PROTOCOLS "OFF\0""PPM\0""XJT\0""DSM2""CRSF""MULT""R9M\0" @@ -1000,6 +1003,7 @@ #define TR_MENUSENSOR "SENSOR" #define TR_SENSOR "SENSOR" #define TR_COUNTRYCODE "Country code" +#define TR_USBMODE "USB Mode" #define TR_VOICELANG "Voice language" #define TR_UNITSSYSTEM "Units" #define TR_EDIT "Edit" @@ -1017,6 +1021,9 @@ #define TR_RESET_TELEMETRY "Reset telemetry" #define TR_STATISTICS "Statistics" #define TR_ABOUT_US "About" +#define TR_USB_JOYSTICK "USB Joystick (HID)" +#define TR_USB_MASS_STORAGE "USB mass storage" +#define TR_USB_SERIAL "USB Serial (Debug)" #define TR_SETUP_SCREENS "Setup screens" #define TR_MONITOR_SCREENS "Monitors" #define TR_AND_SWITCH "AND switch" diff --git a/radio/src/translations/es.h.txt b/radio/src/translations/es.h.txt index 5e00f3545..c38d0e5e0 100644 --- a/radio/src/translations/es.h.txt +++ b/radio/src/translations/es.h.txt @@ -94,6 +94,9 @@ #define LEN_COUNTRYCODES TR("\002", "\007") #define TR_COUNTRYCODES TR("US""JP""EU", "America""Japon\0 ""Europa\0") +#define LEN_USBMODES TR("\006", "\010") +#define TR_USBMODES TR("Ask\0 ""Joyst\0""SDCard""Debug\0", "Ask\0 ""Joystick""Storage\0""Debug\0 ") + #define LEN_TARANIS_PROTOCOLS "\004" #define TR_TARANIS_PROTOCOLS "OFF\0""PPM\0""XJT\0""DSM2""CRSF""MULT""R9M\0" @@ -976,6 +979,7 @@ #define TR_MENUSENSOR "SENSOR" #define TR_SENSOR "SENSOR" #define TR_COUNTRYCODE "Codigo Pais" +#define TR_USBMODE "USB Mode" #define TR_VOICELANG "Idioma voces" #define TR_UNITSSYSTEM "Unidades" #define TR_EDIT "Editar" @@ -993,6 +997,9 @@ #define TR_RESET_TELEMETRY "Reset Telemetria" #define TR_STATISTICS "Estadisticas" #define TR_ABOUT_US "Nosotros" +#define TR_USB_JOYSTICK "USB Joystick (HID)" +#define TR_USB_MASS_STORAGE "USB mass storage" +#define TR_USB_SERIAL "USB Serial (Debug)" #define TR_SETUP_SCREENS "Setup screens" #define TR_MONITOR_SCREENS "Monitors" #define TR_AND_SWITCH "AND Inter." diff --git a/radio/src/translations/fi.h.txt b/radio/src/translations/fi.h.txt index 8f023a54a..5551b276b 100644 --- a/radio/src/translations/fi.h.txt +++ b/radio/src/translations/fi.h.txt @@ -94,6 +94,9 @@ #define LEN_COUNTRYCODES TR("\002", "\007") #define TR_COUNTRYCODES TR("US""JP""EU", "Amerikk""Japani\0""Euroopp") +#define LEN_USBMODES TR("\006", "\010") +#define TR_USBMODES TR("Ask\0 ""Joyst\0""SDCard""Debug\0", "Ask\0 ""Joystick""Storage\0""Debug\0 ") + #define LEN_TARANIS_PROTOCOLS "\004" #define TR_TARANIS_PROTOCOLS "OFF\0""PPM\0""XJT\0""DSM2""CRSF""MULT""R9M\0" @@ -972,6 +975,7 @@ #define TR_MENUSENSOR "SENSOR" #define TR_SENSOR "SENSOR" #define TR_COUNTRYCODE "Country Code" +#define TR_USBMODE "USB Mode" #define TR_VOICELANG "Voice Language" #define TR_UNITSSYSTEM "Units" #define TR_EDIT "Edit" @@ -989,6 +993,9 @@ #define TR_RESET_TELEMETRY "Reset Telemetry" #define TR_STATISTICS "Statistics" #define TR_ABOUT_US "About" +#define TR_USB_JOYSTICK "USB Joystick (HID)" +#define TR_USB_MASS_STORAGE "USB mass storage" +#define TR_USB_SERIAL "USB Serial (Debug)" #define TR_SETUP_SCREENS "Setup screens" #define TR_MONITOR_SCREENS "Monitors" #define TR_AND_SWITCH "AND Switch" diff --git a/radio/src/translations/fr.h.txt b/radio/src/translations/fr.h.txt index 2cb2d4cb6..91381f432 100644 --- a/radio/src/translations/fr.h.txt +++ b/radio/src/translations/fr.h.txt @@ -94,6 +94,9 @@ #define LEN_COUNTRYCODES TR("\002", "\006") #define TR_COUNTRYCODES TR("US""JP""EU", "USA\0 ""Japon\0""Europe") +#define LEN_USBMODES TR("\006", "\010") +#define TR_USBMODES TR("Ask\0 ""Joyst\0""SDCard""Debug\0", "Ask\0 ""Joystick""Storage\0""Debug\0 ") + #define LEN_TARANIS_PROTOCOLS "\004" #define TR_TARANIS_PROTOCOLS "OFF\0""PPM\0""XJT\0""DSM2""CRSF""MULT""R9M\0" @@ -997,6 +1000,7 @@ #define TR_MENUSENSOR "CAPTEUR" #define TR_SENSOR "SENSOR" #define TR_COUNTRYCODE TR("Zone géo.", "Zone géographique") +#define TR_USBMODE "USB Mode" #define TR_VOICELANG TR("Langue voix", "Langue annonces vocales") #define TR_UNITSSYSTEM "Unités" #define TR_EDIT "Editer" @@ -1014,6 +1018,9 @@ #define TR_RESET_TELEMETRY TR("Réinit. Télém.", "Réinit. Télémesure") #define TR_STATISTICS "Statistiques" #define TR_ABOUT_US "A propos" +#define TR_USB_JOYSTICK "USB Joystick (HID)" +#define TR_USB_MASS_STORAGE "USB mass storage" +#define TR_USB_SERIAL "USB Serial (Debug)" #define TR_SETUP_SCREENS "Configuration écrans" #define TR_MONITOR_SCREENS "Moniteurs" #define TR_AND_SWITCH "ET suppl." diff --git a/radio/src/translations/it.h.txt b/radio/src/translations/it.h.txt index 516dd8ab3..dcbd707fe 100644 --- a/radio/src/translations/it.h.txt +++ b/radio/src/translations/it.h.txt @@ -94,6 +94,9 @@ #define LEN_COUNTRYCODES TR("\002", "\007") #define TR_COUNTRYCODES TR("US""JP""EU", "America""Japan\0 ""Europa\0") +#define LEN_USBMODES TR("\006", "\010") +#define TR_USBMODES TR("Ask\0 ""Joyst\0""SDCard""Debug\0", "Ask\0 ""Joystick""Storage\0""Debug\0 ") + #define LEN_TARANIS_PROTOCOLS "\004" #define TR_TARANIS_PROTOCOLS "OFF\0""PPM\0""XJT\0""DSM2""CRSF""MULT""R9M\0" @@ -1001,6 +1004,7 @@ #define TR_MENUSENSOR "SENSOR" #define TR_SENSOR "SENSOR" #define TR_COUNTRYCODE TR("Codice Paese","Standard 2.4Ghz") +#define TR_USBMODE "USB Mode" #define TR_VOICELANG "Lingua Voce" #define TR_UNITSSYSTEM "Unità" #define TR_EDIT "Modifica" @@ -1018,6 +1022,9 @@ #define TR_RESET_TELEMETRY "Azzera Telemetria" #define TR_STATISTICS "Statistiche" #define TR_ABOUT_US "Info su" +#define TR_USB_JOYSTICK "USB Joystick (HID)" +#define TR_USB_MASS_STORAGE "USB mass storage" +#define TR_USB_SERIAL "USB Serial (Debug)" #define TR_SETUP_SCREENS "Setup screens" #define TR_MONITOR_SCREENS "Monitors" #define TR_AND_SWITCH "Inter. AND" diff --git a/radio/src/translations/nl.h.txt b/radio/src/translations/nl.h.txt index 338419ee8..195ceea4d 100644 --- a/radio/src/translations/nl.h.txt +++ b/radio/src/translations/nl.h.txt @@ -99,6 +99,9 @@ #define LEN_COUNTRYCODES TR("\002", "\007") #define TR_COUNTRYCODES TR("US""JP""EU", "Amerika""Japan\0 ""Europa\0") +#define LEN_USBMODES TR("\006", "\010") +#define TR_USBMODES TR("Ask\0 ""Joyst\0""SDCard""Debug\0", "Ask\0 ""Joystick""Storage\0""Debug\0 ") + #define LEN_TARANIS_PROTOCOLS "\004" #define TR_TARANIS_PROTOCOLS "UIT\0""PPM\0""XJT\0""DSM2""CRSF""MULT""R9M\0" @@ -996,6 +999,7 @@ #define TR_MENUSENSOR "SENSOR" #define TR_SENSOR "SENSOR" #define TR_COUNTRYCODE "Landcode" +#define TR_USBMODE "USB Mode" #define TR_VOICELANG "Taal" #define TR_UNITSSYSTEM "Eenheden" #define TR_EDIT "Wijzigen" @@ -1013,6 +1017,9 @@ #define TR_RESET_TELEMETRY "Reset Telemetrie" #define TR_STATISTICS "Statistieken" #define TR_ABOUT_US "De Programmeurs" +#define TR_USB_JOYSTICK "USB Joystick (HID)" +#define TR_USB_MASS_STORAGE "USB mass storage" +#define TR_USB_SERIAL "USB Serial (Debug)" #define TR_SETUP_SCREENS "Setup screens" #define TR_MONITOR_SCREENS "Monitors" #define TR_AND_SWITCH "AND Switch" diff --git a/radio/src/translations/pl.h.txt b/radio/src/translations/pl.h.txt index 88e19d963..cf90cad9f 100644 --- a/radio/src/translations/pl.h.txt +++ b/radio/src/translations/pl.h.txt @@ -95,6 +95,9 @@ #define LEN_COUNTRYCODES TR("\002", "\007") #define TR_COUNTRYCODES TR("US""JP""EU", "Ameryka""Japonia""Europa\0") +#define LEN_USBMODES TR("\006", "\010") +#define TR_USBMODES TR("Ask\0 ""Joyst\0""SDCard""Debug\0", "Ask\0 ""Joystick""Storage\0""Debug\0 ") + #define LEN_TARANIS_PROTOCOLS "\004" #define TR_TARANIS_PROTOCOLS "OFF\0""PPM\0""XJT\0""DSM2""CRSF""MULT""R9M\0" @@ -1004,6 +1007,7 @@ #define TR_MENUSENSOR "CZUJNIK" #define TR_SENSOR "SENSOR" #define TR_COUNTRYCODE "Kod regionu" +#define TR_USBMODE "USB Mode" #define TR_VOICELANG "Język głosu" #define TR_UNITSSYSTEM "Jednostki" #define TR_EDIT "Edytuj" @@ -1021,6 +1025,9 @@ #define TR_RESET_TELEMETRY "Wyczyść telemetrię" #define TR_STATISTICS "Statystyki" #define TR_ABOUT_US "O nas" +#define TR_USB_JOYSTICK "USB Joystick (HID)" +#define TR_USB_MASS_STORAGE "USB mass storage" +#define TR_USB_SERIAL "USB Serial (Debug)" #define TR_SETUP_SCREENS "Setup screens" #define TR_MONITOR_SCREENS "Monitors" #define TR_AND_SWITCH "Przełącznik AND" diff --git a/radio/src/translations/pt.h.txt b/radio/src/translations/pt.h.txt index 1827d2d1a..86f349079 100644 --- a/radio/src/translations/pt.h.txt +++ b/radio/src/translations/pt.h.txt @@ -94,6 +94,9 @@ #define LEN_COUNTRYCODES TR("\002", "\007") #define TR_COUNTRYCODES TR("US""JP""EU", "America""Japan\0 ""Europe\0") +#define LEN_USBMODES TR("\006", "\010") +#define TR_USBMODES TR("Ask\0 ""Joyst\0""SDCard""Debug\0", "Ask\0 ""Joystick""Storage\0""Debug\0 ") + #define LEN_TARANIS_PROTOCOLS "\004" #define TR_TARANIS_PROTOCOLS "OFF\0""PPM\0""XJT\0""DSM2""CRSF""MULT""R9M\0" @@ -977,6 +980,7 @@ #define TR_MENUSENSOR "SENSOR" #define TR_SENSOR "SENSOR" #define TR_COUNTRYCODE "Country Code" +#define TR_USBMODE "USB Mode" #define TR_VOICELANG "Voice Language" #define TR_UNITSSYSTEM "Units" #define TR_EDIT "Edit" @@ -994,6 +998,9 @@ #define TR_RESET_TELEMETRY "Reset Telemetry" #define TR_STATISTICS "Statistics" #define TR_ABOUT_US "About Us" +#define TR_USB_JOYSTICK "USB Joystick (HID)" +#define TR_USB_MASS_STORAGE "USB mass storage" +#define TR_USB_SERIAL "USB Serial (Debug)" #define TR_SETUP_SCREENS "Setup screens" #define TR_MONITOR_SCREENS "Monitors" #define TR_AND_SWITCH "AND Switch" diff --git a/radio/src/translations/se.h.txt b/radio/src/translations/se.h.txt index d0dc8ec72..3632280b2 100644 --- a/radio/src/translations/se.h.txt +++ b/radio/src/translations/se.h.txt @@ -94,6 +94,9 @@ #define LEN_COUNTRYCODES TR("\002", "\007") #define TR_COUNTRYCODES TR("US""JP""EU", "Amerika""Japan\0 ""Europa\0") +#define LEN_USBMODES TR("\006", "\010") +#define TR_USBMODES TR("Ask\0 ""Joyst\0""SDCard""Debug\0", "Ask\0 ""Joystick""Storage\0""Debug\0 ") + #define LEN_TARANIS_PROTOCOLS "\004" #define TR_TARANIS_PROTOCOLS "Av\0 ""PPM\0""XJT\0""DSM2""CRSF""MULT""R9M\0" @@ -1015,6 +1018,7 @@ #define TR_MENUSENSOR "SENSOR" #define TR_SENSOR "SENSOR" #define TR_COUNTRYCODE "Landskod" +#define TR_USBMODE "USB Mode" #define TR_VOICELANG "Röstspråk" #define TR_UNITSSYSTEM "Enheter" #define TR_EDIT "Redigera" @@ -1032,6 +1036,9 @@ #define TR_RESET_TELEMETRY "Nollställ Telemetri" #define TR_STATISTICS "Statistik" #define TR_ABOUT_US "Om Oss" +#define TR_USB_JOYSTICK "USB Joystick (HID)" +#define TR_USB_MASS_STORAGE "USB mass storage" +#define TR_USB_SERIAL "USB Serial (Debug)" #define TR_SETUP_SCREENS "Setup screens" #define TR_MONITOR_SCREENS "Monitors" #define TR_AND_SWITCH "OCH Brytare" diff --git a/radio/util/fwoptions.py b/radio/util/fwoptions.py index 54aa307d9..060251da6 100755 --- a/radio/util/fwoptions.py +++ b/radio/util/fwoptions.py @@ -242,8 +242,6 @@ options_taranis = { "faimode": ("FAI", "YES", None), "faichoice": ("FAI", "CHOICE", None), "nooverridech": ("OVERRIDE_CHANNEL_FUNCTION", "NO", "YES"), - "massstorage": ("USB", "MASSSTORAGE", None), - "cli": ("USB", "SERIAL", None), "internalppm": ("TARANIS_INTERNAL_PPM", "YES", "NO"), "shutdownconfirm": ("SHUTDOWN_CONFIRMATION", "YES", "NO"), "eu": ("SUPPORT_D16_EU_ONLY", "YES", "NO"), @@ -262,8 +260,6 @@ options_taranisplus = { "faimode": ("FAI", "YES", None), "faichoice": ("FAI", "CHOICE", None), "nooverridech": ("OVERRIDE_CHANNEL_FUNCTION", "NO", "YES"), - "massstorage": ("USB", "MASSSTORAGE", None), - "cli": ("USB", "SERIAL", None), "internalppm": ("TARANIS_INTERNAL_PPM", "YES", "NO"), "shutdownconfirm": ("SHUTDOWN_CONFIRMATION", "YES", "NO"), "eu": ("SUPPORT_D16_EU_ONLY", "YES", "NO"), @@ -282,8 +278,6 @@ options_taranisx9e = { "faimode": ("FAI", "YES", None), "faichoice": ("FAI", "CHOICE", None), "nooverridech": ("OVERRIDE_CHANNEL_FUNCTION", "NO", "YES"), - "massstorage": ("USB", "MASSSTORAGE", None), - "cli": ("USB", "SERIAL", None), "internalppm": ("TARANIS_INTERNAL_PPM", "YES", "NO"), "shutdownconfirm": ("SHUTDOWN_CONFIRMATION", "YES", "NO"), "eu": ("SUPPORT_D16_EU_ONLY", "YES", "NO"), @@ -301,8 +295,6 @@ options_x12s = { "faimode": ("FAI", "YES", None), "faichoice": ("FAI", "CHOICE", None), "nooverridech": ("OVERRIDE_CHANNEL_FUNCTION", "NO", "YES"), - "massstorage": ("USB", "MASSSTORAGE", None), - "cli": ("USB", "SERIAL", None), "eu": ("SUPPORT_D16_EU_ONLY", "YES", "NO"), "multimodule": ("MULTIMODULE", "YES", "NO"), "pcbdev": ("PCBREV", "10", None), @@ -318,8 +310,6 @@ options_x10 = { "faimode": ("FAI", "YES", None), "faichoice": ("FAI", "CHOICE", None), "nooverridech": ("OVERRIDE_CHANNEL_FUNCTION", "NO", "YES"), - "massstorage": ("USB", "MASSSTORAGE", None), - "cli": ("USB", "SERIAL", None), "eu": ("SUPPORT_D16_EU_ONLY", "YES", "NO"), "multimodule": ("MULTIMODULE", "YES", "NO"), "bindopt": ("BINDING_OPTIONS", "YES", "NO")