├── .gitattributes ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── 1-Bug_report.md │ └── config.yml └── workflows │ ├── artifacts.yml │ ├── build.yml │ └── stale.yml ├── .gitignore ├── LICENSE ├── README.md └── src ├── .clang-format ├── .editorconfig ├── .gitattributes ├── .gitignore ├── .travis.yml ├── VERSION ├── basic └── ELRS.bas ├── boards ├── FM30.json ├── FM30_mini.json ├── GHOST_ATTO.json ├── GHOST_TX.json ├── R9MM.json ├── esp8285-8285.json ├── l432kb.json └── r9mx.json ├── bootloader ├── bluepill_bootloader.bin ├── erase_chip.bat ├── firmware.bin ├── flashbootloader.bat ├── fm30_bootloader.bin ├── fm30_mini_bootloader.bin ├── fm30_mini_rxtx_bootloader.bin ├── ghost │ ├── bl_ghost_atto.bin │ ├── ghost_atto_bootloader.bin │ └── ghost_tx_bootloader.bin ├── jumper_r900_bootloader.bin ├── jumper_r900_no_btn_bootloader.bin ├── namimnorc │ ├── rx │ │ ├── flash_2400_bootloader.bin │ │ └── voyager_900_bootloader.bin │ └── tx │ │ └── namimnorc_tx_bootloader.bin ├── r9m_bootloader.bin ├── r9m_elrs_bl.frk ├── r9m_lite_pro_bootloader.bin ├── r9mm_bootloader.bin ├── r9mm_elrs_bl.frk ├── r9mm_no_btn_bootloader.bin ├── r9mm_no_btn_elrs_bl.frk ├── r9mx_bootloader.bin ├── r9mx_elrs_bl.frk ├── r9mx_no_btn_bootloader.bin ├── r9mx_no_btn_elrs_bl.frk ├── r9slim_bootloader.bin ├── r9slim_elrs_bl.frk ├── r9slim_no_btn_bootloader.bin ├── r9slim_no_btn_elrs_bl.frk ├── r9slim_plus_bootloader.bin ├── r9slim_plus_elrs_bl.frk ├── r9slim_plus_ota_bootloader.bin ├── r9slim_plus_ota_elrs_bl.frk ├── reboot_chip.bat ├── src │ ├── .gitattributes │ ├── .gitignore │ ├── README.md │ ├── Src │ │ ├── flash.c │ │ ├── flash.h │ │ ├── frsky.c │ │ ├── frsky.h │ │ ├── irq.c │ │ ├── irq.h │ │ ├── it.c │ │ ├── it.h │ │ ├── led.c │ │ ├── led.h │ │ ├── main.c │ │ ├── main.h │ │ ├── stk500.c │ │ ├── stk500.h │ │ ├── syscalls.c │ │ ├── uart.c │ │ ├── uart.h │ │ ├── xmodem.c │ │ └── xmodem.h │ ├── boards │ │ ├── rak4200.json │ │ ├── stm32f103c8.json │ │ ├── stm32f301.json │ │ ├── stm32f302.json │ │ └── stm32f303.json │ ├── linker │ │ └── stm32.ld │ ├── platformio.ini │ └── python │ │ ├── stlink.py │ │ └── upload_stlink.py ├── sx1272_pcb_bootloader.bin ├── sx1280_rx_2020_pcb_v0.2_bootloader.bin └── sx1280_rx_nano_pcb_v0.5_bootloader.bin ├── elrs.flash.1m64.ld ├── html ├── .eslintrc.yml ├── cw.html ├── cw.js ├── elrs.css ├── footer-template.html ├── hardware.html ├── hardware.js ├── index.html ├── libs.js ├── logo-template.svg ├── lr1121.html ├── lr1121.js ├── mui.css ├── mui.js └── scan.js ├── include ├── LowPassFilter.h ├── README ├── common.h ├── deferred.h ├── dynpower.h ├── encryption.h ├── hardware.h ├── helpers.h ├── native.h ├── rxtx_common.h ├── rxtx_intf.h ├── target │ ├── DIY_2400_RX_STM32_CCG_Nano_v0_5.h │ ├── DIY_900_RX_STM32.h │ ├── DIY_900_RX_STM32_SX1272.h │ ├── DIY_900_TX_STM32_SX1272.h │ ├── FM30_RX_MINI.h │ ├── FM30_TX.h │ ├── Frsky_RX_R9M.h │ ├── Frsky_TX_R9M.h │ ├── Frsky_TX_R9M_LITE.h │ ├── Frsky_TX_R9M_LITE_PRO.h │ ├── GHOST_2400_TX.h │ ├── GHOST_2400_TX_LITE.h │ ├── GHOST_ATTO_2400_RX.h │ ├── HappyModel_TX_ES915TX.h │ ├── NamimnoRC_FLASH_2400_RX_STM32.h │ ├── NamimnoRC_FLASH_2400_TX.h │ ├── NamimnoRC_VOYAGER_900_RX.h │ ├── NamimnoRC_VOYAGER_900_TX.h │ ├── Unified_ESP32_TX.h │ ├── Unified_ESP8285_TX.h │ └── Unified_ESP_RX.h └── targets.h ├── lib ├── AnalogVbat │ ├── devAnalogVbat.cpp │ ├── devAnalogVbat.h │ └── median.h ├── BLE │ ├── devBLE.cpp │ └── devBLE.h ├── BUTTON │ ├── button.h │ ├── devButton.cpp │ └── devButton.h ├── BUZZER │ ├── devBuzzer.cpp │ └── devBuzzer.h ├── Backpack │ ├── devBackpack.cpp │ └── devBackpack.h ├── Baro │ ├── baro_base.cpp │ ├── baro_base.h │ ├── baro_bmp085.cpp │ ├── baro_bmp085.h │ ├── baro_bmp085_regs.h │ ├── baro_bmp280.cpp │ ├── baro_bmp280.h │ ├── baro_bmp280_regs.h │ ├── baro_spl06.cpp │ ├── baro_spl06.h │ ├── baro_spl06_regs.h │ ├── devBaro.cpp │ └── devBaro.h ├── CONFIG │ ├── config.cpp │ ├── config.h │ └── config_legacy.h ├── CRC │ ├── crc.cpp │ └── crc.h ├── CRSF2MSP │ ├── crsf2msp.cpp │ ├── crsf2msp.h │ ├── crsfmsp_common.h │ ├── msp2crsf.cpp │ └── msp2crsf.h ├── CrsfProtocol │ ├── crsf_protocol.h │ └── dummy.c ├── Crypto │ ├── LICENSE │ ├── LICENSE.txt │ ├── README.md │ ├── keywords.txt │ ├── library.json │ ├── library.properties │ └── src │ │ ├── CTR.h │ │ ├── ChaCha.cpp │ │ ├── ChaCha.h │ │ ├── Cipher.cpp │ │ ├── Cipher.h │ │ ├── Crypto.cpp │ │ ├── Crypto.h │ │ └── utility │ │ ├── EndianUtil.h │ │ ├── LimbUtil.h │ │ ├── ProgMemUtil.h │ │ └── RotateUtil.h ├── DAC │ ├── DAC.cpp │ └── DAC.h ├── DEVICE │ ├── device.cpp │ └── device.h ├── FEC │ ├── COPYING │ ├── COPYING.LESSER │ ├── FEC.cpp │ ├── FEC.h │ ├── hamming.cpp │ └── hamming.h ├── FHSS │ ├── FHSS.cpp │ ├── FHSS.h │ ├── random.cpp │ └── random.h ├── FIFO │ └── FIFO.h ├── FSKRadioLib │ ├── FSK_SX127X.h │ └── FSK_SX127x.cpp ├── GSENSOR │ ├── devGsensor.cpp │ ├── devGsensor.h │ ├── gsensor.cpp │ ├── gsensor.h │ ├── stk8baxx.cpp │ └── stk8baxx.h ├── HWTIMER │ ├── ESP32_hwTimer.cpp │ ├── ESP8266_hwTimer.cpp │ ├── STM32_hwTimer.cpp │ └── hwTimer.h ├── Handset │ ├── AutoDetect.cpp │ ├── AutoDetect.h │ ├── CRSF.cpp │ ├── CRSF.h │ ├── CRSFHandset.cpp │ ├── CRSFHandset.h │ ├── PPMHandset.cpp │ ├── PPMHandset.h │ ├── devHandset.cpp │ ├── devHandset.h │ └── handset.h ├── LBT │ ├── LBT.cpp │ └── LBT.h ├── LED │ ├── STM32F3_WS2812B_LED.h │ ├── devLED.cpp │ ├── devLED.h │ ├── devRGB.cpp │ ├── esp32rgb.cpp │ └── esp32rgb.h ├── LQCALC │ └── LQCALC.h ├── LR1121Driver │ ├── LR1121.cpp │ ├── LR1121.h │ ├── LR1121Driver.h │ ├── LR1121_Regs.h │ ├── LR1121_hal.cpp │ └── LR1121_hal.h ├── LUA │ ├── devLUA.h │ ├── lua.cpp │ ├── lua.h │ ├── rx_devLUA.cpp │ ├── rxtx_devLua.cpp │ ├── rxtx_devLua.h │ └── tx_devLUA.cpp ├── MAVLink │ ├── MAVLink.cpp │ ├── MAVLink.h │ └── ardupilot_protocol.h ├── MSP │ ├── msp.cpp │ ├── msp.h │ └── msptypes.h ├── MSPVTX │ ├── devMSPVTX.cpp │ ├── devMSPVTX.h │ ├── freqTable.cpp │ └── freqTable.h ├── MeanAccumulator │ └── MeanAccumulator.h ├── OPTIONS │ ├── EspFlashStream.cpp │ ├── EspFlashStream.h │ ├── hardware.cpp │ ├── options.cpp │ └── options.h ├── OTA │ ├── OTA.cpp │ └── OTA.h ├── PFD │ └── PFD.h ├── POWERMGNT │ ├── POWERMGNT.cpp │ └── POWERMGNT.h ├── POWER_DETECT │ ├── devPDET.cpp │ └── devPDET.h ├── PWM │ ├── PWM.cpp │ ├── PWM.h │ ├── PWM_ESP32.cpp │ ├── PWM_ESP8266.cpp │ ├── waveform_8266.cpp │ └── waveform_8266.h ├── README ├── RFAMP │ ├── RFAMP_hal.cpp │ └── RFAMP_hal.h ├── SCREEN │ ├── FiveWayButton │ │ ├── FiveWayButton.cpp │ │ └── FiveWayButton.h │ ├── OLED │ │ ├── XBMStrings.h │ │ ├── oleddisplay.cpp │ │ └── oleddisplay.h │ ├── TFT │ │ ├── Pragma_Sans314pt7b.h │ │ ├── Pragma_Sans36pt7b.h │ │ ├── Pragma_Sans37pt7b.h │ │ ├── logos.h │ │ ├── tftdisplay.cpp │ │ └── tftdisplay.h │ ├── devScreen.cpp │ ├── devScreen.h │ ├── display.cpp │ ├── display.h │ ├── fsm.cpp │ ├── fsm.h │ ├── menu.cpp │ └── menu.h ├── SPIEx │ ├── SPIEx.cpp │ └── SPIEx.h ├── SX127xDriver │ ├── SX127x.cpp │ ├── SX127x.h │ ├── SX127xDriver.h │ ├── SX127xHal.cpp │ ├── SX127xHal.h │ ├── SX127xRegs.h │ └── license.txt ├── SX1280Driver │ ├── SX1280.cpp │ ├── SX1280.h │ ├── SX1280Driver.h │ ├── SX1280_Regs.h │ ├── SX1280_hal.cpp │ └── SX1280_hal.h ├── SX12xxDriverCommon │ └── SX12xxDriverCommon.h ├── SerialUpdate │ ├── devSerialUpdate.cpp │ ├── devSerialUpdate.h │ ├── slip.cpp │ ├── slip.h │ ├── soc_support.h │ ├── stub_commands.cpp │ ├── stub_commands.h │ ├── stub_flasher.cpp │ ├── stub_flasher.h │ ├── stub_write_flash.cpp │ └── stub_write_flash.h ├── ServoOutput │ ├── DShotRMT.cpp │ ├── DShotRMT.h │ ├── devServoOutput.cpp │ └── devServoOutput.h ├── StubbornReceiver │ ├── stubborn_receiver.cpp │ └── stubborn_receiver.h ├── StubbornSender │ ├── stubborn_sender.cpp │ └── stubborn_sender.h ├── TCPSOCKET │ ├── tcpsocket.cpp │ └── tcpsocket.h ├── THERMAL │ ├── devThermal.cpp │ ├── devThermal.h │ ├── lm75a.cpp │ ├── lm75a.h │ ├── rpm.cpp │ ├── thermal.cpp │ └── thermal.h ├── Telemetry │ ├── telemetry.cpp │ └── telemetry.h ├── TelemetryProtocol │ ├── dummy.c │ └── telemetry_protocol.h ├── VTX │ ├── devVTX.cpp │ └── devVTX.h ├── VTXSPI │ ├── devVTXSPI.cpp │ └── devVTXSPI.h ├── WIFI │ ├── devWIFI.cpp │ ├── devWIFI.h │ ├── lr1121.cpp │ ├── lr1121.h │ ├── wifiJoystick.cpp │ └── wifiJoystick.h ├── elrs_eeprom │ ├── elrs_eeprom.cpp │ └── elrs_eeprom.h └── logging │ ├── VA_OPT.h │ ├── logging.cpp │ └── logging.h ├── lua ├── ELRS.lua ├── README.md ├── elrsV3.lua └── mockup │ ├── README.md │ └── elrsmock.lua ├── platformio.ini ├── privacylrs └── screenshot_choose_local.png ├── python ├── BFinitPassthrough.py ├── ETXinitPassthrough.py ├── MANIFEST.in ├── SerialHelper.py ├── UARTupload.py ├── UnifiedConfiguration.py ├── __init__.py ├── __main__.py ├── binary_configurator.py ├── binary_flash.py ├── bind.py ├── bootloader.py ├── build_env_setup.py ├── build_flags.py ├── build_html.py ├── elrs_helpers.py ├── esp_compress.py ├── external │ ├── __init__.py │ ├── bottle.py │ ├── esptool │ │ ├── LICENSE │ │ ├── README.md │ │ ├── __init__.py │ │ ├── esptool.py │ │ └── esptool │ │ │ ├── __init__.py │ │ │ ├── __main__.py │ │ │ ├── bin_image.py │ │ │ ├── cmds.py │ │ │ ├── loader.py │ │ │ ├── targets │ │ │ ├── __init__.py │ │ │ ├── esp32.py │ │ │ ├── esp32c2.py │ │ │ ├── esp32c3.py │ │ │ ├── esp32c6beta.py │ │ │ ├── esp32h2beta1.py │ │ │ ├── esp32h2beta2.py │ │ │ ├── esp32s2.py │ │ │ ├── esp32s3.py │ │ │ ├── esp32s3beta2.py │ │ │ ├── esp8266.py │ │ │ └── stub_flasher │ │ │ │ ├── stub_flasher_32.json │ │ │ │ ├── stub_flasher_32c2.json │ │ │ │ ├── stub_flasher_32c3.json │ │ │ │ ├── stub_flasher_32c6beta.json │ │ │ │ ├── stub_flasher_32h2beta1.json │ │ │ │ ├── stub_flasher_32h2beta2.json │ │ │ │ ├── stub_flasher_32s2.json │ │ │ │ ├── stub_flasher_32s3.json │ │ │ │ ├── stub_flasher_32s3beta2.json │ │ │ │ └── stub_flasher_8266.json │ │ │ └── util.py │ ├── inputimeout │ │ ├── LICENSE │ │ ├── README.rst │ │ ├── __init__.py │ │ ├── __version__.py │ │ └── inputimeout.py │ ├── jmespath │ │ ├── __init__.py │ │ ├── ast.py │ │ ├── compat.py │ │ ├── exceptions.py │ │ ├── functions.py │ │ ├── lexer.py │ │ ├── parser.py │ │ └── visitor.py │ ├── minify │ │ ├── __init__.py │ │ ├── html_minifier.py │ │ ├── rcssmin.py │ │ ├── rjsmin.py │ │ └── variables.py │ ├── pystlink │ │ ├── __init__.py │ │ ├── bin │ │ │ ├── install.bat │ │ │ └── libusb-1.0.dll │ │ ├── lib │ │ │ ├── __init__.py │ │ │ ├── dbg.py │ │ │ ├── srec.py │ │ │ ├── stlinkex.py │ │ │ ├── stlinkusb.py │ │ │ ├── stlinkv2.py │ │ │ ├── stm32.py │ │ │ ├── stm32devices.py │ │ │ ├── stm32fp.py │ │ │ ├── stm32fs.py │ │ │ ├── stm32h7.py │ │ │ ├── stm32l0.py │ │ │ └── stm32l4.py │ │ ├── list_new_stm32.py │ │ ├── pystlink │ │ ├── pystlink_api.py │ │ └── stlinkv2.rules │ ├── rtttl.py │ ├── six.py │ ├── streamexpect.py │ ├── usb │ │ ├── __init__.py │ │ ├── _debug.py │ │ ├── _interop.py │ │ ├── _lookup.py │ │ ├── _objfinalizer.py │ │ ├── _version.py │ │ ├── backend │ │ │ ├── __init__.py │ │ │ ├── libusb0.py │ │ │ ├── libusb1.py │ │ │ └── openusb.py │ │ ├── control.py │ │ ├── core.py │ │ ├── legacy.py │ │ ├── libloader.py │ │ └── util.py │ ├── wheezy │ │ ├── __init__.py │ │ └── template │ │ │ ├── __init__.py │ │ │ ├── builder.py │ │ │ ├── comp.py │ │ │ ├── compiler.py │ │ │ ├── console.py │ │ │ ├── engine.py │ │ │ ├── ext │ │ │ ├── __init__.py │ │ │ ├── code.py │ │ │ ├── core.py │ │ │ ├── determined.py │ │ │ └── tests │ │ │ │ ├── __init__.py │ │ │ │ ├── test_code.py │ │ │ │ ├── test_core.py │ │ │ │ └── test_determined.py │ │ │ ├── lexer.py │ │ │ ├── loader.py │ │ │ ├── parser.py │ │ │ ├── preprocessor.py │ │ │ ├── py.typed │ │ │ ├── tests │ │ │ ├── __init__.py │ │ │ ├── test_builder.py │ │ │ ├── test_console.py │ │ │ ├── test_engine.py │ │ │ ├── test_lexer.py │ │ │ ├── test_loader.py │ │ │ ├── test_parser.py │ │ │ ├── test_preprocessor.py │ │ │ └── test_utils.py │ │ │ ├── typing.py │ │ │ └── utils.py │ └── xmodem.py ├── firmware.py ├── linspace_hopfreqs_gen_2400M.py ├── linspace_hopfreqs_gen_915AU.py ├── melodyparser.py ├── opentx.py ├── query_yes_no.py ├── randgentext_hopseq.py ├── serials_find.py ├── serve_html.py ├── set_model.py ├── setup.py ├── stlink.py ├── test_tools │ └── power_sweep.py ├── upload_stlink.py └── upload_via_esp8266_backpack.py ├── src ├── common.cpp ├── dynpower.cpp ├── hal │ └── hal_stm32.cpp ├── rx-serial │ ├── SerialAirPort.cpp │ ├── SerialAirPort.h │ ├── SerialCRSF.cpp │ ├── SerialCRSF.h │ ├── SerialHoTT_TLM.cpp │ ├── SerialHoTT_TLM.h │ ├── SerialIO.cpp │ ├── SerialIO.h │ ├── SerialMavlink.cpp │ ├── SerialMavlink.h │ ├── SerialNOOP.h │ ├── SerialSBUS.cpp │ ├── SerialSBUS.h │ ├── SerialSUMD.cpp │ ├── SerialSUMD.h │ ├── SerialSmartAudio.cpp │ ├── SerialSmartAudio.h │ ├── SerialTramp.cpp │ ├── SerialTramp.h │ ├── devSerialIO.cpp │ └── devSerialIO.h ├── rx_main.cpp ├── rxtx_common.cpp ├── test_main.cpp └── tx_main.cpp ├── targets ├── common.ini ├── diy_2400.ini ├── diy_900.ini ├── frsky.ini ├── happymodel_2400.ini ├── happymodel_900.ini ├── imrc.ini ├── namimnorc_2400.ini ├── namimnorc_900.ini ├── siyi.ini └── unified.ini ├── test ├── README ├── test_crc │ ├── test_crc.cpp │ ├── ucrc_t.cpp │ └── ucrc_t.h ├── test_crsf │ └── test_crsf.cpp ├── test_embedded │ ├── eeprom_tests.h │ ├── output_export.cpp │ ├── rx_sx1280_test.cpp │ ├── test_main.cpp │ └── tx_sx1280_test.cpp ├── test_fhss │ └── test_fhss.cpp ├── test_fifo │ └── test_fifo.cpp ├── test_fmap │ └── test_fmap.cpp ├── test_msp │ ├── encapsulated_msp_tests.cpp │ ├── mock_serial.h │ └── msp_tests.cpp ├── test_msp2crsf2msp │ └── test_msp2crsf2msp.cpp ├── test_msp_vtx │ └── msp_vtx_tests.cpp ├── test_ota │ ├── crsf_sysmocks.cpp │ ├── crsf_sysmocks.h │ └── test_switches.cpp ├── test_stubborn │ └── test_stubborn.cpp └── test_telemetry │ └── test_telemetry.cpp ├── user_defines.txt └── variants ├── FM30 ├── PeripheralPins.c ├── PinNamesVar.h ├── ldscript.ld ├── variant_FM30.cpp └── variant_FM30.h ├── FM30_mini ├── PeripheralPins.c ├── PinNamesVar.h ├── ldscript.ld ├── variant_FM30_MINI.cpp └── variant_FM30_MINI.h ├── GHOST_ATTO ├── PeripheralPins.c ├── PinNamesVar.h ├── ldscript.ld ├── variant_GHOST_ATTO.cpp └── variant_GHOST_ATTO.h ├── GHOST_TX ├── PeripheralPins.c ├── PinNamesVar.h ├── ldscript.ld ├── variant_GHOST_TX.cpp └── variant_GHOST_TX.h ├── L432K ├── PeripheralPins.c ├── PinNamesVar.h ├── ldscript.ld ├── variant_L432KB.cpp └── variant_L432KB.h ├── NamimnoRC_Alpha.ld ├── R9MM ├── PeripheralPins.c ├── PinNamesVar.h ├── R9MM_ldscript.ld ├── variant_R9MM.cpp └── variant_R9MM.h ├── R9M_Lite_Pro_ldscript.ld ├── R9M_ldscript.ld ├── R9M_ldscript_old_bl.ld ├── ldscript_gen.ld ├── r9mx ├── PeripheralPins.c ├── PinNamesVar.h ├── ldscript.ld ├── variant_R9MX.cpp └── variant_R9MX.h └── stm32f303xx.ld /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | open_collective: expresslrs 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/1-Bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: You found a bug in ExpressLRS. 🐞 4 | labels: 'bug' 5 | --- 6 | 7 | ## Current Behavior 8 | 9 | 10 | 11 | ## Steps to Reproduce 12 | 13 | 14 | 15 | 16 | 1. 17 | 18 | 2. 19 | 20 | 3. 21 | 22 | 4. 23 | 24 | ## Possible Solution (Not obligatory) 25 | 26 | 27 | 28 | ## Details 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | ## Your Environment 37 | 38 | 39 | 40 | - TX hardware: 41 | - RX hardware: 42 | - Handset model: 43 | - OpenTX version (including nightly number) 44 | - ExpressLRS version (TX & RX MUST MATCH): 45 | - Packet Rate: 46 | - Telemetry Ratio: 47 | - user_defines: 48 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: true 2 | contact_links: 3 | - name: Feature Requests 4 | url: https://github.com/ExpressLRS/ExpressLRS/discussions/new 5 | about: Request features in the ideas section of the disscussion 6 | - name: Community Discord 7 | url: https://discord.gg/dS6ReFY 8 | about: Please ask and answer questions here 9 | - name: Facebook Group 10 | url: https://www.facebook.com/groups/636441730280366 11 | about: Please ask and answer questions here 12 | - name: Website 13 | url: https://www.expresslrs.org/ 14 | about: If you look for information regarding ELRS, you will find it here 15 | -------------------------------------------------------------------------------- /.github/workflows/artifacts.yml: -------------------------------------------------------------------------------- 1 | name: Cleanup stale artifacts 2 | on: 3 | schedule: 4 | - cron: "30 2 * * *" 5 | 6 | jobs: 7 | cleanup-artifacts: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - name: Checkout code 11 | uses: actions/checkout@v4 12 | with: 13 | fetch-depth: 0 14 | 15 | - name: Remove stale artifacts from R2 16 | env: 17 | AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} 18 | AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} 19 | AWS_ENDPOINT_URL: ${{ secrets.AWS_ENDPOINT_URL }} 20 | AWS_REGION: "auto" 21 | run: | 22 | if [[ -z $AWS_ACCESS_KEY_ID || -z $AWS_SECRET_ACCESS_KEY || -z $AWS_ENDPOINT_URL ]]; then 23 | echo "Artifactory credentials are not defined. Most likely action is running from pull request. Not a bug." 24 | exit 0 25 | fi 26 | 27 | echo "Generating artifact index" 28 | aws s3 ls --endpoint-url $AWS_ENDPOINT_URL s3://expresslrs/ExpressLRS/ | grep PRE | awk '{print $2}' | sed s/\\/// > /tmp/artifacts 29 | 30 | git branch --list --remotes --format '%(objectname)' > /tmp/hashes 31 | git tag --list --format '%(objectname)' >> /tmp/hashes 32 | 33 | for i in `grep -v -f /tmp/hashes /tmp/artifacts`; do 34 | aws s3 rm --recursive --endpoint-url $AWS_ENDPOINT_URL s3://expresslrs/ExpressLRS/$i 35 | done 36 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: Close inactive issues 2 | on: 3 | schedule: 4 | - cron: "30 1 * * *" 5 | 6 | jobs: 7 | close-issues: 8 | runs-on: ubuntu-latest 9 | permissions: 10 | issues: write 11 | pull-requests: write 12 | steps: 13 | - uses: actions/stale@v9 14 | with: 15 | days-before-issue-stale: -1 16 | days-before-issue-close: 12 17 | stale-issue-label: "closing :door:" 18 | close-issue-message: "This issue was closed because it has been inactive for 12 days since being marked as closing." 19 | days-before-pr-stale: -1 20 | days-before-pr-close: -1 21 | repo-token: ${{ secrets.GITHUB_TOKEN }} 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | oldcode/oldcode.txt 3 | oldcode/ESP8266_OStimer.cpp 4 | oldcode/ESP8266_OStimer.h 5 | src/firmware.map 6 | src/src/fhss_freqs.h 7 | src/.vscode 8 | src/data/*.ini 9 | src/data/*.json 10 | src/hardware 11 | -------------------------------------------------------------------------------- /src/.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: Microsoft 2 | ColumnLimit: 0 3 | AccessModifierOffset: -4 4 | IndentWidth: 4 5 | AllowShortFunctionsOnASingleLine: Inline 6 | -------------------------------------------------------------------------------- /src/.editorconfig: -------------------------------------------------------------------------------- 1 | # top-most EditorConfig file 2 | root = true 3 | 4 | # Unix-style newlines with a newline ending every file 5 | [*] 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | end_of_line = lf 9 | insert_final_newline = true 10 | 11 | # Tab indentation (no size specified) 12 | [Makefile] 13 | indent_style = tab 14 | 15 | [*.{c,h,cpp,hpp}] 16 | indent_size = 4 17 | 18 | [tx_main.cpp] 19 | indent_size = 2 20 | -------------------------------------------------------------------------------- /src/.gitattributes: -------------------------------------------------------------------------------- 1 | VERSION export-subst 2 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | .pioenvs 3 | .piolibdeps 4 | .vscode/.browse.c_cpp.db* 5 | .vscode/c_cpp_properties.json 6 | .vscode/launch.json 7 | python/__pycache__/ 8 | *.pyc 9 | super_defines.txt 10 | include/WebContent.h 11 | include/flashdiscrim.h 12 | .DS_Store 13 | -------------------------------------------------------------------------------- /src/VERSION: -------------------------------------------------------------------------------- 1 | commit 8132761da5 2 | -------------------------------------------------------------------------------- /src/boards/FM30.json: -------------------------------------------------------------------------------- 1 | { 2 | "comment": "STM32F103C8 definition for use with 16MHz crystal (DIV2 prescaler)", 3 | "build": { 4 | "core": "stm32", 5 | "extra_flags": "-DSTM32F103xB", 6 | "cpu": "cortex-m3", 7 | "f_cpu": "72000000L", 8 | "ldscript": "variants/FM30/ldscript.ld", 9 | "mcu": "stm32f103c8t6", 10 | "variants_dir": "variants", 11 | "variant": "FM30" 12 | }, 13 | "debug": { 14 | "default_tools": [ 15 | "stlink" 16 | ], 17 | "jlink_device": "STM32F103C8", 18 | "openocd_extra_args": [ 19 | "-c", 20 | "reset_config none" 21 | ], 22 | "openocd_target": "stm32f1x", 23 | "svd_path": "STM32F103xx.svd" 24 | }, 25 | "frameworks": [ 26 | "arduino", 27 | "mbed", 28 | "cmsis", 29 | "libopencm3", 30 | "stm32cube" 31 | ], 32 | "name": "FM30", 33 | "upload": { 34 | "maximum_ram_size": 20480, 35 | "maximum_size": 65536, 36 | "protocol": "stlink", 37 | "protocols": [ 38 | "jlink", 39 | "cmsis-dap", 40 | "stlink", 41 | "blackmagic", 42 | "mbed", 43 | "dfu" 44 | ] 45 | }, 46 | "url": "http://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32f1-series/stm32f103/stm32f103c8.html", 47 | "vendor": "Generic" 48 | } 49 | -------------------------------------------------------------------------------- /src/boards/FM30_mini.json: -------------------------------------------------------------------------------- 1 | { 2 | "comment": "STM32F373CC definition for use with 16MHz crystal (DIV2 prescaler)", 3 | "build": { 4 | "cpu": "cortex-m4", 5 | "extra_flags": "-DSTM32F3 -DSTM32F373xC", 6 | "f_cpu": "72000000L", 7 | "ldscript": "variants/FM30_mini/ldscript.ld", 8 | "mcu": "stm32f373cct6", 9 | "product_line": "STM32F373xC", 10 | "variants_dir": "variants", 11 | "variant": "FM30_mini" 12 | }, 13 | "connectivity": [ 14 | "can" 15 | ], 16 | "debug": { 17 | "jlink_device": "STM32F373CC", 18 | "openocd_target": "stm32f3x", 19 | "svd_path": "STM32F30x.svd" 20 | }, 21 | "frameworks": [ 22 | "cmsis", 23 | "stm32cube", 24 | "libopencm3", 25 | "arduino" 26 | ], 27 | "name": "FM30_mini", 28 | "upload": { 29 | "maximum_ram_size": 32768, 30 | "maximum_size": 262144, 31 | "protocol": "stlink", 32 | "protocols": [ 33 | "jlink", 34 | "cmsis-dap", 35 | "stlink", 36 | "blackmagic" 37 | ] 38 | }, 39 | "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32f373.html", 40 | "vendor": "ST" 41 | } 42 | -------------------------------------------------------------------------------- /src/boards/GHOST_ATTO.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "cpu": "cortex-m4", 4 | "extra_flags": "-DSTM32F301x8=1 -DSTM32F3xx=1 -DSTM32F301=1", 5 | "f_cpu": "72000000L", 6 | "ldscript": "ldscript.ld", 7 | "mcu": "stm32f301k8", 8 | "product_line": "STM32F301x8", 9 | "variants_dir": "variants", 10 | "variant": "GHOST_ATTO" 11 | }, 12 | "connectivity": [ 13 | "can" 14 | ], 15 | "debug": { 16 | "default_tools": [ 17 | "stlink" 18 | ], 19 | "jlink_device": "STM32F301K8", 20 | "onboard_tools": [ 21 | "stlink" 22 | ], 23 | "openocd_board": "st_nucleo_f3", 24 | "svd_path": "STM32F30x.svd" 25 | }, 26 | "frameworks": [ 27 | "arduino", 28 | "cmsis", 29 | "mbed", 30 | "stm32cube", 31 | "libopencm3" 32 | ], 33 | "name": "STM32F301K8", 34 | "upload": { 35 | "maximum_ram_size": 16384, 36 | "maximum_size": 65536, 37 | "protocol": "stlink", 38 | "protocols": [ 39 | "jlink", 40 | "stlink", 41 | "blackmagic", 42 | "mbed" 43 | ] 44 | }, 45 | "url": "https://www.st.com/content/st_com/en/products/microcontrollers-microprocessors/stm32-32-bit-arm-cortex-mcus/stm32-mainstream-mcus/stm32f3-series/stm32f301/stm32f301k8.html", 46 | "vendor": "ST" 47 | } 48 | -------------------------------------------------------------------------------- /src/boards/GHOST_TX.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "core": "stm32", 4 | "cpu": "cortex-m4", 5 | "extra_flags": "-DSTM32F3 -DSTM32F303xC -DBLACKPILL_F303CC", 6 | "f_cpu": "72000000L", 7 | "ldscript": "ldscript.ld", 8 | "mcu": "stm32f303cct6", 9 | "product_line": "STM32F303xC", 10 | "variants_dir": "variants", 11 | "variant": "GHOST_TX" 12 | }, 13 | "connectivity": [ 14 | "can" 15 | ], 16 | "debug": { 17 | "jlink_device": "STM32F303CC", 18 | "openocd_target": "stm32f3x", 19 | "svd_path": "STM32F30x.svd" 20 | }, 21 | "frameworks": [ 22 | "arduino", 23 | "cmsis", 24 | "stm32cube", 25 | "libopencm3" 26 | ], 27 | "name": "GHOST TX", 28 | "upload": { 29 | "maximum_ram_size": 40960, 30 | "maximum_size": 245760, 31 | "protocol": "stlink", 32 | "protocols": [ 33 | "jlink", 34 | "stlink", 35 | "blackmagic" 36 | ] 37 | }, 38 | "url": "https://www.immersionrc.com/fpv-products/ghost/", 39 | "vendor": "ImmersionRC" 40 | } 41 | -------------------------------------------------------------------------------- /src/boards/R9MM.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "core": "stm32", 4 | "cpu": "cortex-m3", 5 | "extra_flags": "-DSTM32F103xB", 6 | "f_cpu": "72000000L", 7 | "ldscript": "variants/R9MM/R9MM_ldscript.ld", 8 | "mcu": "stm32f103rbt6", 9 | "variants_dir": "variants", 10 | "variant": "R9MM" 11 | }, 12 | "debug": { 13 | "default_tools": [ 14 | "stlink" 15 | ], 16 | "jlink_device": "STM32F103RB", 17 | "onboard_tools": [ 18 | "stlink" 19 | ], 20 | "openocd_board": "st_nucleo_f103rb", 21 | "svd_path": "STM32F103xx.svd" 22 | }, 23 | "frameworks": [ 24 | "arduino", 25 | "mbed", 26 | "libopencm3", 27 | "stm32cube", 28 | "zephyr" 29 | ], 30 | "name": "R9MM receiver", 31 | "upload": { 32 | "maximum_ram_size": 20480, 33 | "maximum_size": 98304, 34 | "protocol": "custom", 35 | "protocols": [ 36 | "jlink", 37 | "stlink", 38 | "blackmagic", 39 | "mbed" 40 | ] 41 | }, 42 | "url": "https://developer.mbed.org/platforms/ST-Nucleo-F103RB/", 43 | "vendor": "ST" 44 | } 45 | -------------------------------------------------------------------------------- /src/boards/esp8285-8285.json: -------------------------------------------------------------------------------- 1 | { 2 | "comment": "esp8285 variant for ExpressLRS that uses variant=esp8285 instead of variant=generic", 3 | "build": { 4 | "arduino": { 5 | "ldscript": "eagle.flash.1m256.ld" 6 | }, 7 | "core": "esp8266", 8 | "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_ESP01", 9 | "f_cpu": "80000000L", 10 | "f_flash": "40000000L", 11 | "flash_mode": "dout", 12 | "mcu": "esp8266", 13 | "variant": "esp8285" 14 | }, 15 | "connectivity": [ 16 | "wifi" 17 | ], 18 | "frameworks": [ 19 | "arduino", 20 | "esp8266-rtos-sdk", 21 | "esp8266-nonos-sdk" 22 | ], 23 | "name": "Generic ESP8285 Module", 24 | "upload": { 25 | "maximum_ram_size": 81920, 26 | "maximum_size": 1048576, 27 | "require_upload_port": true, 28 | "resetmethod": "ck", 29 | "speed": 115200 30 | }, 31 | "url": "http://www.esp8266.com/wiki/doku.php?id=esp8266-module-family", 32 | "vendor": "Espressif" 33 | } 34 | -------------------------------------------------------------------------------- /src/boards/l432kb.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "cpu": "cortex-m4", 4 | "extra_flags": "-DSTM32L432xx", 5 | "f_cpu": "80000000L", 6 | "mcu": "stm32l432kbu6", 7 | "product_line": "STM32L432xx", 8 | "ldscript": "ldscript.ld", 9 | "variants_dir": "variants", 10 | "variant": "L432K" 11 | }, 12 | "debug": { 13 | "default_tools": [ 14 | "stlink" 15 | ], 16 | "jlink_device": "STM32L432KB", 17 | "onboard_tools": [ 18 | "stlink" 19 | ], 20 | "openocd_target": "stm32l4x", 21 | "svd_path": "STM32L4x2.svd" 22 | }, 23 | "frameworks": [ 24 | "arduino", 25 | "cmsis", 26 | "stm32cube" 27 | ], 28 | "name": "CCG ExLRS 2.4G Nano RX", 29 | "upload": { 30 | "maximum_ram_size": 65536, 31 | "maximum_size": 131072, 32 | "protocol": "stlink", 33 | "protocols": [ 34 | "jlink", 35 | "stlink", 36 | "blackmagic", 37 | "mbed" 38 | ] 39 | }, 40 | "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32l432kb.html", 41 | "vendor": "ST" 42 | } 43 | -------------------------------------------------------------------------------- /src/boards/r9mx.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "core": "stm32", 4 | "cpu": "cortex-m4", 5 | "extra_flags": "-DSTM32L4xx -DSTM32L43x -DSTM32L433xx", 6 | "f_cpu": "80000000L", 7 | "ldscript": "variants/r9mx/ldscript.ld", 8 | "mcu": "stm32l433cby6", 9 | "product_line": "STM32L433xx", 10 | "variants_dir": "variants", 11 | "variant": "r9mx" 12 | }, 13 | "debug": { 14 | "default_tools": [ 15 | "stlink" 16 | ], 17 | "jlink_device": "STM32L433CB", 18 | "onboard_tools": [ 19 | "stlink" 20 | ], 21 | "openocd_board": "st_nucleo_l4", 22 | "svd_path": "STM32L4x3.svd" 23 | }, 24 | "frameworks": [ 25 | "arduino", 26 | "cmsis", 27 | "mbed", 28 | "stm32cube" 29 | ], 30 | "name": "FrSky R9MX receiver", 31 | "upload": { 32 | "maximum_ram_size": 65536, 33 | "maximum_size": 98304, 34 | "protocol": "custom", 35 | "protocols": [ 36 | "jlink", 37 | "stlink", 38 | "blackmagic", 39 | "mbed" 40 | ] 41 | }, 42 | "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32l433cb.html", 43 | "vendor": "ST" 44 | } 45 | -------------------------------------------------------------------------------- /src/bootloader/bluepill_bootloader.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/bluepill_bootloader.bin -------------------------------------------------------------------------------- /src/bootloader/erase_chip.bat: -------------------------------------------------------------------------------- 1 | ST-LINK_CLI.exe -c SWD SWCLK=8 -ME -------------------------------------------------------------------------------- /src/bootloader/firmware.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/firmware.bin -------------------------------------------------------------------------------- /src/bootloader/flashbootloader.bat: -------------------------------------------------------------------------------- 1 | ST-LINK_CLI.exe -c -ME SWD SWCLK=8 -P bootloader.hex -RST -------------------------------------------------------------------------------- /src/bootloader/fm30_bootloader.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/fm30_bootloader.bin -------------------------------------------------------------------------------- /src/bootloader/fm30_mini_bootloader.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/fm30_mini_bootloader.bin -------------------------------------------------------------------------------- /src/bootloader/fm30_mini_rxtx_bootloader.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/fm30_mini_rxtx_bootloader.bin -------------------------------------------------------------------------------- /src/bootloader/ghost/bl_ghost_atto.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/ghost/bl_ghost_atto.bin -------------------------------------------------------------------------------- /src/bootloader/ghost/ghost_atto_bootloader.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/ghost/ghost_atto_bootloader.bin -------------------------------------------------------------------------------- /src/bootloader/ghost/ghost_tx_bootloader.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/ghost/ghost_tx_bootloader.bin -------------------------------------------------------------------------------- /src/bootloader/jumper_r900_bootloader.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/jumper_r900_bootloader.bin -------------------------------------------------------------------------------- /src/bootloader/jumper_r900_no_btn_bootloader.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/jumper_r900_no_btn_bootloader.bin -------------------------------------------------------------------------------- /src/bootloader/namimnorc/rx/flash_2400_bootloader.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/namimnorc/rx/flash_2400_bootloader.bin -------------------------------------------------------------------------------- /src/bootloader/namimnorc/rx/voyager_900_bootloader.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/namimnorc/rx/voyager_900_bootloader.bin -------------------------------------------------------------------------------- /src/bootloader/namimnorc/tx/namimnorc_tx_bootloader.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/namimnorc/tx/namimnorc_tx_bootloader.bin -------------------------------------------------------------------------------- /src/bootloader/r9m_bootloader.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/r9m_bootloader.bin -------------------------------------------------------------------------------- /src/bootloader/r9m_elrs_bl.frk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/r9m_elrs_bl.frk -------------------------------------------------------------------------------- /src/bootloader/r9m_lite_pro_bootloader.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/r9m_lite_pro_bootloader.bin -------------------------------------------------------------------------------- /src/bootloader/r9mm_bootloader.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/r9mm_bootloader.bin -------------------------------------------------------------------------------- /src/bootloader/r9mm_elrs_bl.frk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/r9mm_elrs_bl.frk -------------------------------------------------------------------------------- /src/bootloader/r9mm_no_btn_bootloader.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/r9mm_no_btn_bootloader.bin -------------------------------------------------------------------------------- /src/bootloader/r9mm_no_btn_elrs_bl.frk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/r9mm_no_btn_elrs_bl.frk -------------------------------------------------------------------------------- /src/bootloader/r9mx_bootloader.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/r9mx_bootloader.bin -------------------------------------------------------------------------------- /src/bootloader/r9mx_elrs_bl.frk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/r9mx_elrs_bl.frk -------------------------------------------------------------------------------- /src/bootloader/r9mx_no_btn_bootloader.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/r9mx_no_btn_bootloader.bin -------------------------------------------------------------------------------- /src/bootloader/r9mx_no_btn_elrs_bl.frk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/r9mx_no_btn_elrs_bl.frk -------------------------------------------------------------------------------- /src/bootloader/r9slim_bootloader.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/r9slim_bootloader.bin -------------------------------------------------------------------------------- /src/bootloader/r9slim_elrs_bl.frk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/r9slim_elrs_bl.frk -------------------------------------------------------------------------------- /src/bootloader/r9slim_no_btn_bootloader.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/r9slim_no_btn_bootloader.bin -------------------------------------------------------------------------------- /src/bootloader/r9slim_no_btn_elrs_bl.frk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/r9slim_no_btn_elrs_bl.frk -------------------------------------------------------------------------------- /src/bootloader/r9slim_plus_bootloader.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/r9slim_plus_bootloader.bin -------------------------------------------------------------------------------- /src/bootloader/r9slim_plus_elrs_bl.frk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/r9slim_plus_elrs_bl.frk -------------------------------------------------------------------------------- /src/bootloader/r9slim_plus_ota_bootloader.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/r9slim_plus_ota_bootloader.bin -------------------------------------------------------------------------------- /src/bootloader/r9slim_plus_ota_elrs_bl.frk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/r9slim_plus_ota_elrs_bl.frk -------------------------------------------------------------------------------- /src/bootloader/reboot_chip.bat: -------------------------------------------------------------------------------- 1 | ST-LINK_CLI.exe -RST -------------------------------------------------------------------------------- /src/bootloader/src/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /src/bootloader/src/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | .vscode/.browse.c_cpp.db* 3 | .vscode/c_cpp_properties.json 4 | .vscode/launch.json 5 | .vscode/ipch 6 | *.code-workspace 7 | .vscode 8 | __pycache__ 9 | *.pyc 10 | *.map 11 | binaries 12 | -------------------------------------------------------------------------------- /src/bootloader/src/README.md: -------------------------------------------------------------------------------- 1 | # Bootloader 2 | Supports Express LRS application code update using XMODEM protocol. 3 | 4 | 5 | This version forked from nice [STM32-bootloader](https://github.com/ferenc-nemeth/stm32-bootloader) project. 6 | 7 | Big thanks to original author @ferenc-nemeth ! 8 | -------------------------------------------------------------------------------- /src/bootloader/src/Src/frsky.h: -------------------------------------------------------------------------------- 1 | #ifndef FRSKY_H_ 2 | #define FRSKY_H_ 3 | 4 | #include 5 | 6 | int8_t frsky_check(void); 7 | 8 | #endif /* FRSKY_H_ */ 9 | -------------------------------------------------------------------------------- /src/bootloader/src/Src/irq.h: -------------------------------------------------------------------------------- 1 | // Definitions for irq enable/disable on ARM Cortex-M processors 2 | // 3 | // Copyright (C) 2019 Kevin O'Connor 4 | // https://github.com/KevinOConnor/klipper 5 | // 6 | // This file may be distributed under the terms of the GNU GPLv3 license. 7 | 8 | #ifndef __GENERIC_IRQ_H 9 | #define __GENERIC_IRQ_H 10 | 11 | #include 12 | 13 | #ifdef __cplusplus 14 | extern "C" 15 | { 16 | #endif 17 | 18 | typedef unsigned long irqstatus_t; 19 | 20 | void irq_disable(void); 21 | void irq_enable(void); 22 | irqstatus_t irq_save(void); 23 | void irq_restore(irqstatus_t flag); 24 | void irq_wait(void); 25 | void irq_poll(void); 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | 30 | #endif // irq.h 31 | -------------------------------------------------------------------------------- /src/bootloader/src/Src/led.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_H_ 2 | #define __LED_H_ 3 | 4 | #include 5 | 6 | #if defined(WS2812_LED_PIN) 7 | void ws2812_init(void); 8 | void ws2812_set_color(uint8_t const r, uint8_t const g, uint8_t const b); 9 | void ws2812_set_color_u32(uint32_t const rgb); 10 | #else 11 | #define ws2812_init() 12 | #define ws2812_set_color(...) 13 | #define ws2812_set_color_u32(...) 14 | #endif 15 | #endif /* __LED_H_ */ 16 | -------------------------------------------------------------------------------- /src/bootloader/src/Src/syscalls.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/src/Src/syscalls.c -------------------------------------------------------------------------------- /src/bootloader/src/Src/uart.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file uart.h 3 | * @author Ferenc Nemeth 4 | * @date 21 Dec 2018 5 | * @brief This module is a layer between the HAL UART functions and my Xmodem protocol. 6 | * 7 | * Copyright (c) 2018 Ferenc Nemeth - https://github.com/ferenc-nemeth 8 | */ 9 | 10 | #ifndef UART_H_ 11 | #define UART_H_ 12 | 13 | #include 14 | 15 | /* Timeout for HAL. */ 16 | #define UART_TIMEOUT ((uint16_t)2000u) 17 | 18 | /* Status report for the functions. */ 19 | typedef enum 20 | { 21 | UART_OK = 0x00u, /**< The action was successful. */ 22 | UART_ERROR = 0xFFu /**< Generic error. */ 23 | } uart_status; 24 | 25 | uart_status uart_clear(void); 26 | uart_status uart_receive(uint8_t *data, uint16_t length); 27 | uart_status uart_receive_timeout(uint8_t *data, uint16_t length, uint16_t timeout); 28 | uart_status uart_transmit_str(char * data); 29 | uart_status uart_transmit_ch(uint8_t data); 30 | uart_status uart_transmit_bytes(uint8_t *data, uint32_t len); 31 | 32 | void uart_init(uint32_t baud, int32_t rx_pin, int32_t tx_pin, 33 | int32_t duplexpin, int8_t inverted); 34 | void uart_deinit(void); 35 | 36 | #endif /* UART_H_ */ 37 | -------------------------------------------------------------------------------- /src/bootloader/src/boards/rak4200.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "core": "stm32", 4 | "cpu": "cortex-m0plus", 5 | "extra_flags": "-DSTM32L0xx -DSTM32L071xx", 6 | "f_cpu": "32000000L", 7 | "framework_extra_flags": { 8 | "arduino": "-D__CORTEX_SC=0" 9 | }, 10 | "mcu": "stm32l071k8", 11 | "product_line": "STM32L07xkB", 12 | "variant": "RAK4200" 13 | }, 14 | "connectivity": [ 15 | "can" 16 | ], 17 | "debug": { 18 | "jlink_device": "STM32L071K8", 19 | "openocd_target": "stm32l0x", 20 | "svd_path": "STM32L071x.svd" 21 | }, 22 | "frameworks": [ 23 | "arduino", 24 | "cmsis", 25 | "stm32cube" 26 | ], 27 | "name": "RAK4200", 28 | "upload": { 29 | "maximum_ram_size": 20480, 30 | "maximum_size": 65536, 31 | "protocol": "serial", 32 | "protocols": [ 33 | "jlink", 34 | "stlink", 35 | "blackmagic", 36 | "dfu", 37 | "serial" 38 | ] 39 | }, 40 | "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32l071k8.html", 41 | "vendor": "ST" 42 | } 43 | -------------------------------------------------------------------------------- /src/bootloader/src/boards/stm32f103c8.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "core": "stm32", 4 | "cpu": "cortex-m3", 5 | "extra_flags": "-DSTM32F1=1 -DSTM32F1xx=1 -DSTM32F103xB=1 -DARDUINO_BLUEPILL_F103C8=1", 6 | "f_cpu": "72000000L", 7 | "hwids": [ 8 | [ 9 | "0x1EAF", 10 | "0x0003" 11 | ], 12 | [ 13 | "0x1EAF", 14 | "0x0004" 15 | ] 16 | ], 17 | "ldscript": "linker/stm32.ld", 18 | "mcu": "stm32f103c8t6", 19 | "product_line": "STM32F103xB", 20 | "variants_dir": "variants", 21 | "variant": "F103XX", 22 | "zephyr": { 23 | "variant": "stm32_min_dev_blue" 24 | } 25 | }, 26 | "debug": { 27 | "default_tools": [ 28 | "stlink" 29 | ], 30 | "jlink_device": "STM32F103C8", 31 | "openocd_extra_args": [ 32 | "-c", 33 | "reset_config none" 34 | ], 35 | "openocd_target": "stm32f1x", 36 | "svd_path": "STM32F103xx.svd" 37 | }, 38 | "frameworks": [ 39 | "arduino", 40 | "cmsis", 41 | "libopencm3", 42 | "stm32cube", 43 | "zephyr" 44 | ], 45 | "name": "BL_F103C8", 46 | "upload": { 47 | "maximum_ram_size": 20480, 48 | "maximum_size": 16384, 49 | "protocol": "stlink", 50 | "protocols": [ 51 | "jlink", 52 | "stlink", 53 | "blackmagic", 54 | "dfu" 55 | ] 56 | }, 57 | "url": "http://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32f1-series/stm32f103/stm32f103c8.html", 58 | "vendor": "Generic" 59 | } 60 | -------------------------------------------------------------------------------- /src/bootloader/src/boards/stm32f301.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "cpu": "cortex-m4", 4 | "extra_flags": "-DSTM32F301x8=1 -DSTM32F3xx=1 -DSTM32F301=1", 5 | "f_cpu": "72000000L", 6 | "mcu": "stm32f301k8", 7 | "product_line": "STM32F301x8", 8 | "variant": "STM32F301K8" 9 | }, 10 | "connectivity": [ 11 | "can" 12 | ], 13 | "debug": { 14 | "default_tools": [ 15 | "stlink" 16 | ], 17 | "jlink_device": "STM32F301K8", 18 | "onboard_tools": [ 19 | "stlink" 20 | ], 21 | "openocd_board": "st_nucleo_f3", 22 | "svd_path": "STM32F30x.svd" 23 | }, 24 | "frameworks": [ 25 | "arduino", 26 | "cmsis", 27 | "mbed", 28 | "stm32cube" 29 | ], 30 | "name": "STM32F301K8", 31 | "upload": { 32 | "maximum_ram_size": 16384, 33 | "maximum_size": 65536, 34 | "protocol": "stlink", 35 | "protocols": [ 36 | "jlink", 37 | "stlink", 38 | "blackmagic", 39 | "mbed" 40 | ] 41 | }, 42 | "url": "https://www.st.com/content/st_com/en/products/microcontrollers-microprocessors/stm32-32-bit-arm-cortex-mcus/stm32-mainstream-mcus/stm32f3-series/stm32f301/stm32f301k8.html", 43 | "vendor": "ST" 44 | } 45 | -------------------------------------------------------------------------------- /src/bootloader/src/boards/stm32f302.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "core": "stm32", 4 | "cpu": "cortex-m4", 5 | "extra_flags": "-DSTM32F302xC=1 -DSTM32F3xx=1 -DSTM32F302=1", 6 | "f_cpu": "72000000L", 7 | "mcu": "stm32f302cct6", 8 | "product_line": "STM32F302xC", 9 | "variant": "STM32F302CC" 10 | }, 11 | "connectivity": [ 12 | "can" 13 | ], 14 | "debug": { 15 | "default_tools": [ 16 | "stlink" 17 | ], 18 | "jlink_device": "STM32F302CC", 19 | "openocd_target": "stm32f3x", 20 | "svd_path": "STM32F30x.svd" 21 | }, 22 | "frameworks": [ 23 | "arduino", 24 | "cmsis", 25 | "mbed", 26 | "stm32cube" 27 | ], 28 | "name": "STM32F302CC", 29 | "upload": { 30 | "maximum_ram_size": 40960, 31 | "maximum_size": 262144, 32 | "protocol": "stlink", 33 | "protocols": [ 34 | "jlink", 35 | "stlink", 36 | "blackmagic", 37 | "mbed" 38 | ] 39 | }, 40 | "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32f302cc.html", 41 | "vendor": "ST" 42 | } 43 | -------------------------------------------------------------------------------- /src/bootloader/src/boards/stm32f303.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "core": "stm32", 4 | "cpu": "cortex-m4", 5 | "extra_flags": "-DSTM32F303xC=1 -DSTM32F3xx=1 -DSTM32F303=1", 6 | "f_cpu": "72000000L", 7 | "mcu": "stm32f303cct6", 8 | "product_line": "STM32F303xC", 9 | "variant": "STM32F303CC" 10 | }, 11 | "connectivity": [ 12 | "can" 13 | ], 14 | "debug": { 15 | "default_tools": [ 16 | "stlink" 17 | ], 18 | "jlink_device": "STM32F303CC", 19 | "openocd_target": "stm32f3x", 20 | "svd_path": "STM32F30x.svd" 21 | }, 22 | "frameworks": [ 23 | "arduino", 24 | "cmsis", 25 | "mbed", 26 | "stm32cube" 27 | ], 28 | "name": "STM32F303CC", 29 | "upload": { 30 | "maximum_ram_size": 40960, 31 | "maximum_size": 262144, 32 | "protocol": "stlink", 33 | "protocols": [ 34 | "jlink", 35 | "stlink", 36 | "blackmagic", 37 | "mbed" 38 | ] 39 | }, 40 | "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32f303cc.html", 41 | "vendor": "ST" 42 | } 43 | -------------------------------------------------------------------------------- /src/bootloader/sx1272_pcb_bootloader.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/sx1272_pcb_bootloader.bin -------------------------------------------------------------------------------- /src/bootloader/sx1280_rx_2020_pcb_v0.2_bootloader.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/sx1280_rx_2020_pcb_v0.2_bootloader.bin -------------------------------------------------------------------------------- /src/bootloader/sx1280_rx_nano_pcb_v0.5_bootloader.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/bootloader/sx1280_rx_nano_pcb_v0.5_bootloader.bin -------------------------------------------------------------------------------- /src/elrs.flash.1m64.ld: -------------------------------------------------------------------------------- 1 | /* Flash Split for 1M chips */ 2 | /* sketch @0x40200000 (~967KB) (991216B) */ 3 | /* empty @0x402F1FF0 (~4KB) (4112B) */ 4 | /* spiffs @0x402F3000 (~32KB) (32768B) */ 5 | /* eeprom @0x402FB000 (4KB) */ 6 | /* rfcal @0x402FC000 (4KB) */ 7 | /* wifi @0x402FD000 (12KB) */ 8 | 9 | MEMORY 10 | { 11 | dport0_0_seg : org = 0x3FF00000, len = 0x10 12 | dram0_0_seg : org = 0x3FFE8000, len = 0x14000 13 | irom0_0_seg : org = 0x40201010, len = 0xF1ff0 14 | } 15 | 16 | PROVIDE ( _FS_start = 0x402F3000 ); 17 | PROVIDE ( _FS_end = 0x402FB000 ); 18 | PROVIDE ( _FS_page = 0x100 ); 19 | PROVIDE ( _FS_block = 0x1000 ); 20 | PROVIDE ( _EEPROM_start = 0x402fb000 ); 21 | /* The following symbols are DEPRECATED and will be REMOVED in a future release */ 22 | PROVIDE ( _SPIFFS_start = 0x402F3000 ); 23 | PROVIDE ( _SPIFFS_end = 0x402FB000 ); 24 | PROVIDE ( _SPIFFS_page = 0x100 ); 25 | PROVIDE ( _SPIFFS_block = 0x1000 ); 26 | 27 | INCLUDE "local.eagle.app.v6.common.ld" 28 | -------------------------------------------------------------------------------- /src/html/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | env: 2 | browser: true 3 | es2021: true 4 | extends: 5 | - google 6 | parserOptions: 7 | ecmaVersion: latest 8 | rules: {} 9 | -------------------------------------------------------------------------------- /src/include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /src/include/deferred.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | void deferExecutionMicros(unsigned long us, std::function f); 6 | void executeDeferredFunction(unsigned long now); 7 | 8 | static inline void deferExecutionMillis(unsigned long ms, std::function f) 9 | { 10 | deferExecutionMicros(ms * 1000, f); 11 | } -------------------------------------------------------------------------------- /src/include/dynpower.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #if defined(TARGET_TX) 10 | 11 | #include 12 | 13 | #define DYNPOWER_UPDATE_NOUPDATE -128 14 | #define DYNPOWER_UPDATE_MISSED -127 15 | 16 | // Call DynamicPower_Init in setup() 17 | void DynamicPower_Init(); 18 | // Call DynamicPower_Update from loop() 19 | void DynamicPower_Update(uint32_t now); 20 | // Call DynamicPower_TelemetryUpdate from ISR with DYNPOWER_UPDATE_MISSED or ScaledSNR value 21 | void DynamicPower_TelemetryUpdate(int8_t snrScaled); 22 | 23 | #endif // TARGET_TX 24 | 25 | #if defined(TARGET_RX) 26 | 27 | // Call DynamicPower_UpdateRx from loop() 28 | void DynamicPower_UpdateRx(bool initialize); 29 | 30 | #endif // TARGET_RX -------------------------------------------------------------------------------- /src/include/encryption.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef USE_ENCRYPTION 4 | 5 | #include 6 | 7 | #define stringify_literal(x) # x 8 | #define stringify_expanded(x) stringify_literal(x) 9 | 10 | typedef enum : uint8_t { 11 | ENCRYPTION_STATE_NONE, 12 | ENCRYPTION_STATE_PROPOSED, 13 | ENCRYPTION_STATE_FULL, 14 | ENCRYPTION_STATE_DISABLED 15 | } encryptionState_e; 16 | 17 | typedef struct encryption_params_s 18 | { 19 | uint8_t nonce[8]; 20 | uint8_t key[16]; 21 | 22 | } encryption_params_t; 23 | 24 | bool ICACHE_RAM_ATTR DecryptMsg(uint8_t *input); 25 | void ICACHE_RAM_ATTR EncryptMsg(uint8_t *input, uint8_t *output); 26 | 27 | /// in: valid chars are 0-9 + A-F + a-f 28 | /// out_len_max==0: convert until the end of input string, out_len_max>0 only convert this many numbers 29 | /// returns actual out size 30 | int hexStr2Arr(unsigned char* out, const char* in, size_t out_len_max = 0); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/include/helpers.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "targets.h" 4 | 5 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) 6 | 7 | #ifndef UNUSED 8 | #define UNUSED(x) (void)(x) 9 | #endif 10 | 11 | class NullStream : public Stream 12 | { 13 | public: 14 | int available() override 15 | { 16 | return 0; 17 | } 18 | 19 | void flush() override 20 | { 21 | } 22 | 23 | int peek() override 24 | { 25 | return -1; 26 | } 27 | 28 | int read() override 29 | { 30 | return -1; 31 | } 32 | 33 | size_t write(uint8_t u_Data) override 34 | { 35 | UNUSED(u_Data); 36 | return 0x01; 37 | } 38 | 39 | size_t write(const uint8_t *buffer, size_t size) override 40 | { 41 | UNUSED(buffer); 42 | return size; 43 | } 44 | }; 45 | 46 | #if defined(PLATFORM_STM32) 47 | inline const char *strchrnul(const char *pos, const char find) 48 | { 49 | const char *semi = strchr(pos, find); 50 | if (semi == nullptr) 51 | { 52 | semi = pos + strlen(pos); 53 | } 54 | return semi; 55 | } 56 | #endif 57 | 58 | -------------------------------------------------------------------------------- /src/include/rxtx_common.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "targets.h" 4 | #include "common.h" 5 | #include "config.h" 6 | #include "CRSF.h" 7 | #include "FHSS.h" 8 | #include "helpers.h" 9 | #include "hwTimer.h" 10 | #include "logging.h" 11 | #include "LBT.h" 12 | #include "LQCALC.h" 13 | #include "OTA.h" 14 | #include "POWERMGNT.h" 15 | #include "deferred.h" 16 | 17 | void setupTargetCommon(); 18 | -------------------------------------------------------------------------------- /src/include/rxtx_intf.h: -------------------------------------------------------------------------------- 1 | /*** 2 | * This file defines the interface from device units to functions in either rx_main or tx_main 3 | * Use this instead of drectly declaring externs in your unit 4 | ***/ 5 | 6 | #include "common.h" 7 | 8 | /*** 9 | * TX interface 10 | ***/ 11 | #if defined(TARGET_TX) 12 | #endif 13 | 14 | /*** 15 | * RX interface 16 | ***/ 17 | #if defined(TARGET_RX) 18 | uint8_t getLq(); 19 | #endif 20 | -------------------------------------------------------------------------------- /src/include/target/DIY_2400_RX_STM32_CCG_Nano_v0_5.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVICE_NAME 2 | #define DEVICE_NAME "ELRS 2400RX" 3 | #endif 4 | 5 | // GPIO pin definitions 6 | #define GPIO_PIN_NSS PA4 7 | #define GPIO_PIN_MOSI PA7 8 | #define GPIO_PIN_MISO PA6 9 | #define GPIO_PIN_SCK PA5 10 | 11 | #define GPIO_PIN_DIO1 PA10 12 | #define GPIO_PIN_RST PB4 13 | #define GPIO_PIN_BUSY PA11 14 | 15 | #define GPIO_PIN_RCSIGNAL_RX PB7 // USART1, AFAIO 16 | #define GPIO_PIN_RCSIGNAL_TX PB6 // USART1, AFAIO 17 | 18 | #define GPIO_PIN_LED_RED PB5 19 | 20 | // Output Power - use default SX1280 21 | 22 | #define POWER_OUTPUT_FIXED 13 //MAX power for 2400 RXes that doesn't have PA is 12.5dbm 23 | -------------------------------------------------------------------------------- /src/include/target/DIY_900_RX_STM32.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVICE_NAME 2 | #define DEVICE_NAME "ELRS 900RX" 3 | #endif 4 | 5 | #define TARGET_DIY_900_RX_STM32 6 | 7 | // GPIO pin definitions 8 | #define GPIO_PIN_NSS PA4 9 | #define GPIO_PIN_MOSI PA7 10 | #define GPIO_PIN_MISO PA6 11 | #define GPIO_PIN_SCK PA5 12 | 13 | #define GPIO_PIN_DIO0 PA0 14 | #define GPIO_PIN_DIO1 PA1 15 | #define GPIO_PIN_RST PA2 16 | #define GPIO_PIN_BUSY PA3 17 | 18 | #define GPIO_PIN_RCSIGNAL_RX PA10 // USART1 19 | #define GPIO_PIN_RCSIGNAL_TX PA9 // USART1 20 | 21 | #define GPIO_PIN_DEBUG_RX PB11 // USART3 22 | #define GPIO_PIN_DEBUG_TX PB10 // USART3 23 | 24 | #define GPIO_PIN_LED_GREEN PC13 25 | #define GPIO_LED_GREEN_INVERTED 1 26 | 27 | // Output Power 28 | #define MinPower PWR_10mW 29 | #define MaxPower PWR_50mW 30 | #define DefaultPower PWR_50mW 31 | #define POWER_OUTPUT_VALUES {120,124,127} 32 | -------------------------------------------------------------------------------- /src/include/target/DIY_900_RX_STM32_SX1272.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVICE_NAME 2 | #define DEVICE_NAME "ELRS 900RX" 3 | #endif 4 | 5 | #define TARGET_DIY_900_RX_STM32_PCB 6 | 7 | // GPIO pin definitions 8 | #define GPIO_PIN_NSS PA4 9 | #define GPIO_PIN_MOSI PA7 10 | #define GPIO_PIN_MISO PA6 11 | #define GPIO_PIN_SCK PA5 12 | 13 | #define GPIO_PIN_RST PB0 14 | #define GPIO_PIN_DIO0 PB1 15 | #define GPIO_PIN_DIO1 PB2 16 | #define GPIO_PIN_BUSY PB3 17 | 18 | #define GPIO_PIN_RX_ENABLE PA2 19 | #define GPIO_PIN_TX_ENABLE PA3 20 | 21 | #define GPIO_PIN_RCSIGNAL_RX PB11 // UART 3 22 | #define GPIO_PIN_RCSIGNAL_TX PB10 // UART 3 23 | 24 | #define GPIO_PIN_DEBUG_RX PB7 // UART 1 25 | #define GPIO_PIN_DEBUG_TX PB6 // UART 1 26 | 27 | #define GPIO_PIN_LED_GREEN PA10 28 | #define GPIO_LED_GREEN_INVERTED 0 29 | 30 | #define GPIO_PIN_LED GPIO_PIN_LED_GREEN 31 | 32 | #define RADIO_SX1272 33 | 34 | // Output Power 35 | #define MinPower PWR_10mW 36 | #define MaxPower PWR_50mW 37 | #define DefaultPower PWR_50mW 38 | #define POWER_OUTPUT_VALUES {120,124,127} -------------------------------------------------------------------------------- /src/include/target/DIY_900_TX_STM32_SX1272.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVICE_NAME 2 | #define DEVICE_NAME "ELRS 900TX" 3 | #endif 4 | 5 | #define TARGET_DIY_900_TX_STM32_PCB 6 | 7 | #define BACKPACK_LOGGING_BAUD 420000 8 | 9 | // GPIO pin definitions 10 | #define GPIO_PIN_NSS PA4 11 | #define GPIO_PIN_MOSI PA7 12 | #define GPIO_PIN_MISO PA6 13 | #define GPIO_PIN_SCK PA5 14 | 15 | #define GPIO_PIN_RST PB0 16 | #define GPIO_PIN_DIO0 PB1 17 | #define GPIO_PIN_DIO1 PB2 18 | #define GPIO_PIN_BUSY PB3 19 | 20 | #define GPIO_PIN_RX_ENABLE PA2 21 | #define GPIO_PIN_TX_ENABLE PA3 22 | 23 | #define GPIO_PIN_RCSIGNAL_RX PB11 // UART 3 24 | #define GPIO_PIN_RCSIGNAL_TX PB10 // UART 3 25 | 26 | #define GPIO_PIN_DEBUG_RX PB7 // UART 1 27 | #define GPIO_PIN_DEBUG_TX PB6 // UART 1 28 | 29 | #define GPIO_PIN_LED_GREEN PA10 30 | #define GPIO_LED_GREEN_INVERTED 0 31 | 32 | #define GPIO_PIN_LED GPIO_PIN_LED_GREEN 33 | 34 | #define RADIO_SX1272 35 | 36 | // Output Power 37 | #define MinPower PWR_10mW 38 | #define MaxPower PWR_50mW 39 | #define DefaultPower PWR_50mW 40 | #define POWER_OUTPUT_VALUES {120,124,127} 41 | -------------------------------------------------------------------------------- /src/include/target/Frsky_TX_R9M_LITE.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVICE_NAME 2 | #define DEVICE_NAME "FrSky R9M Lite" 3 | #endif 4 | 5 | #define TARGET_USE_EEPROM 1 6 | #define TARGET_EEPROM_ADDR 0x51 7 | 8 | // GPIO pin definitions 9 | #define GPIO_PIN_RFswitch_CONTROL PC13 // need to confirm //HIGH = RX, LOW = TX 10 | 11 | #define GPIO_PIN_NSS PB12 12 | #define GPIO_PIN_DIO0 PC15 13 | #define GPIO_PIN_MOSI PB15 14 | #define GPIO_PIN_MISO PB14 15 | #define GPIO_PIN_SCK PB13 16 | #define GPIO_PIN_RST PC14 17 | #define GPIO_PIN_RX_ENABLE PC13 //PB3 // need to confirm 18 | #define GPIO_PIN_SDA PB7 19 | #define GPIO_PIN_SCL PB6 20 | #define GPIO_PIN_RCSIGNAL_RX PB11 // not yet confirmed 21 | #define GPIO_PIN_RCSIGNAL_TX PB10 // not yet confirmed 22 | #define GPIO_PIN_LED_RED PA1 // Red LED // not yet confirmed 23 | #define GPIO_PIN_LED_GREEN PA4 // Green LED // not yet confirmed 24 | 25 | #define GPIO_PIN_DEBUG_RX PA3 // confirmed 26 | #define GPIO_PIN_DEBUG_TX PA2 // confirmed 27 | 28 | #define GPIO_PIN_BUFFER_OE PA5 //CONFIRMED 29 | #define GPIO_PIN_BUFFER_OE_INVERTED 0 30 | 31 | // Output Power 32 | #define MinPower PWR_10mW 33 | #define MaxPower PWR_50mW 34 | #define POWER_OUTPUT_VALUES {120,124,127} 35 | -------------------------------------------------------------------------------- /src/include/target/GHOST_2400_TX_LITE.h: -------------------------------------------------------------------------------- 1 | // This target extends the GHOST_2400_TX target 2 | #ifndef DEVICE_NAME 3 | #define DEVICE_NAME "Ghost 24TX Lite" 4 | #endif 5 | 6 | // There is some special handling for this target 7 | #define TARGET_TX_GHOST_LITE 8 | #define USE_OLED_SPI_SMALL 9 | 10 | /* Joystick values {UP, DOWN, LEFT, RIGHT, ENTER, IDLE}*/ 11 | #define JOY_ADC_VALUES {182, 325, 461, 512, 92, 1021} -------------------------------------------------------------------------------- /src/include/target/GHOST_ATTO_2400_RX.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVICE_NAME 2 | #define DEVICE_NAME "GHOST ATTO" 3 | #endif 4 | // There is some special handling for this target 5 | #define TARGET_RX_GHOST_ATTO_V1 6 | 7 | // GPIO pin definitions 8 | #define GPIO_PIN_NSS PA15 9 | #define GPIO_PIN_BUSY PA3 10 | #define GPIO_PIN_DIO1 PA1 11 | #define GPIO_PIN_MOSI PB5 12 | #define GPIO_PIN_MISO PB4 13 | #define GPIO_PIN_SCK PB3 14 | #define GPIO_PIN_RST PB0 15 | //#define GPIO_PIN_RCSIGNAL_RX PB7 16 | //#define GPIO_PIN_RCSIGNAL_TX PB6 17 | #define GPIO_PIN_RCSIGNAL_RX PB6 // USART1, half duplex 18 | #define GPIO_PIN_RCSIGNAL_TX PA2 // USART2, half duplex 19 | //#define GPIO_PIN_LED PA7 20 | #define GPIO_PIN_LED_WS2812 PA7 21 | #define GPIO_PIN_LED_WS2812_FAST PA_7 22 | //#define GPIO_PIN_BUTTON PA12 23 | 24 | // Output Power - use default SX1280 25 | 26 | #define POWER_OUTPUT_FIXED 13 //MAX power for 2400 RXes that doesn't have PA is 12.5dbm 27 | -------------------------------------------------------------------------------- /src/include/target/HappyModel_TX_ES915TX.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVICE_NAME 2 | #define DEVICE_NAME "HM ES915TX" 3 | #endif 4 | 5 | #define POWER_OUTPUT_VALUES {875,1065,1200,1355,1600,1900,2400,2600} 6 | #define POWER_OUTPUT_VALUES_868 {375,850,1200,1400,1700,2000,2400,2600} 7 | 8 | #include "target/Frsky_TX_R9M.h" 9 | -------------------------------------------------------------------------------- /src/include/target/NamimnoRC_FLASH_2400_RX_STM32.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVICE_NAME 2 | #define DEVICE_NAME "Namimno 2G4RX" 3 | #endif 4 | 5 | // GPIO pin definitions 6 | #define GPIO_PIN_RST PB4 7 | #define GPIO_PIN_BUSY PB5 8 | #define GPIO_PIN_DIO1 PB6 9 | #define GPIO_PIN_DIO2 PB7 10 | #define GPIO_PIN_NSS PA4 11 | #define GPIO_PIN_MOSI PA7 12 | #define GPIO_PIN_MISO PA6 13 | #define GPIO_PIN_SCK PA5 14 | #define GPIO_PIN_LED_RED PA1 15 | 16 | #define GPIO_PIN_RCSIGNAL_RX PA10 17 | #define GPIO_PIN_RCSIGNAL_TX PA9 18 | 19 | // Output Power - default for SX120 20 | 21 | #define POWER_OUTPUT_FIXED 13 //MAX power for 2400 RXes that doesn't have PA is 12.5dbm 22 | -------------------------------------------------------------------------------- /src/include/target/NamimnoRC_FLASH_2400_TX.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVICE_NAME 2 | #define DEVICE_NAME "Namimno Flash" 3 | #endif 4 | 5 | #define USE_TX_BACKPACK 6 | #define CRITICAL_FLASH 7 | 8 | // GPIO pin definitions 9 | #define GPIO_PIN_RST PB4 10 | #define GPIO_PIN_BUSY PB5 11 | #define GPIO_PIN_DIO1 PB6 12 | #define GPIO_PIN_DIO2 PB7 13 | #define GPIO_PIN_NSS PA4 14 | #define GPIO_PIN_MOSI PA7 15 | #define GPIO_PIN_MISO PA6 16 | #define GPIO_PIN_SCK PA5 17 | // SKY65383-11 front end control 18 | #define GPIO_PIN_RX_ENABLE PA8 // CRX 19 | #define GPIO_PIN_TX_ENABLE PA11 // CTX 20 | #define GPIO_PIN_PA_ENABLE PA12 // CSD 21 | 22 | /* S.Port input signal */ 23 | #define GPIO_PIN_RCSIGNAL_RX PB11 /* USART3 */ 24 | #define GPIO_PIN_RCSIGNAL_TX PB10 /* USART3 */ 25 | #define GPIO_PIN_BUFFER_OE PA1 26 | #define GPIO_PIN_BUFFER_OE_INVERTED 1 27 | #define GPIO_PIN_FAN_EN PB1 28 | /* Backpack logger connection */ 29 | #define GPIO_PIN_DEBUG_RX PA10 30 | #define GPIO_PIN_DEBUG_TX PA9 31 | /* WS2812 led */ 32 | #define GPIO_PIN_LED_WS2812 PB0 33 | #define GPIO_PIN_LED_WS2812_FAST PB_0 34 | 35 | // Output Power 36 | #define MinPower PWR_25mW 37 | #define MaxPower PWR_1000mW 38 | #define POWER_OUTPUT_VALUES {-18,-15,-12,-8,-5,3} 39 | -------------------------------------------------------------------------------- /src/include/target/NamimnoRC_VOYAGER_900_RX.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVICE_NAME 2 | #define DEVICE_NAME "Namimno 900RX" 3 | #endif 4 | 5 | // GPIO pin definitions 6 | #define GPIO_PIN_RST PC14 7 | #define GPIO_PIN_DIO0 PA15 8 | #define GPIO_PIN_DIO1 PA1 9 | #define GPIO_PIN_NSS PB12 10 | #define GPIO_PIN_MOSI PB15 11 | #define GPIO_PIN_MISO PB14 12 | #define GPIO_PIN_SCK PB13 13 | #define GPIO_PIN_LED_RED PA11 14 | // RF Switch: LOW = RX, HIGH = TX 15 | #define GPIO_PIN_TX_ENABLE PB3 16 | 17 | #define GPIO_PIN_RCSIGNAL_RX PA10 18 | #define GPIO_PIN_RCSIGNAL_TX PA9 19 | 20 | // Output Power - default for SX127x 21 | #define POWER_OUTPUT_FIXED 127 //MAX power for 900 RXes 22 | -------------------------------------------------------------------------------- /src/include/target/NamimnoRC_VOYAGER_900_TX.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVICE_NAME 2 | #define DEVICE_NAME "Namimno Voyager" 3 | #endif 4 | 5 | #define USE_TX_BACKPACK 6 | 7 | // GPIO pin definitions 8 | #define GPIO_PIN_NSS PB12 9 | #define GPIO_PIN_DIO0 PA15 10 | #define GPIO_PIN_MOSI PB15 11 | #define GPIO_PIN_MISO PB14 12 | #define GPIO_PIN_SCK PB13 13 | #define GPIO_PIN_RST PC14 14 | #define GPIO_PIN_RX_ENABLE PB3 //HIGH = RX, LOW = TX 15 | /* DAC settings */ 16 | #define GPIO_PIN_SDA PB9 17 | #define GPIO_PIN_SCL PB8 18 | 19 | /* S.Port input signal */ 20 | #define GPIO_PIN_RCSIGNAL_RX PB11 /* USART3 */ 21 | #define GPIO_PIN_RCSIGNAL_TX PB10 /* USART3 */ 22 | #define GPIO_PIN_BUFFER_OE PA1 23 | #define GPIO_PIN_BUFFER_OE_INVERTED 1 24 | #define GPIO_PIN_FAN_EN PB1 25 | /* Backpack logger connection */ 26 | #define GPIO_PIN_DEBUG_RX PA10 27 | #define GPIO_PIN_DEBUG_TX PA9 28 | /* WS2812 led */ 29 | #define GPIO_PIN_LED_WS2812 PB0 30 | #define GPIO_PIN_LED_WS2812_FAST PB_0 31 | 32 | // Output Power 33 | #define POWER_OUTPUT_DAC 0b0001101 34 | #define MinPower PWR_10mW 35 | #define MaxPower PWR_2000mW 36 | #define POWER_OUTPUT_VALUES {895,1030,1128,1240,1465,1700,2050,2600} 37 | #define POWER_OUTPUT_VALUES_868 {500,860,1000,1170,1460,1730,2100,2600} 38 | -------------------------------------------------------------------------------- /src/lib/AnalogVbat/devAnalogVbat.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "common.h" 4 | #include "device.h" 5 | 6 | #if defined(USE_ANALOG_VBAT) 7 | void Vbat_enableSlowUpdate(bool enable); 8 | 9 | extern device_t AnalogVbat_device; 10 | #endif -------------------------------------------------------------------------------- /src/lib/BLE/devBLE.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "device.h" 4 | 5 | #if defined(PLATFORM_ESP32) 6 | extern device_t BLE_device; 7 | #define HAS_BLE 8 | #endif -------------------------------------------------------------------------------- /src/lib/BUTTON/devButton.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "device.h" 4 | #include "common.h" 5 | 6 | typedef void (*ButtonAction_fn)(); 7 | 8 | #if defined(GPIO_PIN_BUTTON) 9 | extern device_t Button_device; 10 | #define HAS_BUTTON 11 | 12 | #include 13 | #include 14 | 15 | typedef struct action { 16 | uint8_t button; 17 | bool longPress; 18 | uint8_t count; 19 | action_e action; 20 | } action_t; 21 | 22 | void registerButtonFunction(action_e action, ButtonAction_fn function); 23 | size_t button_GetActionCnt(); 24 | #else 25 | inline void registerButtonFunction(uint8_t action, ButtonAction_fn function) {} 26 | inline size_t button_GetActionCnt() { return 0; } 27 | #endif 28 | -------------------------------------------------------------------------------- /src/lib/BUZZER/devBuzzer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "device.h" 4 | 5 | #if defined(GPIO_PIN_BUZZER) 6 | extern device_t Buzzer_device; 7 | #define HAS_BUZZER 8 | #endif 9 | -------------------------------------------------------------------------------- /src/lib/Backpack/devBackpack.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "device.h" 4 | 5 | void checkBackpackUpdate(); 6 | void sendCRSFTelemetryToBackpack(uint8_t *data); 7 | void sendMAVLinkTelemetryToBackpack(uint8_t *data); 8 | 9 | extern bool HTEnableFlagReadyToSend; 10 | extern bool BackpackTelemReadyToSend; 11 | 12 | extern device_t Backpack_device; 13 | -------------------------------------------------------------------------------- /src/lib/Baro/baro_base.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "baro_base.h" 5 | 6 | uint8_t BaroI2CBase::m_address = 0; 7 | 8 | /** 9 | * @brief: Return altitude in cm from pressure in deci-Pascals 10 | **/ 11 | int32_t BaroBase::pressureToAltitude(uint32_t pressuredPa) 12 | { 13 | const float seaLeveldPa = 1013250; // 1013.25hPa 14 | return 4433000 * (1.0 - pow(pressuredPa / seaLeveldPa, 0.1903)); 15 | } 16 | 17 | void BaroI2CBase::readRegister(uint8_t reg, uint8_t *data, size_t size) 18 | { 19 | Wire.beginTransmission(m_address); 20 | Wire.write(reg); 21 | if (Wire.endTransmission() == 0) 22 | { 23 | Wire.requestFrom(m_address, size); 24 | Wire.readBytes(data, size); 25 | } 26 | } 27 | 28 | void BaroI2CBase::writeRegister(uint8_t reg, uint8_t *data, size_t size) 29 | { 30 | Wire.beginTransmission(m_address); 31 | Wire.write(reg); 32 | Wire.write(data, size); 33 | Wire.endTransmission(); 34 | } 35 | -------------------------------------------------------------------------------- /src/lib/Baro/baro_base.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class BaroBase 7 | { 8 | public: 9 | static const int32_t ALTITUDE_INVALID = 0x7fffffff; 10 | static const int32_t TEMPERATURE_INVALID = 0x7fffffff; 11 | static const uint32_t PRESSURE_INVALID = 0xffffffff; 12 | 13 | BaroBase() : m_initialized(false), m_altitudeHome(ALTITUDE_INVALID) {} 14 | 15 | virtual void initialize() = 0; 16 | // Return expected duration of pressure measurement (ms) 17 | virtual uint8_t getPressureDuration() = 0; 18 | // Start reading pressure 19 | virtual void startPressure() = 0; 20 | // Get pressure result (deci-Pascals) 21 | virtual uint32_t getPressure() = 0; 22 | // Return expected duration of temperature measurement (ms) 23 | virtual uint8_t getTemperatureDuration() = 0; 24 | // Start reading temperature 25 | virtual void startTemperature() = 0; 26 | // Get temperature result (centiDegrees) 27 | virtual int32_t getTemperature() = 0; 28 | 29 | // Base functions 30 | bool isInitialized() const { return m_initialized; } 31 | int32_t pressureToAltitude(uint32_t pressurePa); 32 | // Properties 33 | int32_t getAltitudeHome() const { return m_altitudeHome; } 34 | void setAltitudeHome(int32_t altitudeHome) { m_altitudeHome = altitudeHome; } 35 | protected: 36 | bool m_initialized; 37 | int32_t m_altitudeHome; 38 | }; 39 | 40 | class BaroI2CBase : public BaroBase 41 | { 42 | protected: 43 | static uint8_t m_address; 44 | static void readRegister(uint8_t reg, uint8_t *data, size_t size); 45 | static void writeRegister(uint8_t reg, uint8_t *data, size_t size); 46 | }; 47 | -------------------------------------------------------------------------------- /src/lib/Baro/baro_bmp085.h: -------------------------------------------------------------------------------- 1 | #if 0 2 | // BRY: I implemented this entire unit thinking I had a BMP085 on hand 3 | // but I do not so this code is completely untested and never has run 4 | // but it compiles, so ship it! 5 | #pragma once 6 | 7 | #include "baro_base.h" 8 | #include "baro_bmp085_regs.h" 9 | 10 | class BMP085 : public BaroI2CBase 11 | { 12 | public: 13 | // Detect if chip is present 14 | static bool detect(); 15 | 16 | // BaroBase methods 17 | void initialize(); 18 | uint8_t getPressureDuration(); 19 | void startPressure(); 20 | uint32_t getPressure(); 21 | uint8_t getTemperatureDuration(); 22 | void startTemperature(); 23 | int32_t getTemperature(); 24 | 25 | protected: 26 | // 3x pressure + temperature = 30.5ms per update 27 | // 0x=4.5ms, 1x=7.5ms, 2x=13.5ms, 3x=25.5ms 28 | // +3 +9 +21 29 | const uint8_t OVERSAMPLING_PRESSURE = 3; 30 | 31 | // calibration data, if initialized 32 | // Packed to be able to read all at once 33 | struct tagCalibrationData 34 | { 35 | int16_t ac1; 36 | int16_t ac2; 37 | int16_t ac3; 38 | uint16_t ac4; 39 | uint16_t ac5; 40 | uint16_t ac6; 41 | int16_t b1; 42 | int16_t b2; 43 | int16_t mb; 44 | int16_t mc; 45 | int16_t md; 46 | } __attribute__((packed)) m_calib; 47 | 48 | uint16_t m_temperatureLast; 49 | 50 | private: 51 | int32_t computeB5(int32_t UT) const; 52 | }; 53 | #endif -------------------------------------------------------------------------------- /src/lib/Baro/baro_bmp085_regs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define BMP085_I2C_ADDR 0x77 4 | #define BMP085_CHIPID 0x55 5 | 6 | // Registers 7 | #define BMP085_CALIB_COEFFS_START 0xAA 8 | #define BMP085_CALIB_COEFFS_END 0xBE 9 | #define BMP085_REG_CHIPID 0xD0 10 | #define BMP085_REG_CONTROL 0xF4 11 | #define BMP085_REG_TEMPERATURE_DATA 0xF6 // uses same scratchpad as press 12 | #define BMP085_REG_PRESSURE_DATA 0xF6 // uses same scratchpad as temp 13 | #define BMP085_CMD_MEAS_TEMPERATURE 0x2E 14 | #define BMP085_CMD_MEAS_PRESSURE 0x34 15 | 16 | #define BMP085_CALIB_COEFFS_LEN (BMP085_CALIB_COEFFS_END - BMP085_CALIB_COEFFS_START + 1) 17 | -------------------------------------------------------------------------------- /src/lib/Baro/baro_spl06.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "baro_base.h" 4 | #include "baro_spl06_regs.h" 5 | 6 | class SPL06 : public BaroI2CBase 7 | { 8 | public: 9 | SPL06() : BaroI2CBase(), m_calib{0} {} 10 | 11 | // Detect if chip is present 12 | static bool detect(); 13 | 14 | // BaroBase methods 15 | void initialize(); 16 | uint8_t getPressureDuration(); 17 | void startPressure(); 18 | uint32_t getPressure(); 19 | uint8_t getTemperatureDuration(); 20 | void startTemperature(); 21 | int32_t getTemperature(); 22 | protected: 23 | // 32x Pressure + 8x Temperature = 70ms per update 24 | // 4x=8.4ms/2.5PaRMS, 8x=14.8ms, 16x=27.6ms/1.2Pa, 32x=53.2ms/0.9Pa, 64x=104.4ms/0.5Pa 25 | const uint8_t OVERSAMPLING_PRESSURE = 32; 26 | const uint8_t OVERSAMPLING_TEMPERATURE = 8; 27 | 28 | uint8_t oversampleToRegVal(const uint8_t oversamples) const; 29 | int32_t oversampleToScaleFactor(const uint8_t oversamples) const; 30 | float m_temperatureLast; // last uncompensated temperature value 31 | 32 | struct tagCalibrationData 33 | { 34 | int16_t c0; 35 | int16_t c1; 36 | int32_t c00; 37 | int32_t c10; 38 | int16_t c01; 39 | int16_t c11; 40 | int16_t c20; 41 | int16_t c21; 42 | int16_t c30; 43 | } m_calib; // calibration data, if initialized 44 | 45 | }; -------------------------------------------------------------------------------- /src/lib/Baro/devBaro.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "common.h" 4 | #include "device.h" 5 | #if defined(USE_ANALOG_VBAT) 6 | #include "devAnalogVbat.h" 7 | #endif 8 | 9 | #if defined(TARGET_UNIFIED_RX) 10 | #define HAS_BARO 11 | #endif 12 | 13 | #if defined(HAS_BARO) 14 | 15 | enum eBaroReadState : uint8_t 16 | { 17 | brsNoBaro, 18 | brsUninitialized, 19 | brsReadTemp, 20 | brsWaitingTemp, 21 | brsReadPres, 22 | brsWaitingPress 23 | }; 24 | 25 | extern device_t Baro_device; 26 | #endif -------------------------------------------------------------------------------- /src/lib/CRC/crc.cpp: -------------------------------------------------------------------------------- 1 | #include "crc.h" 2 | 3 | GENERIC_CRC8::GENERIC_CRC8(uint8_t poly) 4 | { 5 | uint8_t crc; 6 | 7 | for (uint16_t i = 0; i < crclen; i++) 8 | { 9 | crc = i; 10 | for (uint8_t j = 0; j < 8; j++) 11 | { 12 | crc = (crc << 1) ^ ((crc & 0x80) ? poly : 0); 13 | } 14 | crc8tab[i] = crc & 0xFF; 15 | } 16 | } 17 | 18 | uint8_t ICACHE_RAM_ATTR GENERIC_CRC8::calc(const uint8_t data) 19 | { 20 | return crc8tab[data]; 21 | } 22 | 23 | uint8_t ICACHE_RAM_ATTR GENERIC_CRC8::calc(const uint8_t *data, uint16_t len, uint8_t crc) 24 | { 25 | while (len--) 26 | { 27 | crc = crc8tab[crc ^ *data++]; 28 | } 29 | return crc; 30 | } 31 | 32 | void Crc2Byte::init(uint8_t bits, uint16_t poly) 33 | { 34 | if (bits == _bits && poly == _poly) 35 | return; 36 | _poly = poly; 37 | _bits = bits; 38 | _bitmask = (1 << _bits) - 1; 39 | uint16_t highbit = 1 << (_bits - 1); 40 | uint16_t crc; 41 | for (uint16_t i = 0; i < crclen; i++) 42 | { 43 | crc = i << (bits - 8); 44 | for (uint8_t j = 0; j < 8; j++) 45 | { 46 | crc = (crc << 1) ^ ((crc & highbit) ? poly : 0); 47 | } 48 | _crctab[i] = crc; 49 | } 50 | } 51 | 52 | uint16_t ICACHE_RAM_ATTR Crc2Byte::calc(uint8_t *data, uint8_t len, uint16_t crc) 53 | { 54 | while (len--) 55 | { 56 | crc = (crc << 8) ^ _crctab[((crc >> (_bits - 8)) ^ (uint16_t) *data++) & 0x00FF]; 57 | } 58 | return crc & _bitmask; 59 | } 60 | -------------------------------------------------------------------------------- /src/lib/CRC/crc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "targets.h" 4 | 5 | #define crclen 256 6 | 7 | class GENERIC_CRC8 8 | { 9 | private: 10 | uint8_t crc8tab[crclen]; 11 | uint8_t crcpoly; 12 | 13 | public: 14 | GENERIC_CRC8(uint8_t poly); 15 | uint8_t calc(const uint8_t data); 16 | uint8_t calc(const uint8_t *data, uint16_t len, uint8_t crc = 0); 17 | }; 18 | 19 | class Crc2Byte 20 | { 21 | private: 22 | uint16_t _crctab[crclen]; 23 | uint8_t _bits; 24 | uint16_t _bitmask; 25 | uint16_t _poly; 26 | 27 | public: 28 | void init(uint8_t bits, uint16_t poly); 29 | uint16_t calc(uint8_t *data, uint8_t len, uint16_t crc); 30 | }; 31 | -------------------------------------------------------------------------------- /src/lib/CRSF2MSP/crsf2msp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "FIFO.h" 5 | #include "crsfmsp_common.h" 6 | #include "crc.h" 7 | #include "logging.h" 8 | 9 | /* Takes a CRSF(MSP) frame and converts it to raw MSP frame 10 | adding the MSP header and checksum. Handles chunked MSP messages. 11 | */ 12 | 13 | class CROSSFIRE2MSP 14 | { 15 | private: 16 | uint8_t outBuffer[MSP_FRAME_MAX_LEN]; 17 | uint32_t pktLen; // packet length of the incomming msp frame 18 | uint32_t idx; // number of bytes received in the current msp frame 19 | uint8_t seqNumberPrev; 20 | bool frameComplete; 21 | uint8_t src; // source of the msp frame (from CRSF ext header) 22 | uint8_t dest; // destination of the msp frame (from CRSF ext header) 23 | MSPframeType_e MSPvers; // need to store the MSP version since it can only be inferred from the first frame 24 | 25 | bool isNewFrame(const uint8_t *data); 26 | bool isError(const uint8_t *data); 27 | 28 | uint8_t getSeqNumber(const uint8_t *data); 29 | MSPframeType_e getVersion(const uint8_t *data); 30 | uint8_t getHeaderDir(const uint8_t *data); 31 | uint8_t getChecksum(const uint8_t *data, const uint32_t packetLen, MSPframeType_e mspVersion); 32 | uint32_t getFrameLen(const uint8_t *data, MSPframeType_e mspVersion); 33 | 34 | public: 35 | CROSSFIRE2MSP(); 36 | FIFO FIFOout; 37 | void parse(const uint8_t *data); // accept crsf frame input 38 | bool isFrameReady(); 39 | const uint8_t *getFrame(); 40 | uint32_t getFrameLen(); 41 | void reset(); 42 | uint8_t getSrc(); 43 | uint8_t getDest(); 44 | }; 45 | 46 | extern CROSSFIRE2MSP crsf2msp; 47 | -------------------------------------------------------------------------------- /src/lib/CRSF2MSP/msp2crsf.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "FIFO.h" 5 | #include "crsfmsp_common.h" 6 | #include "crsf_protocol.h" 7 | #include "crc.h" 8 | #include "logging.h" 9 | 10 | /* Takes a MSP frame and converts it to raw CRSF frame 11 | adding the CRSF header and checksum. Handles chunking of messages 12 | */ 13 | 14 | class MSP2CROSSFIRE 15 | { 16 | private: 17 | // bool isBusy; 18 | void setNewFrame(uint8_t &data, bool isNewFrame); 19 | void setSeqNumber(uint8_t &data, uint8_t seqNumber); 20 | void setVersion(uint8_t &data, MSPframeType_e version); 21 | uint8_t getHeaderDir(uint8_t headerDir); 22 | void setError(uint8_t &data, bool isError); 23 | uint8_t seqNum; 24 | 25 | uint32_t getFrameLen(uint32_t payloadLen, uint8_t mspVersion); 26 | MSPframeType_e getVersion(const uint8_t *data); 27 | uint32_t getPayloadLen(const uint8_t *data, MSPframeType_e mspVersion); 28 | 29 | public: 30 | MSP2CROSSFIRE(); 31 | FIFO FIFOout; 32 | void parse(const uint8_t *data, uint32_t frameLen, uint8_t src = CRSF_ADDRESS_CRSF_RECEIVER, uint8_t dest = CRSF_ADDRESS_FLIGHT_CONTROLLER); 33 | bool validate(const uint8_t *data, uint32_t expectLen); 34 | }; 35 | 36 | extern MSP2CROSSFIRE msp2crsf; 37 | -------------------------------------------------------------------------------- /src/lib/CrsfProtocol/dummy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is here to ensure that the library has an object file created for native test builds 3 | */ 4 | int __crsf_dummy; 5 | -------------------------------------------------------------------------------- /src/lib/Crypto/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Operator Foundation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/lib/Crypto/LICENSE.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Southern Storm Software, Pty Ltd. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | * DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | -------------------------------------------------------------------------------- /src/lib/Crypto/README.md: -------------------------------------------------------------------------------- 1 | 2 | Arduino Cryptography Library 3 | ============================ 4 | 5 | This distribution contains a libraries and example applications to perform 6 | cryptography operations on Arduino devices. They are distributed under the 7 | terms of the MIT license. 8 | 9 | The [documentation](http://rweather.github.com/arduinolibs/crypto.html) 10 | contains more information on the libraries and examples. 11 | 12 | This repository used to contain a number of other examples and libraries 13 | for other areas of Arduino functionality but most users are only interested 14 | in the cryptography code. The other projects have been moved to a 15 | separate [repository](https://github.com/rweather/arduino-projects) and 16 | only the cryptography code remains in this repository. 17 | 18 | For more information on these libraries, to report bugs, or to suggest 19 | improvements, please contact the author Rhys Weatherley via 20 | [email](mailto:rhys.weatherley@gmail.com). 21 | 22 | Recent significant changes to the library 23 | ----------------------------------------- 24 | 25 | Apr 2018: 26 | 27 | * Acorn128 and Ascon128 authenticated ciphers (finalists in the CAESAR AEAD 28 | competition in the light-weight category). 29 | * Split the library into Crypto (core), CryptoLW (light-weight), and 30 | CryptoLegacy (deprecated algorithms). 31 | * Tiny and small versions of AES for reducing memory requirements. 32 | * Port the library to ESP8266 and ESP32. 33 | * Make the RNG class more robust if the app doesn't call begin() or loop(). 34 | 35 | Nov 2017: 36 | 37 | * Fix the AVR assembly version of Speck and speed it up a little. 38 | * API improvements to the RNG class. 39 | -------------------------------------------------------------------------------- /src/lib/Crypto/keywords.txt: -------------------------------------------------------------------------------- 1 | AES128 KEYWORD1 2 | AES192 KEYWORD1 3 | AES256 KEYWORD1 4 | AESTiny128 KEYWORD1 5 | AESTiny256 KEYWORD1 6 | AESSmall128 KEYWORD1 7 | AESSmall256 KEYWORD1 8 | ChaCha KEYWORD1 9 | ChaChaPoly KEYWORD1 10 | 11 | BLAKE2b KEYWORD1 12 | BLAKE2s KEYWORD1 13 | SHA224 KEYWORD1 14 | SHA256 KEYWORD1 15 | SHA384 KEYWORD1 16 | SHA512 KEYWORD1 17 | SHA3_256 KEYWORD1 18 | SHA3_512 KEYWORD1 19 | KeccakCore KEYWORD1 20 | Poly1305 KEYWORD1 21 | GHASH KEYWORD1 22 | OMAC KEYWORD1 23 | GF128 KEYWORD1 24 | 25 | SHAKE128 KEYWORD1 26 | SHAKE256 KEYWORD1 27 | 28 | Curve25519 KEYWORD1 29 | Ed25519 KEYWORD1 30 | 31 | CBC KEYWORD1 32 | CFB KEYWORD1 33 | CTR KEYWORD1 34 | OFB KEYWORD1 35 | HKDF KEYWORD1 36 | GCM KEYWORD1 37 | EAX KEYWORD1 38 | 39 | RNG KEYWORD1 40 | 41 | keySize KEYWORD2 42 | ivSize KEYWORD2 43 | tagSize KEYWORD2 44 | setKey KEYWORD2 45 | setIV KEYWORD2 46 | encrypt KEYWORD2 47 | decrypt KEYWORD2 48 | clear KEYWORD2 49 | addAuthData KEYWORD2 50 | extract KEYWORD2 51 | 52 | hashSize KEYWORD2 53 | blockSize KEYWORD2 54 | reset KEYWORD2 55 | update KEYWORD2 56 | finalize KEYWORD2 57 | 58 | begin KEYWORD2 59 | setAutoSaveTime KEYWORD2 60 | rand KEYWORD2 61 | available KEYWORD2 62 | stir KEYWORD2 63 | save KEYWORD2 64 | loop KEYWORD2 65 | destroy KEYWORD2 66 | calibrating KEYWORD2 67 | 68 | eval KEYWORD2 69 | dh1 KEYWORD2 70 | dh2 KEYWORD2 71 | 72 | sign KEYWORD2 73 | verify KEYWORD2 74 | generatePrivateKey KEYWORD2 75 | derivePublicKey KEYWORD2 76 | -------------------------------------------------------------------------------- /src/lib/Crypto/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Crypto", 3 | "version": "0.4.0", 4 | "keywords": "AES128,AES192,AES256,Speck,CTR,CFB,CBC,OFB,EAX,GCM,HKDF,XTS,ChaCha,ChaChaPoly,EAX,GCM,SHA224,SHA256,SHA384,SHA512,SHA3-256,SHA3-512,BLAKE2s,BLAKE2b,SHAKE128,SHAKE256,Poly1305,GHASH,OMAC,Curve25519,Ed25519,P521,RNG,NOISE", 5 | "description": "Arduino CryptoLibs - All cryptographic algorithms have been optimized for 8-bit Arduino platforms like the Uno", 6 | "authors": 7 | { 8 | "name": "Rhys Weatherley", 9 | "email": "rhys.weatherley@gmail.com", 10 | "url": "https://rweather.github.io/arduinolibs/crypto.html" 11 | }, 12 | "export": { 13 | "include": "libraries/Crypto" 14 | }, 15 | "repository": 16 | { 17 | "type": "git", 18 | "url": "https://github.com/rweather/arduinolibs.git" 19 | }, 20 | "frameworks": "arduino", 21 | "platforms": "*" 22 | } 23 | -------------------------------------------------------------------------------- /src/lib/Crypto/library.properties: -------------------------------------------------------------------------------- 1 | name=Crypto 2 | version=0.4.0 3 | author=Rhys Weatherley rhys.weatherley@gmail.com 4 | maintainer=Dr. Brandon Wiley brandon@operatorfoundation.org 5 | sentence=Rhys Weatherley's arduinolibs Crypto library. 6 | paragraph=All cryptographic algorithms have been optimized for 8-bit Arduino platforms like the Uno. 7 | category=Other 8 | url=https://rweather.github.io/arduinolibs/crypto.html 9 | architectures=* 10 | -------------------------------------------------------------------------------- /src/lib/DAC/DAC.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "DAC.h" 3 | 4 | #if defined(POWER_OUTPUT_DAC) 5 | #include "helpers.h" 6 | #include "logging.h" 7 | #include 8 | 9 | #ifndef DAC_REF_VCC 10 | #define DAC_REF_VCC 3300 11 | #endif 12 | 13 | void DAC::init() 14 | { 15 | DBGLN("Init DAC Driver"); 16 | 17 | // I2C initialization is the responsibility of the caller 18 | // e.g. Wire.begin(GPIO_PIN_SDA, GPIO_PIN_SCL); 19 | 20 | m_state = UNKNOWN; 21 | } 22 | 23 | void DAC::standby() 24 | { 25 | if (m_state != STANDBY) 26 | { 27 | Wire.beginTransmission(POWER_OUTPUT_DAC); 28 | Wire.write(0x00); 29 | Wire.write(0x00); 30 | Wire.endTransmission(); 31 | m_state = STANDBY; 32 | } 33 | } 34 | 35 | void DAC::resume() 36 | { 37 | if (m_state != RUNNING) 38 | { 39 | DAC::setVoltageRegDirect(m_currVoltageRegVal); 40 | } 41 | } 42 | 43 | void DAC::setVoltageRegDirect(uint8_t voltReg) 44 | { 45 | m_currVoltageRegVal = voltReg; 46 | uint8_t RegH = ((voltReg & 0b11110000) >> 4) + (0b0000 << 4); 47 | uint8_t RegL = (voltReg & 0b00001111) << 4; 48 | 49 | Wire.beginTransmission(POWER_OUTPUT_DAC); 50 | Wire.write(RegH); 51 | Wire.write(RegL); 52 | Wire.endTransmission(); 53 | } 54 | 55 | void DAC::setPower(uint32_t milliVolts) 56 | { 57 | uint8_t ScaledVolts = map(milliVolts, 0, DAC_REF_VCC, 0, 255); 58 | setVoltageRegDirect(ScaledVolts); 59 | DBGLN("DAC::setPower(%umV)", milliVolts); 60 | } 61 | 62 | DAC TxDAC; 63 | 64 | #endif // defined(POWER_OUTPUT_DAC) 65 | -------------------------------------------------------------------------------- /src/lib/DAC/DAC.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "targets.h" 4 | 5 | #if defined(POWER_OUTPUT_DAC) 6 | 7 | typedef enum 8 | { 9 | UNKNOWN = 0, 10 | RUNNING = 1, 11 | STANDBY = 2 12 | } DAC_STATE_; 13 | 14 | ////////////////////////////////////////////////////// 15 | 16 | class DAC 17 | { 18 | public: 19 | void init(); 20 | void standby(); 21 | void resume(); 22 | void setVoltageRegDirect(uint8_t voltReg); 23 | void setPower(uint32_t milliVolts); 24 | 25 | private: 26 | DAC_STATE_ m_state; 27 | uint8_t m_currVoltageRegVal; 28 | }; 29 | 30 | extern DAC TxDAC; 31 | #endif // defined(POWER_OUTPUT_DAC) 32 | -------------------------------------------------------------------------------- /src/lib/FEC/FEC.cpp: -------------------------------------------------------------------------------- 1 | #include "FEC.h" 2 | 3 | void FECEncode(uint8_t *incomingData, uint8_t *FECBuffer) 4 | { 5 | // Encode Hamming(7,4) 6 | uint8_t encodedBuffer[8 * 2] = {0}; 7 | for (uint8_t i = 0; i < 8; i++) 8 | { 9 | encodedBuffer[i * 2 + 0] = HammingTableEncode(incomingData[i] & 0x0F); // LSB nibble 10 | encodedBuffer[i * 2 + 1] = HammingTableEncode(incomingData[i] >> 4); // MSB nibble 11 | } 12 | 13 | // Interleaving 14 | for (uint8_t i = 0; i < (14 / 2); i++) 15 | { 16 | for (uint8_t j = 0; j < 8; j++) 17 | { 18 | FECBuffer[i * 2 + 0] |= ((encodedBuffer[j + 0] >> i) & 0x01) << j; 19 | FECBuffer[i * 2 + 1] |= ((encodedBuffer[j + 8] >> i) & 0x01) << j; 20 | } 21 | } 22 | } 23 | 24 | void FECDecode(uint8_t *incomingFECBuffer, uint8_t *outgoingData) 25 | { 26 | // Interleaving 27 | uint8_t encodedBuffer[16] = {0}; 28 | for (uint8_t i = 0; i < 8; i++) 29 | { 30 | for (uint8_t j = 0; j < 7; j++) 31 | { 32 | encodedBuffer[i + 0] |= ((incomingFECBuffer[j * 2 + 0] >> i) & 0x01) << j; 33 | encodedBuffer[i + 8] |= ((incomingFECBuffer[j * 2 + 1] >> i) & 0x01) << j; 34 | } 35 | } 36 | 37 | // Decode Hamming(7,4) 38 | for (uint8_t i = 0; i < 8; i++) 39 | { 40 | outgoingData[i] = HammingTableDecode(encodedBuffer[i * 2 + 0]); // LSB nibble 41 | outgoingData[i] |= HammingTableDecode(encodedBuffer[i * 2 + 1]) << 4; // MSB nibble 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/lib/FEC/FEC.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "hamming.h" 4 | 5 | /** 6 | * @brief Hamming(7,4) + Interleaving 7 | * 8 | * The below functions may look flexible, but they are not! 9 | * Only send it an 8B payload that will go into a 14B FECBuffer. 10 | * The encoding will be ok but interleaving expects 8B going into 14B. 11 | * 12 | * Hamming(7,4) - 4b chucks are converted into a 7b codeword. Each 13 | * codeword can correct a single bit error during transmission. 14 | * 15 | * Interleaving - The 7b codeword is spread across the entire packet. 16 | * A single bit is placed in every second byte of the payload. This 17 | * should provide the best defence against burst interference, and single 18 | * bit errors in each codeword can be repaired. 19 | */ 20 | 21 | void FECEncode(uint8_t *incomingData, uint8_t *FECBuffer); 22 | void FECDecode(uint8_t *incomingFECBuffer, uint8_t *outgoingData); 23 | -------------------------------------------------------------------------------- /src/lib/FHSS/random.cpp: -------------------------------------------------------------------------------- 1 | #include "random.h" 2 | 3 | static uint32_t seed = 0; 4 | 5 | // returns values between 0 and 0x7FFF 6 | // NB rngN depends on this output range, so if we change the 7 | // behaviour rngN will need updating 8 | uint16_t rng(void) 9 | { 10 | const uint32_t m = 2147483648; 11 | const uint32_t a = 214013; 12 | const uint32_t c = 2531011; 13 | seed = (a * seed + c) % m; 14 | return seed >> 16; 15 | } 16 | 17 | void rngSeed(const uint32_t newSeed) 18 | { 19 | seed = newSeed; 20 | } 21 | 22 | // returns 0 <= x < max where max < 256 23 | uint8_t rngN(const uint8_t max) 24 | { 25 | return rng() % max; 26 | } 27 | 28 | // 0..255 returned 29 | uint8_t rng8Bit(void) 30 | { 31 | return rng() & 0xff; 32 | } 33 | 34 | // 0..31 returned 35 | uint8_t rng5Bit(void) 36 | { 37 | return rng() & 0x1F; 38 | } 39 | -------------------------------------------------------------------------------- /src/lib/FHSS/random.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | // the max value returned by rng 6 | #define RNG_MAX 0x7FFF 7 | 8 | uint16_t rng(void); 9 | 10 | void rngSeed(uint32_t newSeed); 11 | // 0..255 returned 12 | uint8_t rng8Bit(void); 13 | // 0..31 returned 14 | uint8_t rng5Bit(void); 15 | 16 | // returns 0 <= x < upper where n < 256 17 | uint8_t rngN(uint8_t upper); 18 | -------------------------------------------------------------------------------- /src/lib/FSKRadioLib/FSK_SX127X.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/lib/FSKRadioLib/FSK_SX127X.h -------------------------------------------------------------------------------- /src/lib/FSKRadioLib/FSK_SX127x.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/lib/FSKRadioLib/FSK_SX127x.cpp -------------------------------------------------------------------------------- /src/lib/GSENSOR/devGsensor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "device.h" 4 | #include "CRSF.h" 5 | 6 | extern device_t Gsensor_device; 7 | -------------------------------------------------------------------------------- /src/lib/GSENSOR/gsensor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "targets.h" 4 | 5 | typedef enum 6 | { 7 | GSENSOR_STATUS_FAIL = 0, 8 | GSENSOR_STATUS_NORMAL = 1, 9 | GSENSOR_STATUS_SUSPEND = 2 10 | } Gsensor_Status_t; 11 | 12 | typedef enum 13 | { 14 | GSENSOR_SYSTEM_STATE_MOVING = 0, 15 | GSENSOR_SYSTEM_STATE_QUIET = 1 16 | } Gsensor_System_State_t; 17 | 18 | class Gsensor 19 | { 20 | private: 21 | int system_state; 22 | bool is_flipped; 23 | public: 24 | bool init(); 25 | void handle(); 26 | bool hasTriggered(unsigned long now); 27 | void getGSensorData(float *X_DataOut, float *Y_DataOut, float *Z_DataOut); 28 | int getSystemState(); 29 | bool isFlipped(); 30 | }; 31 | -------------------------------------------------------------------------------- /src/lib/Handset/AutoDetect.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "handset.h" 4 | 5 | #include 6 | 7 | class AutoDetect final : public Handset 8 | { 9 | public: 10 | void Begin() override; 11 | void End() override; 12 | bool IsArmed() override; 13 | void handleInput() override; 14 | 15 | private: 16 | void migrateTo(Handset *that) const; 17 | void startPPM() const; 18 | void startCRSF() const; 19 | 20 | int input_detect = 0; 21 | RingbufHandle_t rb = nullptr; 22 | uint32_t lastDetect = 0; 23 | }; -------------------------------------------------------------------------------- /src/lib/Handset/CRSF.h: -------------------------------------------------------------------------------- 1 | #ifndef H_CRSF 2 | #define H_CRSF 3 | 4 | #include "crsf_protocol.h" 5 | #include "telemetry_protocol.h" 6 | #include "msp.h" 7 | #include "msptypes.h" 8 | 9 | class CRSF 10 | { 11 | public: 12 | static elrsLinkStatistics_t LinkStatistics; // Link Statistics Stored as Struct 13 | 14 | static void GetMspMessage(uint8_t **data, uint8_t *len); 15 | static void UnlockMspMessage(); 16 | static void AddMspMessage(uint8_t length, uint8_t *data); 17 | static void AddMspMessage(mspPacket_t *packet, uint8_t destination); 18 | static void ResetMspQueue(); 19 | 20 | static void GetDeviceInformation(uint8_t *frame, uint8_t fieldCount); 21 | static void SetMspV2Request(uint8_t *frame, uint16_t function, uint8_t *payload, uint8_t payloadLength); 22 | static void SetHeaderAndCrc(uint8_t *frame, crsf_frame_type_e frameType, uint8_t frameSize, crsf_addr_e destAddr); 23 | static void SetExtendedHeaderAndCrc(uint8_t *frame, crsf_frame_type_e frameType, uint8_t frameSize, crsf_addr_e senderAddr, crsf_addr_e destAddr); 24 | static uint32_t VersionStrToU32(const char *verStr); 25 | 26 | #if defined(CRSF_RX_MODULE) 27 | public: 28 | static void updateUplinkPower(uint8_t uplinkPower); 29 | static bool clearUpdatedUplinkPower(); 30 | 31 | private: 32 | static bool HasUpdatedUplinkPower; 33 | #endif 34 | 35 | private: 36 | static uint8_t MspData[ELRS_MSP_BUFFER]; 37 | static uint8_t MspDataLength; 38 | }; 39 | 40 | extern GENERIC_CRC8 crsf_crc; 41 | 42 | #endif -------------------------------------------------------------------------------- /src/lib/Handset/PPMHandset.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "handset.h" 3 | 4 | #include 5 | 6 | class PPMHandset final : public Handset 7 | { 8 | public: 9 | void Begin() override; 10 | void End() override; 11 | bool IsArmed() override; 12 | void handleInput() override; 13 | 14 | private: 15 | uint32_t lastPPM = 0; 16 | size_t numChannels = 0; 17 | RingbufHandle_t rb = nullptr; 18 | }; 19 | 20 | #if defined(PLATFORM_ESP32_S3) 21 | constexpr rmt_channel_t PPM_RMT_CHANNEL = RMT_CHANNEL_4; 22 | #else 23 | constexpr rmt_channel_t PPM_RMT_CHANNEL = RMT_CHANNEL_0; 24 | #endif 25 | -------------------------------------------------------------------------------- /src/lib/Handset/devHandset.cpp: -------------------------------------------------------------------------------- 1 | #include "targets.h" 2 | 3 | #ifdef TARGET_TX 4 | 5 | #include "CRSF.h" 6 | #include "CRSFHandset.h" 7 | #include "POWERMGNT.h" 8 | #include "devHandset.h" 9 | 10 | #if defined(PLATFORM_ESP32) 11 | #include "AutoDetect.h" 12 | #endif 13 | 14 | Handset *handset; 15 | 16 | static void initialize() 17 | { 18 | #if defined(PLATFORM_ESP32) 19 | if (GPIO_PIN_RCSIGNAL_RX == GPIO_PIN_RCSIGNAL_TX) 20 | { 21 | handset = new AutoDetect(); 22 | return; 23 | } 24 | #endif 25 | handset = new CRSFHandset(); 26 | } 27 | 28 | static int start() 29 | { 30 | handset->Begin(); 31 | #if defined(DEBUG_TX_FREERUN) 32 | handset->forceConnection(); 33 | #endif 34 | return DURATION_IMMEDIATELY; 35 | } 36 | 37 | static int timeout() 38 | { 39 | handset->handleInput(); 40 | return DURATION_IMMEDIATELY; 41 | } 42 | 43 | static int event() 44 | { 45 | // An event should be generated every time the TX power changes 46 | CRSF::LinkStatistics.uplink_TX_Power = powerToCrsfPower(PowerLevelContainer::currPower()); 47 | return DURATION_IGNORE; 48 | } 49 | 50 | device_t Handset_device = { 51 | .initialize = initialize, 52 | .start = start, 53 | .event = event, 54 | .timeout = timeout}; 55 | #endif 56 | -------------------------------------------------------------------------------- /src/lib/Handset/devHandset.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "device.h" 4 | 5 | extern device_t Handset_device; -------------------------------------------------------------------------------- /src/lib/LBT/LBT.h: -------------------------------------------------------------------------------- 1 | #if defined(Regulatory_Domain_EU_CE_2400) 2 | #pragma once 3 | 4 | #include "POWERMGNT.h" 5 | #include "LQCALC.h" 6 | #include "SX1280Driver.h" 7 | 8 | extern LQCALC<100> LBTSuccessCalc; 9 | extern bool LBTEnabled; 10 | 11 | void ICACHE_RAM_ATTR SetClearChannelAssessmentTime(void); 12 | SX12XX_Radio_Number_t ICACHE_RAM_ATTR ChannelIsClear(SX12XX_Radio_Number_t radioNumber); 13 | #endif 14 | -------------------------------------------------------------------------------- /src/lib/LED/devLED.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "device.h" 4 | 5 | #if defined(GPIO_PIN_LED_WS2812) 6 | extern device_t RGB_device; 7 | #define HAS_RGB 8 | #endif 9 | 10 | #if defined(GPIO_PIN_LED) \ 11 | || defined(GPIO_PIN_LED_RED) \ 12 | || defined(GPIO_PIN_LED_GREEN) \ 13 | || defined(GPIO_PIN_LED_BLUE) 14 | extern device_t LED_device; 15 | #define HAS_LED 16 | #endif -------------------------------------------------------------------------------- /src/lib/LED/esp32rgb.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | class RgbColor 4 | { 5 | public: 6 | RgbColor(uint8_t r, uint8_t g, uint8_t b) : R(r), G(g), B(b) {} 7 | explicit RgbColor(uint8_t brightness) : R(brightness), G(brightness), B(brightness) {} 8 | 9 | uint8_t R; 10 | uint8_t G; 11 | uint8_t B; 12 | }; 13 | 14 | class ESP32S3LedDriver 15 | { 16 | public: 17 | ESP32S3LedDriver(int count, int pin); 18 | ~ESP32S3LedDriver(); 19 | 20 | void Begin(); 21 | void Show(); 22 | void ClearTo(RgbColor color, uint16_t first, uint16_t last); 23 | virtual void SetPixelColor(uint16_t indexPixel, RgbColor color) = 0; 24 | 25 | private: 26 | RgbColor *ledsbuff = nullptr; 27 | uint16_t *out_buffer = nullptr; 28 | size_t out_buffer_size; 29 | int num_leds; 30 | int gpio_pin; 31 | 32 | friend class ESP32S3LedDriverGRB; 33 | friend class ESP32S3LedDriverRGB; 34 | }; 35 | 36 | class ESP32S3LedDriverGRB : public ESP32S3LedDriver 37 | { 38 | public: 39 | ESP32S3LedDriverGRB(int count, int pin) : ESP32S3LedDriver(count, pin) {} 40 | void SetPixelColor(uint16_t indexPixel, RgbColor color) override; 41 | }; 42 | 43 | class ESP32S3LedDriverRGB : public ESP32S3LedDriver 44 | { 45 | public: 46 | ESP32S3LedDriverRGB(int count, int pin) : ESP32S3LedDriver(count, pin) {} 47 | void SetPixelColor(uint16_t indexPixel, RgbColor color) override; 48 | }; 49 | -------------------------------------------------------------------------------- /src/lib/LR1121Driver/LR1121Driver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "LR1121_Regs.h" 3 | #include "LR1121_hal.h" 4 | #include "LR1121.h" 5 | -------------------------------------------------------------------------------- /src/lib/LR1121Driver/LR1121_hal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "LR1121_Regs.h" 4 | #include "LR1121.h" 5 | 6 | class LR1121Hal 7 | { 8 | public: 9 | static LR1121Hal *instance; 10 | 11 | LR1121Hal(); 12 | 13 | void init(); 14 | void end(); 15 | void reset(bool bootloader = false); 16 | 17 | void ICACHE_RAM_ATTR WriteCommand(uint16_t opcode, SX12XX_Radio_Number_t radioNumber); 18 | void ICACHE_RAM_ATTR WriteCommand(uint16_t opcode, uint8_t *buffer, uint8_t size, SX12XX_Radio_Number_t radioNumber); 19 | 20 | void ICACHE_RAM_ATTR ReadCommand(uint8_t *buffer, uint8_t size, SX12XX_Radio_Number_t radioNumber); 21 | 22 | bool ICACHE_RAM_ATTR WaitOnBusy(SX12XX_Radio_Number_t radioNumber); 23 | 24 | static ICACHE_RAM_ATTR void dioISR_1(); 25 | static ICACHE_RAM_ATTR void dioISR_2(); 26 | void (*IsrCallback_1)(); 27 | void (*IsrCallback_2)(); 28 | 29 | private: 30 | 31 | }; 32 | -------------------------------------------------------------------------------- /src/lib/LUA/devLUA.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "device.h" 4 | 5 | extern device_t LUA_device; 6 | 7 | #if defined(TARGET_TX) 8 | void luadevUpdateFolderNames(); 9 | #endif -------------------------------------------------------------------------------- /src/lib/LUA/rxtx_devLua.cpp: -------------------------------------------------------------------------------- 1 | #include "rxtx_devLua.h" 2 | #include "POWERMGNT.h" 3 | 4 | char strPowerLevels[] = "10;25;50;100;250;500;1000;2000;MatchTX "; 5 | const char STR_EMPTYSPACE[] = { 0 }; 6 | 7 | void luadevGeneratePowerOpts(luaItem_selection *luaPower) 8 | { 9 | // This function modifies the strPowerLevels in place and must not 10 | // be called more than once! 11 | char *out = strPowerLevels; 12 | PowerLevels_e pwr = PWR_10mW; 13 | // Count the semicolons to move `out` to point to the MINth item 14 | while (pwr < POWERMGNT::getMinPower()) 15 | { 16 | while (*out++ != ';') ; 17 | pwr = (PowerLevels_e)((unsigned int)pwr + 1); 18 | } 19 | // There is no min field, compensate by shifting the index when sending/receiving 20 | // luaPower->min = (uint8_t)MinPower; 21 | luaPower->options = (const char *)out; 22 | 23 | // Continue until after than MAXth item and drop a null in the orginal 24 | // string on the semicolon (not after like the previous loop) 25 | while (pwr <= POWERMGNT::getMaxPower()) 26 | { 27 | // If out still points to a semicolon from the last loop move past it 28 | if (*out) 29 | ++out; 30 | while (*out && *out != ';') 31 | ++out; 32 | pwr = (PowerLevels_e)((unsigned int)pwr + 1); 33 | } 34 | *out = '\0'; 35 | 36 | #if defined(TARGET_RX) 37 | // The RX has the dynamic option added on to the end 38 | // the space on the end is to make it display "MatchTX mW" 39 | // but only if it has more than one power level 40 | if (POWERMGNT::getMinPower() != POWERMGNT::getMaxPower()) 41 | strcat(strPowerLevels, ";MatchTX "); 42 | #endif 43 | } 44 | -------------------------------------------------------------------------------- /src/lib/LUA/rxtx_devLua.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "common.h" 4 | #include "device.h" 5 | #include "lua.h" 6 | #include "config.h" 7 | #include "POWERMGNT.h" 8 | 9 | // Common functions 10 | void luadevGeneratePowerOpts(luaItem_selection *luaPower); 11 | 12 | // Common Lua storage (mutable) 13 | extern char strPowerLevels[]; 14 | 15 | // Common Lua storate (constant) 16 | extern const char STR_EMPTYSPACE[]; 17 | extern const char STR_LUA_PACKETRATES[]; 18 | -------------------------------------------------------------------------------- /src/lib/MAVLink/MAVLink.h: -------------------------------------------------------------------------------- 1 | #include "CRSF.h" 2 | #if !defined(PLATFORM_STM32) 3 | #define MAVLINK_COMM_NUM_BUFFERS 1 4 | #include "common/mavlink.h" 5 | #endif 6 | #include 7 | 8 | // Takes a MAVLink message wrapped in CRSF and possibly converts it to a CRSF telemetry message 9 | void convert_mavlink_to_crsf_telem(uint8_t *CRSFinBuffer, uint8_t count, Handset *handset); 10 | 11 | bool isThisAMavPacket(uint8_t *buffer, uint16_t bufferSize); 12 | uint16_t buildMAVLinkELRSModeChange(uint8_t mode, uint8_t *buffer); -------------------------------------------------------------------------------- /src/lib/MSPVTX/devMSPVTX.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "device.h" 4 | 5 | extern device_t MSPVTx_device; 6 | 7 | void mspVtxProcessPacket(uint8_t *packet); 8 | void disableMspVtx(void); 9 | -------------------------------------------------------------------------------- /src/lib/MSPVTX/freqTable.cpp: -------------------------------------------------------------------------------- 1 | #include "freqTable.h" 2 | 3 | uint8_t getFreqTableChannels(void) 4 | { 5 | return CHANNEL_COUNT; 6 | } 7 | 8 | uint8_t getFreqTableBands(void) 9 | { 10 | return FREQ_TABLE_SIZE / getFreqTableChannels(); 11 | } 12 | 13 | uint16_t getFreqByIdx(uint8_t idx) 14 | { 15 | return channelFreqTable[idx]; 16 | } 17 | 18 | uint8_t channelFreqLabelByIdx(uint8_t idx) 19 | { 20 | return channelFreqLabel[idx]; 21 | } 22 | 23 | uint8_t getBandLetterByIdx(uint8_t idx) 24 | { 25 | return bandLetter[idx]; 26 | } 27 | -------------------------------------------------------------------------------- /src/lib/MeanAccumulator/MeanAccumulator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | template 4 | class MeanAccumulator 5 | { 6 | public: 7 | void add(IncrementType val) 8 | { 9 | _accumulator += val; 10 | ++_count; 11 | } 12 | 13 | IncrementType mean() 14 | { 15 | if (_count) 16 | { 17 | _previousMean = _accumulator / _count; 18 | reset(); 19 | 20 | return _previousMean; 21 | } 22 | return NoValueReturn; 23 | } 24 | 25 | IncrementType previousMean() 26 | { 27 | return _previousMean; 28 | } 29 | 30 | void reset() 31 | { 32 | _accumulator = 0; 33 | _count = 0; 34 | } 35 | 36 | size_t getCount() const 37 | { 38 | return _count; 39 | } 40 | 41 | private: 42 | StorageType _accumulator; 43 | StorageType _count; 44 | IncrementType _previousMean; 45 | }; -------------------------------------------------------------------------------- /src/lib/OPTIONS/EspFlashStream.cpp: -------------------------------------------------------------------------------- 1 | #if defined(TARGET_UNIFIED_TX) || defined(TARGET_UNIFIED_RX) 2 | 3 | #include "EspFlashStream.h" 4 | 5 | EspFlashStream::EspFlashStream() 6 | { 7 | setBaseAddress(0); 8 | } 9 | 10 | void EspFlashStream::fillBuffer() 11 | { 12 | // Could also use spi_flash_read() here, but the return values differ between ESP (SPI_FLASH_RESULT_OK) and ESP32 (ESP_OK) 13 | if (ESP.flashRead(_flashBase + _flashOffset, (uint32_t *)_buffer, sizeof(_buffer))) 14 | { 15 | _bufferPos = 0; 16 | } 17 | else 18 | { 19 | // _bufferPos > sizeof() indicates error 20 | _bufferPos = sizeof(_buffer) + 1; 21 | } 22 | } 23 | 24 | void EspFlashStream::setBaseAddress(size_t base) 25 | { 26 | _flashBase = base; 27 | _flashOffset = 0 - sizeof(_buffer); // underflow intentionally so offset+pos = 0 28 | _bufferPos = sizeof(_buffer); 29 | } 30 | 31 | void EspFlashStream::setPosition(size_t offset) 32 | { 33 | // align(4), rounding down 34 | _flashOffset = (offset >> 2) << 2; 35 | // capture the new bufferPos before fill advances it 36 | uint8_t newBufferPos = offset - _flashOffset; 37 | 38 | fillBuffer(); 39 | _bufferPos = newBufferPos; 40 | } 41 | 42 | int EspFlashStream::read() 43 | { 44 | int retVal = peek(); 45 | ++_bufferPos; 46 | return retVal; 47 | } 48 | 49 | int EspFlashStream::peek() 50 | { 51 | if (_bufferPos == sizeof(_buffer)) 52 | { 53 | _flashOffset += sizeof(_buffer); 54 | fillBuffer(); 55 | } 56 | return _buffer[_bufferPos]; 57 | } 58 | 59 | #endif -------------------------------------------------------------------------------- /src/lib/OPTIONS/EspFlashStream.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "targets.h" 4 | 5 | class EspFlashStream : public Stream 6 | { 7 | public: 8 | EspFlashStream(); 9 | // Set the starting address to use with seek()s 10 | void setBaseAddress(size_t base); 11 | size_t getPosition() const { return _flashOffset + _bufferPos; } 12 | void setPosition(size_t offset); 13 | 14 | // Stream class overrides 15 | virtual size_t write(uint8_t) { return 0; } 16 | virtual int available() { return (_bufferPos <= sizeof(_buffer)) ? 1 : 0; } 17 | virtual int read(); 18 | virtual int peek(); 19 | 20 | private: 21 | WORD_ALIGNED_ATTR uint8_t _buffer[4]; 22 | size_t _flashBase; 23 | size_t _flashOffset; 24 | uint8_t _bufferPos; 25 | 26 | void fillBuffer(); 27 | }; -------------------------------------------------------------------------------- /src/lib/PFD/PFD.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "../../src/include/targets.h" 5 | 6 | class PFD 7 | { 8 | private: 9 | uint32_t intEventTime = 0; 10 | uint32_t extEventTime = 0; 11 | bool gotExtEvent; 12 | bool gotIntEvent; 13 | 14 | public: 15 | inline void extEvent(uint32_t time) // reference (external osc) 16 | { 17 | extEventTime = time; 18 | gotExtEvent = true; 19 | } 20 | 21 | inline void intEvent(uint32_t time) // internal osc event 22 | { 23 | intEventTime = time; 24 | gotIntEvent = true; 25 | } 26 | 27 | inline void reset() 28 | { 29 | gotExtEvent = false; 30 | gotIntEvent = false; 31 | } 32 | 33 | int32_t calcResult() const 34 | { 35 | // Assumes caller has verified hasResult() 36 | return (int32_t)(extEventTime - intEventTime); 37 | } 38 | 39 | bool hasResult() const 40 | { 41 | return gotExtEvent && gotIntEvent; 42 | } 43 | 44 | volatile uint32_t getIntEventTime() const { return intEventTime; } 45 | volatile uint32_t getExtEventTime() const { return extEventTime; } 46 | }; 47 | -------------------------------------------------------------------------------- /src/lib/POWER_DETECT/devPDET.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "device.h" 4 | 5 | extern device_t PDET_device; -------------------------------------------------------------------------------- /src/lib/PWM/PWM.cpp: -------------------------------------------------------------------------------- 1 | #include "PWM.h" 2 | 3 | PWMController PWM; 4 | -------------------------------------------------------------------------------- /src/lib/PWM/PWM.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | typedef int pwm_channel_t; 4 | 5 | class PWMController 6 | { 7 | public: 8 | /** 9 | * @brief Allocate a pin/frequency to a PWM channel 10 | * 11 | * @param pin the GPIO pin to output the PWM signal on 12 | * @param frequency the output frequency of the PWM signal 13 | * @return the allocated PWM channel or -1 if a channel cannot be assigned 14 | */ 15 | pwm_channel_t allocate(uint8_t pin, uint32_t frequency); 16 | 17 | /** 18 | * @brief release a channel back to the allocator 19 | * 20 | * @param channel the channel to release 21 | */ 22 | void release(pwm_channel_t channel); 23 | 24 | /** 25 | * @brief Set the duty cycle of the PWM signal 26 | * The duty is in one-tenths of percent (i.e. value is 0-1000) 27 | * 28 | * @param channel the channel to adjust the signal on 29 | * @param duty the high time percentage in tenths of a percent 30 | */ 31 | void setDuty(pwm_channel_t channel, uint16_t duty); 32 | 33 | /** 34 | * @brief Set the output PWM signal high for the supplied microseconds 35 | * 36 | * @param channel the channel to adjust the signal on 37 | * @param microseconds the high time in microseconds 38 | */ 39 | void setMicroseconds(pwm_channel_t channel, uint16_t microseconds); 40 | }; 41 | 42 | extern PWMController PWM; 43 | -------------------------------------------------------------------------------- /src/lib/PWM/PWM_ESP8266.cpp: -------------------------------------------------------------------------------- 1 | #include "PWM.h" 2 | 3 | #if defined(PLATFORM_ESP8266) 4 | 5 | #include 6 | #include "waveform_8266.h" 7 | 8 | #define MAX_PWM_CHANNELS 13 9 | 10 | static uint16_t refreshInterval[MAX_PWM_CHANNELS] = {0}; 11 | static int8_t pwm_gpio[MAX_PWM_CHANNELS] = {-1}; 12 | 13 | pwm_channel_t PWMController::allocate(uint8_t pin, uint32_t frequency) 14 | { 15 | for(int channel=0 ; channel THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | -------------------------------------------------------------------------------- /src/lib/RFAMP/RFAMP_hal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SX12xxDriverCommon.h" 4 | #include 5 | 6 | class RFAMP_hal 7 | { 8 | public: 9 | static RFAMP_hal *instance; 10 | 11 | RFAMP_hal(); 12 | 13 | void init(); 14 | void ICACHE_RAM_ATTR TXenable(SX12XX_Radio_Number_t radioNumber); 15 | void ICACHE_RAM_ATTR RXenable(); 16 | void ICACHE_RAM_ATTR TXRXdisable(); 17 | 18 | private: 19 | #if defined(PLATFORM_ESP32) 20 | uint64_t txrx_disable_clr_bits; 21 | uint64_t tx1_enable_set_bits; 22 | uint64_t tx1_enable_clr_bits; 23 | uint64_t tx2_enable_set_bits; 24 | uint64_t tx2_enable_clr_bits; 25 | uint64_t tx_all_enable_set_bits; 26 | uint64_t tx_all_enable_clr_bits; 27 | uint64_t rx_enable_set_bits; 28 | uint64_t rx_enable_clr_bits; 29 | #else 30 | bool rx_enabled; 31 | bool tx1_enabled; 32 | bool tx2_enabled; 33 | #endif 34 | }; -------------------------------------------------------------------------------- /src/lib/SCREEN/FiveWayButton/FiveWayButton.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "targets.h" 4 | 5 | typedef enum 6 | { 7 | INPUT_KEY_LEFT_PRESS = 2, 8 | INPUT_KEY_UP_PRESS = 3, 9 | INPUT_KEY_RIGHT_PRESS = 4, 10 | INPUT_KEY_DOWN_PRESS = 5, 11 | INPUT_KEY_OK_PRESS = 6, 12 | INPUT_KEY_NO_PRESS = 7 13 | } Input_Key_Value_t; 14 | 15 | // Number of values in JOY_ADC_VALUES, if defined 16 | // These must be ADC readings for {UP, DOWN, LEFT, RIGHT, ENTER, IDLE} 17 | constexpr size_t N_JOY_ADC_VALUES = 6; 18 | 19 | class FiveWayButton 20 | { 21 | private: 22 | int keyInProcess; 23 | uint32_t keyDownStart; 24 | bool isLongPressed; 25 | #if defined(JOY_ADC_VALUES) 26 | static uint16_t joyAdcValues[N_JOY_ADC_VALUES]; 27 | uint16_t fuzzValues[N_JOY_ADC_VALUES]; 28 | void calcFuzzValues(); 29 | #endif 30 | 31 | int readKey(); 32 | 33 | public: 34 | FiveWayButton(); 35 | void init(); 36 | void update(int *keyValue, bool *keyLongPressed); 37 | 38 | static constexpr uint32_t KEY_DEBOUNCE_MS = 25; 39 | static constexpr uint32_t KEY_LONG_PRESS_MS = 1000; 40 | }; 41 | -------------------------------------------------------------------------------- /src/lib/SCREEN/OLED/oleddisplay.h: -------------------------------------------------------------------------------- 1 | #include "display.h" 2 | 3 | class OLEDDisplay : public Display 4 | { 5 | public: 6 | void init(); 7 | void doScreenBackLight(screen_backlight_t state); 8 | void printScreenshot(); 9 | 10 | void displaySplashScreen(); 11 | void displayIdleScreen(uint8_t changed, uint8_t rate_index, uint8_t power_index, uint8_t ratio_index, uint8_t motion_index, uint8_t fan_index, bool dynamic, uint8_t running_power_index, uint8_t temperature, message_index_t message_index); 12 | void displayMainMenu(menu_item_t menu); 13 | void displayValue(menu_item_t menu, uint8_t value_index); 14 | void displayBLEConfirm(); 15 | void displayBLEStatus(); 16 | void displayBindConfirm(); 17 | void displayBindStatus(); 18 | void displayWiFiConfirm(); 19 | void displayWiFiStatus(); 20 | void displayRunning(); 21 | void displaySending(); 22 | void displayLinkstats(); 23 | }; 24 | -------------------------------------------------------------------------------- /src/lib/SCREEN/TFT/tftdisplay.h: -------------------------------------------------------------------------------- 1 | #include "display.h" 2 | 3 | class TFTDisplay : public Display 4 | { 5 | public: 6 | void init(); 7 | void doScreenBackLight(screen_backlight_t state); 8 | void printScreenshot(); 9 | 10 | void displaySplashScreen(); 11 | void displayIdleScreen(uint8_t changed, uint8_t rate_index, uint8_t power_index, uint8_t ratio_index, uint8_t motion_index, uint8_t fan_index, bool dynamic, uint8_t running_power_index, uint8_t temperature, message_index_t message_index); 12 | void displayMainMenu(menu_item_t menu); 13 | void displayValue(menu_item_t menu, uint8_t value_index); 14 | void displayBLEConfirm(); 15 | void displayBLEStatus(); 16 | void displayBindConfirm(); 17 | void displayBindStatus(); 18 | void displayWiFiConfirm(); 19 | void displayWiFiStatus(); 20 | void displayRunning(); 21 | void displaySending(); 22 | void displayLinkstats(); 23 | }; 24 | -------------------------------------------------------------------------------- /src/lib/SCREEN/devScreen.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "device.h" 4 | 5 | extern device_t Screen_device; 6 | -------------------------------------------------------------------------------- /src/lib/SX127xDriver/SX127xDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "targets.h" 3 | #include "SX127xHal.h" 4 | #include "SX127x.h" 5 | -------------------------------------------------------------------------------- /src/lib/SX127xDriver/SX127xHal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SX127xRegs.h" 4 | #include "SX12xxDriverCommon.h" 5 | 6 | class SX127xHal 7 | { 8 | 9 | public: 10 | static SX127xHal *instance; 11 | 12 | SX127xHal(); 13 | 14 | void init(); 15 | void end(); 16 | void reset(); 17 | 18 | uint8_t ICACHE_RAM_ATTR readRegisterBits(uint8_t reg, uint8_t mask, SX12XX_Radio_Number_t radioNumber); 19 | uint8_t ICACHE_RAM_ATTR readRegister(uint8_t reg, SX12XX_Radio_Number_t radioNumber); 20 | void ICACHE_RAM_ATTR readRegister(uint8_t reg, uint8_t *data, uint8_t numBytes, SX12XX_Radio_Number_t radioNumber); 21 | 22 | void ICACHE_RAM_ATTR writeRegisterBits(uint8_t reg, uint8_t value, uint8_t mask, SX12XX_Radio_Number_t radioNumber); 23 | void ICACHE_RAM_ATTR writeRegister(uint8_t reg, uint8_t data, SX12XX_Radio_Number_t radioNumber); 24 | void ICACHE_RAM_ATTR writeRegister(uint8_t reg, uint8_t *data, uint8_t numBytes, SX12XX_Radio_Number_t radioNumber); 25 | 26 | static ICACHE_RAM_ATTR void dioISR_1(); 27 | static ICACHE_RAM_ATTR void dioISR_2(); 28 | void (*IsrCallback_1)(); // function pointer for callback 29 | void (*IsrCallback_2)(); // function pointer for callback 30 | 31 | private: 32 | 33 | }; -------------------------------------------------------------------------------- /src/lib/SX127xDriver/license.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/lib/SX127xDriver/license.txt -------------------------------------------------------------------------------- /src/lib/SX1280Driver/SX1280Driver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "SX1280_Regs.h" 3 | #include "SX1280_hal.h" 4 | #include "SX1280.h" 5 | -------------------------------------------------------------------------------- /src/lib/SerialUpdate/devSerialUpdate.cpp: -------------------------------------------------------------------------------- 1 | #include "targets.h" 2 | 3 | #if defined(PLATFORM_ESP32) && defined(TARGET_RX) 4 | #include 5 | 6 | #include "devSerialUpdate.h" 7 | #include "common.h" 8 | #include "hwTimer.h" 9 | #include "POWERMGNT.h" 10 | #include "devVTXSPI.h" 11 | #include "devMSPVTX.h" 12 | 13 | #include "telemetry.h" 14 | 15 | extern void start_esp_upload(); 16 | extern void stub_handle_rx_byte(char byte); 17 | 18 | static bool running = false; 19 | 20 | static void initialize() 21 | { 22 | running = true; 23 | } 24 | 25 | static int event() 26 | { 27 | if (connectionState == serialUpdate && running) 28 | { 29 | running = false; 30 | hwTimer::stop(); 31 | #ifdef HAS_VTX_SPI 32 | disableVTxSpi(); 33 | #endif 34 | #ifdef HAS_MSP_VTX 35 | disableMspVtx(); 36 | #endif 37 | POWERMGNT::setPower(MinPower); 38 | Radio.End(); 39 | return DURATION_IMMEDIATELY; 40 | } 41 | return DURATION_IGNORE; 42 | } 43 | 44 | static int timeout() 45 | { 46 | if (connectionState != serialUpdate) 47 | { 48 | return DURATION_NEVER; 49 | } 50 | 51 | start_esp_upload(); 52 | while (true) 53 | { 54 | uint8_t buf[64]; 55 | int count = Serial.read(buf, sizeof(buf)); 56 | for (int i=0 ; i 13 | 14 | /* Send the SLIP frame begin/end delimiter. */ 15 | void SLIP_send_frame_delimiter(void); 16 | 17 | /* Send a single character of SLIP frame data, escaped as per SLIP escaping. */ 18 | void SLIP_send_frame_data(char ch); 19 | 20 | /* Send the status byte (prefixed with the error flag). */ 21 | void SLIP_send_frame_status(char status); 22 | 23 | /* Send some SLIP frame data, escaped as per SLIP escaping. */ 24 | void SLIP_send_frame_data_buf(const void *buf, uint32_t size); 25 | 26 | /* Send a full SLIP frame, with specified contents. */ 27 | void SLIP_send(const void *pkt, uint32_t size); 28 | 29 | typedef enum { 30 | SLIP_NO_FRAME, 31 | SLIP_FRAME, 32 | SLIP_FRAME_ESCAPING 33 | } slip_state_t; 34 | 35 | int16_t SLIP_recv_byte(char byte, slip_state_t *state); 36 | 37 | #define SLIP_FINISHED_FRAME -2 38 | #define SLIP_NO_BYTE -1 39 | 40 | /* Receive a SLIP frame, with specified contents. */ 41 | uint32_t SLIP_recv(void *pkt, uint32_t max_len); 42 | 43 | #endif /* SLIP_H_ */ 44 | -------------------------------------------------------------------------------- /src/lib/SerialUpdate/soc_support.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | /* SoC-level support for ESP8266/ESP32. 8 | * 9 | * Provide a unified register-level interface. 10 | * 11 | * This is the same information provided in the register headers 12 | * of ESP8266 Non-OS SDK and ESP-IDF soc component, however 13 | * only values that are needed for the flasher stub are included here. 14 | * 15 | */ 16 | #pragma once 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #define READ_REG(REG) (*((volatile uint32_t *)(REG))) 23 | #define WRITE_REG(REG, VAL) *((volatile uint32_t *)(REG)) = (VAL) 24 | #define REG_SET_MASK(reg, mask) WRITE_REG((reg), (READ_REG(reg)|(mask))) 25 | #define REG_CLR_MASK(reg, mask) WRITE_REG((reg), (READ_REG(reg)&(~(mask)))) 26 | 27 | /********************************************************** 28 | * Per-SOC capabilities 29 | */ 30 | #if defined(PLATFORM_ESP32_S3) || defined(PLATFORM_ESP32_C3) 31 | #define HAS_SECURITY_INFO 32 | #define SECURITY_INFO_BYTES 20 33 | #endif 34 | -------------------------------------------------------------------------------- /src/lib/SerialUpdate/stub_commands.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #include "targets.h" 8 | 9 | #if defined(PLATFORM_ESP32) && defined(TARGET_RX) 10 | 11 | #include "soc_support.h" 12 | #include "stub_commands.h" 13 | #include "stub_flasher.h" 14 | #include "slip.h" 15 | 16 | #if defined(HAS_SECURITY_INFO) 17 | #if defined(PLATFORM_ESP32_S3) 18 | uint32_t (* GetSecurityInfoProc)(int* pMsg, int* pnErr, uint8_t *buf) = (uint32_t (*)(int* pMsg, int* pnErr, uint8_t *buf))0x40048174; // pMsg and pnErr unused in ROM 19 | #elif defined(PLATFORM_ESP32_C3) 20 | uint32_t (* GetSecurityInfoProc)(int* pMsg, int* pnErr, uint8_t *buf) = (uint32_t (*)(int* pMsg, int* pnErr, uint8_t *buf))0x4004b9da; // pMsg and pnErr unused in ROM 21 | extern uint32_t _rom_eco_version; // rom constant to define ECO version 22 | uint32_t (*GetSecurityInfoProcNewEco)(int* pMsg, int* pnErr, uint8_t *buf) = (uint32_t (*)(int* pMsg, int* pnErr, uint8_t *buf))0x4004d51e; // GetSecurityInfo for C3 ECO7+ 23 | #endif 24 | 25 | esp_command_error handle_get_security_info() 26 | { 27 | uint8_t buf[SECURITY_INFO_BYTES]; 28 | esp_command_error ret; 29 | 30 | #if defined(PLATFORM_ESP32_C3) 31 | if (_rom_eco_version >= 7) 32 | ret = (esp_command_error)GetSecurityInfoProcNewEco(NULL, NULL, buf); 33 | else 34 | ret = (esp_command_error)GetSecurityInfoProc(NULL, NULL, buf); 35 | #else 36 | ret = (esp_command_error)(*GetSecurityInfoProc)(NULL, NULL, buf); 37 | #endif // ESP32C3 38 | if (ret == ESP_UPDATE_OK) 39 | SLIP_send_frame_data_buf(buf, sizeof(buf)); 40 | return ret; 41 | } 42 | #endif 43 | #endif -------------------------------------------------------------------------------- /src/lib/SerialUpdate/stub_commands.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | /* Flasher command handlers, called from stub_flasher.c 8 | 9 | Commands related to writing flash are in stub_write_flash_xxx. 10 | */ 11 | #pragma once 12 | #include 13 | #include "soc_support.h" 14 | #include "stub_flasher.h" 15 | 16 | /* Get security info command only on ESP32S2 and later */ 17 | #if defined(HAS_SECURITY_INFO) 18 | esp_command_error handle_get_security_info(); 19 | #endif 20 | -------------------------------------------------------------------------------- /src/lib/SerialUpdate/stub_write_flash.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | /* Flasher commands related to writing flash */ 8 | #pragma once 9 | #include "stub_flasher.h" 10 | #include 11 | 12 | bool is_in_flash_mode(void); 13 | 14 | esp_command_error get_flash_error(void); 15 | 16 | esp_command_error handle_flash_begin(uint32_t total_size, uint32_t offset); 17 | void handle_flash_data(uint8_t *data_buf, uint32_t length); 18 | 19 | esp_command_error handle_flash_deflated_begin(uint32_t uncompressed_size, uint32_t compressed_size, uint32_t offset); 20 | void handle_flash_deflated_data(uint8_t *data_buf, uint32_t length); 21 | 22 | esp_command_error handle_flash_get_md5sum(uint32_t addr, uint32_t len); 23 | 24 | esp_command_error handle_flash_end(void); 25 | -------------------------------------------------------------------------------- /src/lib/ServoOutput/devServoOutput.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #if defined(GPIO_PIN_PWM_OUTPUTS) 3 | 4 | #include "device.h" 5 | #include "common.h" 6 | 7 | #if (defined(PLATFORM_ESP32)) 8 | #include "DShotRMT.h" 9 | #endif 10 | 11 | extern device_t ServoOut_device; 12 | #define HAS_SERVO_OUTPUT 13 | #define OPT_HAS_SERVO_OUTPUT (GPIO_PIN_PWM_OUTPUTS_COUNT > 0) 14 | 15 | // Notify this unit that new channel data has arrived 16 | void servoNewChannelsAvailable(); 17 | #else 18 | inline void servoNewChannelsAvailable(){}; 19 | #endif 20 | -------------------------------------------------------------------------------- /src/lib/StubbornReceiver/stubborn_receiver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class StubbornReceiver 6 | { 7 | public: 8 | StubbornReceiver(); 9 | void setMaxPackageIndex(uint8_t maxPackageIndex); 10 | void ResetState(); 11 | void SetDataToReceive(uint8_t* dataToReceive, uint8_t maxLength); 12 | void ReceiveData(uint8_t const packageIndex, uint8_t const * const receiveData, uint8_t dataLen); 13 | bool HasFinishedData(); 14 | void Unlock(); 15 | bool GetCurrentConfirm(); 16 | private: 17 | uint8_t *data; 18 | bool finishedData; 19 | uint8_t length; 20 | uint8_t currentOffset; 21 | uint8_t currentPackage; 22 | bool telemetryConfirm; 23 | uint8_t maxPackageIndex; 24 | }; 25 | -------------------------------------------------------------------------------- /src/lib/StubbornSender/stubborn_sender.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | // The number of times to resend the same package index before going to RESYNC 6 | #define SSENDER_MAX_MISSED_PACKETS 20 7 | 8 | typedef enum { 9 | SENDER_IDLE = 0, 10 | SEND_PENDING, 11 | SENDING, 12 | WAIT_UNTIL_NEXT_CONFIRM, 13 | RESYNC, 14 | RESYNC_THEN_SEND, // perform a RESYNC then go to SENDING 15 | } stubborn_sender_state_e; 16 | 17 | class StubbornSender 18 | { 19 | public: 20 | StubbornSender(); 21 | void setMaxPackageIndex(uint8_t maxPackageIndex); 22 | void ResetState(); 23 | void UpdateTelemetryRate(uint16_t airRate, uint8_t tlmRatio, uint8_t tlmBurst); 24 | void SetDataToTransmit(uint8_t* dataToTransmit, uint8_t lengthToTransmit); 25 | uint8_t GetCurrentPayload(uint8_t *outData, uint8_t maxLen); 26 | void ConfirmCurrentPayload(bool telemetryConfirmValue); 27 | bool IsActive() const { return senderState != SENDER_IDLE; } 28 | uint16_t GetMaxPacketsBeforeResync() const { return maxWaitCount; } 29 | private: 30 | uint8_t *data; 31 | uint8_t length; 32 | uint8_t currentOffset; 33 | uint8_t bytesLastPayload; 34 | uint8_t currentPackage; 35 | bool telemetryConfirmExpectedValue; 36 | uint16_t waitCount; 37 | uint16_t maxWaitCount; 38 | uint8_t maxPackageIndex; 39 | stubborn_sender_state_e senderState; 40 | }; 41 | -------------------------------------------------------------------------------- /src/lib/TCPSOCKET/tcpsocket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #if defined(USE_MSP_WIFI) 3 | 4 | #include 5 | #include 6 | #include "ESPAsyncWebServer.h" 7 | #include "FIFO.h" 8 | 9 | #define BUFFER_OUTPUT_SIZE 1024 10 | #define BUFFER_INPUT_SIZE 1024 11 | 12 | // buffers reads and write to the specified TCP port 13 | 14 | class TCPSOCKET 15 | { 16 | private: 17 | static TCPSOCKET *instance; 18 | //std::vector clients; // a list to hold all clients for MSP to WIFI bridge nut not using multi-client for now 19 | 20 | AsyncServer *TCPserver; 21 | AsyncClient *TCPclient = NULL; 22 | uint32_t TCPport; 23 | const uint32_t clientTimeoutPeriod = 2000; 24 | uint32_t clientTimeoutLastData; 25 | 26 | static void handleNewClient(void *arg, AsyncClient *client); 27 | static void handleDataIn(void *arg, AsyncClient *client, void *data, size_t len); 28 | static void handleDisconnect(void *arg, AsyncClient *client); 29 | static void handleTimeOut(void *arg, AsyncClient *client, uint32_t time); 30 | static void handleError(void *arg, AsyncClient *client, int8_t error); 31 | 32 | FIFO FIFOout; 33 | FIFO FIFOin; 34 | 35 | public: 36 | TCPSOCKET(const uint32_t port); 37 | void begin(); 38 | void handle(); 39 | bool hasClient(); 40 | uint16_t bytesReady(); // has x bytes in the input buffer ready 41 | bool write(uint8_t *data, uint16_t len); 42 | void read(uint8_t *data); 43 | }; 44 | 45 | #endif -------------------------------------------------------------------------------- /src/lib/THERMAL/devThermal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(HAS_THERMAL) || defined(HAS_FAN) 4 | #include "device.h" 5 | #include "CRSF.h" 6 | 7 | extern device_t Thermal_device; 8 | #endif -------------------------------------------------------------------------------- /src/lib/THERMAL/lm75a.cpp: -------------------------------------------------------------------------------- 1 | #ifdef HAS_THERMAL_LM75A 2 | #include 3 | #include "lm75a.h" 4 | #include "logging.h" 5 | 6 | 7 | int LM75A::init() 8 | { 9 | uint8_t buffer[5]; 10 | 11 | ReadAccRegister(LM75A_REG_TOS, buffer, 2); 12 | 13 | DBGLN("thermal lma75 read Tos = 0x%x", buffer[0]); 14 | 15 | if(buffer[0] == 0) 16 | { 17 | ERRLN("thermal lma75 init failed!"); 18 | return -1; 19 | } 20 | 21 | return 0; 22 | } 23 | 24 | uint8_t LM75A::read_lm75a() 25 | { 26 | uint8_t buffer[5]; 27 | ReadAccRegister(LM75A_REG_TEMP, buffer, 2); 28 | 29 | // ignore the second byte as it's the decimal part of a degree. 30 | return buffer[0]; 31 | } 32 | 33 | void LM75A::update_lm75a_threshold(uint8_t tos, uint8_t thyst) 34 | { 35 | uint8_t buffer[5]; 36 | buffer[0] = thyst; 37 | buffer[1] = 0; 38 | WriteAccRegister(LM75A_REG_THYST, buffer, 2); 39 | 40 | buffer[0] = tos; 41 | buffer[1] = 0; 42 | WriteAccRegister(LM75A_REG_TOS, buffer, 2); 43 | } 44 | 45 | void LM75A::ReadAccRegister(uint8_t reg, uint8_t *data, int size) 46 | { 47 | Wire.beginTransmission(LM75A_I2C_ADDRESS); 48 | Wire.write(reg); 49 | Wire.endTransmission(); 50 | 51 | Wire.requestFrom(LM75A_I2C_ADDRESS, size); // request 1 bytes from slave device 52 | Wire.readBytes(data, size); 53 | } 54 | 55 | void LM75A::WriteAccRegister(uint8_t reg, uint8_t *data, int size) 56 | { 57 | Wire.beginTransmission(LM75A_I2C_ADDRESS); 58 | Wire.write(reg); 59 | Wire.write(data, size); 60 | Wire.endTransmission(); 61 | } 62 | #endif -------------------------------------------------------------------------------- /src/lib/THERMAL/lm75a.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "targets.h" 4 | 5 | class LM75A 6 | { 7 | private: 8 | void ReadAccRegister(uint8_t reg, uint8_t *data, int size); 9 | void WriteAccRegister(uint8_t reg, uint8_t *data, int size); 10 | public: 11 | int init(); 12 | uint8_t read_lm75a(); 13 | void update_lm75a_threshold(uint8_t tos, uint8_t thyst); 14 | }; 15 | 16 | #define LM75A_I2C_ADDRESS 0x48 17 | 18 | #define LM75A_REG_TEMP 0x00 19 | #define LM75A_REG_CONF 0x01 20 | 21 | #define LM75A_REG_THYST 0x02 22 | #define LM75A_REG_TOS 0x03 23 | #define LM75A_TOS_DEFAULT_VALUE 0x50 24 | -------------------------------------------------------------------------------- /src/lib/THERMAL/thermal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "targets.h" 4 | 5 | typedef enum 6 | { 7 | THERMAL_STATUS_FAIL = 0, 8 | THERMAL_STATUS_NORMAL = 1 9 | } Thermal_Status_t; 10 | 11 | class Thermal 12 | { 13 | private: 14 | uint8_t temp_value; 15 | 16 | public: 17 | void init(); 18 | void handle(); 19 | uint8_t read_temp(); 20 | void update_threshold(int index); 21 | uint8_t getTempValue() { return temp_value; } 22 | }; 23 | 24 | #define THERMAL_FAN_DEFAULT_LOW_THRESHOLD 35 25 | #define THERMAL_FAN_DEFAULT_HIGH_THRESHOLD 50 26 | 27 | #define THERMAL_FAN_ALWAYS_ON_LOW_THRESHOLD 0xFF 28 | #define THERMAL_FAN_ALWAYS_ON_HIGH_THRESHOLD 0xFD 29 | 30 | #define THERMAL_FAN_OFF_LOW_THRESHOLD 0x7D 31 | #define THERMAL_FAN_OFF_HIGH_THRESHOLD 0x7F 32 | -------------------------------------------------------------------------------- /src/lib/TelemetryProtocol/dummy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is here to ensure that the library has an object file created for native test builds 3 | */ 4 | int __telemetry_protocol_dummy; 5 | -------------------------------------------------------------------------------- /src/lib/TelemetryProtocol/telemetry_protocol.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define ELRS_TELEMETRY_TYPE_LINK 0x01 4 | #define ELRS_TELEMETRY_TYPE_DATA 0x02 5 | #define ELRS_TELEMETRY_TYPE_ENCRYPTION 0x03 6 | 7 | #define ELRS4_TELEMETRY_SHIFT 2 8 | #define ELRS4_TELEMETRY_BYTES_PER_CALL 5 9 | #define ELRS4_TELEMETRY_MAX_PACKAGES (255 >> ELRS4_TELEMETRY_SHIFT) 10 | #define ELRS8_TELEMETRY_BYTES_PER_CALL 10 // some of this is consumed by LinkStats buuuut.... 11 | #define ELRS8_TELEMETRY_SHIFT 3 12 | #define ELRS8_TELEMETRY_MAX_PACKAGES (255 >> ELRS8_TELEMETRY_SHIFT) 13 | 14 | #define ELRS4_MSP_BYTES_PER_CALL 5 15 | #define ELRS8_MSP_BYTES_PER_CALL 10 16 | #define ELRS_MSP_BUFFER 65 17 | #define ELRS_MSP_MAX_PACKAGES ((ELRS_MSP_BUFFER/ELRS4_MSP_BYTES_PER_CALL)+1) 18 | 19 | #define AP_MAX_BUF_LEN 64 20 | -------------------------------------------------------------------------------- /src/lib/VTX/devVTX.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "device.h" 4 | 5 | // Call this to trigger sending of Vtx packet 6 | void VtxTriggerSend(); 7 | void VtxPitmodeSwitchUpdate(); 8 | extern device_t VTX_device; -------------------------------------------------------------------------------- /src/lib/VTXSPI/devVTXSPI.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "device.h" 4 | 5 | extern device_t VTxSPI_device; 6 | 7 | extern uint16_t vtxSPIFrequency; 8 | extern uint8_t vtxSPIPowerIdx; 9 | extern uint8_t vtxSPIPitmode; 10 | 11 | void VTxOutputMinimum(); 12 | void disableVTxSpi(); 13 | -------------------------------------------------------------------------------- /src/lib/WIFI/devWIFI.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "device.h" 4 | 5 | #if defined(PLATFORM_ESP32) || defined(PLATFORM_ESP8266) 6 | #include "devButton.h" 7 | 8 | extern device_t WIFI_device; 9 | #define HAS_WIFI 10 | #endif -------------------------------------------------------------------------------- /src/lib/WIFI/lr1121.h: -------------------------------------------------------------------------------- 1 | #if (defined(PLATFORM_ESP8266) || defined(PLATFORM_ESP32)) && defined(RADIO_LR1121) 2 | 3 | #include 4 | 5 | void addLR1121Handlers(AsyncWebServer &server); 6 | 7 | #endif -------------------------------------------------------------------------------- /src/lib/elrs_eeprom/elrs_eeprom.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #define RESERVED_EEPROM_SIZE 1024 7 | 8 | class ELRS_EEPROM 9 | { 10 | public: 11 | void Begin(); 12 | uint8_t ReadByte(const uint32_t address); 13 | void WriteByte(const uint32_t address, const uint8_t value); 14 | void Commit(); 15 | 16 | // The extEEPROM lib that we use for STM doesn't have the get and put templates 17 | // These templates need to be reimplemented here 18 | template void Get(uint32_t addr, T &value) 19 | { 20 | uint8_t* p = (uint8_t*)(void*)&value; 21 | size_t i = sizeof(value); 22 | while(i--) *p++ = ReadByte(addr++); 23 | }; 24 | 25 | template const void Put(uint32_t addr, const T &value) 26 | { 27 | const uint8_t* p = (const uint8_t*)(const void*)&value; 28 | size_t i = sizeof(value); 29 | while(i--) WriteByte(addr++, *p++); 30 | }; 31 | }; 32 | -------------------------------------------------------------------------------- /src/lua/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Which file do I need? 3 | * For transmitters on master, ExpressLRS 2.x, or 3.0 -> elrsV3.lua 4 | * For transmitters on 1.x -> ELRS.lua 5 | 6 | ### Downloading from Github: 7 | Click the file link above, find the "Raw" button near the top of that page. Right-click, Save link as.., copy the .lua file into the /SCRIPTS/TOOLS directory of the SD card on your handset. 8 | 9 | ### Downloading from Configurator: 10 | Use the button shown in the image below to download the .lua script into the /SCRIPTS/TOOLS directory of the SD card on your handset. 11 | ![downloadlua](https://user-images.githubusercontent.com/68074253/129203116-c1234719-3e8c-4cbf-a391-b7fb8dc0262d.png) 12 | -------------------------------------------------------------------------------- /src/lua/mockup/README.md: -------------------------------------------------------------------------------- 1 | This file is for development purposes only and provides field definitions for filling the screen in the OpenTX Companion Simulator. Users do not need this file on their handset's SD card! 2 | 3 | ### Using 4 | Copy the entire mockup directory into the same directory as `elrsV2.lua` on your hard drive where you've set the OpenTX Companion "SD Structure Path". The SD structure path should look like this: 5 | ``` 6 | SCRIPTS/TOOLS/elrsV2.lua 7 | SCRIPTS/TOOLS/mockup/elrsmock.lua 8 | SCRIPTS/TOOLS/mockup/README.md <- this file 9 | ``` 10 | When you execute elrsV2.lua, the screen will be populated with fake ELRS Lua config fields. -------------------------------------------------------------------------------- /src/lua/mockup/elrsmock.lua: -------------------------------------------------------------------------------- 1 | return { 2 | {name='Packet Rate', id=0, type=9, values={'250(-108dBm)','500(-105dBm)'}, value=1, unit='Hz'}, 3 | {name='Telem Ratio', id=1, type=9, values={'Off','1:128'}, value=1, unit=''}, 4 | {name='Switch Mode', id=2, type=9, values={'Hybrid','Wide'}, value=1, unit=''}, 5 | {name='Model Match', id=3, type=9, values={'Off',''}, grey=true, value=0, unit='(ID:1)'}, 6 | {name='TX Power', id=4, type=11}, 7 | {name='Max Power', id=5, type=9, parent=4, values={'10','25','50'}, value=2, unit='mW'}, 8 | {name='Dynamic', id=6, type=9, parent=4, values={'Off','On','AUX9'}, value=1, unit=''}, 9 | {name='Fan Thresh', id=7, type=9, parent=4, values={'10mW','25mW','50mW', '250mW'}, value=3, unit=''}, 10 | {name='VTX Administrator', id=8, type=11}, 11 | {name='Band', id=9, type=9, parent=8, values={'Off', 'A', 'B', 'F', 'R', 'L'}, value=0, unit=''}, 12 | {name='Channel', id=10, type=0, parent=8, value=1, step=1, min=1, max=8, unit=''}, 13 | {name='Pwr Lvl', id=11, type=9, parent=8, values={'-', '1', '2', '3' }, value=0, unit=''}, 14 | {name='Pitmode', id=12, type=9, parent=8, values={'Off', 'On'}, value=0, unit=''}, 15 | {name='Send VTx', id=13, type=13, parent=8}, 16 | {name='Bind', id=14, type=13}, 17 | {name='Wifi Update', id=15, type=13}, 18 | {name='BLE Joystick', id=16, type=13}, 19 | {name='master', id=17, type=16, value='f00fcb'}, 20 | {name='Float Tst', id=18, type=8, value=-15, step=5, prec=1000, min=-50, max=50, unit='flt', fmt='%.3fflt'}, 21 | 22 | {name="----BACK----", type=14, parent=255}, 23 | {name="----EXIT----", type=14, exit = true} 24 | }, "0/500 C", "ExpressLRS TX" -------------------------------------------------------------------------------- /src/platformio.ini: -------------------------------------------------------------------------------- 1 | ; ExpressLRS PlatformIO Project Configuration File 2 | 3 | [platformio] 4 | extra_configs = 5 | # keep common first 6 | targets/common.ini 7 | # defined one by one to maintain the order 8 | targets/unified.ini 9 | targets/diy_900.ini 10 | targets/diy_2400.ini 11 | targets/frsky.ini 12 | targets/happymodel_900.ini 13 | targets/happymodel_2400.ini 14 | targets/imrc.ini 15 | targets/namimnorc_900.ini 16 | targets/namimnorc_2400.ini 17 | targets/siyi.ini 18 | 19 | # ------------------------- TARGET ENV DEFINITIONS ----------------- 20 | 21 | [env:native] 22 | platform = native 23 | framework = 24 | test_ignore = test_embedded 25 | lib_ignore = BUTTON, DAC, LQCALC, LBT, SPIEx, PWM, WIFI, TCPSOCKET, LR1121Driver 26 | build_src_filter = ${common_env_data.build_src_filter} - - - - - - - 27 | build_flags = 28 | -std=c++11 29 | -Iinclude 30 | -D PROGMEM="" 31 | -D UNIT_TEST=1 32 | -D TARGET_NATIVE 33 | -D CRSF_RX_MODULE 34 | -D CRSF_TX_MODULE 35 | -------------------------------------------------------------------------------- /src/privacylrs/screenshot_choose_local.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/privacylrs/screenshot_choose_local.png -------------------------------------------------------------------------------- /src/python/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include *.py 2 | recursive-include external *.py *.json 3 | -------------------------------------------------------------------------------- /src/python/__init__.py: -------------------------------------------------------------------------------- 1 | import binary_configurator 2 | 3 | if __name__ == '__main__': 4 | binary_configurator.main() 5 | -------------------------------------------------------------------------------- /src/python/__main__.py: -------------------------------------------------------------------------------- 1 | import binary_configurator 2 | 3 | if __name__ == '__main__': 4 | binary_configurator.main() 5 | -------------------------------------------------------------------------------- /src/python/bootloader.py: -------------------------------------------------------------------------------- 1 | 2 | INIT_SEQ = { 3 | "CRSF": [0xEC,0x04,0x32,ord('b'),ord('l')], 4 | "GHST": [0x89,0x04,0x32,ord('b'),ord('l')], 5 | } 6 | 7 | BIND_SEQ = { 8 | "CRSF": [0xEC,0x04,0x32,ord('b'),ord('d')], 9 | "GHST": [0x89,0x04,0x32,ord('b'),ord('d')], 10 | } 11 | 12 | MODEL_SEQ = [0xEC,0x04,0x32,ord('m'),ord('m')] 13 | 14 | def calc_crc8(payload, poly=0xD5): 15 | crc = 0 16 | for data in payload: 17 | crc ^= data 18 | for _ in range(8): 19 | if crc & 0x80: 20 | crc = (crc << 1) ^ poly 21 | else: 22 | crc = crc << 1 23 | return crc & 0xFF 24 | 25 | def get_telemetry_seq(seq, key=None): 26 | payload = list(seq) 27 | if payload: 28 | if key: 29 | if type(key) == str: 30 | key = [ord(x) for x in key] 31 | payload += key 32 | payload[1] += len(key) 33 | payload += [calc_crc8(payload[2:])] 34 | return bytes(payload) 35 | 36 | def get_init_seq(module, key=None): 37 | return get_telemetry_seq(INIT_SEQ.get(module, []), key) 38 | 39 | def get_bind_seq(module, key=None): 40 | return get_telemetry_seq(BIND_SEQ.get(module, []), key) 41 | 42 | def get_model_seq(model): 43 | return get_telemetry_seq(MODEL_SEQ, model) 44 | 45 | if __name__ == '__main__': 46 | print("CRC: %s" % get_init_seq('CRSF', [ord(x) for x in 'R9MM'])) 47 | print("CRC: %s" % get_init_seq('CRSF', 'R9MM')) 48 | -------------------------------------------------------------------------------- /src/python/elrs_helpers.py: -------------------------------------------------------------------------------- 1 | import os 2 | import re 3 | import subprocess 4 | 5 | def git_cmd(*args): 6 | return subprocess.check_output(["git"] + list(args)).decode("utf-8").rstrip('\r\n') 7 | 8 | 9 | def get_git_version(): 10 | """ 11 | Return a dict with keys 12 | version: The version tag if HEAD is a version, or branch otherwise 13 | sha: the 6 character short sha for the current HEAD revison, falling back to 14 | VERSION file if not in a git repo 15 | """ 16 | ver = "ver.unknown" 17 | sha = "000000" 18 | 19 | try: 20 | sha = git_cmd("rev-parse", "HEAD") 21 | ver = git_cmd("rev-parse", "--abbrev-ref", "HEAD") 22 | # failure here is acceptable, unnamed commits might not have a branch 23 | # associated 24 | try: 25 | ver = re.sub(r".*/", "", git_cmd("describe", 26 | "--all", "--exact-match")) 27 | except: 28 | pass 29 | except: 30 | if os.path.exists("VERSION"): 31 | with open("VERSION") as _f: 32 | data = _f.readline() 33 | _f.close() 34 | sha = data.split()[1].strip() 35 | 36 | return dict(version=ver, sha=sha[:6]) 37 | 38 | 39 | class ElrsUploadResult: 40 | # SUCCESS 41 | Success = 0 42 | # ERROR: Unspecified 43 | ErrorGeneral = -1 44 | # ERROR: target mismatch 45 | ErrorMismatch = -2 46 | -------------------------------------------------------------------------------- /src/python/external/__init__.py: -------------------------------------------------------------------------------- 1 | import binary_configurator 2 | 3 | if __name__ == '__main__': 4 | binary_configurator.main() 5 | -------------------------------------------------------------------------------- /src/python/external/esptool/README.md: -------------------------------------------------------------------------------- 1 | # esptool.py 2 | 3 | A Python-based, open-source, platform-independent utility to communicate with the ROM bootloader in Espressif chips. 4 | 5 | [![Test esptool](https://github.com/espressif/esptool/actions/workflows/test_esptool.yml/badge.svg?branch=master)](https://github.com/espressif/esptool/actions/workflows/test_esptool.yml) [![Build esptool](https://github.com/espressif/esptool/actions/workflows/build_esptool.yml/badge.svg?branch=master)](https://github.com/espressif/esptool/actions/workflows/build_esptool.yml) 6 | 7 | ## Documentation 8 | 9 | Visit the [documentation](https://docs.espressif.com/projects/esptool/) or run `esptool.py -h`. 10 | 11 | ## Contribute 12 | 13 | If you're interested in contributing to esptool.py, please check the [contributions guide](https://docs.espressif.com/projects/esptool/en/latest/contributing.html). 14 | 15 | ## About 16 | 17 | esptool.py was initially created by Fredrik Ahlberg (@[themadinventor](https://github.com/themadinventor/)), and later maintained by Angus Gratton (@[projectgus](https://github.com/projectgus/)). It is now supported by Espressif Systems. It has also received improvements from many members of the community. 18 | 19 | ## License 20 | 21 | This document and the attached source code are released as Free Software under GNU General Public License Version 2 or later. See the accompanying [LICENSE file](https://github.com/espressif/esptool/blob/master/LICENSE) for a copy. 22 | -------------------------------------------------------------------------------- /src/python/external/esptool/__init__.py: -------------------------------------------------------------------------------- 1 | import binary_configurator 2 | 3 | if __name__ == '__main__': 4 | binary_configurator.main() 5 | -------------------------------------------------------------------------------- /src/python/external/esptool/esptool.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # SPDX-FileCopyrightText: 2014-2022 Fredrik Ahlberg, Angus Gratton, 4 | # Espressif Systems (Shanghai) CO LTD, other contributors as noted. 5 | # 6 | # SPDX-License-Identifier: GPL-2.0-or-later 7 | 8 | # This executable script is a thin wrapper around the main functionality 9 | # in the esptool Python package 10 | 11 | # When updating this script, please also update espefuse.py and espsecure.py 12 | 13 | import contextlib 14 | import os 15 | import sys 16 | 17 | if os.name != "nt": 18 | # Linux/macOS: remove current script directory to avoid importing this file 19 | # as a module; we want to import the installed esptool module instead 20 | with contextlib.suppress(ValueError): 21 | if sys.path[0].endswith("/bin"): 22 | sys.path.pop(0) 23 | sys.path.remove(os.path.dirname(sys.executable)) 24 | 25 | # Linux/macOS: delete imported module entry to force Python to load 26 | # the module from scratch; this enables importing esptool module in 27 | # other Python scripts 28 | with contextlib.suppress(KeyError): 29 | del sys.modules["esptool"] 30 | 31 | import esptool 32 | 33 | if __name__ == "__main__": 34 | esptool._main() 35 | -------------------------------------------------------------------------------- /src/python/external/esptool/esptool/__main__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # SPDX-FileCopyrightText: 2014-2022 Fredrik Ahlberg, Angus Gratton, 4 | # Espressif Systems (Shanghai) CO LTD, other contributors as noted. 5 | # 6 | # SPDX-License-Identifier: GPL-2.0-or-later 7 | 8 | import esptool 9 | 10 | if __name__ == "__main__": 11 | esptool._main() 12 | -------------------------------------------------------------------------------- /src/python/external/esptool/esptool/targets/__init__.py: -------------------------------------------------------------------------------- 1 | from .esp32 import ESP32ROM 2 | from .esp32c2 import ESP32C2ROM 3 | from .esp32c3 import ESP32C3ROM 4 | from .esp32c6beta import ESP32C6BETAROM 5 | from .esp32h2beta1 import ESP32H2BETA1ROM 6 | from .esp32h2beta2 import ESP32H2BETA2ROM 7 | from .esp32s2 import ESP32S2ROM 8 | from .esp32s3 import ESP32S3ROM 9 | from .esp32s3beta2 import ESP32S3BETA2ROM 10 | from .esp8266 import ESP8266ROM 11 | 12 | 13 | CHIP_DEFS = { 14 | "esp8266": ESP8266ROM, 15 | "esp32": ESP32ROM, 16 | "esp32s2": ESP32S2ROM, 17 | "esp32s3beta2": ESP32S3BETA2ROM, 18 | "esp32s3": ESP32S3ROM, 19 | "esp32c3": ESP32C3ROM, 20 | "esp32c6beta": ESP32C6BETAROM, 21 | "esp32h2beta1": ESP32H2BETA1ROM, 22 | "esp32h2beta2": ESP32H2BETA2ROM, 23 | "esp32c2": ESP32C2ROM, 24 | } 25 | 26 | CHIP_LIST = list(CHIP_DEFS.keys()) 27 | ROM_LIST = list(CHIP_DEFS.values()) 28 | -------------------------------------------------------------------------------- /src/python/external/esptool/esptool/targets/esp32c6beta.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2014-2022 Fredrik Ahlberg, Angus Gratton, 2 | # Espressif Systems (Shanghai) CO LTD, other contributors as noted. 3 | # 4 | # SPDX-License-Identifier: GPL-2.0-or-later 5 | 6 | from .esp32c3 import ESP32C3ROM 7 | 8 | 9 | class ESP32C6BETAROM(ESP32C3ROM): 10 | CHIP_NAME = "ESP32-C6(beta)" 11 | IMAGE_CHIP_ID = 7 12 | 13 | CHIP_DETECT_MAGIC_VALUE = [0x0DA1806F] 14 | 15 | UART_DATE_REG_ADDR = 0x00000500 16 | 17 | def get_chip_description(self): 18 | chip_name = { 19 | 0: "ESP32-C6", 20 | }.get(self.get_pkg_version(), "unknown ESP32-C6") 21 | chip_revision = self.get_chip_revision() 22 | 23 | return "%s (revision %d)" % (chip_name, chip_revision) 24 | -------------------------------------------------------------------------------- /src/python/external/esptool/esptool/targets/esp32h2beta2.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2014-2022 Fredrik Ahlberg, Angus Gratton, 2 | # Espressif Systems (Shanghai) CO LTD, other contributors as noted. 3 | # 4 | # SPDX-License-Identifier: GPL-2.0-or-later 5 | 6 | from .esp32h2beta1 import ESP32H2BETA1ROM 7 | 8 | 9 | class ESP32H2BETA2ROM(ESP32H2BETA1ROM): 10 | CHIP_NAME = "ESP32-H2(beta2)" 11 | IMAGE_CHIP_ID = 14 12 | 13 | CHIP_DETECT_MAGIC_VALUE = [0x6881B06F] 14 | 15 | def get_chip_description(self): 16 | chip_name = { 17 | 1: "ESP32-H2(beta2)", 18 | }.get(self.get_pkg_version(), "unknown ESP32-H2") 19 | chip_revision = self.get_chip_revision() 20 | 21 | return "{} (revision {})".format(chip_name, chip_revision) 22 | 23 | 24 | class ESP32H2BETA2StubLoader(ESP32H2BETA2ROM): 25 | """Access class for ESP32H2BETA2 stub loader, runs on top of ROM. 26 | 27 | (Basically the same as ESP32StubLoader, but different base class. 28 | Can possibly be made into a mixin.) 29 | """ 30 | 31 | FLASH_WRITE_SIZE = 0x4000 # matches MAX_WRITE_BLOCK in stub_loader.c 32 | STATUS_BYTES_LENGTH = 2 # same as ESP8266, different to ESP32 ROM 33 | IS_STUB = True 34 | 35 | def __init__(self, rom_loader): 36 | self.secure_download_mode = rom_loader.secure_download_mode 37 | self._port = rom_loader._port 38 | self._trace_enabled = rom_loader._trace_enabled 39 | self.flush_input() # resets _slip_reader 40 | 41 | 42 | ESP32H2BETA2ROM.STUB_CLASS = ESP32H2BETA2StubLoader 43 | -------------------------------------------------------------------------------- /src/python/external/esptool/esptool/targets/esp32s3beta2.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2014-2022 Fredrik Ahlberg, Angus Gratton, 2 | # Espressif Systems (Shanghai) CO LTD, other contributors as noted. 3 | # 4 | # SPDX-License-Identifier: GPL-2.0-or-later 5 | 6 | from .esp32s3 import ESP32S3ROM 7 | 8 | 9 | class ESP32S3BETA2ROM(ESP32S3ROM): 10 | CHIP_NAME = "ESP32-S3(beta2)" 11 | IMAGE_CHIP_ID = 4 12 | 13 | CHIP_DETECT_MAGIC_VALUE = [0xEB004136] 14 | 15 | EFUSE_BASE = 0x6001A000 # BLOCK0 read base address 16 | 17 | def get_chip_description(self): 18 | return "ESP32-S3(beta2)" 19 | 20 | 21 | class ESP32S3BETA2StubLoader(ESP32S3BETA2ROM): 22 | """Access class for ESP32S3 stub loader, runs on top of ROM. 23 | 24 | (Basically the same as ESP32StubLoader, but different base class. 25 | Can possibly be made into a mixin.) 26 | """ 27 | 28 | FLASH_WRITE_SIZE = 0x4000 # matches MAX_WRITE_BLOCK in stub_loader.c 29 | STATUS_BYTES_LENGTH = 2 # same as ESP8266, different to ESP32 ROM 30 | IS_STUB = True 31 | 32 | def __init__(self, rom_loader): 33 | self.secure_download_mode = rom_loader.secure_download_mode 34 | self._port = rom_loader._port 35 | self._trace_enabled = rom_loader._trace_enabled 36 | self.flush_input() # resets _slip_reader 37 | 38 | 39 | ESP32S3BETA2ROM.STUB_CLASS = ESP32S3BETA2StubLoader 40 | -------------------------------------------------------------------------------- /src/python/external/inputimeout/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Mitsuo Heijo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/python/external/inputimeout/__init__.py: -------------------------------------------------------------------------------- 1 | from .inputimeout import inputimeout, TimeoutOccurred # noqa 2 | from .__version__ import ( # noqa 3 | __version__, __author__, __author_email__, __copyright__, __license__, 4 | __description__, __title__, __url__, 5 | ) 6 | -------------------------------------------------------------------------------- /src/python/external/inputimeout/__version__.py: -------------------------------------------------------------------------------- 1 | __title__ = 'inputimeout' 2 | __description__ = 'Multi platform standard input with timeout' 3 | __url__ = 'http://github.com/johejo/inutimeout' 4 | __version__ = '1.0.4' 5 | __author__ = 'Mitsuo Heijo' 6 | __author_email__ = 'mitsuo_h@outlook.com' 7 | __license__ = 'MIT' 8 | __copyright__ = 'Copyright 2018 Mitsuo Heijo' 9 | -------------------------------------------------------------------------------- /src/python/external/jmespath/__init__.py: -------------------------------------------------------------------------------- 1 | from external.jmespath import parser 2 | from external.jmespath.visitor import Options 3 | 4 | __version__ = '1.0.0' 5 | 6 | 7 | def compile(expression): 8 | return parser.Parser().parse(expression) 9 | 10 | 11 | def search(expression, data, options=None): 12 | return parser.Parser().parse(expression).search(data, options=options) 13 | -------------------------------------------------------------------------------- /src/python/external/jmespath/compat.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import inspect 3 | from itertools import zip_longest 4 | 5 | 6 | text_type = str 7 | string_type = str 8 | 9 | 10 | def with_str_method(cls): 11 | # In python3, we don't need to do anything, we return a str type. 12 | return cls 13 | 14 | def with_repr_method(cls): 15 | return cls 16 | 17 | def get_methods(cls): 18 | for name, method in inspect.getmembers(cls, predicate=inspect.isfunction): 19 | yield name, method 20 | -------------------------------------------------------------------------------- /src/python/external/minify/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/python/external/minify/__init__.py -------------------------------------------------------------------------------- /src/python/external/pystlink/__init__.py: -------------------------------------------------------------------------------- 1 | from pystlink.pystlink_api import * -------------------------------------------------------------------------------- /src/python/external/pystlink/bin/install.bat: -------------------------------------------------------------------------------- 1 | @rem ----[ This code block detects if the script is being running with admin PRIVILEGES If it isn't it pauses and then quits]------- 2 | @echo OFF 3 | NET SESSION >nul 2>&1 4 | IF NOT %ERRORLEVEL% EQU 0 ( 5 | echo ######## ######## ######## ####### ######## 6 | echo ## ## ## ## ## ## ## ## ## 7 | echo ## ## ## ## ## ## ## ## ## 8 | echo ###### ######## ######## ## ## ######## 9 | echo ## ## ## ## ## ## ## ## ## 10 | echo ## ## ## ## ## ## ## ## ## 11 | echo ######## ## ## ## ## ####### ## ## 12 | echo. 13 | echo. 14 | echo ####### ERROR: ADMINISTRATOR PRIVILEGES REQUIRED ######### 15 | echo This script must be run as administrator to work properly! 16 | echo If you're seeing this after clicking on a start menu icon, then right click on the shortcut and select "Run As Administrator". 17 | echo ########################################################## 18 | echo. 19 | PAUSE 20 | EXIT /B 1 21 | ) 22 | @echo ON 23 | copy %~dp0libusb-1.0.dll C:\Windows\System32\libusb-1.0.dll 24 | @pause 25 | -------------------------------------------------------------------------------- /src/python/external/pystlink/bin/libusb-1.0.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/python/external/pystlink/bin/libusb-1.0.dll -------------------------------------------------------------------------------- /src/python/external/pystlink/lib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/python/external/pystlink/lib/__init__.py -------------------------------------------------------------------------------- /src/python/external/pystlink/lib/stlinkex.py: -------------------------------------------------------------------------------- 1 | class StlinkException(Exception): 2 | def __init__(self, msg): 3 | self._msg = msg 4 | 5 | def __str__(self): 6 | return self._msg 7 | 8 | 9 | class StlinkExceptionBadParam(StlinkException): 10 | def __init__(self, info=None, cmd=None): 11 | self._info = info 12 | self._cmd = cmd 13 | 14 | def set_cmd(self, cmd): 15 | self._cmd = cmd 16 | return self 17 | 18 | def __str__(self): 19 | msg = 'Bad param: "%s"' % self._cmd 20 | if self._info: 21 | msg += ': %s' % self._info 22 | return msg 23 | 24 | 25 | class StlinkExceptionCpuNotSelected(StlinkException): 26 | def __init__(self): 27 | self._msg = 'CPU is not selected' 28 | -------------------------------------------------------------------------------- /src/python/external/pystlink/pystlink: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | exec_file=$0 4 | 5 | if [ -L "$exec_file" ] ; then 6 | exec_file=`readlink $exec_file` 7 | fi 8 | 9 | work_dir=`dirname $exec_file` 10 | 11 | python3 $work_dir/pystlink.py $* 12 | -------------------------------------------------------------------------------- /src/python/external/pystlink/stlinkv2.rules: -------------------------------------------------------------------------------- 1 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", MODE:="0666", SYMLINK+="stlinkv2_%n" 2 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b", MODE:="0666", SYMLINK+="stlinkv2-1_%n" 3 | -------------------------------------------------------------------------------- /src/python/external/usb/_version.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | # file generated by setuptools_scm 3 | # don't change, don't track in version control 4 | version = '1.2.1' 5 | version_tuple = (1, 2, 1) 6 | -------------------------------------------------------------------------------- /src/python/external/wheezy/__init__.py: -------------------------------------------------------------------------------- 1 | import typing 2 | 3 | # See 4 | # http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages 5 | try: 6 | __import__("pkg_resources").declare_namespace(__name__) 7 | except ImportError: 8 | from pkgutil import extend_path 9 | 10 | __path__: typing.Iterable[str] = extend_path(__path__, __name__) 11 | -------------------------------------------------------------------------------- /src/python/external/wheezy/template/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | 4 | from external.wheezy.template.engine import Engine 5 | from external.wheezy.template.ext.code import CodeExtension 6 | from external.wheezy.template.ext.core import CoreExtension 7 | from external.wheezy.template.loader import DictLoader, FileLoader, PreprocessLoader 8 | from external.wheezy.template.preprocessor import Preprocessor 9 | 10 | __all__ = ( 11 | "Engine", 12 | "CodeExtension", 13 | "CoreExtension", 14 | "DictLoader", 15 | "FileLoader", 16 | "PreprocessLoader", 17 | "Preprocessor", 18 | ) 19 | 20 | __version__ = "0.1" 21 | -------------------------------------------------------------------------------- /src/python/external/wheezy/template/comp.py: -------------------------------------------------------------------------------- 1 | import ast 2 | import typing 3 | from _thread import allocate_lock # noqa 4 | 5 | 6 | def adjust_source_lineno(source: str, name: str, lineno: int) -> typing.Any: 7 | node = compile(source, name, "exec", ast.PyCF_ONLY_AST) 8 | ast.increment_lineno(node, lineno) 9 | return node 10 | -------------------------------------------------------------------------------- /src/python/external/wheezy/template/compiler.py: -------------------------------------------------------------------------------- 1 | import typing 2 | from types import ModuleType 3 | 4 | from external.wheezy.template.comp import adjust_source_lineno 5 | 6 | 7 | class Compiler(object): 8 | def __init__( 9 | self, global_vars: typing.Dict[str, typing.Any], source_lineno: int 10 | ) -> None: 11 | self.global_vars = global_vars 12 | self.source_lineno = source_lineno 13 | 14 | def compile_module(self, source: str, name: str) -> ModuleType: 15 | node = adjust_source_lineno(source, name, self.source_lineno) 16 | compiled = compile(node, name, "exec") 17 | module = ModuleType(name) 18 | module.__name__ = name 19 | module.__dict__.update(self.global_vars) 20 | exec(compiled, module.__dict__) 21 | return module 22 | 23 | def compile_source( 24 | self, source: str, name: str 25 | ) -> typing.Dict[str, typing.Any]: 26 | node = adjust_source_lineno(source, name, self.source_lineno) 27 | compiled = compile(node, name, "exec") 28 | local_vars: typing.Dict[str, typing.Any] = {} 29 | exec(compiled, self.global_vars, local_vars) 30 | return local_vars 31 | -------------------------------------------------------------------------------- /src/python/external/wheezy/template/ext/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/python/external/wheezy/template/ext/__init__.py -------------------------------------------------------------------------------- /src/python/external/wheezy/template/ext/code.py: -------------------------------------------------------------------------------- 1 | import re 2 | import typing 3 | 4 | from external.wheezy.template.typing import Builder, LexerRule, ParserRule, Token 5 | from external.wheezy.template.utils import find_balanced 6 | 7 | # region: lexer extensions 8 | 9 | 10 | def code_token(m: typing.Match[str]) -> Token: 11 | source = m.string 12 | start = m.end() 13 | end = find_balanced(source, start) 14 | if source[end::1] == "\n": 15 | end += 1 16 | return end, "code", source[start:end] 17 | 18 | 19 | # region: parser 20 | 21 | 22 | def parse_code(value: str) -> typing.List[str]: 23 | lines = value.rstrip("\n")[1:-1].split("\n") 24 | lines[0] = lines[0].lstrip() 25 | if len(lines) == 1: 26 | return lines 27 | line = lines[1] 28 | n = len(line) - len(line.lstrip()) 29 | return [s[:n].lstrip() + s[n:] for s in lines] 30 | 31 | 32 | # region: block_builders 33 | 34 | 35 | def build_code( 36 | builder: Builder, lineno: int, token: str, lines: typing.List[str] 37 | ) -> bool: 38 | for line in lines: 39 | builder.add(lineno, line) 40 | lineno += 1 41 | return True 42 | 43 | 44 | # region: core extension 45 | 46 | 47 | class CodeExtension: 48 | """Includes support for embedded python code.""" 49 | 50 | def __init__(self, token_start: str = "@") -> None: 51 | 52 | self.lexer_rules: typing.Mapping[int, LexerRule] = { 53 | 300: (re.compile(r"\s*%s(?=\()" % token_start), code_token), 54 | } 55 | 56 | parser_rules: typing.Mapping[str, ParserRule] = {"code": parse_code} 57 | 58 | builder_rules: typing.List[typing.Tuple[str, typing.Any]] = [ 59 | ("code", build_code) 60 | ] 61 | -------------------------------------------------------------------------------- /src/python/external/wheezy/template/ext/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/python/external/wheezy/template/ext/tests/__init__.py -------------------------------------------------------------------------------- /src/python/external/wheezy/template/ext/tests/test_determined.py: -------------------------------------------------------------------------------- 1 | """ Unit tests for ``wheezy.templates.ext.determined``. 2 | """ 3 | 4 | import unittest 5 | 6 | from wheezy.template.ext.determined import DeterminedExtension 7 | 8 | 9 | class DeterminedTestCase(unittest.TestCase): 10 | """Test the ``DeterminedExtension``.""" 11 | 12 | def setUp(self) -> None: 13 | self.preprocess = DeterminedExtension( 14 | known_calls=["path_for", "_"] 15 | ).preprocessors[0] 16 | 17 | def test_determined(self) -> None: 18 | """Substitute determinded expressions for known calls to 19 | preprocessor calls. 20 | """ 21 | assert """\ 22 | #ctx['_']('Name:') 23 | #ctx['path_for']('default') 24 | #ctx['path_for']('static', path='/static/css/site.css') 25 | """ == self.preprocess( 26 | """\ 27 | @_('Name:') 28 | @path_for('default') 29 | @path_for('static', path='/static/css/site.css') 30 | """ 31 | ) 32 | 33 | def test_undetermined(self) -> None: 34 | """Calls that are not determined left unchanged.""" 35 | assert """\ 36 | @path_for('item', id=id) 37 | @model.username.label(_('Username: ')) 38 | """ == self.preprocess( 39 | """\ 40 | @path_for('item', id=id) 41 | @model.username.label(_('Username: ')) 42 | """ 43 | ) 44 | -------------------------------------------------------------------------------- /src/python/external/wheezy/template/py.typed: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/python/external/wheezy/template/py.typed -------------------------------------------------------------------------------- /src/python/external/wheezy/template/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensei-hacker/PrivacyLRS/8132761da5d3df5777ef737d12107b3783a3901d/src/python/external/wheezy/template/tests/__init__.py -------------------------------------------------------------------------------- /src/python/external/wheezy/template/tests/test_console.py: -------------------------------------------------------------------------------- 1 | """ Unit tests for ``wheezy.templates.console``. 2 | """ 3 | 4 | import unittest 5 | 6 | from wheezy.template.console import main 7 | 8 | 9 | class ConsoleTestCase(unittest.TestCase): 10 | """Test the console ``main`` function.""" 11 | 12 | def test_usage(self) -> None: 13 | assert 2 == main(["-h"]) 14 | assert 2 == main(["-t @"]) 15 | assert 2 == main(["-j \\"]) 16 | assert 2 == main(["-x"]) 17 | 18 | def test_context_file(self) -> None: 19 | assert 0 == main( 20 | ["demos/helloworld/hello.txt", "demos/helloworld/hello.json"] 21 | ) 22 | 23 | def test_context_string(self) -> None: 24 | assert 0 == main(["demos/helloworld/hello.txt", '{"name": "World"}']) 25 | 26 | def test_master(self) -> None: 27 | assert 0 == main(["-s", "demos/master", "index.html"]) 28 | 29 | def test_line_join(self) -> None: 30 | assert 0 == main(["-j", "\\", "-s", "demos/master", "index.html"]) 31 | -------------------------------------------------------------------------------- /src/python/external/wheezy/template/utils.py: -------------------------------------------------------------------------------- 1 | def find_all_balanced(text: str, start: int = 0) -> int: 2 | """Finds balanced ``([`` with ``])`` assuming 3 | that ``start`` is pointing to ``(`` or ``[`` in ``text``. 4 | """ 5 | if start >= len(text) or text[start] not in "([": 6 | return start 7 | while 1: 8 | pos = find_balanced(text, start) 9 | pos = find_balanced(text, pos, "[", "]") 10 | if pos != start: 11 | start = pos 12 | else: 13 | return pos 14 | 15 | 16 | def find_balanced( 17 | text: str, start: int = 0, start_sep: str = "(", end_sep: str = ")" 18 | ) -> int: 19 | """Finds balanced ``start_sep`` with ``end_sep`` assuming 20 | that ``start`` is pointing to ``start_sep`` in ``text``. 21 | """ 22 | if start >= len(text) or start_sep != text[start]: 23 | return start 24 | balanced = 1 25 | pos = start + 1 26 | while pos < len(text): 27 | token = text[pos] 28 | pos += 1 29 | if token == end_sep: 30 | if balanced == 1: 31 | return pos 32 | balanced -= 1 33 | elif token == start_sep: 34 | balanced += 1 35 | return start 36 | 37 | 38 | def print_source(source: str, lineno: int = 1) -> None: # pragma: nocover 39 | lines = [] 40 | for line in source.split("\n"): 41 | lines.append("%02d " % lineno + line) 42 | lineno += line.count("\n") + 1 43 | print("\n".join(lines)) 44 | -------------------------------------------------------------------------------- /src/python/firmware.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | from enum import Enum 4 | from typing import NamedTuple 5 | 6 | class MCUType(Enum): 7 | STM32 = 0 8 | ESP32 = 1 9 | ESP8266 = 2 10 | 11 | class DeviceType(Enum): 12 | TX = 0 13 | RX = 1 14 | TX_Backpack = 2 15 | VRx_Backpack = 3 16 | 17 | class RadioType(Enum): 18 | SX127X = 0 19 | SX1280 = 1 20 | LR1121 = 2 21 | 22 | class FirmwareOptions(NamedTuple): 23 | hasWiFi: bool 24 | hasBuzzer: bool 25 | mcuType: MCUType 26 | deviceType: DeviceType 27 | radioChip: RadioType 28 | luaName: str 29 | bootloader: str 30 | offset: int 31 | firmware: str 32 | 33 | 34 | class TXType(Enum): 35 | internal = 'internal' 36 | external = 'external' 37 | 38 | def __str__(self): 39 | return self.value 40 | 41 | 42 | def find_patch_location(mm): 43 | return mm.find(b'\xBE\xEF\xBA\xBE\xCA\xFE\xF0\x0D') 44 | 45 | def get_hardware(mm): 46 | pos = mm.find(b'\xBE\xEF\xBA\xBE\xCA\xFE\xF0\x0D') 47 | if pos != -1: 48 | pos += 8 + 2 # Skip magic & version 49 | 50 | return pos 51 | -------------------------------------------------------------------------------- /src/python/linspace_hopfreqs_gen_2400M.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | start = 2400000000 4 | stop = 2483000000 5 | bandwidth = 800000 6 | numfreqs = 80 7 | stopband = bandwidth*0.25 8 | 9 | output = np.linspace(start, stop, numfreqs) 10 | 11 | 12 | prev = start + bandwidth/2 +0 13 | startf = prev 14 | 15 | for x in range(0,numfreqs): 16 | print(prev) 17 | prev = prev + bandwidth + stopband 18 | 19 | 20 | print(startf-(start+bandwidth/2)) 21 | print(stop-(prev+bandwidth/2)) 22 | -------------------------------------------------------------------------------- /src/python/linspace_hopfreqs_gen_915AU.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | start = 915000000 4 | stop = 928000000 5 | bandwidth = 500000 6 | numfreqs = 20 7 | stopband = 100000 8 | 9 | output = np.linspace(start, stop, numfreqs) 10 | 11 | 12 | prev = start + bandwidth/2 +250000 13 | startf = prev 14 | 15 | for x in range(0,numfreqs): 16 | print(prev) 17 | prev = prev + bandwidth + stopband 18 | 19 | 20 | print(startf-(start+bandwidth/2)) 21 | print(stop-(prev+bandwidth/2)) 22 | -------------------------------------------------------------------------------- /src/python/query_yes_no.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from external.inputimeout import inputimeout, TimeoutOccurred 3 | 4 | 5 | def query_yes_no(question='') -> bool: #https://code.activestate.com/recipes/577058/ 6 | """Ask a yes/no question via raw_input() and return their answer. 7 | "question" is a string that is presented to the user. 8 | The "answer" return value is True for "yes" or False for "no". 9 | """ 10 | # Always return false if not in an interactive shell 11 | if not sys.stdin.isatty(): 12 | return False 13 | 14 | valid = {"yes": True, "y": True, "ye": True, "no": False, "n": False} 15 | 16 | while True: 17 | choice = '' 18 | try: 19 | choice = inputimeout(prompt=question, timeout=5) 20 | except TimeoutOccurred: 21 | sys.stdout.write("Please respond with 'yes' or 'no' (or 'y' or 'n')") 22 | sys.stdout.flush() 23 | 24 | if choice in valid: 25 | return valid[choice] 26 | -------------------------------------------------------------------------------- /src/python/randgentext_hopseq.py: -------------------------------------------------------------------------------- 1 | import random 2 | import matplotlib.pyplot as plt 3 | import math 4 | 5 | X = [] 6 | length = 256 7 | 8 | n = 20 9 | limit = math.floor(length/n) 10 | print(limit) 11 | 12 | prev_val = 0 13 | rand = 0 14 | 15 | last_zero = 0 16 | last_zero_interval = n 17 | 18 | tracker = [0 for x in range(n+1)] 19 | 20 | for i in range(0,length): 21 | 22 | if(i >= last_zero + last_zero_interval): 23 | rand = 0 24 | last_zero = i 25 | 26 | else: 27 | 28 | while(prev_val == rand or tracker[rand] >= limit or rand > n): 29 | rand = random.randint(1,n) 30 | 31 | 32 | X.append(rand) 33 | print(0) 34 | tracker[rand] = tracker[rand] + 1 35 | prev_val = rand 36 | 37 | print(X) 38 | 39 | plt.hist(X, bins=n+1) # arguments are passed to np.histogram 40 | plt.show() 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/python/set_model.py: -------------------------------------------------------------------------------- 1 | import serial, time 2 | import argparse 3 | import serials_find 4 | import bootloader 5 | from BFinitPassthrough import * 6 | 7 | 8 | def send_model_command(args): 9 | dbg_print("======== SEND SET MODEL COMMAND ========") 10 | s = serial.Serial(port=args.port, baudrate=args.baud, 11 | bytesize=8, parity='N', stopbits=1, 12 | timeout=1, xonxoff=0, rtscts=0) 13 | TelemSeq = bootloader.get_model_seq(args.model) 14 | s.write(TelemSeq) 15 | s.flush() 16 | time.sleep(.5) 17 | s.close() 18 | 19 | 20 | if __name__ == '__main__': 21 | parser = argparse.ArgumentParser( 22 | description="Initialize BetaFlight passthrough and send the 'enter bind mode' command") 23 | parser.add_argument( 24 | 'model', metavar='int', nargs=1, type=int, 25 | help='The model match number to set') 26 | parser.add_argument("-b", "--baud", type=int, default=420000, 27 | help="Baud rate for passthrough communication") 28 | parser.add_argument("-p", "--port", type=str, 29 | help="Override serial port autodetection and use PORT") 30 | args = parser.parse_args() 31 | 32 | if (args.port == None): 33 | args.port = serials_find.get_serial_port() 34 | 35 | try: 36 | bf_passthrough_init(args.port, args.baud) 37 | except PassthroughEnabled as err: 38 | dbg_print(str(err)) 39 | 40 | send_model_command(args) 41 | -------------------------------------------------------------------------------- /src/python/setup.py: -------------------------------------------------------------------------------- 1 | import setuptools 2 | setuptools.setup( 3 | name="binary_configurator", 4 | version="3.4.0", 5 | author="ExpressLRS Team", 6 | author_email="", 7 | description="ExpressLRS Binary Installer", 8 | long_description='ExpressLRS binary configurator and flasher tool all-in-one', 9 | long_description_content_type="text/markdown", 10 | url="https://github.com/ExpressLRS/ExpressLRS", 11 | packages=['.'] + setuptools.find_packages(), 12 | include_package_data=True, 13 | entry_points={ 14 | "console_scripts": ["flash=binary_configurator:main"], 15 | }, 16 | install_requires=['pyserial'], 17 | classifiers=[ 18 | "Programming Language :: Python :: 3", 19 | "Operating System :: OS Independent", 20 | ], 21 | python_requires='>=3.6', 22 | ) 23 | -------------------------------------------------------------------------------- /src/python/upload_stlink.py: -------------------------------------------------------------------------------- 1 | Import("env") 2 | import stlink 3 | 4 | env.Replace(UPLOADCMD=stlink.on_upload) 5 | -------------------------------------------------------------------------------- /src/src/hal/hal_stm32.cpp: -------------------------------------------------------------------------------- 1 | 2 | #if defined(PLATFORM_STM32) 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | void __attribute__((used)) copy_functions_to_ram(void) 10 | { 11 | /* Copy RAM_CODE section into RAM. 12 | * NOTE: vectors are the first and then other code. 13 | * Check variants/ldscript_gen.ld file. 14 | */ 15 | extern uint8_t ram_code_start; 16 | extern uint8_t ram_code_end; 17 | extern uint8_t ram_code; 18 | memcpy(&ram_code_start, &ram_code, (size_t) (&ram_code_end - &ram_code_start)); 19 | } 20 | 21 | void __attribute__((constructor(102))) __attribute__((used)) init_vectors(void) 22 | { 23 | copy_functions_to_ram(); 24 | 25 | /** Reset vector location 26 | * 27 | * g_pfnVectors variable comes from the system startup files and 28 | * must always point to beginning of the vectors table where 29 | * stack pointer is the first word and second is the reset vector. 30 | * Vector table is automatically aligned by the linker command file. 31 | */ 32 | extern uint32_t g_pfnVectors; 33 | SCB->VTOR = (__IO uint32_t) &g_pfnVectors; 34 | } 35 | 36 | extern "C" 37 | void __attribute__((used)) initVariant(void) 38 | { 39 | /* This can be used to run some init before \ref setup() */ 40 | } 41 | 42 | #endif // PLATFORM_STM32 43 | -------------------------------------------------------------------------------- /src/src/rx-serial/SerialAirPort.cpp: -------------------------------------------------------------------------------- 1 | #if defined(TARGET_RX) 2 | 3 | #include "SerialAirPort.h" 4 | #include "device.h" 5 | #include "common.h" 6 | 7 | // Variables / constants for Airport // 8 | FIFO apInputBuffer; 9 | FIFO apOutputBuffer; 10 | 11 | 12 | uint32_t SerialAirPort::sendRCFrame(bool frameAvailable, bool frameMissed, uint32_t *channelData) 13 | { 14 | return DURATION_IMMEDIATELY; 15 | } 16 | 17 | int SerialAirPort::getMaxSerialReadSize() 18 | { 19 | return AP_MAX_BUF_LEN - apInputBuffer.size(); 20 | } 21 | 22 | void SerialAirPort::processBytes(uint8_t *bytes, u_int16_t size) 23 | { 24 | if (connectionState == connected) 25 | { 26 | apInputBuffer.atomicPushBytes(bytes, size); 27 | } 28 | } 29 | 30 | void SerialAirPort::sendQueuedData(uint32_t maxBytesToSend) 31 | { 32 | auto size = apOutputBuffer.size(); 33 | if (size != 0) 34 | { 35 | uint8_t buf[size]; 36 | apOutputBuffer.lock(); 37 | apOutputBuffer.popBytes(buf, size); 38 | apOutputBuffer.unlock(); 39 | _outputPort->write(buf, size); 40 | } 41 | } 42 | #endif 43 | -------------------------------------------------------------------------------- /src/src/rx-serial/SerialAirPort.h: -------------------------------------------------------------------------------- 1 | #include "SerialIO.h" 2 | #include "FIFO.h" 3 | #include "telemetry_protocol.h" 4 | 5 | // Variables / constants for Airport // 6 | extern FIFO apInputBuffer; 7 | extern FIFO apOutputBuffer; 8 | 9 | class SerialAirPort : public SerialIO { 10 | public: 11 | explicit SerialAirPort(Stream &out, Stream &in) : SerialIO(&out, &in) {} 12 | virtual ~SerialAirPort() {} 13 | 14 | void queueLinkStatisticsPacket() override {} 15 | void queueMSPFrameTransmission(uint8_t* data) override {} 16 | uint32_t sendRCFrame(bool frameAvailable, bool frameMissed, uint32_t *channelData) override; 17 | 18 | int getMaxSerialReadSize() override; 19 | void sendQueuedData(uint32_t maxBytesToSend) override; 20 | 21 | private: 22 | void processBytes(uint8_t *bytes, u_int16_t size) override; 23 | }; 24 | -------------------------------------------------------------------------------- /src/src/rx-serial/SerialCRSF.h: -------------------------------------------------------------------------------- 1 | #include "SerialIO.h" 2 | 3 | class SerialCRSF : public SerialIO { 4 | public: 5 | explicit SerialCRSF(Stream &out, Stream &in) : SerialIO(&out, &in) {} 6 | virtual ~SerialCRSF() {} 7 | 8 | uint32_t sendRCFrame(bool frameAvailable, bool frameMissed, uint32_t *channelData) override; 9 | void queueMSPFrameTransmission(uint8_t* data) override; 10 | void queueLinkStatisticsPacket() override; 11 | void sendQueuedData(uint32_t maxBytesToSend) override; 12 | 13 | private: 14 | void processBytes(uint8_t *bytes, uint16_t size) override; 15 | }; 16 | -------------------------------------------------------------------------------- /src/src/rx-serial/SerialIO.cpp: -------------------------------------------------------------------------------- 1 | #include "SerialIO.h" 2 | 3 | void SerialIO::setFailsafe(bool failsafe) 4 | { 5 | this->failsafe = failsafe; 6 | } 7 | 8 | void SerialIO::processSerialInput() 9 | { 10 | auto maxBytes = getMaxSerialReadSize(); 11 | uint8_t buffer[maxBytes]; 12 | auto size = min(_inputPort->available(), maxBytes); 13 | _inputPort->readBytes(buffer, size); 14 | processBytes(buffer, size); 15 | } 16 | 17 | void SerialIO::sendQueuedData(uint32_t maxBytesToSend) 18 | { 19 | uint32_t bytesWritten = 0; 20 | 21 | while (_fifo.size() > _fifo.peek() && (bytesWritten + _fifo.peek()) < maxBytesToSend) 22 | { 23 | _fifo.lock(); 24 | uint8_t OutPktLen = _fifo.pop(); 25 | uint8_t OutData[OutPktLen]; 26 | _fifo.popBytes(OutData, OutPktLen); 27 | _fifo.unlock(); 28 | this->_outputPort->write(OutData, OutPktLen); // write the packet out 29 | bytesWritten += OutPktLen; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/src/rx-serial/SerialMavlink.h: -------------------------------------------------------------------------------- 1 | #include "SerialIO.h" 2 | #include "FIFO.h" 3 | #include "telemetry_protocol.h" 4 | 5 | #define MAV_INPUT_BUF_LEN 1024 6 | #define MAV_OUTPUT_BUF_LEN 512 7 | 8 | // Variables / constants 9 | extern FIFO mavlinkInputBuffer; 10 | extern FIFO mavlinkOutputBuffer; 11 | 12 | class SerialMavlink : public SerialIO { 13 | public: 14 | explicit SerialMavlink(Stream &out, Stream &in); 15 | virtual ~SerialMavlink() {} 16 | 17 | void queueLinkStatisticsPacket() override {} 18 | void queueMSPFrameTransmission(uint8_t* data) override {} 19 | uint32_t sendRCFrame(bool frameAvailable, bool frameMissed, uint32_t *channelData) override; 20 | 21 | int getMaxSerialReadSize() override; 22 | void sendQueuedData(uint32_t maxBytesToSend) override; 23 | 24 | private: 25 | void processBytes(uint8_t *bytes, u_int16_t size) override; 26 | 27 | const uint8_t this_system_id; 28 | const uint8_t this_component_id; 29 | 30 | const uint8_t target_system_id; 31 | const uint8_t target_component_id; 32 | 33 | uint32_t lastSentFlowCtrl = 0; 34 | }; 35 | -------------------------------------------------------------------------------- /src/src/rx-serial/SerialNOOP.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SerialIO.h" 4 | 5 | class SerialNOOP : public SerialIO { 6 | public: 7 | explicit SerialNOOP() : SerialIO(nullptr, nullptr) {} 8 | virtual ~SerialNOOP() {} 9 | 10 | void queueLinkStatisticsPacket() override {} 11 | void queueMSPFrameTransmission(uint8_t* data) override {} 12 | uint32_t sendRCFrame(bool frameAvailable, bool frameMissed, uint32_t *channelData) override { return DURATION_NEVER; } 13 | 14 | void processSerialInput() override {} 15 | 16 | private: 17 | void processBytes(uint8_t *bytes, uint16_t size) override {} 18 | }; 19 | -------------------------------------------------------------------------------- /src/src/rx-serial/SerialSBUS.h: -------------------------------------------------------------------------------- 1 | #include "SerialIO.h" 2 | 3 | class SerialSBUS : public SerialIO { 4 | public: 5 | explicit SerialSBUS(Stream &out, Stream &in) : SerialIO(&out, &in) 6 | { 7 | streamOut = &out; 8 | } 9 | 10 | ~SerialSBUS() override = default; 11 | 12 | void queueLinkStatisticsPacket() override {} 13 | void queueMSPFrameTransmission(uint8_t* data) override {} 14 | uint32_t sendRCFrame(bool frameAvailable, bool frameMissed, uint32_t *channelData) override; 15 | 16 | private: 17 | void processBytes(uint8_t *bytes, uint16_t size) override {}; 18 | 19 | Stream *streamOut; 20 | }; 21 | -------------------------------------------------------------------------------- /src/src/rx-serial/SerialSUMD.h: -------------------------------------------------------------------------------- 1 | #include "SerialIO.h" 2 | #include "crc.h" 3 | 4 | class SerialSUMD : public SerialIO { 5 | public: 6 | explicit SerialSUMD(Stream &out, Stream &in) : SerialIO(&out, &in) { crc2Byte.init(16, 0x1021); } 7 | virtual ~SerialSUMD() {} 8 | 9 | void queueLinkStatisticsPacket() override {} 10 | void queueMSPFrameTransmission(uint8_t* data) override {} 11 | uint32_t sendRCFrame(bool frameAvailable, bool frameMissed, uint32_t *channelData) override; 12 | 13 | private: 14 | Crc2Byte crc2Byte; 15 | void processBytes(uint8_t *bytes, uint16_t size) override {}; 16 | }; 17 | -------------------------------------------------------------------------------- /src/src/rx-serial/SerialTramp.h: -------------------------------------------------------------------------------- 1 | #include "SerialIO.h" 2 | 3 | #define TRAMP_FRAME_SIZE 16 4 | #define TRAMP_HEADER 0x0F 5 | // check value for MSP_SET_VTX_CONFIG to determine if value is encoded 6 | // band/channel or frequency in MHz (3 bits for band and 3 bits for channel) 7 | #define VTXCOMMON_MSP_BANDCHAN_CHKVAL ((uint16_t)((7 << 3) + 7)) 8 | 9 | class SerialTramp : public SerialIO { 10 | public: 11 | explicit SerialTramp(Stream &out, Stream &in, int8_t serial1TXpin) : SerialIO(&out, &in) { 12 | #if defined(PLATFORM_ESP32) 13 | // we are on UART1, use Serial1 TX assigned pin for half duplex 14 | UTXDoutIdx = U1TXD_OUT_IDX; 15 | URXDinIdx = U1RXD_IN_IDX; 16 | halfDuplexPin = serial1TXpin; 17 | #endif 18 | setRXMode(); 19 | } 20 | virtual ~SerialTramp() {} 21 | 22 | void queueLinkStatisticsPacket() override {} 23 | void queueMSPFrameTransmission(uint8_t* data) override; 24 | void sendQueuedData(uint32_t maxBytesToSend) override; 25 | uint32_t sendRCFrame(bool frameAvailable, bool frameMissed, uint32_t *channelData) override { return DURATION_IMMEDIATELY; } 26 | private: 27 | void processBytes(uint8_t *bytes, uint16_t size) override {}; 28 | void setTXMode(); 29 | void setRXMode(); 30 | #if defined(PLATFORM_ESP32) 31 | int8_t halfDuplexPin; 32 | uint8_t UTXDoutIdx; 33 | uint8_t URXDinIdx; 34 | #endif 35 | }; 36 | -------------------------------------------------------------------------------- /src/src/rx-serial/devSerialIO.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "device.h" 4 | 5 | extern device_t Serial0_device; 6 | #if defined(PLATFORM_ESP32) 7 | extern device_t Serial1_device; 8 | #endif 9 | extern void handleSerialIO(); 10 | extern void crsfRCFrameAvailable(); 11 | extern void crsfRCFrameMissed(); 12 | -------------------------------------------------------------------------------- /src/src/test_main.cpp: -------------------------------------------------------------------------------- 1 | #ifndef UNIT_TEST 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | cout << "Doing nothing just keep build all happy!" << endl; 9 | return 0; 10 | } 11 | #endif 12 | -------------------------------------------------------------------------------- /src/targets/diy_2400.ini: -------------------------------------------------------------------------------- 1 | 2 | # ******************************** 3 | # Transmitter targets 4 | # ******************************** 5 | 6 | # ******************************** 7 | # Receiver targets 8 | # ******************************** 9 | 10 | [env:DIY_2400_RX_STM32_CCG_Nano_v0_5_via_STLINK] 11 | extends = env_common_stm32, radio_2400 12 | board = l432kb 13 | # max size = 131072 - 0x4000 = 114688 14 | board_upload.maximum_size = 114688 15 | build_flags = 16 | ${env_common_stm32.build_flags} 17 | ${radio_2400.build_flags} 18 | ${common_env_data.build_flags_rx} 19 | -include target/DIY_2400_RX_STM32_CCG_Nano_v0_5.h 20 | -D HAL_RTC_MODULE_DISABLED=1 21 | -D HAL_ADC_MODULE_DISABLED=1 22 | -D DISABLE_GENERIC_SERIALUSB=1 23 | -D HSI_VALUE=16000000U 24 | -D USE_HSI=1 25 | -O3 26 | -D FLASH_BASE_ADDRESS='((uint32_t)((FLASH_SIZE) - FLASH_PAGE_SIZE))' 27 | -D VECT_TAB_OFFSET=0x4000U 28 | -D FLASH_APP_OFFSET=0x4000U 29 | -Wl,--defsym=FLASH_APP_OFFSET=16K 30 | build_src_filter = ${env_common_stm32.build_src_filter} - 31 | upload_flags = 32 | BOOTLOADER=bootloader/sx1280_rx_nano_pcb_v0.5_bootloader.bin 33 | VECT_OFFSET=0x4000 34 | 35 | [env:DIY_2400_RX_STM32_CCG_Nano_v0_5_via_BetaflightPassthrough] 36 | extends = env:DIY_2400_RX_STM32_CCG_Nano_v0_5_via_STLINK 37 | -------------------------------------------------------------------------------- /src/targets/happymodel_2400.ini: -------------------------------------------------------------------------------- 1 | 2 | # ******************************** 3 | # Transmitter targets 4 | # ******************************** 5 | 6 | # ******************************** 7 | # Receiver targets 8 | # ******************************** 9 | 10 | [env:HappyModel_PP_2400_RX_via_STLINK] 11 | extends = env:DIY_2400_RX_STM32_CCG_Nano_v0_5_via_STLINK 12 | 13 | [env:HappyModel_PP_2400_RX_via_BetaflightPassthrough] 14 | extends = env:HappyModel_PP_2400_RX_via_STLINK 15 | -------------------------------------------------------------------------------- /src/targets/happymodel_900.ini: -------------------------------------------------------------------------------- 1 | 2 | # ******************************** 3 | # Transmitter targets 4 | # ******************************** 5 | 6 | [env:HappyModel_TX_ES915TX_via_STLINK] 7 | extends = env_common_stm32, radio_900 8 | build_flags = 9 | ${env_common_stm32.build_flags} 10 | ${radio_900.build_flags} 11 | ${common_env_data.build_flags_tx} 12 | -include target/HappyModel_TX_ES915TX.h 13 | -flto 14 | -D HSE_VALUE=12000000U 15 | -D VECT_TAB_OFFSET=0x4000U 16 | board_build.ldscript = variants/R9M_ldscript.ld 17 | board_build.flash_offset = 0x4000 18 | build_src_filter = ${env_common_stm32.build_src_filter} - 19 | upload_flags = 20 | BOOTLOADER=bootloader/r9m_bootloader.bin 21 | VECT_OFFSET=0x4000 22 | 23 | [env:HappyModel_TX_ES915TX_via_stock_BL] 24 | extends = env:HappyModel_TX_ES915TX_via_STLINK 25 | 26 | [env:HappyModel_TX_ES915TX_via_WIFI] 27 | extends = env:HappyModel_TX_ES915TX_via_STLINK 28 | 29 | # ******************************** 30 | # Receiver targets 31 | # ******************************** 32 | 33 | [env:HappyModel_RX_ES915RX_via_STLINK] 34 | extends = env_common_stm32, radio_900 35 | board = R9MM 36 | build_flags = 37 | ${env_common_stm32.build_flags} 38 | ${radio_900.build_flags} 39 | ${common_env_data.build_flags_rx} 40 | -include target/Frsky_RX_R9M.h 41 | -D HSE_VALUE=24000000U 42 | -DVECT_TAB_OFFSET=0x08008000U 43 | build_src_filter = ${env_common_stm32.build_src_filter} - 44 | upload_flags = 45 | BOOTLOADER=bootloader/r9mm_bootloader.bin 46 | VECT_OFFSET=0x8000 47 | 48 | [env:HappyModel_RX_ES915RX_via_BetaflightPassthrough] 49 | extends = env:HappyModel_RX_ES915RX_via_STLINK 50 | -------------------------------------------------------------------------------- /src/targets/namimnorc_2400.ini: -------------------------------------------------------------------------------- 1 | 2 | # ******************************** 3 | # Transmitter targets 4 | # ******************************** 5 | 6 | [env:NamimnoRC_FLASH_2400_TX_via_STLINK] 7 | extends = env_common_stm32, radio_2400 8 | build_flags = 9 | ${env_common_stm32.build_flags} 10 | ${radio_2400.build_flags} 11 | ${common_env_data.build_flags_tx} 12 | -flto 13 | -D HSE_VALUE=12000000U 14 | -D VECT_TAB_OFFSET=0x4000U 15 | -include target/NamimnoRC_FLASH_2400_TX.h 16 | board_build.ldscript = variants/NamimnoRC_Alpha.ld 17 | build_src_filter = ${env_common_stm32.build_src_filter} - 18 | upload_flags = 19 | BOOTLOADER=bootloader/namimnorc/tx/namimnorc_tx_bootloader.bin 20 | VECT_OFFSET=0x4000 21 | 22 | [env:NamimnoRC_FLASH_2400_TX_via_WIFI] 23 | extends = env:NamimnoRC_FLASH_2400_TX_via_STLINK 24 | 25 | # ******************************** 26 | # Receiver targets 27 | # ******************************** 28 | 29 | [env:NamimnoRC_FLASH_2400_RX_via_STLINK] 30 | extends = env_common_stm32, radio_2400 31 | build_flags = 32 | ${env_common_stm32.build_flags} 33 | ${radio_2400.build_flags} 34 | ${common_env_data.build_flags_rx} 35 | -D HSE_VALUE=12000000U 36 | -D VECT_TAB_OFFSET=0x8000U 37 | -include target/NamimnoRC_FLASH_2400_RX_STM32.h 38 | board_build.ldscript = variants/R9MM/R9MM_ldscript.ld 39 | build_src_filter = ${env_common_stm32.build_src_filter} - 40 | upload_flags = 41 | BOOTLOADER=bootloader/namimnorc/rx/flash_2400_bootloader.bin 42 | VECT_OFFSET=0x8000 43 | 44 | [env:NamimnoRC_FLASH_2400_RX_via_BetaflightPassthrough] 45 | extends = env:NamimnoRC_FLASH_2400_RX_via_STLINK 46 | -------------------------------------------------------------------------------- /src/targets/namimnorc_900.ini: -------------------------------------------------------------------------------- 1 | 2 | # ******************************** 3 | # Transmitter targets 4 | # ******************************** 5 | 6 | [env:NamimnoRC_VOYAGER_900_TX_via_STLINK] 7 | extends = env_common_stm32, radio_900 8 | build_flags = 9 | ${env_common_stm32.build_flags} 10 | ${radio_900.build_flags} 11 | ${common_env_data.build_flags_tx} 12 | -include target/NamimnoRC_VOYAGER_900_TX.h 13 | -flto 14 | -D HSE_VALUE=12000000U 15 | -D VECT_TAB_OFFSET=0x4000U 16 | board_build.ldscript = variants/NamimnoRC_Alpha.ld 17 | build_src_filter = ${env_common_stm32.build_src_filter} - 18 | upload_flags = 19 | BOOTLOADER=bootloader/namimnorc/tx/namimnorc_tx_bootloader.bin 20 | VECT_OFFSET=0x4000 21 | lib_deps = 22 | 23 | [env:NamimnoRC_VOYAGER_900_TX_via_WIFI] 24 | extends = env:NamimnoRC_VOYAGER_900_TX_via_STLINK 25 | 26 | # ******************************** 27 | # Receiver targets 28 | # ******************************** 29 | 30 | [env:NamimnoRC_VOYAGER_900_RX_via_STLINK] 31 | extends = env_common_stm32, radio_900 32 | build_flags = 33 | ${env_common_stm32.build_flags} 34 | ${radio_900.build_flags} 35 | ${common_env_data.build_flags_rx} 36 | -D HSE_VALUE=12000000U 37 | -D VECT_TAB_OFFSET=0x8000U 38 | -include target/NamimnoRC_VOYAGER_900_RX.h 39 | board_build.ldscript = variants/R9MM/R9MM_ldscript.ld 40 | build_src_filter = ${env_common_stm32.build_src_filter} - 41 | upload_flags = 42 | BOOTLOADER=bootloader/namimnorc/rx/voyager_900_bootloader.bin 43 | VECT_OFFSET=0x8000 44 | lib_deps = 45 | 46 | [env:NamimnoRC_VOYAGER_900_RX_via_BetaflightPassthrough] 47 | extends = env:NamimnoRC_VOYAGER_900_RX_via_STLINK 48 | -------------------------------------------------------------------------------- /src/test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PIO Unit Testing and project tests. 3 | 4 | Unit Testing is a software testing method by which individual units of 5 | source code, sets of one or more MCU program modules together with associated 6 | control data, usage procedures, and operating procedures, are tested to 7 | determine whether they are fit for use. Unit testing finds problems early 8 | in the development cycle. 9 | 10 | More information about PIO Unit Testing: 11 | - https://docs.platformio.org/page/plus/unit-testing.html 12 | -------------------------------------------------------------------------------- /src/test/test_embedded/eeprom_tests.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "elrs_eeprom.h" 4 | 5 | ELRS_EEPROM eeprom; 6 | 7 | void test_eeprom_rw(void) 8 | { 9 | // TEST CASE: 10 | // GIVEN the eeprom object has been initialised 11 | // WHEN the write method is called using a valid address and value 12 | // THEN the value is stored at that address in eeprom 13 | 14 | // Initialise the eeprom 15 | eeprom.Begin(); 16 | 17 | uint8_t address; 18 | uint8_t value; 19 | uint8_t success; 20 | 21 | // Write the first value variable into the eeprom at the specified address 22 | address = 1; 23 | value = 1; 24 | eeprom.WriteByte(address, value); 25 | 26 | // Assert that value in eeprom matches what was written 27 | TEST_ASSERT_EQUAL(value, eeprom.ReadByte(address)); 28 | 29 | // Write the second value variable into the eeprom at the specified address 30 | address = 2; 31 | value = 2; 32 | eeprom.WriteByte(address, value); 33 | 34 | // Assert that value in eeprom matches what was written 35 | TEST_ASSERT_EQUAL(value, eeprom.ReadByte(address)); 36 | } 37 | -------------------------------------------------------------------------------- /src/test/test_embedded/output_export.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | 6 | #ifdef __GNUC__ 7 | void output_start(unsigned int baudrate __attribute__((unused))) 8 | #else 9 | void output_start(unsigned int baudrate) 10 | #endif 11 | { 12 | Serial.begin(115200); 13 | } 14 | 15 | void output_char(int c) 16 | { 17 | Serial.write(c); 18 | } 19 | 20 | void output_flush(void) 21 | { 22 | Serial.flush(); 23 | } 24 | 25 | void output_complete(void) 26 | { 27 | Serial.end(); 28 | } -------------------------------------------------------------------------------- /src/test/test_embedded/rx_sx1280_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "targets.h" 3 | #include "SX1280Driver.h" 4 | #include "ESP8266WiFi.h" 5 | #include "FHSS.h" 6 | 7 | SX1280Driver Radio; 8 | 9 | uint8_t testdata[8] = {0x80}; 10 | 11 | void ICACHE_RAM_ATTR TXdoneCallback() 12 | { 13 | Serial.println("TXdoneCallback1"); 14 | //delay(1000); 15 | //Radio.TXnb(testdata, sizeof(testdata)); 16 | } 17 | 18 | void ICACHE_RAM_ATTR RXdoneCallback(SX12xxDriverCommon::rx_status const /*status*/) 19 | { 20 | Serial.println("RXdoneCallback"); 21 | } 22 | 23 | void setup() 24 | { 25 | Serial.begin(115200); 26 | Serial.println("Begin SX1280 testing..."); 27 | 28 | Radio.Begin(FHSSgetMinimumFreq(), FHSSgetMaximumFreq()); 29 | Radio.Config(SX1280_LORA_BW_0800, SX1280_LORA_SF6, SX1280_LORA_CR_4_7, 2420000000, 12, 8); 30 | Radio.TXdoneCallback = &TXdoneCallback; 31 | //Radio.TXnb(testdata, sizeof(testdata)); 32 | Radio.SetFrequencyReg(FHSSfreqs[0]); 33 | Radio.RXnb(); 34 | } 35 | 36 | void loop() 37 | { 38 | 39 | //delay(250); 40 | //Serial.println("about to TX"); 41 | //Radio.TXnb(testdata, 8); 42 | 43 | // Serial.println("about to RX"); 44 | // Radio.RXnb(); 45 | // delay(random(50,200)); 46 | } 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/test/test_embedded/test_main.cpp: -------------------------------------------------------------------------------- 1 | #define UNIT_TEST 2 | 3 | #include 4 | #include 5 | #include "eeprom_tests.h" 6 | 7 | // Unity setup/teardown 8 | void setUp() {} 9 | void tearDown() {} 10 | 11 | void setup() { 12 | // NOTE!!! Wait for >2 secs 13 | // if board doesn't support software reset via Serial.DTR/RTS 14 | delay(2000); 15 | 16 | UNITY_BEGIN(); // IMPORTANT LINE! 17 | 18 | RUN_TEST(test_eeprom_rw); 19 | } 20 | 21 | void loop() { 22 | UNITY_END(); // stop unit testing 23 | } 24 | -------------------------------------------------------------------------------- /src/test/test_embedded/tx_sx1280_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "targets.h" 3 | #include "SX1280Driver.h" 4 | #include "esp32-hal.h" 5 | #include "common.h" 6 | #include "FHSS.h" 7 | 8 | SX1280Driver Radio; 9 | 10 | uint8_t testdata[8] = {0x80}; 11 | 12 | void ICACHE_RAM_ATTR TXdoneCallback() 13 | { 14 | Serial.println("TXdoneCallback"); 15 | Radio.TXnb(testdata, sizeof(testdata)); 16 | } 17 | 18 | void ICACHE_RAM_ATTR RXdoneCallback(SX12xxDriverCommon::rx_status const /*status*/) 19 | { 20 | Serial.println("RXdoneCallback"); 21 | for (int i = 0; i < 8; i++) 22 | { 23 | Serial.print(Radio.RXdataBuffer[i], HEX); 24 | Serial.print(","); 25 | } 26 | Serial.println(""); 27 | //Radio.RXnb(); 28 | } 29 | 30 | void setup() 31 | { 32 | Serial.begin(115200); 33 | Serial.println("Begin SX1280 testing..."); 34 | 35 | Radio.Begin(FHSSgetMinimumFreq(), FHSSgetMaximumFreq()); 36 | //Radio.Config(SX1280_LORA_BW_0800, SX1280_LORA_SF6, SX1280_LORA_CR_4_7, 2420000000, SX1280_PREAMBLE_LENGTH_32_BITS); 37 | Radio.TXdoneCallback = &TXdoneCallback; 38 | Radio.RXdoneCallback = &RXdoneCallback; 39 | Radio.SetFrequencyReg(FHSSfreqs[0]); 40 | //Radio.RXnb(); 41 | Radio.TXnb(testdata, sizeof(testdata)); 42 | } 43 | 44 | void loop() 45 | { 46 | // Serial.println("about to TX"); 47 | 48 | //delay(1000); 49 | 50 | // Serial.println("about to RX"); 51 | //Radio.RXnb(); 52 | delay(100); 53 | //delay(random(50,200)); 54 | //delay(100); 55 | //Radio.GetStatus(); 56 | 57 | yield(); 58 | } -------------------------------------------------------------------------------- /src/test/test_fmap/test_fmap.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | static uint16_t fmapf(uint16_t x, float in_min, float in_max, float out_min, float out_max) { return round((x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min); }; 8 | 9 | void test_fmap_consistent_with_float(void) 10 | { 11 | for (int i = 172; i <= 1811; i++) 12 | { 13 | uint16_t iv = fmap(i, 172, 1811, 0, 1023); 14 | uint16_t fv = fmapf(i, 172, 1811, 0, 1023); 15 | 16 | // assert that the integer function is equivalent to the floating point function 17 | TEST_ASSERT_EQUAL(fv, iv); 18 | } 19 | } 20 | 21 | void test_fmap_consistent_bider(void) 22 | { 23 | for (int i = 172; i <= 1811; i++) 24 | { 25 | uint16_t iv = fmap(i, 172, 1811, 0, 1023); 26 | uint16_t iiv = fmap(iv, 0, 1023, 172, 1811); 27 | uint16_t fiv = fmapf(iv, 0, 1023, 172, 1811); 28 | 29 | // make sure that integer and floats return the same values 30 | TEST_ASSERT_EQUAL(fiv, iiv); 31 | 32 | // make sure that the full cycle value is +/- 1 error given that the input range is under 2x the output range 33 | TEST_ASSERT_GREATER_OR_EQUAL(i-1, iiv); 34 | TEST_ASSERT_LESS_OR_EQUAL(i+1, iiv); 35 | } 36 | } 37 | 38 | // Unity setup/teardown 39 | void setUp() {} 40 | void tearDown() {} 41 | 42 | int main(int argc, char **argv) 43 | { 44 | UNITY_BEGIN(); 45 | RUN_TEST(test_fmap_consistent_with_float); 46 | RUN_TEST(test_fmap_consistent_bider); 47 | UNITY_END(); 48 | 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /src/test/test_msp/mock_serial.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "msp.h" 5 | 6 | // Mock the serial port using a string stream class 7 | // This will allow us to assert what gets sent on the serial port 8 | class StringStream : public Stream 9 | { 10 | public: 11 | StringStream(std::string &s) : buf(s), position(0) { } 12 | 13 | // Stream methods 14 | int available() { return buf.length() - position; } 15 | int read() { return position < buf.length() ? buf[position++] : -1; } 16 | int peek() { return position < buf.length() ? buf[position] : -1; } 17 | void flush() { } 18 | 19 | // Print methods 20 | size_t write(uint8_t c) 21 | { 22 | buf += (char)c; return 1; 23 | } 24 | size_t write(const uint8_t *c, size_t l) 25 | { 26 | for (int i=0; i(high)?(high):(amt))) 9 | #define CROSSFIRE_CENTER 0x3E0 // 992 10 | #define CROSSFIRE_CENTER_CH_OFFSET (0) 11 | #define PPM_CENTER 1500 12 | #define PPM_CH_CENTER (PPM_CENTER) 13 | 14 | uint32_t OpenTx_to_Crsf(int16_t pulse) 15 | { 16 | uint32_t val = limit(0, CROSSFIRE_CENTER + (CROSSFIRE_CENTER_CH_OFFSET * 4) / 5 + (pulse * 4) / 5, 2 * CROSSFIRE_CENTER); 17 | return val; 18 | } 19 | 20 | int16_t Crsf_to_OpenTx(uint32_t crsfval) 21 | { 22 | int16_t val = (crsfval - CROSSFIRE_CENTER - (CROSSFIRE_CENTER_CH_OFFSET * 5 / 4)) * 5 / 4; 23 | return val; 24 | } 25 | 26 | uint32_t OpenTx_to_Us(int16_t pulse) 27 | { 28 | return PPM_CENTER + (pulse / 2); 29 | } 30 | 31 | int16_t Us_to_OpenTx(uint32_t us) 32 | { 33 | return 2 * ((int32_t)(us) - PPM_CENTER); 34 | } 35 | 36 | uint32_t Crsf_to_OpenTx_to_Us(uint32_t crsfval) 37 | { 38 | return OpenTx_to_Us(Crsf_to_OpenTx(crsfval)); 39 | } 40 | 41 | uint32_t Crsf_to_Uint10_to_Crsf(uint32_t crsfval) 42 | { 43 | return UINT10_to_CRSF(CRSF_to_UINT10(crsfval)); 44 | } 45 | 46 | #define CRSF_RC_CHANNEL_SCALE_LEGACY 0.62477120195241f 47 | uint32_t Crsf_to_BfUs(uint32_t crsfval) 48 | { 49 | float val = (CRSF_RC_CHANNEL_SCALE_LEGACY * (float)crsfval) + 881; 50 | //printf("%u=%f ", crsfval, val); 51 | return val; 52 | } 53 | 54 | } // extern "C" -------------------------------------------------------------------------------- /src/test/test_ota/crsf_sysmocks.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern "C" { 4 | 5 | uint32_t OpenTx_to_Crsf(int16_t pulse); 6 | int16_t Crsf_to_OpenTx(uint32_t crsfval); 7 | uint32_t OpenTx_to_Us(int16_t pulse); 8 | int16_t Us_to_OpenTx(uint32_t us); 9 | uint32_t Crsf_to_OpenTx_to_Us(uint32_t crsfval); 10 | uint32_t Crsf_to_Uint10_to_Crsf(uint32_t crsfval); 11 | uint32_t Crsf_to_BfUs(uint32_t crsfval); 12 | 13 | } -------------------------------------------------------------------------------- /src/variants/FM30/PinNamesVar.h: -------------------------------------------------------------------------------- 1 | /* SYS_WKUP */ 2 | #ifdef PWR_WAKEUP_PIN1 3 | SYS_WKUP1 = PA_0, 4 | #endif 5 | #ifdef PWR_WAKEUP_PIN2 6 | SYS_WKUP2 = NC, 7 | #endif 8 | #ifdef PWR_WAKEUP_PIN3 9 | SYS_WKUP3 = NC, 10 | #endif 11 | #ifdef PWR_WAKEUP_PIN4 12 | SYS_WKUP4 = NC, 13 | #endif 14 | #ifdef PWR_WAKEUP_PIN5 15 | SYS_WKUP5 = NC, 16 | #endif 17 | #ifdef PWR_WAKEUP_PIN6 18 | SYS_WKUP6 = NC, 19 | #endif 20 | #ifdef PWR_WAKEUP_PIN7 21 | SYS_WKUP7 = NC, 22 | #endif 23 | #ifdef PWR_WAKEUP_PIN8 24 | SYS_WKUP8 = NC, 25 | #endif 26 | /* USB */ 27 | #ifdef USBCON 28 | USB_DM = PA_11, 29 | USB_DP = PA_12, 30 | #endif 31 | -------------------------------------------------------------------------------- /src/variants/FM30/ldscript.ld: -------------------------------------------------------------------------------- 1 | 2 | /* Specify the memory areas */ 3 | MEMORY 4 | { 5 | RAM_CODE (rx) : ORIGIN = 0x20000000, LENGTH = 1K 6 | RAM_DATA (xrw) : ORIGIN = 0x20000000 + LENGTH(RAM_CODE), LENGTH = LD_MAX_DATA_SIZE - LENGTH(RAM_CODE) 7 | CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 0K 8 | FLASH (rx) : ORIGIN = 0x8000000 + FLASH_APP_OFFSET, LENGTH = LD_MAX_SIZE - FLASH_APP_OFFSET 9 | } 10 | 11 | INCLUDE "variants/ldscript_gen.ld" 12 | -------------------------------------------------------------------------------- /src/variants/FM30_mini/ldscript.ld: -------------------------------------------------------------------------------- 1 | 2 | /* Memories definition */ 3 | MEMORY 4 | { 5 | RAM_CODE (rx) : ORIGIN = 0x20000000, LENGTH = 1K 6 | RAM_DATA (xrw) : ORIGIN = 0x20000000 + LENGTH(RAM_CODE), LENGTH = LD_MAX_DATA_SIZE - LENGTH(RAM_CODE) 7 | CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 0K 8 | FLASH (rx) : ORIGIN = 0x8000000 + FLASH_APP_OFFSET, LENGTH = LD_MAX_SIZE - FLASH_APP_OFFSET 9 | } 10 | 11 | INCLUDE "variants/ldscript_gen.ld" 12 | -------------------------------------------------------------------------------- /src/variants/GHOST_ATTO/PinNamesVar.h: -------------------------------------------------------------------------------- 1 | /* SYS_WKUP */ 2 | #ifdef PWR_WAKEUP_PIN1 3 | SYS_WKUP1 = PA_0, 4 | #endif 5 | #ifdef PWR_WAKEUP_PIN2 6 | SYS_WKUP2 = PC_13, /* manually updated */ 7 | #endif 8 | #ifdef PWR_WAKEUP_PIN3 9 | SYS_WKUP3 = NC, 10 | #endif 11 | #ifdef PWR_WAKEUP_PIN4 12 | SYS_WKUP4 = NC, 13 | #endif 14 | #ifdef PWR_WAKEUP_PIN5 15 | SYS_WKUP5 = NC, 16 | #endif 17 | #ifdef PWR_WAKEUP_PIN6 18 | SYS_WKUP6 = NC, 19 | #endif 20 | #ifdef PWR_WAKEUP_PIN7 21 | SYS_WKUP7 = NC, 22 | #endif 23 | #ifdef PWR_WAKEUP_PIN8 24 | SYS_WKUP8 = NC, 25 | #endif 26 | -------------------------------------------------------------------------------- /src/variants/GHOST_ATTO/ldscript.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ** Abstract : Linker script for STM32F303K8Tx Device with 3 | ** 64KByte FLASH, 12KByte RAM 4 | */ 5 | 6 | /* Specify the memory areas */ 7 | MEMORY 8 | { 9 | RAM_CODE (rx) : ORIGIN = 0x20000000, LENGTH = 1K 10 | RAM_DATA (xrw) : ORIGIN = 0x20000000 + LENGTH(RAM_CODE), LENGTH = 16K - LENGTH(RAM_CODE) 11 | CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 4K 12 | FLASH (rx) : ORIGIN = 0x08000000 + FLASH_APP_OFFSET, LENGTH = 64K - FLASH_APP_OFFSET 13 | } 14 | 15 | INCLUDE "variants/ldscript_gen.ld" 16 | -------------------------------------------------------------------------------- /src/variants/GHOST_TX/PinNamesVar.h: -------------------------------------------------------------------------------- 1 | /* SYS_WKUP */ 2 | #ifdef PWR_WAKEUP_PIN1 3 | SYS_WKUP1 = PA_0, 4 | #endif 5 | #ifdef PWR_WAKEUP_PIN2 6 | SYS_WKUP2 = PC_13, 7 | #endif 8 | #ifdef PWR_WAKEUP_PIN3 9 | SYS_WKUP3 = NC, 10 | #endif 11 | #ifdef PWR_WAKEUP_PIN4 12 | SYS_WKUP4 = NC, 13 | #endif 14 | #ifdef PWR_WAKEUP_PIN5 15 | SYS_WKUP5 = NC, 16 | #endif 17 | #ifdef PWR_WAKEUP_PIN6 18 | SYS_WKUP6 = NC, 19 | #endif 20 | #ifdef PWR_WAKEUP_PIN7 21 | SYS_WKUP7 = NC, 22 | #endif 23 | #ifdef PWR_WAKEUP_PIN8 24 | SYS_WKUP8 = NC, 25 | #endif 26 | /* USB */ 27 | #ifdef USBCON 28 | USB_DM = PA_11, 29 | USB_DP = PA_12, 30 | #endif 31 | -------------------------------------------------------------------------------- /src/variants/GHOST_TX/ldscript.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ** Abstract : Linker script for STM32F303CC Device with 3 | ** 256KByte FLASH, 40KByte RAM, 8KByte CCMRAM 4 | */ 5 | 6 | /* Specify the memory areas */ 7 | MEMORY 8 | { 9 | RAM_CODE (rx) : ORIGIN = 0x20000000, LENGTH = 1K 10 | RAM_DATA (xrw) : ORIGIN = 0x20000000 + LENGTH(RAM_CODE), LENGTH = 40K - LENGTH(RAM_CODE) 11 | CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 8K 12 | FLASH (rx) : ORIGIN = 0x8000000 + 16K, LENGTH = 256K - 16K 13 | } 14 | 15 | INCLUDE "variants/ldscript_gen.ld" 16 | -------------------------------------------------------------------------------- /src/variants/L432K/PinNamesVar.h: -------------------------------------------------------------------------------- 1 | /* SYS_WKUP */ 2 | #ifdef PWR_WAKEUP_PIN1 3 | SYS_WKUP1 = PA_0, 4 | #endif 5 | #ifdef PWR_WAKEUP_PIN2 6 | SYS_WKUP2 = PC_13, /* manually updated */ 7 | #endif 8 | #ifdef PWR_WAKEUP_PIN3 9 | SYS_WKUP3 = NC, 10 | #endif 11 | #ifdef PWR_WAKEUP_PIN4 12 | SYS_WKUP4 = PA_2, 13 | #endif 14 | #ifdef PWR_WAKEUP_PIN5 15 | SYS_WKUP5 = PC_5, /* manually updated */ 16 | #endif 17 | #ifdef PWR_WAKEUP_PIN6 18 | SYS_WKUP6 = NC, 19 | #endif 20 | #ifdef PWR_WAKEUP_PIN7 21 | SYS_WKUP7 = NC, 22 | #endif 23 | #ifdef PWR_WAKEUP_PIN8 24 | SYS_WKUP8 = NC, 25 | #endif 26 | /* USB */ 27 | #ifdef USBCON 28 | USB_DM = PA_11, 29 | USB_DP = PA_12, 30 | USB_NOE = PA_13, 31 | #endif 32 | -------------------------------------------------------------------------------- /src/variants/L432K/ldscript.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ** Abstract : Linker script for STM32L432KCUx Device with 3 | ** 256KByte FLASH, 64KByte RAM 4 | */ 5 | 6 | /* Specify the memory areas */ 7 | MEMORY 8 | { 9 | RAM_CODE (rx) : ORIGIN = 0x20000000, LENGTH = 1K 10 | RAM_DATA (xrw) : ORIGIN = 0x20000000 + LENGTH(RAM_CODE), LENGTH = 64K - LENGTH(RAM_CODE) 11 | CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 0K 12 | FLASH (rx) : ORIGIN = 0x8000000 + FLASH_APP_OFFSET, LENGTH = 128K - FLASH_APP_OFFSET 13 | } 14 | 15 | INCLUDE "variants/ldscript_gen.ld" 16 | -------------------------------------------------------------------------------- /src/variants/NamimnoRC_Alpha.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ** Abstract : Linker script for STM32F103C(8-B)Tx Device with 3 | ** 32/64/128KByte FLASH, 10/20KByte RAM 4 | */ 5 | 6 | BOOTLOADER_SIZE = 16K; 7 | 8 | /* Specify the memory areas */ 9 | MEMORY 10 | { 11 | RAM_CODE (rx) : ORIGIN = 0x20000000, LENGTH = 1K 12 | RAM_DATA (xrw) : ORIGIN = 0x20000000 + LENGTH(RAM_CODE), LENGTH = 20K - LENGTH(RAM_CODE) 13 | CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 0K 14 | FLASH (rx) : ORIGIN = 0x8000000 + BOOTLOADER_SIZE, LENGTH = 64K - BOOTLOADER_SIZE 15 | } 16 | 17 | INCLUDE "variants/ldscript_gen.ld" 18 | -------------------------------------------------------------------------------- /src/variants/R9MM/PinNamesVar.h: -------------------------------------------------------------------------------- 1 | /* SYS_WKUP */ 2 | #ifdef PWR_WAKEUP_PIN1 3 | SYS_WKUP1 = PA_0, 4 | #endif 5 | #ifdef PWR_WAKEUP_PIN2 6 | SYS_WKUP2 = NC, 7 | #endif 8 | #ifdef PWR_WAKEUP_PIN3 9 | SYS_WKUP3 = NC, 10 | #endif 11 | #ifdef PWR_WAKEUP_PIN4 12 | SYS_WKUP4 = NC, 13 | #endif 14 | #ifdef PWR_WAKEUP_PIN5 15 | SYS_WKUP5 = NC, 16 | #endif 17 | #ifdef PWR_WAKEUP_PIN6 18 | SYS_WKUP6 = NC, 19 | #endif 20 | #ifdef PWR_WAKEUP_PIN7 21 | SYS_WKUP7 = NC, 22 | #endif 23 | #ifdef PWR_WAKEUP_PIN8 24 | SYS_WKUP8 = NC, 25 | #endif 26 | /* USB */ 27 | #ifdef USBCON 28 | USB_DM = PA_11, 29 | USB_DP = PA_12, 30 | #endif 31 | -------------------------------------------------------------------------------- /src/variants/R9MM/R9MM_ldscript.ld: -------------------------------------------------------------------------------- 1 | 2 | /* Specify the memory areas */ 3 | MEMORY 4 | { 5 | RAM_CODE (rx) : ORIGIN = 0x20000000, LENGTH = 1K 6 | RAM_DATA (xrw) : ORIGIN = 0x20000000 + LENGTH(RAM_CODE), LENGTH = 20K - LENGTH(RAM_CODE) 7 | CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 0K 8 | FLASH (rx) : ORIGIN = 0x08008000, LENGTH = 96K 9 | } 10 | 11 | INCLUDE "variants/ldscript_gen.ld" 12 | -------------------------------------------------------------------------------- /src/variants/R9M_Lite_Pro_ldscript.ld: -------------------------------------------------------------------------------- 1 | 2 | /* Specify the memory areas */ 3 | MEMORY 4 | { 5 | RAM_CODE (rx) : ORIGIN = 0x20000000, LENGTH = 1K 6 | RAM_DATA (xrw) : ORIGIN = 0x20000000 + LENGTH(RAM_CODE), LENGTH = 40K - LENGTH(RAM_CODE) 7 | CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 0K 8 | FLASH (rx) : ORIGIN = 0x8008000, LENGTH = 128K - 0x8000 9 | } 10 | 11 | INCLUDE "variants/ldscript_gen.ld" 12 | -------------------------------------------------------------------------------- /src/variants/R9M_ldscript.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ** Abstract : Linker script for STM32F103C(8-B)Tx Device with 3 | ** 32/64/128KByte FLASH, 10/20KByte RAM 4 | */ 5 | 6 | /* Specify the memory areas */ 7 | MEMORY 8 | { 9 | RAM_CODE (rx) : ORIGIN = 0x20000000, LENGTH = 1K 10 | RAM_DATA (xrw) : ORIGIN = 0x20000000 + LENGTH(RAM_CODE), LENGTH = 20K - LENGTH(RAM_CODE) 11 | CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 0K 12 | FLASH (rx) : ORIGIN = 0x8004000, LENGTH = 64K - 0x4000 13 | } 14 | 15 | INCLUDE "variants/ldscript_gen.ld" 16 | -------------------------------------------------------------------------------- /src/variants/R9M_ldscript_old_bl.ld: -------------------------------------------------------------------------------- 1 | /* 2 | NOTE: Don't use this linker file for any new target!! 3 | */ 4 | 5 | /* Specify the memory areas */ 6 | MEMORY 7 | { 8 | RAM_CODE (rx) : ORIGIN = 0x20000000, LENGTH = 1K 9 | RAM_DATA (xrw) : ORIGIN = 0x20000000 + LENGTH(RAM_CODE), LENGTH = 20K - LENGTH(RAM_CODE) 10 | CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 0K 11 | FLASH (rx) : ORIGIN = 0x8002000, LENGTH = 128K - 0x2000 12 | } 13 | 14 | INCLUDE "variants/ldscript_gen.ld" 15 | -------------------------------------------------------------------------------- /src/variants/r9mx/PinNamesVar.h: -------------------------------------------------------------------------------- 1 | /* SYS_WKUP */ 2 | #ifdef PWR_WAKEUP_PIN1 3 | SYS_WKUP1 = PA_0, 4 | #endif 5 | #ifdef PWR_WAKEUP_PIN2 6 | SYS_WKUP2 = PC_13, 7 | #endif 8 | #ifdef PWR_WAKEUP_PIN3 9 | SYS_WKUP3 = PE_6, 10 | #endif 11 | #ifdef PWR_WAKEUP_PIN4 12 | SYS_WKUP4 = PA_2, 13 | #endif 14 | #ifdef PWR_WAKEUP_PIN5 15 | SYS_WKUP5 = PC_5, 16 | #endif 17 | #ifdef PWR_WAKEUP_PIN6 18 | SYS_WKUP6 = NC, 19 | #endif 20 | #ifdef PWR_WAKEUP_PIN7 21 | SYS_WKUP7 = NC, 22 | #endif 23 | #ifdef PWR_WAKEUP_PIN8 24 | SYS_WKUP8 = NC, 25 | #endif 26 | /* USB */ 27 | #ifdef USBCON 28 | USB_DM = PA_11, 29 | USB_DP = PA_12, 30 | /* USB_NOE = PA_13, */ 31 | /* USB_NOE = PC_9, */ 32 | #endif -------------------------------------------------------------------------------- /src/variants/r9mx/ldscript.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | ** 4 | ** Linker command file for STM32L433CB 5 | ** 6 | ***************************************************************************** 7 | */ 8 | 9 | /* Memories definition */ 10 | MEMORY 11 | { 12 | RAM_CODE (rx) : ORIGIN = 0x20000000, LENGTH = 1K 13 | RAM_DATA (xrw) : ORIGIN = 0x20000000 + LENGTH(RAM_CODE), LENGTH = 64K - LENGTH(RAM_CODE) 14 | CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 0K 15 | FLASH (rx) : ORIGIN = 0x8000000 + FLASH_OFFSET, LENGTH = 128K - FLASH_OFFSET 16 | } 17 | 18 | INCLUDE "variants/ldscript_gen.ld" 19 | -------------------------------------------------------------------------------- /src/variants/stm32f303xx.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ***************************************************************************** 3 | ** 4 | 5 | ** Abstract : Linker script for STM32F303CC Device with 6 | ** 256KByte FLASH, 40KByte RAM, 8KByte CCMRAM 7 | ** 8 | 9 | /* Specify the memory areas */ 10 | MEMORY 11 | { 12 | RAM_CODE (rx) : ORIGIN = 0x20000000, LENGTH = 1K 13 | RAM_DATA (xrw) : ORIGIN = 0x20000000 + LENGTH(RAM_CODE), LENGTH = 40K - LENGTH(RAM_CODE) 14 | CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 8K 15 | FLASH (rx) : ORIGIN = 0x8008000, LENGTH = 256K - 0x8000 16 | } 17 | 18 | INCLUDE "variants/ldscript_gen.ld" 19 | --------------------------------------------------------------------------------