├── docs ├── assets │ ├── images │ │ ├── zadig-dfu.png │ │ ├── StickPositions.png │ │ ├── blheli-bootloader.png │ │ └── serial1wire-cc3d-wiring.jpg │ └── cleanflight │ │ ├── cleanflight-icon_128.png │ │ ├── cleanflight-logo-light-wide-1-240px.jpg │ │ └── cleanflight-logo-light-wide-1-240px-transparent.png ├── development │ ├── assets │ │ ├── Thumbs.db │ │ ├── 013.compile.png │ │ ├── 001.cygwin_dl.png │ │ ├── 008.toolchain.png │ │ ├── 002.cygwin_setup.png │ │ ├── 003.cygwin_setup.png │ │ ├── 004.cygwin_setup.png │ │ ├── 005.cygwin_setup.png │ │ ├── 006.cygwin_setup.png │ │ ├── 007.cygwin_setup.png │ │ ├── 011.git_checkout.png │ │ ├── 012.git_checkout.png │ │ ├── 009.toolchain_path.png │ │ ├── 010.toolchain_path.png │ │ ├── hardware │ │ │ ├── j-link-edu.jpg │ │ │ ├── cjmcu-jlink-back.jpg │ │ │ ├── cjmcu-jlink-front.jpg │ │ │ ├── THAOYU-USB-MiniJTAG.jpg │ │ │ ├── cepark-stlink-v2-front.jpg │ │ │ └── OLIMEX-ARM-JTAG-ADAPTER-2144328-40.jpg │ │ └── mac-prompt-tools-install.png │ ├── Travis.md │ └── Building Manual.md ├── Screenshots │ ├── cleanflight-gui.png │ ├── blackbox-dataflash.png │ ├── blackbox-screenshot-1.jpg │ ├── adjustments-pid-via-two-3pos.png │ ├── adjustments-incorrect-config-1.png │ ├── adjustments-incorrect-config-2.png │ ├── adjustments-pid-via-6pos-and-3pos.png │ ├── adjustments-rates-via-a-2pos-and-3pos.png │ ├── adjustments-incorrect-config-2-corrected.png │ ├── adjustments-rate-profile-selection-via-3pos.png │ └── adjustments-pitch-and-roll-rate-adjustment-via-3pos.png ├── Wiring │ ├── PPMRSSI conditioning.pdf │ ├── CC3D - buzzer circuit.pdf │ ├── blackbox-installation-1.jpg │ ├── Crius CO-16 OLED diagram.png │ └── Crius CO-16 OLED modifications.jpg ├── override.css ├── Board - RMDO.md ├── Introduction.md ├── Sonar.md ├── Boards.md ├── Rssi.md ├── Safety.md ├── Installation.md ├── Profiles.md └── Configuration.md ├── src ├── main │ ├── drivers │ │ ├── accgyro_lsm303dlhc.h │ │ ├── timer_stm32f10x.h │ │ ├── timer_stm32f30x.h │ │ ├── accgyro_spi_mpu6000.h │ │ ├── accgyro_bma280.h │ │ ├── accgyro_l3gd20.h │ │ ├── accgyro_mma845x.h │ │ ├── accgyro_l3g4200d.h │ │ ├── barometer_bmp280.h │ │ ├── timer_impl.h │ │ ├── barometer_ms5611.h │ │ ├── accgyro_adxl345.h │ │ ├── accgyro_mpu6050.h │ │ ├── compass_ak8963.h │ │ ├── compass_ak8975.h │ │ ├── barometer_icp10111.h │ │ ├── adc_impl.h │ │ ├── compass_ak09916.h │ │ ├── accgyro_spi_mpu6500.h │ │ ├── compass.h │ │ ├── accgyro_mpu3050.h │ │ ├── sensor.h │ │ ├── inverter.h │ │ ├── accgyro_mpu6500.h │ │ ├── accgyro_icm20948.h │ │ ├── serial_usb_vcp.h │ │ ├── sonar_hcsr04.h │ │ ├── flash.h │ │ ├── exti.h │ │ ├── serial_uart_impl.h │ │ ├── compass_hmc5883l.h │ │ ├── inverter.c │ │ ├── barometer_bmp085.h │ │ ├── light_led.c │ │ ├── bus_spi.h │ │ ├── sound_beeper_stm32f30x.c │ │ ├── sound_beeper_stm32f10x.cpp │ │ ├── flash_m25p16.h │ │ ├── serial_softserial.h │ │ ├── sound_beeper.h │ │ ├── pwm_rx.h │ │ ├── bus_i2c.h │ │ ├── opticflow_paw3903.h │ │ ├── adc.h │ │ ├── accgyro.h │ │ ├── ranging_vl53l0x.h │ │ ├── display_ug2864hsweg01.h │ │ ├── adc.cpp │ │ ├── system_stm32f10x.cpp │ │ ├── sound_beeper.c │ │ ├── pwm_output.h │ │ └── barometer.h │ ├── common │ │ ├── colorconversion.h │ │ ├── encoding.cpp │ │ ├── encoding.h │ │ ├── typeconversion.h │ │ ├── axis.h │ │ └── color.h │ ├── flight │ │ ├── filter.h │ │ ├── filter.cpp │ │ ├── gps_conversion.h │ │ ├── gtune.h │ │ ├── opticflow.h │ │ ├── acrobats.h │ │ ├── lowpass.h │ │ ├── posEstimate.h │ │ └── posControl.h │ ├── telemetry │ │ ├── smartport.h │ │ ├── msp.h │ │ ├── frsky.h │ │ └── telemetry.h │ ├── target │ │ ├── stm32_flash_f103_128k.ld │ │ ├── stm32_flash_f103_256k.ld │ │ ├── stm32_flash_f103_64k.ld │ │ ├── stm32_flash_f303_128k.ld │ │ ├── stm32_flash_f303_256k.ld │ │ ├── PRIMUSV4 │ │ │ ├── hardware_revision.h │ │ │ └── hardware_revision.cpp │ │ └── PRIMUSV3R │ │ │ ├── hardware_revision.h │ │ │ └── hardware_revision.cpp │ ├── API │ │ ├── Specifiers.cpp │ │ ├── Motor.h │ │ ├── PlutoPilot.h │ │ ├── Comman.h │ │ ├── Specifiers.h │ │ ├── XRanging.h │ │ ├── PlutoPilot.cpp │ │ ├── Estimate.h │ │ ├── Sensor.h │ │ ├── Localisation.h │ │ └── Localisation.cpp │ ├── debug.cpp │ ├── rx │ │ ├── pwm.h │ │ ├── sumd.h │ │ ├── sbus.h │ │ ├── sumh.h │ │ ├── xbus.h │ │ ├── msp.h │ │ └── spektrum.h │ ├── io │ │ ├── statusindicator.h │ │ ├── gimbal.h │ │ ├── serial_cli.h │ │ ├── serial_1wire.h │ │ ├── display.h │ │ ├── serial_msp.h │ │ ├── rc_curves.h │ │ ├── escservo.h │ │ ├── oled_display.h │ │ └── flashfs.h │ ├── sensors │ │ ├── sonar.h │ │ ├── initialisation.h │ │ ├── boardalignment.h │ │ ├── gyro.h │ │ └── compass.h │ ├── version.cpp │ ├── blackbox │ │ └── blackbox.h │ ├── build_config.cpp │ ├── build_config.h │ ├── command │ │ ├── localisationCommand.h │ │ └── command.h │ ├── mw.h │ ├── debug.h │ ├── platform.h │ └── version.h └── test │ └── unit │ ├── unittest_macros.h │ ├── platform.h │ └── io_serial_unittest.cc ├── .gitignore ├── lib ├── main │ ├── VL53L0X_API │ │ ├── core │ │ │ ├── inc │ │ │ │ ├── vl53l0x_api.h │ │ │ │ ├── vl53l0x_def.h │ │ │ │ ├── vl53l0x_device.h │ │ │ │ ├── vl53l0x_tuning.h │ │ │ │ ├── vl53l0x_api_core.h │ │ │ │ ├── vl53l0x_api_ranging.h │ │ │ │ ├── vl53l0x_api_strings.h │ │ │ │ ├── vl53l0x_api_calibration.h │ │ │ │ └── vl53l0x_interrupt_threshold_settings.h │ │ │ └── src │ │ │ │ └── vl53l0x_api.c.bak │ │ └── platform │ │ │ ├── inc │ │ │ ├── vl53l0x_types.h │ │ │ ├── vl53l0x_platform.h │ │ │ └── vl53l0x_platform_log.h │ │ │ └── src │ │ │ └── vl53l0x_platform.c │ ├── STM32F30x_StdPeriph_Driver │ │ ├── Release_Notes.html │ │ └── inc │ │ │ └── stm32f30x_hrtim.h │ ├── STM32F10x_StdPeriph_Driver │ │ └── src │ │ │ ├── stm32f10x_i2c.c │ │ │ ├── stm32f10x_flash.c │ │ │ └── stm32f10x_usart.c │ └── STM32_USB-FS-Device_Driver │ │ └── inc │ │ └── usb_int.h └── test │ └── gtest │ └── src │ └── gtest_main.cc ├── support ├── stmloader │ ├── Makefile │ ├── stmbootloader.h │ └── serial.h ├── flash.bat └── buildserver │ └── upload.php ├── JLinkSettings.ini ├── CONTRIBUTING.md ├── fake_travis_build.sh ├── Vagrantfile └── README.md /docs/assets/images/zadig-dfu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/assets/images/zadig-dfu.png -------------------------------------------------------------------------------- /docs/development/assets/Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/development/assets/Thumbs.db -------------------------------------------------------------------------------- /docs/Screenshots/cleanflight-gui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/Screenshots/cleanflight-gui.png -------------------------------------------------------------------------------- /docs/Wiring/PPMRSSI conditioning.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/Wiring/PPMRSSI conditioning.pdf -------------------------------------------------------------------------------- /docs/Screenshots/blackbox-dataflash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/Screenshots/blackbox-dataflash.png -------------------------------------------------------------------------------- /docs/Wiring/CC3D - buzzer circuit.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/Wiring/CC3D - buzzer circuit.pdf -------------------------------------------------------------------------------- /docs/Wiring/blackbox-installation-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/Wiring/blackbox-installation-1.jpg -------------------------------------------------------------------------------- /docs/assets/images/StickPositions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/assets/images/StickPositions.png -------------------------------------------------------------------------------- /docs/development/assets/013.compile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/development/assets/013.compile.png -------------------------------------------------------------------------------- /src/main/drivers/accgyro_lsm303dlhc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/src/main/drivers/accgyro_lsm303dlhc.h -------------------------------------------------------------------------------- /docs/Wiring/Crius CO-16 OLED diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/Wiring/Crius CO-16 OLED diagram.png -------------------------------------------------------------------------------- /docs/assets/images/blheli-bootloader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/assets/images/blheli-bootloader.png -------------------------------------------------------------------------------- /docs/development/assets/001.cygwin_dl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/development/assets/001.cygwin_dl.png -------------------------------------------------------------------------------- /docs/development/assets/008.toolchain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/development/assets/008.toolchain.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #object files 2 | Build/ 3 | #static lib files 4 | libs/ 5 | #Cygnus project settings files and hidden files 6 | .* 7 | !.gitignore -------------------------------------------------------------------------------- /docs/Screenshots/blackbox-screenshot-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/Screenshots/blackbox-screenshot-1.jpg -------------------------------------------------------------------------------- /docs/development/assets/002.cygwin_setup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/development/assets/002.cygwin_setup.png -------------------------------------------------------------------------------- /docs/development/assets/003.cygwin_setup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/development/assets/003.cygwin_setup.png -------------------------------------------------------------------------------- /docs/development/assets/004.cygwin_setup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/development/assets/004.cygwin_setup.png -------------------------------------------------------------------------------- /docs/development/assets/005.cygwin_setup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/development/assets/005.cygwin_setup.png -------------------------------------------------------------------------------- /docs/development/assets/006.cygwin_setup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/development/assets/006.cygwin_setup.png -------------------------------------------------------------------------------- /docs/development/assets/007.cygwin_setup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/development/assets/007.cygwin_setup.png -------------------------------------------------------------------------------- /docs/development/assets/011.git_checkout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/development/assets/011.git_checkout.png -------------------------------------------------------------------------------- /docs/development/assets/012.git_checkout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/development/assets/012.git_checkout.png -------------------------------------------------------------------------------- /lib/main/VL53L0X_API/core/inc/vl53l0x_api.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/lib/main/VL53L0X_API/core/inc/vl53l0x_api.h -------------------------------------------------------------------------------- /lib/main/VL53L0X_API/core/inc/vl53l0x_def.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/lib/main/VL53L0X_API/core/inc/vl53l0x_def.h -------------------------------------------------------------------------------- /docs/Wiring/Crius CO-16 OLED modifications.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/Wiring/Crius CO-16 OLED modifications.jpg -------------------------------------------------------------------------------- /docs/assets/images/serial1wire-cc3d-wiring.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/assets/images/serial1wire-cc3d-wiring.jpg -------------------------------------------------------------------------------- /docs/development/assets/009.toolchain_path.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/development/assets/009.toolchain_path.png -------------------------------------------------------------------------------- /docs/development/assets/010.toolchain_path.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/development/assets/010.toolchain_path.png -------------------------------------------------------------------------------- /lib/main/VL53L0X_API/core/inc/vl53l0x_device.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/lib/main/VL53L0X_API/core/inc/vl53l0x_device.h -------------------------------------------------------------------------------- /lib/main/VL53L0X_API/core/inc/vl53l0x_tuning.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/lib/main/VL53L0X_API/core/inc/vl53l0x_tuning.h -------------------------------------------------------------------------------- /docs/Screenshots/adjustments-pid-via-two-3pos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/Screenshots/adjustments-pid-via-two-3pos.png -------------------------------------------------------------------------------- /docs/assets/cleanflight/cleanflight-icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/assets/cleanflight/cleanflight-icon_128.png -------------------------------------------------------------------------------- /docs/development/assets/hardware/j-link-edu.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/development/assets/hardware/j-link-edu.jpg -------------------------------------------------------------------------------- /lib/main/VL53L0X_API/core/inc/vl53l0x_api_core.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/lib/main/VL53L0X_API/core/inc/vl53l0x_api_core.h -------------------------------------------------------------------------------- /lib/main/VL53L0X_API/core/src/vl53l0x_api.c.bak: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/lib/main/VL53L0X_API/core/src/vl53l0x_api.c.bak -------------------------------------------------------------------------------- /lib/main/VL53L0X_API/platform/inc/vl53l0x_types.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/lib/main/VL53L0X_API/platform/inc/vl53l0x_types.h -------------------------------------------------------------------------------- /docs/Screenshots/adjustments-incorrect-config-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/Screenshots/adjustments-incorrect-config-1.png -------------------------------------------------------------------------------- /docs/Screenshots/adjustments-incorrect-config-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/Screenshots/adjustments-incorrect-config-2.png -------------------------------------------------------------------------------- /lib/main/VL53L0X_API/core/inc/vl53l0x_api_ranging.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/lib/main/VL53L0X_API/core/inc/vl53l0x_api_ranging.h -------------------------------------------------------------------------------- /lib/main/VL53L0X_API/core/inc/vl53l0x_api_strings.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/lib/main/VL53L0X_API/core/inc/vl53l0x_api_strings.h -------------------------------------------------------------------------------- /docs/Screenshots/adjustments-pid-via-6pos-and-3pos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/Screenshots/adjustments-pid-via-6pos-and-3pos.png -------------------------------------------------------------------------------- /docs/development/assets/hardware/cjmcu-jlink-back.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/development/assets/hardware/cjmcu-jlink-back.jpg -------------------------------------------------------------------------------- /docs/development/assets/hardware/cjmcu-jlink-front.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/development/assets/hardware/cjmcu-jlink-front.jpg -------------------------------------------------------------------------------- /docs/development/assets/mac-prompt-tools-install.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/development/assets/mac-prompt-tools-install.png -------------------------------------------------------------------------------- /docs/override.css: -------------------------------------------------------------------------------- 1 | IMG { 2 | max-width: 700px; 3 | } 4 | 5 | /* mainly for the cli reference table */ 6 | TABLE TR TD, TABLE TR TH { 7 | font-size: 9px 8 | } 9 | -------------------------------------------------------------------------------- /lib/main/STM32F30x_StdPeriph_Driver/Release_Notes.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/lib/main/STM32F30x_StdPeriph_Driver/Release_Notes.html -------------------------------------------------------------------------------- /lib/main/VL53L0X_API/platform/inc/vl53l0x_platform.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/lib/main/VL53L0X_API/platform/inc/vl53l0x_platform.h -------------------------------------------------------------------------------- /lib/main/VL53L0X_API/platform/src/vl53l0x_platform.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/lib/main/VL53L0X_API/platform/src/vl53l0x_platform.c -------------------------------------------------------------------------------- /docs/development/assets/hardware/THAOYU-USB-MiniJTAG.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/development/assets/hardware/THAOYU-USB-MiniJTAG.jpg -------------------------------------------------------------------------------- /lib/main/STM32F10x_StdPeriph_Driver/src/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/lib/main/STM32F10x_StdPeriph_Driver/src/stm32f10x_i2c.c -------------------------------------------------------------------------------- /lib/main/VL53L0X_API/core/inc/vl53l0x_api_calibration.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/lib/main/VL53L0X_API/core/inc/vl53l0x_api_calibration.h -------------------------------------------------------------------------------- /lib/main/VL53L0X_API/platform/inc/vl53l0x_platform_log.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/lib/main/VL53L0X_API/platform/inc/vl53l0x_platform_log.h -------------------------------------------------------------------------------- /docs/Screenshots/adjustments-rates-via-a-2pos-and-3pos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/Screenshots/adjustments-rates-via-a-2pos-and-3pos.png -------------------------------------------------------------------------------- /docs/development/assets/hardware/cepark-stlink-v2-front.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/development/assets/hardware/cepark-stlink-v2-front.jpg -------------------------------------------------------------------------------- /lib/main/STM32F10x_StdPeriph_Driver/src/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/lib/main/STM32F10x_StdPeriph_Driver/src/stm32f10x_flash.c -------------------------------------------------------------------------------- /lib/main/STM32F10x_StdPeriph_Driver/src/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/lib/main/STM32F10x_StdPeriph_Driver/src/stm32f10x_usart.c -------------------------------------------------------------------------------- /lib/main/STM32F30x_StdPeriph_Driver/inc/stm32f30x_hrtim.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/lib/main/STM32F30x_StdPeriph_Driver/inc/stm32f30x_hrtim.h -------------------------------------------------------------------------------- /docs/Screenshots/adjustments-incorrect-config-2-corrected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/Screenshots/adjustments-incorrect-config-2-corrected.png -------------------------------------------------------------------------------- /docs/Screenshots/adjustments-rate-profile-selection-via-3pos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/Screenshots/adjustments-rate-profile-selection-via-3pos.png -------------------------------------------------------------------------------- /docs/assets/cleanflight/cleanflight-logo-light-wide-1-240px.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/assets/cleanflight/cleanflight-logo-light-wide-1-240px.jpg -------------------------------------------------------------------------------- /lib/main/VL53L0X_API/core/inc/vl53l0x_interrupt_threshold_settings.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/lib/main/VL53L0X_API/core/inc/vl53l0x_interrupt_threshold_settings.h -------------------------------------------------------------------------------- /docs/development/assets/hardware/OLIMEX-ARM-JTAG-ADAPTER-2144328-40.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/development/assets/hardware/OLIMEX-ARM-JTAG-ADAPTER-2144328-40.jpg -------------------------------------------------------------------------------- /docs/Screenshots/adjustments-pitch-and-roll-rate-adjustment-via-3pos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/Screenshots/adjustments-pitch-and-roll-rate-adjustment-via-3pos.png -------------------------------------------------------------------------------- /docs/assets/cleanflight/cleanflight-logo-light-wide-1-240px-transparent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DronaAviation/Magis/HEAD/docs/assets/cleanflight/cleanflight-logo-light-wide-1-240px-transparent.png -------------------------------------------------------------------------------- /src/main/common/colorconversion.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | rgbColor24bpp_t* hsvToRgb24(const hsvColor_t *c); 8 | 9 | #ifdef __cplusplus 10 | } 11 | #endif 12 | -------------------------------------------------------------------------------- /src/main/drivers/timer_stm32f10x.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | #include "stm32f10x.h" 8 | 9 | void TIM_SelectOCxM_NoDisable(TIM_TypeDef* TIMx, uint16_t TIM_Channel, uint16_t TIM_OCMode); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | -------------------------------------------------------------------------------- /src/main/drivers/timer_stm32f30x.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | #include "stm32f30x.h" 8 | 9 | void TIM_SelectOCxM_NoDisable(TIM_TypeDef* TIMx, uint16_t TIM_Channel, uint16_t TIM_OCMode); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | -------------------------------------------------------------------------------- /support/stmloader/Makefile: -------------------------------------------------------------------------------- 1 | CC = $(CROSS_COMPILE)gcc 2 | AR = $(CROSS_COMPILE)ar 3 | export CC 4 | export AR 5 | 6 | all: 7 | $(CC) -g -o stmloader -I./ \ 8 | loader.c \ 9 | serial.c \ 10 | stmbootloader.c \ 11 | -Wall 12 | 13 | clean: 14 | rm -f stmloader; rm -rf stmloader.dSYM 15 | -------------------------------------------------------------------------------- /src/main/flight/filter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * filter.h 3 | * 4 | * Created on: 24 jun. 2015 5 | * Author: borisb 6 | */ 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | typedef float filterStatePt1_t; 13 | 14 | float filterApplyPt1(float input, filterStatePt1_t* state, uint8_t f_cut); 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /docs/Board - RMDO.md: -------------------------------------------------------------------------------- 1 | # Board - RMDO 2 | 3 | The DoDo board is a clone of the SPRacingF3 board in terms of CPU pin mappings. See the SPRacingF3 documentation. 4 | 5 | Hardware differences compared to SPRacingF3 are as follows: 6 | 7 | * The CPU is the cheaper version of the F3 with only 128KB FLASH. 8 | * The external flash rom is the same size as found on the Naze32 (2MBit) 9 | * The barometer is the cheaper BMP280. 10 | * It does not have any compass sensor. 11 | * Onboard BEC. 12 | * Different physical connectors/pins/pads/ports. 13 | -------------------------------------------------------------------------------- /src/main/telemetry/smartport.h: -------------------------------------------------------------------------------- 1 | /* 2 | * smartport.h 3 | * 4 | * Created on: 25 October 2014 5 | * Author: Frank26080115 6 | */ 7 | 8 | #ifndef TELEMETRY_SMARTPORT_H_ 9 | #define TELEMETRY_SMARTPORT_H_ 10 | 11 | void initSmartPortTelemetry(telemetryConfig_t *); 12 | 13 | void handleSmartPortTelemetry(void); 14 | void checkSmartPortTelemetryState(void); 15 | 16 | void configureSmartPortTelemetryPort(void); 17 | void freeSmartPortTelemetryPort(void); 18 | 19 | bool isSmartPortTimedOut(void); 20 | 21 | #endif /* TELEMETRY_SMARTPORT_H_ */ 22 | -------------------------------------------------------------------------------- /docs/development/Travis.md: -------------------------------------------------------------------------------- 1 | #Travis 2 | 3 | Cleanflight provides Travis build and config files in the repository root. 4 | 5 | ## Pushing builds to a remote server 6 | 7 | ```.travis.sh``` script can upload build artifacts to a remote server. This feature is controlled by the 8 | ```PUBLISH_URL``` environment variable. If set, the build script will use the cURL binary and simulate 9 | a file upload post to the configured server. 10 | 11 | Pleas check the ```notifications``` section in the ```.travis.yml``` file and adjust the irc notifications if you plan on using Travis on your Cleanflight fork 12 | -------------------------------------------------------------------------------- /src/main/flight/filter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * filter.cpp 3 | * 4 | * Created on: 24 jun. 2015 5 | * Author: borisb 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "common/axis.h" 14 | 15 | #include "flight/filter.h" 16 | 17 | extern uint16_t cycleTime; 18 | 19 | // PT1 Low Pass filter 20 | float filterApplyPt1(float input, filterStatePt1_t* state, uint8_t f_cut) 21 | { 22 | float dT = (float) cycleTime * 0.000001f; 23 | float RC = 1.0f / (2.0f * (float) M_PI * f_cut); 24 | 25 | *state = *state + dT / (RC + dT) * (input - *state); 26 | 27 | return *state; 28 | } 29 | -------------------------------------------------------------------------------- /JLinkSettings.ini: -------------------------------------------------------------------------------- 1 | [BREAKPOINTS] 2 | ShowInfoWin = 1 3 | EnableFlashBP = 2 4 | BPDuringExecution = 0 5 | [CFI] 6 | CFISize = 0x00 7 | CFIAddr = 0x00 8 | [CPU] 9 | OverrideMemMap = 0 10 | AllowSimulation = 1 11 | ScriptFile="" 12 | [FLASH] 13 | MinNumBytesFlashDL = 0 14 | SkipProgOnCRCMatch = 1 15 | VerifyDownload = 1 16 | AllowCaching = 1 17 | EnableFlashDL = 2 18 | Override = 0 19 | Device="AD7160" 20 | [GENERAL] 21 | WorkRAMSize = 0x00 22 | WorkRAMAddr = 0x00 23 | [SWO] 24 | SWOLogFile="" 25 | [MEM] 26 | RdOverrideOrMask = 0x00 27 | RdOverrideAndMask = 0xFFFFFFFF 28 | RdOverrideAddr = 0xFFFFFFFF 29 | WrOverrideOrMask = 0x00 30 | WrOverrideAndMask = 0xFFFFFFFF 31 | WrOverrideAddr = 0xFFFFFFFF 32 | -------------------------------------------------------------------------------- /src/main/target/stm32_flash_f103_128k.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ***************************************************************************** 3 | ** 4 | ** File : stm32_flash.ld 5 | ** 6 | ** Abstract : Linker script for STM32F103CB Device with 7 | ** 128KByte FLASH, 20KByte RAM 8 | ** 9 | ***************************************************************************** 10 | */ 11 | 12 | /* Specify the memory areas. */ 13 | MEMORY 14 | { 15 | FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 126K /* last 2kb used for config storage */ 16 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K 17 | MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K 18 | } 19 | 20 | INCLUDE "stm32_flash.ld" 21 | -------------------------------------------------------------------------------- /src/main/target/stm32_flash_f103_256k.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ***************************************************************************** 3 | ** 4 | ** File : stm32_flash.ld 5 | ** 6 | ** Abstract : Linker script for STM32F103RC Device with 7 | ** 256KByte FLASH, 48KByte RAM 8 | ** 9 | ***************************************************************************** 10 | */ 11 | 12 | /* Specify the memory areas. */ 13 | MEMORY 14 | { 15 | FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 252K /* last 4kb used for config storage */ 16 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 48K 17 | MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K 18 | } 19 | 20 | INCLUDE "stm32_flash.ld" 21 | -------------------------------------------------------------------------------- /src/main/target/stm32_flash_f103_64k.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ***************************************************************************** 3 | ** 4 | ** File : stm32_flash.ld 5 | ** 6 | ** Abstract : Linker script for STM32F103C8 Device with 7 | ** 64KByte FLASH, 20KByte RAM 8 | ** 9 | ***************************************************************************** 10 | */ 11 | 12 | /* Specify the memory areas. */ 13 | MEMORY 14 | { 15 | FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 62K /* last 2kb used for config storage */ 16 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K 17 | MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K 18 | } 19 | 20 | INCLUDE "stm32_flash.ld" 21 | -------------------------------------------------------------------------------- /src/main/target/stm32_flash_f303_128k.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ***************************************************************************** 3 | ** 4 | ** File : stm32_flash.ld 5 | ** 6 | ** Abstract : Linker script for STM32F30x Device with 7 | ** 128KByte FLASH and 40KByte RAM 8 | ** 9 | ***************************************************************************** 10 | */ 11 | 12 | /* Specify the memory areas. */ 13 | MEMORY 14 | { 15 | FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 126K /* last 2kb used for config storage */ 16 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 40K 17 | MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K 18 | } 19 | 20 | INCLUDE "stm32_flash.ld" 21 | -------------------------------------------------------------------------------- /src/main/target/stm32_flash_f303_256k.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ***************************************************************************** 3 | ** 4 | ** File : stm32_flash.ld 5 | ** 6 | ** Abstract : Linker script for STM32F30x Device with 7 | ** 256KByte FLASH and 40KByte RAM 8 | ** 9 | ***************************************************************************** 10 | */ 11 | 12 | /* Specify the memory areas. */ 13 | MEMORY 14 | { 15 | FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 252K /* last 4kb used for config storage */ 16 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 40K 17 | MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K 18 | } 19 | 20 | INCLUDE "stm32_flash.ld" 21 | -------------------------------------------------------------------------------- /src/main/drivers/accgyro_spi_mpu6000.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #define MPU6000_CONFIG 0x1A 5 | 6 | #define BITS_DLPF_CFG_256HZ 0x00 7 | #define BITS_DLPF_CFG_188HZ 0x01 8 | #define BITS_DLPF_CFG_98HZ 0x02 9 | #define BITS_DLPF_CFG_42HZ 0x03 10 | 11 | #define GYRO_SCALE_FACTOR 0.00053292f // (4/131) * pi/180 (32.75 LSB = 1 DPS) 12 | 13 | #define MPU6000_WHO_AM_I_CONST (0x68) 14 | 15 | bool mpu6000SpiDetect(void); 16 | 17 | bool mpu6000SpiAccDetect(acc_t *acc); 18 | bool mpu6000SpiGyroDetect(gyro_t *gyro); 19 | 20 | bool mpu6000WriteRegister(uint8_t reg, uint8_t data); 21 | bool mpu6000ReadRegister(uint8_t reg, uint8_t length, uint8_t *data); 22 | -------------------------------------------------------------------------------- /support/flash.bat: -------------------------------------------------------------------------------- 1 | @@echo OFF 2 | 3 | :: User configuration 4 | 5 | :: set your port number. ie: for COM6 , port is 6 6 | set PORT=2 7 | :: location of stmflashloader.exe, this is default 8 | set FLASH_LOADER="C:\Program Files (x86)\STMicroelectronics\Software\Flash Loader Demonstrator\STMFlashLoader.exe" 9 | :: path to firmware 10 | set FIRMWARE="D:\baseflight.hex" 11 | 12 | :: ---------------------------------------------- 13 | 14 | mode COM%PORT% BAUD=115200 PARITY=N DATA=8 STOP=1 XON=OFF DTR=OFF RTS=OFF 15 | echo/|set /p ="R" > COM%PORT%: 16 | 17 | TIMEOUT /T 3 18 | 19 | cd %LOADER_PATH% 20 | 21 | %FLASH_LOADER% ^ 22 | -c --pn %PORT% --br 115200 --db 8 ^ 23 | -i STM32_Med-density_128K ^ 24 | -e --all ^ 25 | -d --fn %FIRMWARE% ^ 26 | -r --a 0x8000000 27 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Issues and Support. 2 | 3 | Please remember the issue tracker on github is _not_ for user support. Please also do not email developers directly for support. 4 | 5 | Issues created without steps to repeat are likely to be closed. E-mail requests for support will go un-answered; All support needs to be public so that other people can read the problems and solutions. 6 | 7 | Remember that issues that are due to mis-configuration, wiring or failure to read documentation just takes time away from the developers and can often be solved without developer interaction by other users. 8 | 9 | Please search for existing issues *before* creating new ones. 10 | 11 | # Developers 12 | 13 | Please refer to the development section in the `docs/development` folder. 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/main/API/Specifiers.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Magis. 3 | * 4 | * Magis is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Magis is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #include "Specifiers.h" 19 | 20 | -------------------------------------------------------------------------------- /src/main/drivers/accgyro_bma280.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | bool bma280Detect(acc_t *acc); 21 | -------------------------------------------------------------------------------- /src/main/drivers/accgyro_l3gd20.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | bool l3gd20Detect(gyro_t *gyro); 21 | -------------------------------------------------------------------------------- /src/main/drivers/accgyro_mma845x.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | bool mma8452Detect(acc_t *acc); 21 | -------------------------------------------------------------------------------- /src/test/unit/unittest_macros.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | 21 | #define UNUSED(x) (void)(x) 22 | -------------------------------------------------------------------------------- /src/main/drivers/accgyro_l3g4200d.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | bool l3g4200dDetect(gyro_t *gyro); 21 | -------------------------------------------------------------------------------- /src/main/drivers/barometer_bmp280.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | bool bmp280Detect(baro_t *baro); 21 | 22 | -------------------------------------------------------------------------------- /fake_travis_build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | targets=("PUBLISHMETA=True" \ 4 | "RUNTESTS=True" \ 5 | "TARGET=CC3D" \ 6 | "TARGET=CHEBUZZF3" \ 7 | "TARGET=CJMCU" \ 8 | "TARGET=COLIBRI_RACE" \ 9 | "TARGET=EUSTM32F103RC" \ 10 | "TARGET=SPRACINGF3" \ 11 | "TARGET=MOTOLAB" \ 12 | "TARGET=NAZE" \ 13 | "TARGET=NAZE32PRO" \ 14 | "TARGET=OLIMEXINO" \ 15 | "TARGET=PORT103R" \ 16 | "TARGET=RMDO" \ 17 | "TARGET=SPARKY" \ 18 | "TARGET=STM32F3DISCOVERY" \ 19 | "TARGET=ALIENWIIF1" \ 20 | "TARGET=ALIENWIIF3") 21 | 22 | #fake a travis build environment 23 | export TRAVIS_BUILD_NUMBER=$(date +%s) 24 | export BUILDNAME=${BUILDNAME:=fake_travis} 25 | export TRAVIS_REPO_SLUG=${TRAVIS_REPO_SLUG:=$USER/simulated} 26 | 27 | for target in "${targets[@]}" 28 | do 29 | unset RUNTESTS PUBLISHMETA TARGET 30 | eval "export $target" 31 | make clean 32 | ./.travis.sh 33 | done 34 | -------------------------------------------------------------------------------- /src/main/flight/gps_conversion.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | uint32_t GPS_coord_to_degrees(const char* coordinateString); 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | -------------------------------------------------------------------------------- /docs/development/Building Manual.md: -------------------------------------------------------------------------------- 1 | #Building Manual. 2 | 3 | The manual PDF file is generated by concatenating relevant markdown files and by transforming the result using Gimli to obtain the final PDF file. This steps are handled automatically by the ```build_docs.sh``` script located in the root of the repository next to the Makefile. 4 | 5 | ##Requirements & Installation 6 | The PDF manual generation uses the Gimli for the conversion. It can be installed via ruby gems. On Debian based systems the installation steps are: 7 | ```bash 8 | sudo apt-get install ruby1.9.1 ruby1.9.1-dev rubygems zlib1g-dev wkhtmltopdf libxml2-dev libxslt-dev 9 | sudo gem1.9.1 install gimli 10 | ``` 11 | 12 | ##Configuration 13 | All markdown files need to be registered in the ```build_manual.sh``` file individually by modifying the ```doc_files``` variable / array: 14 | ```bash 15 | doc_files=( 'Configuration.md' 16 | 'Board - CC3D.md' 17 | '...' 18 | '...' 19 | ) 20 | ``` 21 | -------------------------------------------------------------------------------- /src/main/drivers/timer_impl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | void timerInitTarget(void); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /src/main/debug.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #include "stdint.h" 19 | 20 | #include "debug.h" 21 | 22 | int16_t debug[DEBUG16_VALUE_COUNT]; 23 | 24 | #ifdef DEBUG_SECTION_TIMES 25 | uint32_t sectionTimes[2][4]; 26 | #endif 27 | -------------------------------------------------------------------------------- /src/main/drivers/barometer_ms5611.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | bool ms5611Detect(baro_t *baro); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /src/main/drivers/accgyro_adxl345.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | typedef struct drv_adxl345_config_s { 21 | bool useFifo; 22 | uint16_t dataRate; 23 | } drv_adxl345_config_t; 24 | 25 | bool adxl345Detect(drv_adxl345_config_t *init, acc_t *acc); 26 | -------------------------------------------------------------------------------- /src/main/drivers/accgyro_mpu6050.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | bool mpu6050AccDetect(acc_t *acc); 25 | bool mpu6050GyroDetect(gyro_t *gyro); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | -------------------------------------------------------------------------------- /src/main/flight/gtune.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | void init_Gtune(pidProfile_t *pidProfileToTune); 25 | void calculate_Gtune(uint8_t axis); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | -------------------------------------------------------------------------------- /src/main/API/Motor.h: -------------------------------------------------------------------------------- 1 | /*PlutoX API V.1.0 2 | */ 3 | 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | typedef enum reverse_motor { 14 | M1 = 0x0, 15 | M2, 16 | M3, 17 | M4 18 | } reverse_motor_e; 19 | 20 | typedef enum motor_direction { 21 | CLOCK_WISE = 0, 22 | ANTICLOCK_WISE 23 | } motor_direction_e; 24 | 25 | typedef enum { 26 | FORWARD = 0, 27 | BACKWARD 28 | } motor_terrestrial_direction_e; 29 | 30 | typedef enum std_motor { 31 | M5 = 0x0, 32 | M6, 33 | M7, 34 | M8 35 | } std_motor_e; 36 | 37 | class Motor_P { 38 | 39 | public: 40 | void initReverseMotor ( reverse_motor_e motor ); 41 | void set ( std_motor_e motor, int16_t pwmValue ); 42 | void set ( reverse_motor_e motor, int16_t pwmValue ); 43 | void setDirection ( reverse_motor_e motor, motor_direction_e direction ); 44 | }; 45 | 46 | extern Motor_P Motor; 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | -------------------------------------------------------------------------------- /src/main/rx/pwm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | #include "rx/rx.h" 24 | 25 | void rxPwmInit(rxRuntimeConfig_t *rxRuntimeConfigPtr, rcReadRawDataPtr *callback); 26 | 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | -------------------------------------------------------------------------------- /src/main/drivers/compass_ak8963.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | bool ak8963Detect(mag_t *mag); 25 | bool ak8963Init(void); 26 | bool ak8963Read(int16_t *magData); 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | -------------------------------------------------------------------------------- /src/main/drivers/compass_ak8975.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | bool ak8975Detect(mag_t *mag); 25 | void ak8975Init(void); 26 | bool ak8975Read(int16_t *magData); 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | -------------------------------------------------------------------------------- /src/main/drivers/barometer_icp10111.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | bool icp10111Detect(baro_t *baro); 25 | 26 | 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | -------------------------------------------------------------------------------- /src/main/common/encoding.cpp: -------------------------------------------------------------------------------- 1 | #include "encoding.h" 2 | 3 | /** 4 | * Cast the in-memory representation of the given float directly to an int. 5 | * 6 | * This is useful for printing the hex representation of a float number (which is considerably cheaper 7 | * than a full decimal float formatter, in both code size and output length). 8 | */ 9 | uint32_t castFloatBytesToInt(float f) 10 | { 11 | union floatConvert_t { 12 | float f; 13 | uint32_t u; 14 | } floatConvert; 15 | 16 | floatConvert.f = f; 17 | 18 | return floatConvert.u; 19 | } 20 | 21 | /** 22 | * ZigZag encoding maps all values of a signed integer into those of an unsigned integer in such 23 | * a way that numbers of small absolute value correspond to small integers in the result. 24 | * 25 | * (Compared to just casting a signed to an unsigned which creates huge resulting numbers for 26 | * small negative integers). 27 | */ 28 | uint32_t zigzagEncode(int32_t value) 29 | { 30 | return (uint32_t)((value << 1) ^ (value >> 31)); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/drivers/adc_impl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | #pragma once 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | extern adc_config_t adcConfig[ADC_CHANNEL_COUNT]; 24 | extern volatile uint16_t adcValues[ADC_CHANNEL_COUNT]; 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /src/main/drivers/compass_ak09916.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | bool ak09916Detect(mag_t *mag); 25 | bool ak09916Init(void); 26 | bool ak09916Read(int16_t *magData); 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | -------------------------------------------------------------------------------- /src/main/common/encoding.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | uint32_t castFloatBytesToInt(float f); 27 | uint32_t zigzagEncode(int32_t value); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | -------------------------------------------------------------------------------- /support/stmloader/stmbootloader.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of AutoQuad. 3 | 4 | AutoQuad is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | AutoQuad is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | You should have received a copy of the GNU General Public License 14 | along with AutoQuad. If not, see . 15 | 16 | Copyright © 2011 Bill Nesbitt 17 | */ 18 | 19 | #ifndef _stmbootloader_h 20 | #define _stmbootloader_h 21 | 22 | #include 23 | #include "serial.h" 24 | 25 | extern void stmLoader(serialStruct_t *s, FILE *fp, unsigned char overrideParity, unsigned char noSendR); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/main/rx/sumd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | #include "rx/rx.h" 24 | 25 | uint8_t sumdFrameStatus(void); 26 | bool sumdInit(rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig, rcReadRawDataPtr *callback); 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | -------------------------------------------------------------------------------- /src/main/rx/sbus.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #include "rx/rx.h" 25 | 26 | uint8_t sbusFrameStatus(void); 27 | bool sbusInit(rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig, rcReadRawDataPtr *callback); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | -------------------------------------------------------------------------------- /src/main/drivers/accgyro_spi_mpu6500.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | bool mpu6500SpiDetect(void); 21 | 22 | bool mpu6500SpiAccDetect(acc_t *acc); 23 | bool mpu6500SpiGyroDetect(gyro_t *gyro); 24 | 25 | bool mpu6500WriteRegister(uint8_t reg, uint8_t data); 26 | bool mpu6500ReadRegister(uint8_t reg, uint8_t length, uint8_t *data); 27 | -------------------------------------------------------------------------------- /src/main/rx/sumh.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | 25 | #include "rx/rx.h" 26 | 27 | uint8_t sumhFrameStatus(void); 28 | bool sumhInit(rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig, rcReadRawDataPtr *callback); 29 | 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | -------------------------------------------------------------------------------- /src/main/rx/xbus.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #include "rx/rx.h" 25 | 26 | bool xBusInit(rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig, rcReadRawDataPtr *callback); 27 | uint8_t xBusFrameStatus(void); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | -------------------------------------------------------------------------------- /src/main/API/PlutoPilot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Magis. 3 | * 4 | * Magis is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Magis is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #ifndef _PlutoPilot_H_ 19 | #define _PlutoPilot_H_ 20 | 21 | #include 22 | #include "RxConfig.h" 23 | 24 | void plutoRxConfig ( void ); 25 | 26 | void plutoInit ( void ); 27 | 28 | void onLoopStart ( void ); 29 | 30 | void plutoLoop ( void ); 31 | 32 | void onLoopFinish ( void ); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/main/io/statusindicator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | void warningLedEnable(void); 25 | void warningLedDisable(void); 26 | void warningLedRefresh(void); 27 | void warningLedUpdate(void); 28 | void warningLedFlash(void); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /src/main/sensors/sonar.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | #include "sensors/battery.h" 24 | 25 | void sonarUpdate(void); 26 | 27 | int32_t sonarRead(void); 28 | int32_t sonarCalculateAltitude(int32_t sonarAlt, int16_t tiltAngle); 29 | int32_t sonarGetLatestAltitude(void); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | -------------------------------------------------------------------------------- /src/main/drivers/compass.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | typedef struct mag_s { 25 | sensorInitFuncPtr init; // initialize function 26 | sensorReadFuncPtr read; // read 3 axis data function 27 | } mag_t; 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | -------------------------------------------------------------------------------- /src/main/rx/msp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #include "rx/rx.h" 25 | 26 | void rxMspInit(rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig, rcReadRawDataPtr *callback); 27 | bool rxMspFrameComplete(void); 28 | void rxMspFrameReceive(uint16_t *frame, int channelCount); 29 | 30 | 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | -------------------------------------------------------------------------------- /src/main/drivers/accgyro_mpu3050.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | // Registers 21 | #define MPU3050_SMPLRT_DIV 0x15 22 | #define MPU3050_DLPF_FS_SYNC 0x16 23 | #define MPU3050_INT_CFG 0x17 24 | #define MPU3050_TEMP_OUT 0x1B 25 | #define MPU3050_GYRO_OUT 0x1D 26 | #define MPU3050_USER_CTRL 0x3D 27 | #define MPU3050_PWR_MGM 0x3E 28 | 29 | bool mpu3050Detect(gyro_t *gyro); 30 | -------------------------------------------------------------------------------- /src/main/io/gimbal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | typedef enum { 25 | GIMBAL_MODE_NORMAL = 0, 26 | GIMBAL_MODE_MIXTILT = 1 27 | } gimbalMode_e; 28 | 29 | #define GIMBAL_MODE_MAX (GIMBAL_MODE_MIXTILT) 30 | 31 | typedef struct gimbalConfig_s { 32 | uint8_t mode; 33 | } gimbalConfig_t; 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | -------------------------------------------------------------------------------- /src/main/io/serial_cli.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #ifndef CLI_H_ 19 | #define CLI_H_ 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | extern uint8_t cliMode; 26 | 27 | void cliInit(serialConfig_t *serialConfig); 28 | void cliProcess(void); 29 | bool cliIsActiveOnPort(serialPort_t *serialPort); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif /* CLI_H_ */ 36 | -------------------------------------------------------------------------------- /src/main/API/Comman.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Magis. 3 | * 4 | * Magis is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Magis is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | /* 19 | #pragma once 20 | 21 | ### For use in Cygnus Project Structure 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | typedef enum { 28 | X = 0, 29 | Y, 30 | Z 31 | }axis_e; 32 | 33 | typedef enum { 34 | AG_ROLL = 0, 35 | AG_PITCH, 36 | AG_YAW, 37 | }angle_e; 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | */ 43 | -------------------------------------------------------------------------------- /src/main/sensors/initialisation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | //changes made by DD 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | bool sensorsAutodetectmpu(sensorAlignmentConfig_t *sensorAlignmentConfig, uint16_t gyroLpf, uint8_t accHardwareToUse, uint8_t magHardwareToUse); 25 | bool sensorsAutodetectbaro(uint8_t baroHardwareToUse); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | -------------------------------------------------------------------------------- /src/main/drivers/sensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | typedef void (*sensorInitFuncPtr)(void); // sensor init prototype 25 | typedef bool (*sensorReadFuncPtr)(int16_t *data); // sensor read and align prototype 26 | typedef void (*sensorGyroInitFuncPtr)(uint16_t lpf); // gyro sensor init prototype 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | -------------------------------------------------------------------------------- /src/main/drivers/inverter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #ifdef INVERTER 25 | #define INVERTER_OFF digitalLo(INVERTER_GPIO, INVERTER_PIN) 26 | #define INVERTER_ON digitalHi(INVERTER_GPIO, INVERTER_PIN) 27 | #else 28 | #define INVERTER_OFF do {} while(0) 29 | #define INVERTER_ON do {} while(0) 30 | #endif 31 | 32 | void initInverter(void); 33 | 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /src/main/rx/spektrum.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #include "rx/rx.h" 25 | 26 | #define SPEKTRUM_SAT_BIND_DISABLED 0 27 | #define SPEKTRUM_SAT_BIND_MAX 10 28 | 29 | uint8_t spektrumFrameStatus(void); 30 | void spektrumBind(rxConfig_t *rxConfig); 31 | bool spektrumInit(rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig, rcReadRawDataPtr *callback); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | -------------------------------------------------------------------------------- /src/main/version.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #include "version.h" 19 | 20 | const char *const FwName = __FORKNAME__; 21 | const char *const targetName = __TARGET__; 22 | const char *const shortGitRevision = "0.0.0"; 23 | const char *const buildDate = __BUILD_DATE__; 24 | const char *const buildTime = __BUILD_TIME__; 25 | const char *const FwVersion = __FW_VER__; 26 | const char *const ApiVersion = __API_VER__; 27 | -------------------------------------------------------------------------------- /src/main/telemetry/msp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | /* 19 | * telemetry_MSP.h 20 | * 21 | * Created on: 22 Apr 2014 22 | * Author: trey marc 23 | */ 24 | 25 | #ifndef TELEMETRY_MSP_H_ 26 | #define TELEMETRY_MSP_H_ 27 | 28 | void initMSPTelemetry(telemetryConfig_t *initialTelemetryConfig); 29 | void handleMSPTelemetry(void); 30 | void checkMSPTelemetryState(void); 31 | 32 | void freeMSPTelemetryPort(void); 33 | void configureMSPTelemetryPort(void); 34 | 35 | #endif /* TELEMETRY_MSP_H_ */ 36 | -------------------------------------------------------------------------------- /src/main/blackbox/blackbox.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #include "blackbox/blackbox_fielddefs.h" 25 | 26 | void blackboxLogEvent(FlightLogEvent event, flightLogEventData_t *data); 27 | 28 | void setUserBlackBoxField(char* varName, int32_t& reference); 29 | 30 | void initBlackbox(void); 31 | void handleBlackbox(void); 32 | void startBlackbox(void); 33 | void finishBlackbox(void); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | -------------------------------------------------------------------------------- /src/main/drivers/accgyro_mpu6500.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #define MPU6500_WHO_AM_I_CONST (0x70) 25 | 26 | #define MPU6500_BIT_RESET (0x80) 27 | 28 | 29 | 30 | bool mpu6500AccDetect(acc_t *acc); 31 | bool mpu6500GyroDetect(gyro_t *gyro); 32 | 33 | void mpu6500AccInit(void); 34 | void mpu6500GyroInit(uint16_t lpf); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # All Vagrant configuration is done below. The "2" in Vagrant.configure 5 | # configures the configuration version (we support older styles for 6 | # backwards compatibility). Please don't change it unless you know what 7 | # you're doing. 8 | Vagrant.configure(2) do |config| 9 | # The most common configuration options are documented and commented below. 10 | # For a complete reference, please see the online documentation at 11 | # https://docs.vagrantup.com. 12 | 13 | # Every Vagrant development environment requires a box. You can search for 14 | # boxes at https://atlas.hashicorp.com/search. 15 | config.vm.box = "ubuntu/trusty64" 16 | 17 | # Enable provisioning with a shell script. Additional provisioners such as 18 | # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the 19 | # documentation for more information about their specific syntax and use. 20 | config.vm.provision "shell", inline: <<-SHELL 21 | apt-get remove -y binutils-arm-none-eabi gcc-arm-none-eabi 22 | add-apt-repository ppa:terry.guo/gcc-arm-embedded 23 | apt-get update 24 | apt-get install -y git gcc-arm-none-eabi=4.9.3.2015q3-1trusty1 25 | SHELL 26 | end 27 | -------------------------------------------------------------------------------- /src/main/sensors/boardalignment.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | typedef struct boardAlignment_s { 25 | int16_t rollDegrees; 26 | int16_t pitchDegrees; 27 | int16_t yawDegrees; 28 | } boardAlignment_t; 29 | 30 | void alignSensors(int16_t *src, int16_t *dest, uint8_t rotation); 31 | void initBoardAlignment(boardAlignment_t *boardAlignment); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | -------------------------------------------------------------------------------- /src/main/target/PRIMUSV4/hardware_revision.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | typedef enum cjmcuHardwareRevision_t { 23 | UNKNOWN = 0, 24 | REV_1, // Blue LED3 25 | REV_2 // Green LED3 26 | } cjmcuHardwareRevision_e; 27 | 28 | extern uint8_t hardwareRevision; 29 | #define HARDWARE_REVISION 1 30 | void updateHardwareRevision(void); 31 | void detectHardwareRevision(void); 32 | 33 | void spiBusInit(void); 34 | 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | -------------------------------------------------------------------------------- /src/main/target/PRIMUSV3R/hardware_revision.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | typedef enum cjmcuHardwareRevision_t { 23 | UNKNOWN = 0, 24 | REV_1, // Blue LED3 25 | REV_2 // Green LED3 26 | } cjmcuHardwareRevision_e; 27 | 28 | extern uint8_t hardwareRevision; 29 | #define HARDWARE_REVISION 1 30 | void updateHardwareRevision(void); 31 | void detectHardwareRevision(void); 32 | 33 | void spiBusInit(void); 34 | 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | -------------------------------------------------------------------------------- /src/main/build_config.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #include "stdbool.h" 19 | #include "stdint.h" 20 | 21 | #include "platform.h" 22 | 23 | #include "drivers/gpio.h" 24 | #include "drivers/timer.h" 25 | #include "drivers/pwm_mapping.h" 26 | #include "flight/mixer.h" 27 | 28 | #include "build_config.h" 29 | 30 | #if MAX_PWM_MOTORS != MAX_SUPPORTED_MOTORS 31 | #error Motor configuration mismatch 32 | #endif 33 | 34 | #if MAX_PWM_SERVOS != MAX_SUPPORTED_SERVOS 35 | #error Servo configuration mismatch 36 | #endif 37 | -------------------------------------------------------------------------------- /src/main/drivers/accgyro_icm20948.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | #define ICM20948_GYRO_OUT 0x33 26 | #define ICM20948_ACCEL_OUT 0x2D 27 | 28 | 29 | bool icm20948AccDetect(acc_t *acc); 30 | bool icm20948GyroDetect(gyro_t *gyro); 31 | 32 | void icm20948AccInit(void); 33 | void icm20948GyroInit(uint16_t lpf); 34 | 35 | 36 | 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | -------------------------------------------------------------------------------- /src/main/drivers/serial_usb_vcp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #include "serial.h" 25 | 26 | typedef struct { 27 | serialPort_t port; 28 | 29 | } vcpPort_t; 30 | 31 | serialPort_t *usbVcpOpen(void); 32 | 33 | uint8_t usbVcpAvailable(serialPort_t *instance); 34 | 35 | uint8_t usbVcpRead(serialPort_t *instance); 36 | 37 | void usbVcpWrite(serialPort_t *instance, uint8_t ch); 38 | void usbPrintStr(const char *str); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | -------------------------------------------------------------------------------- /src/main/API/Specifiers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Magis. 3 | * 4 | * Magis is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Magis is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | typedef enum unibus { 25 | Pin1 = 1, 26 | Pin2, 27 | Pin3, 28 | Pin4, 29 | Pin5, 30 | Pin6, 31 | Pin7, 32 | Pin8, 33 | Pin9, 34 | Pin10, 35 | Pin11, 36 | Pin12, 37 | Pin13, 38 | Pin14, 39 | Pin15, 40 | Pin16, 41 | Pin17, 42 | Pin18, 43 | Pin19, 44 | Pin20 45 | } unibus_e; 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | -------------------------------------------------------------------------------- /src/main/drivers/sonar_hcsr04.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | typedef struct sonarHardware_s { 25 | uint16_t trigger_pin; 26 | uint16_t echo_pin; 27 | uint32_t exti_line; 28 | uint8_t exti_pin_source; 29 | IRQn_Type exti_irqn; 30 | } sonarHardware_t; 31 | 32 | #define SONAR_GPIO GPIOB 33 | 34 | void hcsr04_init(const sonarHardware_t *sonarHardware); 35 | 36 | void hcsr04_start_reading(void); 37 | int32_t hcsr04_get_distance(void); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif -------------------------------------------------------------------------------- /docs/Introduction.md: -------------------------------------------------------------------------------- 1 | # Cleanflight 2 | 3 | ![Cleanflight](assets/cleanflight/cleanflight-logo-light-wide-1-240px.jpg) 4 | 5 | Welcome to CleanFlight! 6 | 7 | Cleanflight is an community project which attempts to deliver flight controller firmware and related tools. 8 | 9 | ## Primary Goals 10 | 11 | * Community driven. 12 | * Friendly project atmosphere. 13 | * Focus on the needs of users. 14 | * Great flight performance. 15 | * Understandable and maintainable code. 16 | 17 | ## Hardware 18 | 19 | See the flight controller hardware chapter for details. 20 | 21 | ## Software 22 | 23 | There are two primary components, the firmware and the configuration tool. The firmware is the code that runs on the flight controller board. The GUI configuration tool (configurator) is used to configure the flight controller, it runs on Windows, OSX and Linux. 24 | 25 | ## Feedback & Contributing 26 | 27 | We welcome all feedback. If you love it we want to hear from you, if you have problems please tell us how we could improve things so we can make it better for everyone. 28 | 29 | If you want to contribute please see the notes here: 30 | 31 | https://github.com/cleanflight/cleanflight#contributing 32 | 33 | Developers should read this: 34 | 35 | https://github.com/cleanflight/cleanflight/blob/master/CONTRIBUTING.md 36 | -------------------------------------------------------------------------------- /src/main/drivers/flash.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | typedef struct flashGeometry_s { 27 | uint16_t sectors; // Count of the number of erasable blocks on the device 28 | 29 | uint16_t pagesPerSector; 30 | const uint16_t pageSize; // In bytes 31 | 32 | uint32_t sectorSize; // This is just pagesPerSector * pageSize 33 | 34 | uint32_t totalSize; // This is just sectorSize * sectors 35 | } flashGeometry_t; 36 | 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif -------------------------------------------------------------------------------- /src/main/telemetry/frsky.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #include "rx/rx.h" 19 | 20 | #ifndef TELEMETRY_FRSKY_H_ 21 | #define TELEMETRY_FRSKY_H_ 22 | 23 | typedef enum { 24 | FRSKY_VFAS_PRECISION_LOW = 0, 25 | FRSKY_VFAS_PRECISION_HIGH 26 | } frskyVFasPrecision_e; 27 | 28 | void handleFrSkyTelemetry(rxConfig_t *rxConfig, uint16_t deadband3d_throttle); 29 | void checkFrSkyTelemetryState(void); 30 | 31 | void initFrSkyTelemetry(telemetryConfig_t *telemetryConfig); 32 | void configureFrSkyTelemetryPort(void); 33 | void freeFrSkyTelemetryPort(void); 34 | 35 | #endif /* TELEMETRY_FRSKY_H_ */ 36 | -------------------------------------------------------------------------------- /src/main/drivers/exti.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | typedef struct extiConfig_s { 25 | #ifdef STM32F303 26 | uint32_t gpioAHBPeripherals; 27 | #endif 28 | #ifdef STM32F10X 29 | uint32_t gpioAPB2Peripherals; 30 | #endif 31 | uint16_t gpioPin; 32 | GPIO_TypeDef *gpioPort; 33 | 34 | uint8_t exti_port_source; 35 | uint32_t exti_line; 36 | uint8_t exti_pin_source; 37 | IRQn_Type exti_irqn; 38 | } extiConfig_t; 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | -------------------------------------------------------------------------------- /src/main/io/serial_1wire.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | * Ported from https://github.com/4712/BLHeliSuite/blob/master/Interfaces/Arduino1Wire/Source/Arduino1Wire_C/Arduino1Wire.c 17 | * by Nathan Tsoi 18 | */ 19 | 20 | #pragma once 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | #ifdef USE_SERIAL_1WIRE 26 | 27 | typedef struct { 28 | GPIO_TypeDef* gpio; 29 | uint32_t pinpos; 30 | }escHardware_t; 31 | 32 | void usb1WireInitialize(); 33 | void usb1WirePassthrough(uint8_t escIndex); 34 | #endif 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | -------------------------------------------------------------------------------- /src/main/API/XRanging.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Magis. 3 | * 4 | * Magis is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Magis is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | 21 | #include 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | typedef enum laser_sensors { 28 | LEFT = 0, 29 | RIGHT, 30 | FRONT, 31 | BACK, 32 | EXTERNAL 33 | } laser_e; 34 | 35 | class XRanging_P { 36 | 37 | public: 38 | 39 | void init(void); 40 | void init(laser_e laser); 41 | int16_t getRange(laser_e laser); // returns range in mm 42 | 43 | }; 44 | 45 | extern XRanging_P XRanging; 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | -------------------------------------------------------------------------------- /src/main/drivers/serial_uart_impl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | // device specific uart implementation is defined here 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | extern const struct serialPortVTable uartVTable[]; 27 | 28 | void uartStartTxDMA(uartPort_t *s); 29 | 30 | uartPort_t *serialUSART1(uint32_t baudRate, portMode_t mode, portOptions_t options); 31 | uartPort_t *serialUSART2(uint32_t baudRate, portMode_t mode, portOptions_t options); 32 | uartPort_t *serialUSART3(uint32_t baudRate, portMode_t mode, portOptions_t options); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | -------------------------------------------------------------------------------- /src/main/common/typeconversion.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | #pragma once 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | void uli2a(unsigned long int num, unsigned int base, int uc, char *bf); 24 | void li2a(long num, char *bf); 25 | void ui2a(unsigned int num, unsigned int base, int uc, char *bf); 26 | void i2a(int num, char *bf); 27 | char a2i(char ch, const char **src, int base, int *nump); 28 | char *ftoa(float x, char *floatString); 29 | float fastA2F(const char *p); 30 | 31 | #ifndef HAVE_ITOA_FUNCTION 32 | char *itoa(int i, char *a, int r); 33 | #endif 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | -------------------------------------------------------------------------------- /src/main/drivers/compass_hmc5883l.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | typedef struct hmc5883Config_s { 21 | #ifdef STM32F303 22 | uint32_t gpioAHBPeripherals; 23 | #endif 24 | #ifdef STM32F10X 25 | uint32_t gpioAPB2Peripherals; 26 | #endif 27 | uint16_t gpioPin; 28 | GPIO_TypeDef *gpioPort; 29 | 30 | uint8_t exti_port_source; 31 | uint32_t exti_line; 32 | uint8_t exti_pin_source; 33 | IRQn_Type exti_irqn; 34 | } hmc5883Config_t; 35 | 36 | bool hmc5883lDetect(mag_t* mag, const hmc5883Config_t *hmc5883ConfigToUse); 37 | void hmc5883lInit(void); 38 | bool hmc5883lRead(int16_t *magData); 39 | -------------------------------------------------------------------------------- /src/main/drivers/inverter.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include "platform.h" 22 | 23 | #ifdef INVERTER 24 | 25 | #include "gpio.h" 26 | 27 | #include "inverter.h" 28 | 29 | void initInverter(void) 30 | { 31 | struct { 32 | GPIO_TypeDef *gpio; 33 | gpio_config_t cfg; 34 | } gpio_setup = { 35 | .gpio = INVERTER_GPIO, 36 | // configure for Push-Pull 37 | .cfg = { INVERTER_PIN, Mode_Out_PP, Speed_2MHz } 38 | }; 39 | 40 | RCC_APB2PeriphClockCmd(INVERTER_PERIPHERAL, ENABLE); 41 | 42 | gpioInit(gpio_setup.gpio, &gpio_setup.cfg); 43 | } 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/main/drivers/barometer_bmp085.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | typedef struct bmp085Config_s { 21 | uint32_t gpioAPB2Peripherals; 22 | uint16_t xclrGpioPin; 23 | GPIO_TypeDef *xclrGpioPort; 24 | uint16_t eocGpioPin; 25 | GPIO_TypeDef *eocGpioPort; 26 | } bmp085Config_t; 27 | 28 | bool bmp085Detect(const bmp085Config_t *config, baro_t *baro); 29 | void bmp085Disable(const bmp085Config_t *config); 30 | 31 | #if defined(BARO_EOC_GPIO) 32 | bool bmp085TestEOCConnected(const bmp085Config_t *config); 33 | #endif 34 | 35 | #ifdef UNIT_TEST 36 | void RCC_APB2PeriphClockCmd(uint32_t RCC_APB2Periph, FunctionalState NewState); 37 | #endif 38 | -------------------------------------------------------------------------------- /src/main/drivers/light_led.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #include "light_led.h" 19 | 20 | initLeds(void) 21 | { 22 | struct { 23 | GPIO_TypeDef *gpio; 24 | gpio_config_t cfg; 25 | } gpio_setup[] = { 26 | #ifdef LED_M 27 | { 28 | .gpio = LED0_GPIO, 29 | .cfg = {LED0_PIN, Mode_Out_PP, Speed_2MHz} 30 | }, 31 | #endif 32 | #ifdef LED_R 33 | 34 | { 35 | .gpio = LED1_GPIO, 36 | .cfg = {LED1_PIN, Mode_Out_PP, Speed_2MHz} 37 | }, 38 | #endif 39 | } 40 | 41 | uint8_t gpio_count = sizeof(gpio_setup) / sizeof(gpio_setup[0]); 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/test/unit/platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #define MAG 21 | #define BARO 22 | #define GPS 23 | #define DISPLAY 24 | #define TELEMETRY 25 | #define LED_STRIP 26 | #define USE_SERVOS 27 | 28 | #define SERIAL_PORT_COUNT 4 29 | 30 | #define MAX_SIMULTANEOUS_ADJUSTMENT_COUNT 6 31 | 32 | typedef enum 33 | { 34 | Mode_TEST = 0x0, 35 | Mode_Out_PP = 0x10, 36 | } GPIO_Mode; 37 | 38 | typedef struct 39 | { 40 | void* test; 41 | } GPIO_TypeDef; 42 | 43 | typedef struct 44 | { 45 | void* test; 46 | } TIM_TypeDef; 47 | 48 | typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState; 49 | 50 | typedef enum {TEST_IRQ = 0 } IRQn_Type; 51 | -------------------------------------------------------------------------------- /src/main/build_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | #define UNUSED(x) (void)(x) 24 | #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) 25 | 26 | #ifdef UNIT_TEST 27 | #define STATIC_UNIT_TESTED // make visible to unit test 28 | #define UNIT_TESTED 29 | #else 30 | #define STATIC_UNIT_TESTED static 31 | #define UNIT_TESTED 32 | #endif 33 | 34 | //#define SOFT_I2C // enable to test software i2c 35 | 36 | #ifndef __CC_ARM 37 | #define REQUIRE_CC_ARM_PRINTF_SUPPORT 38 | #define REQUIRE_PRINTF_LONG_SUPPORT 39 | #endif 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | -------------------------------------------------------------------------------- /src/main/drivers/bus_spi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #define SPI_0_5625MHZ_CLOCK_DIVIDER 128 25 | #define SPI_18MHZ_CLOCK_DIVIDER 2 26 | #define SPI_9MHZ_CLOCK_DIVIDER 4 27 | 28 | bool spiInit(SPI_TypeDef *instance); 29 | void spiSetDivisor(SPI_TypeDef *instance, uint16_t divisor); 30 | uint8_t spiTransferByte(SPI_TypeDef *instance, uint8_t in); 31 | 32 | bool spiTransfer(SPI_TypeDef *instance, uint8_t *out, const uint8_t *in, int len); 33 | 34 | uint16_t spiGetErrorCounter(SPI_TypeDef *instance); 35 | void spiResetErrorCounter(SPI_TypeDef *instance); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /src/main/drivers/sound_beeper_stm32f30x.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "platform.h" 23 | 24 | #include "build_config.h" 25 | 26 | #include "gpio.h" 27 | 28 | #include "sound_beeper.h" 29 | 30 | void initBeeperHardware(beeperConfig_t *config) 31 | { 32 | #ifndef BEEPER 33 | UNUSED(config); 34 | #else 35 | gpio_config_t gpioConfig = { 36 | config->gpioPin, 37 | config->gpioMode, 38 | Speed_2MHz 39 | }; 40 | 41 | RCC_AHBPeriphClockCmd(config->gpioPeripheral, ENABLE); 42 | 43 | gpioInit(config->gpioPort, &gpioConfig); 44 | #endif 45 | } 46 | -------------------------------------------------------------------------------- /src/main/drivers/sound_beeper_stm32f10x.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "platform.h" 23 | 24 | #include "build_config.h" 25 | 26 | #include "system.h" 27 | #include "gpio.h" 28 | 29 | #include "sound_beeper.h" 30 | 31 | void initBeeperHardware(beeperConfig_t *config) 32 | { 33 | #ifndef BEEPER 34 | UNUSED(config); 35 | #else 36 | gpio_config_t gpioConfig = { 37 | config->gpioPin, 38 | config->gpioMode, 39 | Speed_2MHz 40 | }; 41 | 42 | RCC_APB2PeriphClockCmd(config->gpioPeripheral, ENABLE); 43 | 44 | gpioInit(config->gpioPort, &gpioConfig); 45 | #endif 46 | } 47 | -------------------------------------------------------------------------------- /src/main/flight/opticflow.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Magis. 3 | * 4 | * Magis is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Magis is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | 27 | extern float debugOpticFlowVar; 28 | extern float debugOpticFlowVar1; 29 | extern float debugOpticFlowVar2; 30 | extern float debugOpticFlowVar3; 31 | extern float debugOpticFlowVar4; 32 | extern float debugOpticFlow[2]; 33 | extern float debugOpticFlow1[2]; 34 | extern float debugOpticFlow2[3]; 35 | 36 | 37 | 38 | extern float sensor_flow_hf[2]; 39 | extern float accel_hf[3]; 40 | extern float accel_hf_prev[3]; 41 | extern float velocity_hf[3]; 42 | extern float opticflowHeight; 43 | void runFlowHold(uint32_t currentTime); 44 | 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/main/io/display.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | //#define ENABLE_DEBUG_OLED_PAGE 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | typedef enum { 24 | PAGE_WELCOME, 25 | PAGE_ARMED, 26 | PAGE_BATTERY, 27 | PAGE_SENSORS, 28 | PAGE_RX, 29 | PAGE_PROFILE, 30 | #ifdef GPS 31 | PAGE_GPS, 32 | #endif 33 | #ifdef ENABLE_DEBUG_OLED_PAGE 34 | PAGE_DEBUG, 35 | #endif 36 | } pageId_e; 37 | 38 | void updateDisplay(void); 39 | 40 | void displayShowFixedPage(pageId_e pageId); 41 | 42 | void displayEnablePageCycling(void); 43 | void displayDisablePageCycling(void); 44 | void displayResetPageCycling(void); 45 | void displaySetNextPageChangeAt(uint32_t futureMicros); 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | -------------------------------------------------------------------------------- /src/main/flight/acrobats.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Magis. 3 | * 4 | * Magis is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Magis is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #define ASCEND 1 25 | #define PITCHING 2 26 | #define SLOWDOWNANDEXIT 3 27 | #define HOLD 4 28 | #define PITCHINGPOS 5 29 | #define SLOWDOWNANDEXITPOS 6 30 | #define HOLDPOS 7 31 | 32 | typedef enum { 33 | 34 | FLIP_BACK=0, 35 | FLIP_FRONT, 36 | FLIP_RIGHT, 37 | FLIP_LEFT, 38 | FLIP_COUNT 39 | 40 | } flipDirection_e; 41 | 42 | 43 | extern uint8_t flipDirection; 44 | extern uint32_t flipState; 45 | extern uint32_t flipStartTime; 46 | 47 | extern bool isPitchStabelised; 48 | extern bool isRollStabelised; 49 | 50 | void flip(bool doFlip); 51 | void robustChuck(); 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | -------------------------------------------------------------------------------- /src/main/command/localisationCommand.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Magis. 3 | * 4 | * Magis is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Magis is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | #define TOTAL_CMDS 25 23 | 24 | typedef enum { 25 | C_TAKE_OFF, 26 | C_LAND, 27 | C_SLEEP, 28 | C_ARM_MOTORS, 29 | C_GO_TO_WAY_POINT, 30 | C_DISARM_MOTORS, 31 | C_LOOP_FROM_START 32 | } cmd_type; 33 | 34 | typedef struct command { 35 | cmd_type id; 36 | int16_t pos_x; 37 | int16_t pos_y; 38 | int16_t height; 39 | } cmd_def; 40 | 41 | void command_add(cmd_def command); 42 | 43 | bool command_verify(void); 44 | 45 | void command_next(void); 46 | 47 | void command_previous(void); 48 | 49 | void command_run(uint32_t current_time); 50 | 51 | void command_jump(int16_t jump); 52 | 53 | extern int32_t debugLCvar; 54 | -------------------------------------------------------------------------------- /src/main/mw.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | extern int8_t returnValue; 23 | 24 | extern int16_t magHold; 25 | extern int16_t headFreeModeHold; 26 | 27 | extern uint32_t total_time; 28 | extern uint32_t previous_time; 29 | extern uint32_t current_time; 30 | extern uint32_t mode_checker; 31 | 32 | extern bool isCalibrated; 33 | extern bool tookOff; 34 | 35 | extern uint32_t arm_time; 36 | 37 | 38 | void applyAndSaveAccelerometerTrimsDelta(rollAndPitchTrims_t *rollAndPitchTrimsDelta); 39 | void handleInflightCalibrationStickPosition(); 40 | 41 | void mwDisarm(void); 42 | void mwArm(void); 43 | 44 | void loop(void); 45 | 46 | 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | -------------------------------------------------------------------------------- /src/main/common/axis.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | typedef enum { 25 | X = 0, 26 | Y, 27 | Z 28 | } axis_e; 29 | 30 | #define XYZ_AXIS_COUNT 3 31 | 32 | // See http://en.wikipedia.org/wiki/Flight_dynamics 33 | typedef enum { 34 | FD_ROLL = 0, 35 | FD_PITCH, 36 | FD_YAW 37 | } flight_dynamics_index_t; 38 | 39 | #define FLIGHT_DYNAMICS_INDEX_COUNT 3 40 | 41 | typedef enum { 42 | AI_ROLL = 0, 43 | AI_PITCH, 44 | AI_YAW 45 | } angle_index_t; 46 | 47 | #define ANGLE_INDEX_COUNT 3 48 | 49 | // for use in API set 50 | typedef enum { 51 | AG_ROLL = 0, 52 | AG_PITCH, 53 | AG_YAW, 54 | } angle_e; 55 | 56 | 57 | 58 | 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | -------------------------------------------------------------------------------- /src/main/API/PlutoPilot.cpp: -------------------------------------------------------------------------------- 1 | // Do not remove the include below 2 | #include "PlutoPilot.h" 3 | 4 | /** 5 | * Configures Pluto's receiver to use PPM or default ESP mode; activate the line matching your setup. 6 | * AUX channel configurations is only for PPM recievers if no custom configureMode function is called this are the default setup 7 | * ARM mode : Rx_AUX2, range 1300 to 2100 8 | * ANGLE mode : Rx_AUX2, range 900 to 2100 9 | * BARO mode : Rx_AUX3, range 1300 to 2100 10 | * MAG mode : Rx_AUX1, range 900 to 1300 11 | * HEADFREE mode : Rx_AUX1, range 1300 to 1700 12 | * DEV mode : Rx_AUX4, range 1500 to 2100 13 | */ 14 | void plutoRxConfig ( void ) { 15 | // Receiver mode: Uncomment one line for ESP or PPM setup. 16 | Receiver.rxMode ( Rx_ESP ); // Onboard ESP 17 | // Receiver.rxMode(Rx_PPM); // PPM based 18 | } 19 | 20 | // The setup function is called once at Pluto's hardware startup 21 | void plutoInit ( void ) { 22 | // Add your hardware initialization code here 23 | } 24 | 25 | 26 | // The function is called once before plutoLoop when you activate Developer Mode 27 | void onLoopStart ( void ) { 28 | // do your one time stuffs here 29 | } 30 | 31 | 32 | // The loop function is called in an endless loop 33 | void plutoLoop ( void ) { 34 | // Add your repeated code here 35 | } 36 | 37 | 38 | // The function is called once after plutoLoop when you deactivate Developer Mode 39 | void onLoopFinish ( void ) { 40 | // do your cleanup stuffs here 41 | } 42 | -------------------------------------------------------------------------------- /support/stmloader/serial.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of AutoQuad. 3 | 4 | AutoQuad is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | AutoQuad is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | You should have received a copy of the GNU General Public License 14 | along with AutoQuad. If not, see . 15 | 16 | Copyright © 2011 Bill Nesbitt 17 | */ 18 | 19 | #ifndef _serial_h 20 | #define _serial_h 21 | 22 | #define INPUT_BUFFER_SIZE 1024 23 | 24 | typedef struct { 25 | int fd; 26 | } serialStruct_t; 27 | 28 | extern serialStruct_t *initSerial(const char *port, unsigned int baud, char ctsRts); 29 | extern void serialWrite(serialStruct_t *s, const char *str, unsigned int len); 30 | extern void serialWriteChar(serialStruct_t *s, unsigned char c); 31 | extern unsigned char serialAvailable(serialStruct_t *s); 32 | extern void serialFlush(serialStruct_t *s); 33 | extern unsigned char serialRead(serialStruct_t *s); 34 | extern void serialEvenParity(serialStruct_t *s); 35 | extern void serialNoParity(serialStruct_t *s); 36 | extern void serialFree(serialStruct_t *s); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Magis 2 | 3 | Magis is flight controller software (firmware) used to fly **Pluto V3R** and **PlutoX** nano drones of **Pluto Platform** 4 | (see https://www.dronaaviation.com/). 5 | 6 | This fork has been ported to C++ from cleanflight to support object oriented paradigm, which has been used to create different set of APIs for Pluto Platform which can be easily used by any **Developer, Tinkerer and Maker** to start their drone journey. 7 | 8 | ## Contributing 9 | 10 | Contributions are welcome and encouraged. You can contribute in many ways: 11 | 12 | * Documentation updates and corrections. 13 | * How-To guides - received help? Help others! 14 | * Bug reporting & fixes. 15 | * New feature ideas & suggestions. 16 | 17 | https://github.com/DronaAviation/Magis/issues 18 | 19 | Before creating new issues please check to see if there is an existing one, search first otherwise you waste peoples time when they could be coding instead! 20 | 21 | ## Developers 22 | 23 | Please refer to the development section in the `docs/development` folder. 24 | 25 | 26 | ## Open Source / Contributors 27 | 28 | Magis is software that is **open source** and is available free of charge without warranty to all users. 29 | 30 | Magis is forked from Cleanflight, so thanks goes to all those whom have contributed to Cleanflight and its origins. 31 | 32 | Origins for this fork (Thanks!): 33 | * **Alexinparis** (for MultiWii), 34 | * **timecop** (for Baseflight), 35 | * **Dominic Clifton** (for Cleanflight), and 36 | * **Sambas** (for the original STM32F4 port). 37 | -------------------------------------------------------------------------------- /docs/Sonar.md: -------------------------------------------------------------------------------- 1 | # Sonar 2 | 3 | A sonar sensor can be used to measure altitude for use with BARO and SONAR altitude 4 | hold modes. 5 | 6 | The sonar sensor is used instead of the pressure sensor (barometer) at low altitudes. 7 | The sonar sensor is only used when the aircraft inclination angle (attitude) is small. 8 | 9 | ## Hardware 10 | 11 | Currently the only supported sensor is the HCSR04 sensor. 12 | 13 | ## Connections 14 | 15 | ### Naze/Flip32+ 16 | 17 | | Mode | Trigger | Echo | Inline 1k resistors | 18 | | ------------------------------- | ------------- | ------------- | ------------------- | 19 | | Parallel PWM/ADC current sensor | PB8 / Motor 5 | PB9 / Motor 6 | NO (5v tolerant) | 20 | | PPM/Serial RX | PB0 / RC7 | PB1 / RC8 | YES (3.3v input) | 21 | 22 | #### Constraints 23 | 24 | Current meter cannot be used in conjunction with Parallel PWM and Sonar. 25 | 26 | ### Olimexino 27 | 28 | | Trigger | Echo | Inline 1k resistors | 29 | | ------------- | ------------- | ------------------- | 30 | | PB0 / RC7 | PB1 / RC8 | YES (3.3v input) | 31 | 32 | #### Constraints 33 | 34 | Current meter cannot be used in conjunction with Sonar. 35 | 36 | ### CC3D 37 | 38 | | Trigger | Echo | Inline 1k resistors | 39 | | ------------- | ------------- | ------------------- | 40 | | PB5 | PB0 | YES (3.3v input) | 41 | 42 | #### Constraints 43 | 44 | Sonar cannot be used in conjuction with SoftSerial or Parallel PWM. 45 | -------------------------------------------------------------------------------- /src/main/io/serial_msp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #include "io/serial.h" 25 | #include "drivers/serial.h" 26 | 27 | // Each MSP port requires state and a receive buffer, revisit this default if someone needs more than 2 MSP ports. 28 | #define MAX_MSP_PORT_COUNT 2 29 | 30 | void mspInit(serialConfig_t *serialConfig); 31 | 32 | void mspProcess(void); 33 | void sendMspTelemetry(void); 34 | void mspSetTelemetryPort(serialPort_t *mspTelemetryPort); 35 | void mspAllocateSerialPorts(serialConfig_t *serialConfig); 36 | void mspReleasePortIfAllocated(serialPort_t *serialPort); 37 | 38 | void serialize8Debug(uint8_t a); 39 | bool mspSerialRxBytesWaiting(void); 40 | uint8_t mspSerialRead(void); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | -------------------------------------------------------------------------------- /src/main/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | #define DEBUG16_VALUE_COUNT 4 23 | extern int16_t debug[DEBUG16_VALUE_COUNT]; 24 | 25 | #define DEBUG_SECTION_TIMES 26 | 27 | #ifdef DEBUG_SECTION_TIMES 28 | extern uint32_t sectionTimes[2][4]; 29 | 30 | #define TIME_SECTION_BEGIN(index) { \ 31 | extern uint32_t sectionTimes[2][4]; \ 32 | sectionTimes[0][index] = micros(); \ 33 | } 34 | 35 | #define TIME_SECTION_END(index) { \ 36 | extern uint32_t sectionTimes[2][4]; \ 37 | sectionTimes[1][index] = micros(); \ 38 | debug[index] = sectionTimes[1][index] - sectionTimes[0][index]; \ 39 | } 40 | #else 41 | 42 | #define TIME_SECTION_BEGIN(index) {} 43 | #define TIME_SECTION_END(index) {} 44 | 45 | #endif 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | -------------------------------------------------------------------------------- /src/main/drivers/flash_m25p16.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | #include "flash.h" 26 | 27 | #define M25P16_PAGESIZE 256 28 | 29 | bool m25p16_init(); 30 | 31 | void m25p16_eraseSector(uint32_t address); 32 | void m25p16_eraseCompletely(); 33 | 34 | void m25p16_pageProgram(uint32_t address, const uint8_t *data, int length); 35 | 36 | void m25p16_pageProgramBegin(uint32_t address); 37 | void m25p16_pageProgramContinue(const uint8_t *data, int length); 38 | void m25p16_pageProgramFinish(); 39 | 40 | int m25p16_readBytes(uint32_t address, uint8_t *buffer, int length); 41 | 42 | bool m25p16_isReady(); 43 | bool m25p16_waitForReady(uint32_t timeoutMillis); 44 | 45 | const flashGeometry_t* m25p16_getGeometry(); 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | -------------------------------------------------------------------------------- /src/main/drivers/serial_softserial.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #define SOFTSERIAL_BUFFER_SIZE 256 25 | 26 | typedef enum { 27 | SOFTSERIAL1 = 0, 28 | SOFTSERIAL2 29 | } softSerialPortIndex_e; 30 | 31 | serialPort_t *openSoftSerial(softSerialPortIndex_e portIndex, serialReceiveCallbackPtr callback, uint32_t baud, portOptions_t options); 32 | 33 | // serialPort API 34 | void softSerialWriteByte(serialPort_t *instance, uint8_t ch); 35 | uint8_t softSerialRxBytesWaiting(serialPort_t *instance); 36 | uint8_t softSerialTxBytesFree(serialPort_t *instance); 37 | uint8_t softSerialReadByte(serialPort_t *instance); 38 | void softSerialSetBaudRate(serialPort_t *s, uint32_t baudRate); 39 | bool isSoftSerialTransmitBufferEmpty(serialPort_t *s); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | -------------------------------------------------------------------------------- /src/main/target/PRIMUSV3R/hardware_revision.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "platform.h" 23 | 24 | #include "build_config.h" 25 | 26 | #include "drivers/system.h" 27 | #include "drivers/bus_spi.h" 28 | #include "drivers/sensor.h" 29 | #include "drivers/accgyro.h" 30 | #include "drivers/accgyro_spi_mpu6500.h" 31 | 32 | #include "hardware_revision.h" 33 | 34 | static const char * const hardwareRevisionNames[] = { 35 | "Unknown", 36 | "R1", 37 | "R2" 38 | }; 39 | 40 | uint8_t hardwareRevision = UNKNOWN; 41 | 42 | void detectHardwareRevision(void) 43 | { 44 | if (GPIOC->IDR & GPIO_Pin_15) { 45 | hardwareRevision = REV_2; 46 | } else { 47 | hardwareRevision = REV_1; 48 | } 49 | } 50 | 51 | void updateHardwareRevision(void) 52 | { 53 | } 54 | -------------------------------------------------------------------------------- /src/main/target/PRIMUSV4/hardware_revision.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "platform.h" 23 | 24 | #include "build_config.h" 25 | 26 | #include "drivers/system.h" 27 | #include "drivers/bus_spi.h" 28 | #include "drivers/sensor.h" 29 | #include "drivers/accgyro.h" 30 | #include "drivers/accgyro_spi_mpu6500.h" 31 | 32 | #include "hardware_revision.h" 33 | 34 | static const char * const hardwareRevisionNames[] = { 35 | "Unknown", 36 | "R1", 37 | "R2" 38 | }; 39 | 40 | uint8_t hardwareRevision = UNKNOWN; 41 | 42 | void detectHardwareRevision(void) 43 | { 44 | if (GPIOC->IDR & GPIO_Pin_15) { 45 | hardwareRevision = REV_2; 46 | } else { 47 | hardwareRevision = REV_1; 48 | } 49 | } 50 | 51 | void updateHardwareRevision(void) 52 | { 53 | } 54 | -------------------------------------------------------------------------------- /src/main/drivers/sound_beeper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | 25 | #ifdef BEEPER 26 | #define BEEP_TOGGLE digitalToggle(BEEP_GPIO, BEEP_PIN) 27 | #define BEEP_OFF systemBeep(false) 28 | #define BEEP_ON systemBeep(true) 29 | #else 30 | #define BEEP_TOGGLE 31 | #define BEEP_OFF 32 | #define BEEP_ON 33 | #endif 34 | 35 | typedef struct beeperConfig_s { 36 | uint32_t gpioPeripheral; 37 | uint16_t gpioPin; 38 | GPIO_TypeDef *gpioPort; 39 | GPIO_Mode gpioMode; 40 | bool isInverted; 41 | } beeperConfig_t; 42 | 43 | void systemBeep(bool onoff); 44 | void beeperInit(beeperConfig_t *beeperConfig); 45 | 46 | void initBeeperHardware(beeperConfig_t *config); 47 | 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | -------------------------------------------------------------------------------- /src/main/io/rc_curves.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #define PITCH_LOOKUP_LENGTH 7 25 | #define YAW_LOOKUP_LENGTH 7 26 | #define THROTTLE_LOOKUP_LENGTH 12 27 | extern int16_t lookupPitchRollRC[PITCH_LOOKUP_LENGTH]; // lookup table for expo & RC rate PITCH+ROLL 28 | extern int16_t lookupYawRC[YAW_LOOKUP_LENGTH]; // lookup table for expo & RC rate YAW 29 | extern int16_t lookupThrottleRC[THROTTLE_LOOKUP_LENGTH]; // lookup table for expo & mid THROTTLE 30 | 31 | void generatePitchRollCurve(controlRateConfig_t *controlRateConfig); 32 | void generateYawCurve(controlRateConfig_t *controlRateConfig); 33 | void generateThrottleCurve(controlRateConfig_t *controlRateConfig, escAndServoConfig_t *escAndServoConfig); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /src/main/platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #ifdef STM32F303xC 25 | #include "stm32f30x_conf.h" 26 | #include "stm32f30x_rcc.h" 27 | #include "stm32f30x_gpio.h" 28 | #include "core_cm4.h" 29 | 30 | // Chip Unique ID on F303 31 | #define U_ID_0 (*(uint32_t*)0x1FFFF7AC) 32 | #define U_ID_1 (*(uint32_t*)0x1FFFF7B0) 33 | #define U_ID_2 (*(uint32_t*)0x1FFFF7B4) 34 | 35 | #endif 36 | 37 | #ifdef STM32F10X 38 | 39 | #include "stm32f10x_conf.h" 40 | #include "stm32f10x_gpio.h" 41 | #include "core_cm3.h" 42 | 43 | // Chip Unique ID on F103 44 | #define U_ID_0 (*(uint32_t*)0x1FFFF7E8) 45 | #define U_ID_1 (*(uint32_t*)0x1FFFF7EC) 46 | #define U_ID_2 (*(uint32_t*)0x1FFFF7F0) 47 | 48 | #endif // STM32F10X 49 | 50 | #include "target.h" 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | -------------------------------------------------------------------------------- /src/main/drivers/pwm_rx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | typedef enum { 25 | INPUT_FILTERING_DISABLED = 0, 26 | INPUT_FILTERING_ENABLED 27 | } inputFilteringMode_e; 28 | 29 | #define PPM_RCVR_TIMEOUT 0 30 | 31 | void ppmInConfig(const timerHardware_t *timerHardwarePtr); 32 | void ppmAvoidPWMTimerClash(const timerHardware_t *timerHardwarePtr, TIM_TypeDef *sharedPwmTimer); 33 | 34 | void pwmInConfig(const timerHardware_t *timerHardwarePtr, uint8_t channel); 35 | uint16_t pwmRead(uint8_t channel); 36 | uint16_t ppmRead(uint8_t channel); 37 | 38 | bool isPPMDataBeingReceived(void); 39 | void resetPPMDataReceivedState(void); 40 | 41 | void pwmRxInit(inputFilteringMode_e initialInputFilteringMode); 42 | 43 | bool isPWMDataBeingReceived(void); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | -------------------------------------------------------------------------------- /src/main/io/escservo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | typedef struct escAndServoConfig_s { 25 | 26 | // PWM values, in milliseconds, common range is 1000-2000 (1 to 2ms) 27 | uint16_t minthrottle; // Set the minimum throttle command sent to the ESC (Electronic Speed Controller). This is the minimum value that allow motors to run at a idle speed. 28 | uint16_t maxthrottle; // This is the maximum value for the ESCs at full power this value can be increased up to 2000 29 | uint16_t mincommand; // This is the value for the ESCs when they are not armed. In some cases, this value must be lowered down to 900 for some specific ESCs 30 | uint16_t servoCenterPulse; // This is the value for servos when they should be in the middle. e.g. 1500. 31 | } escAndServoConfig_t; 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | -------------------------------------------------------------------------------- /src/main/drivers/bus_i2c.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | typedef enum I2CDevice { 25 | I2CDEV_1, 26 | I2CDEV_2, 27 | I2CDEV_MAX = I2CDEV_2, 28 | } I2CDevice; 29 | 30 | void i2cInit(I2CDevice index); 31 | bool i2cWriteBuffer(uint8_t addr_, uint8_t reg_, uint8_t len_, uint8_t *data); 32 | bool i2cWrite(uint8_t addr_, uint8_t reg, uint8_t data); 33 | uint8_t i2cRead(uint8_t addr_, uint8_t reg, uint8_t len, uint8_t* buf); 34 | 35 | bool i2cWriteBufferwithoutregister(uint8_t addr_,uint8_t len_, uint8_t *data); 36 | bool i2cWritewithoutregister(uint8_t addr_, uint8_t data); 37 | uint8_t i2cReadwithoutregister(uint8_t addr_, uint8_t len, uint8_t* buf); 38 | 39 | uint8_t i2cReadDevice(uint8_t addr_, uint8_t len, uint8_t* buf); 40 | 41 | uint16_t i2cGetErrorCounter(void); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | -------------------------------------------------------------------------------- /docs/Boards.md: -------------------------------------------------------------------------------- 1 | # Flight controller hardware 2 | 3 | The current focus is geared towards flight controller hardware that use the STM32F303 and legacy STM32F103 series processors. The core logic is separated from the hardware drivers, porting to other processors is possible. 4 | 5 | The core set of supported flyable boards are: 6 | 7 | * AlienWii32 8 | * CC3D 9 | * CJMCU 10 | * Flip32+ 11 | * Naze32 12 | * Sparky 13 | * SPRacingF3 14 | 15 | Cleanflight also runs on the following developer boards: 16 | 17 | * STM32F3Discovery 18 | * Port103R 19 | * EUSTM32F103RB 20 | 21 | There is also limited support for the following boards which may be removed due to lack of users or commercial availability. 22 | 23 | * Olimexino 24 | * Naze32Pro 25 | * STM32F3Discovery with Chebuzz F3 shield. 26 | 27 | NOTE: Users are advised against purhasing boards that have CPUs with less than 256KB of EEPROM space - available features may be limited. 28 | NOTE: Hardware developers should not design new boards that have CPUs with less than 256KB EEPROM space. 29 | 30 | Each board has it's pros and cons, before purchasing hardware the main thing to check is if the board offers enough serial ports and input/output pins for the hardware you want to use with it and that you can use them at the same time. On some boards some features are mutually exclusive. 31 | 32 | Please see the board-specific chapters in the manual for wiring details. 33 | 34 | There are off-shoots (forks) of the project that support the STM32F4 processors as found on the Revo and Quanton boards. 35 | 36 | Where applicable the chapters also provide links to other hardware that is known to work with Cleanflight, such as receivers, buzzers, etc. 37 | -------------------------------------------------------------------------------- /src/main/API/Estimate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Magis. 3 | * 4 | * Magis is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Magis is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | #include "common/axis.h" 22 | //#include "Comman.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | class Angle_P { 29 | public: 30 | 31 | //unit: decidegree for ROLL and PITCH 32 | //unit: degree for YAW 33 | 34 | int16_t get(angle_e ANGLE); 35 | 36 | }; 37 | 38 | class Rate_P { 39 | public: 40 | 41 | //unit: decidegree 42 | 43 | int16_t get(axis_e AXIS); 44 | 45 | }; 46 | 47 | class Position_P { 48 | public: 49 | 50 | //unit: cm 51 | 52 | int16_t get(axis_e AXIS); 53 | 54 | }; 55 | 56 | class Velocity_P { 57 | public: 58 | 59 | //unit: cm/s 60 | 61 | int16_t get(axis_e AXIS); 62 | 63 | }; 64 | 65 | extern Angle_P Angle; 66 | extern Rate_P Rate; 67 | extern Position_P Position; 68 | extern Velocity_P Velocity; 69 | 70 | #ifdef __cplusplus 71 | } 72 | #endif 73 | -------------------------------------------------------------------------------- /src/main/drivers/opticflow_paw3903.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | 27 | extern uint8_t surface_quality; // image quality (below TBD you can't trust the dx,dy values returned) 28 | extern float flowRate[2]; // optical flow angular rate in rad/sec measured about the X and Y body axis. A RH rotation about a sensor axis produces a positive rate. 29 | extern float bodyRate[2]; // body inertial angular rate in rad/sec measured about the X and Y body axis. A RH rotation about a sensor axis produces a positive rate. 30 | extern uint32_t last_opticflow_update_ms; 31 | 32 | extern float bodyRate1[2]; 33 | extern float bodyRate2[2]; 34 | 35 | 36 | 37 | void initOpticFlow(); 38 | void updateOpticFlow(); 39 | void updateSpiOpticFlow(); 40 | 41 | extern uint8_t opticFlowAddress; 42 | 43 | extern uint8_t debugOf; 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/main/drivers/adc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | typedef enum { 25 | ADC_BATTERY = 0, 26 | ADC_RSSI = 1, 27 | ADC_EXTERNAL1 = 2, 28 | ADC_CURRENT = 3, 29 | ADC_CHANNEL_MAX = ADC_CURRENT 30 | } AdcChannel; 31 | 32 | #define ADC_CHANNEL_COUNT (ADC_CHANNEL_MAX + 1) 33 | 34 | typedef struct adc_config_s { 35 | uint8_t adcChannel; // ADC1_INxx channel number 36 | uint8_t dmaIndex; // index into DMA buffer in case of sparse channels 37 | bool enabled; 38 | uint8_t sampleTime; 39 | } adc_config_t; 40 | 41 | typedef struct drv_adc_config_s { 42 | bool enableVBat; 43 | bool enableRSSI; 44 | bool enableCurrentMeter; 45 | bool enableExternal1; 46 | } drv_adc_config_t; 47 | 48 | void adcInit(drv_adc_config_t *init); 49 | uint16_t adcGetChannel(uint8_t channel); 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | -------------------------------------------------------------------------------- /docs/Rssi.md: -------------------------------------------------------------------------------- 1 | # RSSI 2 | 3 | RSSI is a measurement of signal strength and is very handy so you know when your aircraft isw going out of range or if it is suffering RF interference. 4 | 5 | Some receivers have RSSI outputs. 3 types are supported. 6 | 7 | 1. RSSI via PPM channel 8 | 1. RSSI via Parallel PWM channel 9 | 1. RSSI via ADC with PPM RC that has an RSSI output - aka RSSI ADC 10 | 11 | ## RSSI via PPM 12 | 13 | Configure your receiver to output RSSI on a spare channel, then select the channel used via the CLI. 14 | 15 | e.g. if you used channel 9 then you would set: 16 | 17 | ``` 18 | set rssi_channel = 9 19 | ``` 20 | Note: Some systems such as EZUHF invert the RSSI ( 0 = Full signal / 100 = Lost signal). To correct this problem you can invert the channel input so you will get a correct reading by using command: 21 | 22 | ``` 23 | set rssi_ppm_invert = 1 24 | ``` 25 | Default is set to "0" for normal operation ( 100 = Full signal / 0 = Lost signal). 26 | 27 | ## RSSI via Parallel PWM channel 28 | 29 | Connect the RSSI signal to any PWM input channel then set the RSSI channel as you would for RSSI via PPM 30 | 31 | ## RSSI ADC 32 | 33 | Connect the RSSI signal to the RC2/CH2 input. The signal must be between 0v and 3.3v. 34 | Use inline resistors to lower voltage if required; inline smoothing capacitors may also help. 35 | A simple PPM->RSSI conditioner can easily be made. See the PPM-RSSI conditioning.pdf for details. 36 | 37 | Under CLI : 38 | - enable using the RSSI_ADC feature : `feature RSSI_ADC` 39 | - set the RSSI_SCALE parameter (between 1 and 255) to adjust RSSI level according to your configuration. 40 | 41 | 42 | FrSky D4R-II and X8R supported. 43 | 44 | The feature can not be used when RX_PARALLEL_PWM is enabled. 45 | -------------------------------------------------------------------------------- /src/main/drivers/accgyro.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | extern uint16_t acc_1G; // FIXME move into acc_t 25 | 26 | typedef struct gyro_s { 27 | sensorGyroInitFuncPtr init; // initialize function 28 | sensorReadFuncPtr read; // read 3 axis data function 29 | sensorReadFuncPtr temperature; // read temperature if available 30 | float scale; // scalefactor 31 | } gyro_t; 32 | 33 | typedef struct acc_s { 34 | sensorInitFuncPtr init; // initialize function 35 | sensorReadFuncPtr read; // read 3 axis data function 36 | char revisionCode; // a revision code for the sensor, if known 37 | } acc_t; 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | -------------------------------------------------------------------------------- /src/main/common/color.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | typedef enum { 25 | RGB_RED = 0, 26 | RGB_GREEN, 27 | RGB_BLUE 28 | } colorComponent_e; 29 | 30 | #define RGB_COLOR_COMPONENT_COUNT (RGB_BLUE + 1) 31 | 32 | struct rgbColor24bpp_s { 33 | uint8_t r; 34 | uint8_t g; 35 | uint8_t b; 36 | }; 37 | 38 | typedef union { 39 | struct rgbColor24bpp_s rgb; 40 | uint8_t raw[RGB_COLOR_COMPONENT_COUNT]; 41 | } rgbColor24bpp_t; 42 | 43 | #define HSV_HUE_MAX 359 44 | #define HSV_SATURATION_MAX 255 45 | #define HSV_VALUE_MAX 255 46 | 47 | typedef enum { 48 | HSV_HUE = 0, 49 | HSV_SATURATION, 50 | HSV_VALUE 51 | } hsvColorComponent_e; 52 | 53 | #define HSV_COLOR_COMPONENT_COUNT (HSV_VALUE + 1) 54 | 55 | typedef struct hsvColor_s { 56 | uint16_t h; // 0 - 359 57 | uint8_t s; // 0 - 255 58 | uint8_t v; // 0 - 255 59 | } hsvColor_t; 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | -------------------------------------------------------------------------------- /src/main/flight/lowpass.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #define LOWPASS_NUM_COEF 3 25 | #define LPF_ROUND(x) (x < 0 ? (x - 0.5f) : (x + 0.5f)) 26 | 27 | typedef struct lowpass_s { 28 | bool init; 29 | int16_t freq; // Normalized freq in 1/1000ths 30 | float bf[LOWPASS_NUM_COEF]; 31 | float af[LOWPASS_NUM_COEF]; 32 | int64_t b[LOWPASS_NUM_COEF]; 33 | int64_t a[LOWPASS_NUM_COEF]; 34 | int16_t coeff_shift; 35 | int16_t input_shift; 36 | int32_t input_bias; 37 | float xf[LOWPASS_NUM_COEF]; 38 | float yf[LOWPASS_NUM_COEF]; 39 | int32_t x[LOWPASS_NUM_COEF]; 40 | int32_t y[LOWPASS_NUM_COEF]; 41 | } lowpass_t; 42 | 43 | void generateLowpassCoeffs2(int16_t freq, lowpass_t *filter); 44 | int32_t lowpassFixed(lowpass_t *filter, int32_t in, int16_t freq); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | -------------------------------------------------------------------------------- /src/main/command/command.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Magis. 3 | * 4 | * Magis is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Magis is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #include "../API/Utils.h" 21 | 22 | typedef enum { 23 | 24 | NONE = 0, 25 | TAKE_OFF, 26 | LAND, 27 | B_FLIP, 28 | F_FLIP, 29 | R_FLIP, 30 | L_FLIP 31 | 32 | } command_e; 33 | 34 | typedef enum { 35 | 36 | FINISHED = 0, RUNNING, ABORT 37 | 38 | } command_status_e; 39 | 40 | extern uint8_t current_command; 41 | 42 | extern uint8_t command_status; 43 | 44 | extern bool isLanding; 45 | 46 | extern bool setTakeOffAlt; 47 | 48 | extern bool setTakeOffThrottle; 49 | 50 | extern bool setTakeOffTimer; 51 | 52 | extern bool setLandTimer; 53 | 54 | extern uint32_t takeOffLoopTime; 55 | 56 | 57 | extern int32_t takeOffThrottle; 58 | 59 | extern bool isTookOff; 60 | 61 | extern bool isTakeOffHeightSet; 62 | 63 | 64 | extern uint16_t takeOffHeight; 65 | extern uint16_t landThrottle; 66 | extern bool isUserLandCommand; 67 | 68 | 69 | void resetCommandRCflag(void); 70 | 71 | void executeCommand(); 72 | 73 | void updateCommandStatus(); 74 | 75 | 76 | -------------------------------------------------------------------------------- /src/main/drivers/ranging_vl53l0x.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Magis. 3 | * 4 | * Magis is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Magis is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #include "vl53l0x_def.h" 25 | #include "vl53l0x_device.h" 26 | #include "vl53l0x_platform.h" 27 | #include "API/Specifiers.h" 28 | 29 | class LaserSensor { 30 | 31 | int16_t range; 32 | VL53L0X_Dev_t MyDevice; 33 | unibus_e statusLEDPin; 34 | 35 | public: 36 | 37 | void init(); 38 | void setAddress(uint8_t address); 39 | int16_t startRanging(); 40 | int16_t getLaserRange(); 41 | 42 | }; 43 | 44 | 45 | 46 | void ranging_init(void); 47 | void getRange(void); 48 | bool isTofDataNew(void); 49 | bool isOutofRange(void); 50 | 51 | 52 | 53 | extern VL53L0X_Error Global_Status; 54 | extern VL53L0X_RangingMeasurementData_t RangingMeasurementData; 55 | 56 | extern uint8_t Range_Status; 57 | extern uint16_t NewSensorRange; 58 | extern uint16_t debug_range; 59 | extern bool startRanging; 60 | extern bool isTofDataNewflag; 61 | extern bool useRangingSensor; 62 | 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | -------------------------------------------------------------------------------- /docs/Safety.md: -------------------------------------------------------------------------------- 1 | # Safety 2 | 3 | As many can attest, multirotors and RC models in general can be very dangerous, particularly on the test bench. Here are some simple golden rules to save you a trip to the local ER: 4 | * **NEVER** arm your model with propellers fitted unless you intend to fly! 5 | * **Always** remove your propellers if you are setting up for the first time, flashing firmware, or if in any doubt. 6 | 7 | ## Before Installing 8 | 9 | Please consult the [Cli](Cli.md), [Controls](Controls.md), [Failsafe](Failsafe.md) and [Modes](Modes.md) 10 | pages for further important information. 11 | 12 | You are highly advised to use the Receiver tab in the CleanFlight Configurator, making sure your Rx channel 13 | values are centered at 1500 (1520 for Futaba RC) with minimum & maximums of 1000 and 2000 (respectively) 14 | are reached when controls are operated. Failure to configure these ranges properly can create 15 | problems, such as inability to arm (because you can't reach the endpoints) or immediate activation of 16 | [failsafe](failsafe.md). 17 | 18 | You may have to adjust your channel endpoints and trims/sub-trims on your RC transmitter to achieve the 19 | expected range of 1000 to 2000. 20 | 21 | The referenced values for each channel have marked impact on the operation of the flight controller and the 22 | different flight modes. 23 | 24 | ## Props Spinning When Armed 25 | With the default configuration, when the controller is armed, the propellers *WILL* begin spinning at low speed. 26 | We recommend keeping this setting as it provides a good visual indication the craft is armed. 27 | 28 | If you wish to change this behavior, see the MOTOR_STOP feature in the Configurator and relevant docuemntation pages. 29 | Enabling this feature will stop the props from spinning when armed. 30 | -------------------------------------------------------------------------------- /docs/Installation.md: -------------------------------------------------------------------------------- 1 | # Installation 2 | 3 | ## Using the configurator 4 | This is a generic procedure to flash a board using the configurator. The configurator does not yet support all boards, so please check the documentation corresponding to your board before proceeding. 5 | 6 | Make sure you have the [Cleanflight Configurator](https://github.com/cleanflight/cleanflight-configurator) installed, then: 7 | 8 | * Connect the flight controller to the PC. 9 | * Start the Cleanflight Configurator. 10 | * Click on "Disconnect" if the configurator connected to the board automatically. 11 | * Click on the "Firmware Flasher" tab. 12 | * Make sure you have internet connectivity and click on the "Load Firmware [Online]" button. 13 | * Click on the "Choose a Firmware / Board" dropdown menu, and select the latest stable version for your flight controller. 14 | * IMPORTANT: Read and understand the release notes that are displayed. When upgrading review all release notes since your current firmware. 15 | * If this is the first time Cleanflight is flashed to the board, tick the "Full Chip Erase" checkbox. 16 | * Connect the flight controller board to the PC. Ensure the correct serial port is selected. 17 | * Click on the "Flash Firmware" button and hold still (do not breathe, too). 18 | * When the progress bar becomes green and reads "Programming: SUCCESSFUL" you are done! 19 | 20 | ## Manually 21 | 22 | See the board specific flashing instructions. 23 | 24 | # Upgrading 25 | 26 | When upgrading be sure to backup / dump your existing settings. Some firmware releases are not backwards compatible and default settings are restored when the FC detects an out of date configuration. 27 | 28 | ## Backup/Restore process 29 | 30 | See the CLI section of the docs for details on how to backup and restore your configuration via the CLI. 31 | -------------------------------------------------------------------------------- /support/buildserver/upload.php: -------------------------------------------------------------------------------- 1 | 58 | -------------------------------------------------------------------------------- /src/main/sensors/gyro.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | typedef enum { 25 | GYRO_NONE = 0, 26 | GYRO_DEFAULT, 27 | GYRO_MPU6050, 28 | GYRO_L3G4200D, 29 | GYRO_MPU3050, 30 | GYRO_L3GD20, 31 | GYRO_MPU6000, 32 | GYRO_MPU6500, 33 | GYRO_ICM20948, 34 | GYRO_FAKE 35 | } gyroSensor_e; 36 | 37 | extern gyro_t gyro; 38 | extern sensor_align_e gyroAlign; 39 | 40 | extern int16_t gyroADC[XYZ_AXIS_COUNT]; 41 | extern int16_t gyroZero[FLIGHT_DYNAMICS_INDEX_COUNT]; 42 | 43 | typedef struct gyroConfig_s { 44 | uint8_t gyroMovementCalibrationThreshold; // people keep forgetting that moving model while init results in wrong gyro offsets. and then they never reset gyro. so this is now on by default. 45 | } gyroConfig_t; 46 | 47 | void useGyroConfig(gyroConfig_t *gyroConfigToUse); 48 | void gyroSetCalibrationCycles(uint16_t calibrationCyclesRequired); 49 | void gyroUpdate(void); 50 | bool isGyroCalibrationComplete(void); 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | -------------------------------------------------------------------------------- /src/main/drivers/display_ug2864hsweg01.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #define SCREEN_WIDTH 128 25 | #define SCREEN_HEIGHT 64 26 | 27 | #define FONT_WIDTH 5 28 | #define FONT_HEIGHT 7 29 | #define HORIZONTAL_PADDING 1 30 | #define VERTICAL_PADDING 1 31 | 32 | #define CHARACTER_WIDTH_TOTAL (FONT_WIDTH + HORIZONTAL_PADDING) 33 | #define CHARACTER_HEIGHT_TOTAL (FONT_HEIGHT + VERTICAL_PADDING) 34 | 35 | #define SCREEN_CHARACTER_COLUMN_COUNT (SCREEN_WIDTH / CHARACTER_WIDTH_TOTAL) 36 | #define SCREEN_CHARACTER_ROW_COUNT (SCREEN_HEIGHT / CHARACTER_HEIGHT_TOTAL) 37 | 38 | #define VERTICAL_BARGRAPH_ZERO_CHARACTER (128 + 32) 39 | #define VERTICAL_BARGRAPH_CHARACTER_COUNT 7 40 | 41 | bool ug2864hsweg01InitI2C(void); 42 | 43 | void i2c_OLED_set_xy(uint8_t col, uint8_t row); 44 | void i2c_OLED_set_line(uint8_t row); 45 | void i2c_OLED_send_char(unsigned char ascii); 46 | void i2c_OLED_send_string(const char *string); 47 | void i2c_OLED_clear_display(void); 48 | void i2c_OLED_clear_display_quick(void); 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | -------------------------------------------------------------------------------- /src/main/flight/posEstimate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Magis. 3 | * 4 | * Magis is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Magis is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | 22 | extern "C" { 23 | #endif 24 | #include "common/axis.h" 25 | #include "flight/pid.h"//PS2 26 | 27 | #define LOC_UWB 0 28 | #define LOC_WHYCON 1 29 | #define LOC_VICON 2 30 | 31 | 32 | void addHistPositionBaseEstXY(float positionX, float positionY); 33 | void getFrontHistPositionBaseEstXY(float *posbaseX, float *posbaseY); 34 | bool isPositionBaseXYQueueIsFull(void); 35 | 36 | void PosXYEstimate(uint32_t currentTime); 37 | void resetPosition(void); 38 | void updatePosGains(void); 39 | void setPos(float newX, float newY); 40 | 41 | void configurePosHold2(pidProfile_t *initialPidProfile); 42 | 43 | extern int16_t posX, posY, posZ, deltaTime; 44 | extern int8_t Quality; 45 | extern bool new_position; 46 | extern int8_t localisationType; 47 | 48 | extern float PositionX, PositionY; 49 | extern float PrevPositionX, PrevPositionY; 50 | extern int16_t VelocityX, VelocityY; 51 | extern int16_t inputVx, inputVy; 52 | extern float whyconZ; 53 | extern float accel_EF[2], accel_EF_prev[2]; 54 | 55 | 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | -------------------------------------------------------------------------------- /src/main/io/oled_display.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | # Copyright (c) 2025 Drona Aviatino # 3 | # All rights reserved. # 4 | # ------------------------------------------------------------------------- # 5 | # Author: Ashish Jaiswal (MechAsh) # 6 | # Project: io # 7 | # File: \ssd1306.h # 8 | # Created Date: Sat, 25th Jan 2025 # 9 | # Brief: # 10 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # 11 | # Last Modified: Mon, 27th Jan 2025 # 12 | # Modified By: AJ # 13 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # 14 | # HISTORY: # 15 | # Date By Comments # 16 | # ---------- --- --------------------------------------------------------- # 17 | *******************************************************************************/ 18 | #pragma once 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | extern bool devmode; 29 | 30 | void OledStartUpInit ( void ); 31 | void OledStartUpPage ( void ); 32 | void OledDisplaySystemData ( void ); 33 | void OledDisplayNav ( void ); 34 | void OledDisplayData ( void ); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | -------------------------------------------------------------------------------- /src/main/sensors/compass.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | // Type of magnetometer used/detected 25 | typedef enum { 26 | MAG_DEFAULT = 0, 27 | MAG_NONE = 1, 28 | MAG_HMC5883 = 2, 29 | MAG_AK8975 = 3, 30 | MAG_AK8963 = 4, 31 | MAG_AK09916 = 5 32 | } magSensor_e; 33 | 34 | #define MAG_MAX MAG_AK8963 35 | 36 | 37 | //int16_t mag_declination; // Get your magnetic decliniation from here : http://magnetic-declination.com/ 38 | // For example, -6deg 37min, = -637 Japan, format is [sign]dddmm (degreesminutes) default is zero. 39 | 40 | #ifdef MAG 41 | void compassInit(void); 42 | void updateCompass(flightDynamicsTrims_t *magZero, flightDynamicsTrims_t *magScale); 43 | #endif 44 | void recalculateMagneticDeclination(void); 45 | 46 | extern int16_t magADC[XYZ_AXIS_COUNT]; 47 | extern uint32_t compassLastUpdatedAt; 48 | extern bool have_initial_yaw; 49 | 50 | extern sensor_align_e magAlign; 51 | extern mag_t mag; 52 | extern float magneticDeclination; 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | -------------------------------------------------------------------------------- /src/main/drivers/adc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | #include 18 | #include 19 | 20 | #include "platform.h" 21 | #include "build_config.h" 22 | #include "debug.h" 23 | 24 | #include "system.h" 25 | 26 | #include "adc.h" 27 | #include "adc_impl.h" 28 | 29 | //#define DEBUG_ADC_CHANNELS 30 | 31 | #ifdef USE_ADC 32 | adc_config_t adcConfig[ADC_CHANNEL_COUNT]; 33 | volatile uint16_t adcValues[ADC_CHANNEL_COUNT]; 34 | 35 | uint16_t adcGetChannel(uint8_t channel) 36 | { 37 | #ifdef DEBUG_ADC_CHANNELS 38 | if (adcConfig[0].enabled) { 39 | debug[0] = adcValues[adcConfig[0].dmaIndex]; 40 | } 41 | if (adcConfig[1].enabled) { 42 | debug[1] = adcValues[adcConfig[1].dmaIndex]; 43 | } 44 | if (adcConfig[2].enabled) { 45 | debug[2] = adcValues[adcConfig[2].dmaIndex]; 46 | } 47 | if (adcConfig[3].enabled) { 48 | debug[3] = adcValues[adcConfig[3].dmaIndex]; 49 | } 50 | #endif 51 | return adcValues[adcConfig[channel].dmaIndex]; 52 | } 53 | 54 | #else 55 | uint16_t adcGetChannel(uint8_t channel) 56 | { 57 | UNUSED(channel); 58 | return 0; 59 | } 60 | #endif 61 | -------------------------------------------------------------------------------- /src/main/API/Sensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Magis. 3 | * 4 | * Magis is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Magis is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | #include "common/axis.h" 22 | #include "Comman.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | typedef enum { 29 | 30 | PRESSURE, TEMPERATURE 31 | 32 | } baro_state_e; 33 | 34 | class Accelerometer_P { 35 | public: 36 | 37 | //unit: cm/sec2 38 | 39 | int16_t get(axis_e AXIS); 40 | int32_t getNetAcc(void); 41 | 42 | }; 43 | 44 | class Gyroscope_P { 45 | public: 46 | 47 | //unit: decidegree/sec 48 | 49 | int16_t get(axis_e AXIS); 50 | 51 | }; 52 | 53 | class Magnetometer_P { 54 | public: 55 | 56 | //unit: microTesla 57 | 58 | int16_t get(axis_e AXIS); 59 | 60 | }; 61 | 62 | class Barometer_P { 63 | public: 64 | 65 | //unit: 100*millibar for Pressure 66 | //unit" 100*degreeCelsius Temperature 67 | 68 | int32_t get(baro_state_e STATE); 69 | 70 | }; 71 | 72 | extern Accelerometer_P Acceleration; 73 | extern Gyroscope_P Gyroscope; 74 | extern Magnetometer_P Magnetometer; 75 | extern Barometer_P Barometer; 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | -------------------------------------------------------------------------------- /docs/Profiles.md: -------------------------------------------------------------------------------- 1 | # Profiles 2 | 3 | A profile is a set of configuration settings. 4 | 5 | Currently three profiles are supported. The default profile is profile `0`. 6 | 7 | ## Changing profiles 8 | 9 | Profiles can be selected using a GUI or the following stick combinations: 10 | 11 | | Profile | Throttle | Yaw | Pitch | Roll | 12 | | ------- | -------- | ----- | ------ | ------ | 13 | | 0 | Down | Left | Middle | Left | 14 | | 1 | Down | Left | Up | Middle | 15 | | 2 | Down | Left | Middle | Right | 16 | 17 | The CLI `profile` command can also be used: 18 | 19 | ``` 20 | profile 21 | ``` 22 | 23 | # Rate Profiles 24 | 25 | Cleanflight supports rate profiles in addition to regular profiles. 26 | 27 | Rate profiles contain settings that adjust how your craft behaves based on control input. 28 | 29 | Three rate profiles are supported. 30 | 31 | Rate profiles can be selected while flying using the inflight adjustments feature. 32 | 33 | Each normal profile has a setting called 'default_rate_profile`. When a profile is activated the 34 | corresponding rate profile is also activated. 35 | 36 | Profile 0 has a default rate profile of 0. 37 | Profile 1 has a default rate profile of 1. 38 | Profile 2 has a default rate profile of 2. 39 | 40 | The defaults are set this way so that it's simple to configure a profile and a rate profile at the same. 41 | 42 | The current rate profile can be shown or set using the CLI `rateprofile` command: 43 | 44 | ``` 45 | rateprofile 46 | ``` 47 | 48 | The values contained within a rate profile can be seen by using the CLI `dump rates` command. 49 | 50 | e.g 51 | ``` 52 | # dump rates 53 | 54 | # rateprofile 55 | rateprofile 0 56 | 57 | set rc_rate = 90 58 | set rc_expo = 65 59 | set thr_mid = 50 60 | set thr_expo = 0 61 | set roll_pitch_rate = 0 62 | set yaw_rate = 0 63 | set tpa_rate = 0 64 | set tpa_breakpoint = 1500 65 | ``` 66 | -------------------------------------------------------------------------------- /lib/test/gtest/src/gtest_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include 31 | 32 | #include "gtest/gtest.h" 33 | 34 | GTEST_API_ int main(int argc, char **argv) { 35 | printf("Running main() from gtest_main.cc\n"); 36 | testing::InitGoogleTest(&argc, argv); 37 | return RUN_ALL_TESTS(); 38 | } 39 | -------------------------------------------------------------------------------- /src/main/API/Localisation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Magis. 3 | * 4 | * Magis is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Magis is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | #include "common/axis.h" 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | typedef enum { 28 | UWB, 29 | WHYCON, 30 | VICON 31 | 32 | } localisation_type; 33 | 34 | /* 35 | typedef enum { 36 | LC_TAKE_OFF, 37 | LC_LAND, 38 | LC_SLEEP, 39 | LC_ARM_MOTORS, 40 | LC_GO_TO_WAY_POINT, 41 | LC_DISARM_MOTORS, 42 | LC_LOOP_FROM_START 43 | } localisation_cmd_type; 44 | */ 45 | 46 | class Localisation_P { 47 | 48 | public: 49 | 50 | void init(localisation_type localisation); 51 | 52 | int16_t get(axis_e AXIS); 53 | 54 | /* 55 | 56 | void setCommand(localisation_cmd_type command); 57 | 58 | void setCommand(localisation_cmd_type command, int16_t desiredX, int16_t desiredY); 59 | 60 | void setCommand(localisation_cmd_type command, int16_t desiredX, int16_t desiredY, int16_t desiredZ); 61 | 62 | void startLocalisation(); 63 | 64 | void stopLocalisation(); 65 | 66 | */ 67 | 68 | }; 69 | 70 | extern Localisation_P Localisation; 71 | 72 | #ifdef __cplusplus 73 | } 74 | #endif 75 | -------------------------------------------------------------------------------- /docs/Configuration.md: -------------------------------------------------------------------------------- 1 | # Configuration 2 | 3 | Cleanflight is configured primarily using the Cleanflight Configurator GUI. 4 | 5 | Both the command line interface and GUI are accessible by connecting to a serial port on the target, 6 | be it a USB virtual serial port, physical hardware UART port or a SoftSerial port. 7 | 8 | See the Serial section for more information and see the Board specific sections for details of the serial ports available on the board you are using. 9 | 10 | The GUI cannot currently configure all aspects of the system, the CLI must be used to enable or configure 11 | some features and settings. 12 | 13 | __Due to ongoing development, the fact that the GUI cannot yet backup all your settings and automatic chrome updates of the GUI app it is highly advisable to backup your settings (using the CLI) so that when a new version of the configurator or firmware is released you can re-apply your settings.__ 14 | 15 | 16 | ## GUI 17 | 18 | ![Cleanflight Gui](Screenshots/cleanflight-gui.png) 19 | 20 | The GUI tool is the preferred way of configuration. The GUI tool also includes a terminal which 21 | can be used to interact with the CLI. 22 | 23 | [Cleanflight Configurator on Chrome store](https://chrome.google.com/webstore/detail/cleanflight-configurator/enacoimjcgeinfnnnpajinjgmkahmfgb) 24 | 25 | If you cannot use the latest version of the GUI to access the FC due to firmware compatibility issues you can still access the FC via the CLI to backup your settings, or you can install an old version of the configurator. 26 | 27 | Old versions of the configurator can be downloaded from the configurator releases page: https://github.com/cleanflight/cleanflight-configurator/releases 28 | See the README file that comes with the configurator for installation instructions. 29 | 30 | 31 | ## CLI 32 | 33 | Cleanflight can also be configured by a command line interface. 34 | 35 | See the CLI section of the documentation for more details. 36 | -------------------------------------------------------------------------------- /src/main/drivers/system_stm32f10x.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "platform.h" 23 | 24 | #include "gpio.h" 25 | #include "system.h" 26 | 27 | #define AIRCR_VECTKEY_MASK ((uint32_t)0x05FA0000) 28 | 29 | void systemReset(void) 30 | { 31 | // Generate system reset 32 | SCB->AIRCR = AIRCR_VECTKEY_MASK | (uint32_t) 0x04; 33 | } 34 | 35 | void systemResetToBootloader(void) 36 | { 37 | // 1FFFF000 -> 20000200 -> SP 38 | // 1FFFF004 -> 1FFFF021 -> PC 39 | 40 | *((uint32_t *) 0x20004FF0) = 0xDEADBEEF; // 20KB STM32F103 41 | systemReset(); 42 | } 43 | 44 | void enableGPIOPowerUsageAndNoiseReductions(void) 45 | { 46 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC, ENABLE); 47 | 48 | gpio_config_t gpio; 49 | 50 | gpio.mode = Mode_AIN; 51 | gpio.pin = Pin_All; 52 | gpioInit(GPIOA, &gpio); 53 | gpioInit(GPIOB, &gpio); 54 | gpioInit(GPIOC, &gpio); 55 | } 56 | 57 | bool isMPUSoftReset(void) 58 | { 59 | if (cachedRccCsrValue & RCC_CSR_SFTRSTF) 60 | return true; 61 | else 62 | return false; 63 | } 64 | -------------------------------------------------------------------------------- /src/main/version.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | * This file is part of Cleanflight and Magis. 4 | * 5 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * Cleanflight and Magis are distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this software. If not, see . 17 | */ 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | #define FC_VERSION_MAJOR 2 // increment when a major release is made (big new feature, etc) 24 | #define FC_VERSION_MINOR 0 // increment when a minor release is made (small new feature, change etc) 25 | #define FC_VERSION_PATCH_LEVEL 1 // increment when a bug is fixed 26 | 27 | #define STR_HELPER( x ) #x 28 | #define STR( x ) STR_HELPER ( x ) 29 | #define FC_VERSION_STRING STR ( FC_VERSION_MAJOR ) "." STR ( FC_VERSION_MINOR ) "." STR ( FC_VERSION_PATCH_LEVEL ) 30 | 31 | #define MW_VERSION 231 32 | 33 | extern const char *const targetName; 34 | 35 | #define GIT_SHORT_REVISION_LENGTH 7 // lower case hexadecimal digits. 36 | extern const char *const shortGitRevision; 37 | 38 | #define BUILD_DATE_LENGTH 11 39 | extern const char *const buildDate; // "MMM DD YYYY" MMM = Jan/Feb/... 40 | 41 | #define BUILD_TIME_LENGTH 8 42 | extern const char *const buildTime; // "HH:MM:SS" 43 | 44 | extern const char *const FwVersion; 45 | extern const char *const ApiVersion; 46 | extern const char *const FwName; 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | -------------------------------------------------------------------------------- /src/main/drivers/sound_beeper.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "platform.h" 23 | 24 | #include "build_config.h" 25 | 26 | #include "system.h" 27 | #include "gpio.h" 28 | 29 | #include "sound_beeper.h" 30 | 31 | 32 | #ifdef BEEPER 33 | 34 | void (*systemBeepPtr)(bool onoff) = NULL; 35 | 36 | static void beepNormal(bool onoff) 37 | { 38 | if (onoff) { 39 | digitalLo(BEEP_GPIO, BEEP_PIN); 40 | } else { 41 | digitalHi(BEEP_GPIO, BEEP_PIN); 42 | } 43 | } 44 | 45 | static void beepInverted(bool onoff) 46 | { 47 | if (onoff) { 48 | digitalHi(BEEP_GPIO, BEEP_PIN); 49 | } else { 50 | digitalLo(BEEP_GPIO, BEEP_PIN); 51 | } 52 | } 53 | #endif 54 | 55 | void systemBeep(bool onoff) 56 | { 57 | #ifndef BEEPER 58 | UNUSED(onoff); 59 | #else 60 | systemBeepPtr(onoff); 61 | #endif 62 | } 63 | 64 | void beeperInit(beeperConfig_t *config) 65 | { 66 | #ifndef BEEPER 67 | UNUSED(config); 68 | #else 69 | initBeeperHardware(config); 70 | if (config->isInverted) 71 | systemBeepPtr = beepInverted; 72 | else 73 | systemBeepPtr = beepNormal; 74 | BEEP_OFF; 75 | #endif 76 | } 77 | -------------------------------------------------------------------------------- /src/main/drivers/pwm_output.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | #pragma once 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | #include "platform.h" 29 | 30 | #include "gpio.h" 31 | #include "timer.h" 32 | 33 | #include "flight/failsafe.h" // FIXME dependency into the main code from a driver 34 | 35 | #include "pwm_mapping.h" 36 | 37 | #include "pwm_output.h" 38 | 39 | typedef void (*pwmWriteFuncPtr)(uint8_t index, uint16_t value); // function pointer used to write motors 40 | 41 | 42 | 43 | 44 | typedef struct { 45 | volatile timCCR_t *ccr; 46 | TIM_TypeDef *tim; 47 | uint16_t period; 48 | pwmWriteFuncPtr pwmWritePtr; 49 | } pwmOutputPort_t; 50 | 51 | 52 | pwmOutputPort_t *pwmOutConfig(const timerHardware_t *timerHardware, uint8_t mhz, uint16_t period, uint16_t value); 53 | 54 | void pwmWriteMotor(uint8_t index, uint16_t value); 55 | void pwmShutdownPulsesForAllMotors(uint8_t motorCount); 56 | void pwmCompleteOneshotMotorUpdate(uint8_t motorCount); 57 | 58 | void pwmWriteServo(uint8_t index, uint16_t value); 59 | 60 | bool isMotorBrushed(uint16_t motorPwmRate); 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | -------------------------------------------------------------------------------- /src/test/unit/io_serial_unittest.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | extern "C" { 24 | #include "platform.h" 25 | 26 | #include "drivers/serial.h" 27 | #include "io/serial.h" 28 | 29 | void serialInit(serialConfig_t *initialSerialConfig); 30 | 31 | } 32 | 33 | #include "unittest_macros.h" 34 | #include "gtest/gtest.h" 35 | 36 | //uint32_t testFeatureMask = 0; 37 | uint8_t cliMode = 0; 38 | 39 | TEST(IoSerialTest, TestFindPortConfig) 40 | { 41 | // given 42 | serialConfig_t serialConfig; 43 | memset(&serialConfig, 0, sizeof(serialConfig)); 44 | 45 | // when 46 | serialInit(&serialConfig); 47 | 48 | // and 49 | serialPortConfig_t *portConfig = findSerialPortConfig(FUNCTION_MSP); 50 | 51 | // then 52 | EXPECT_EQ(NULL, portConfig); 53 | } 54 | 55 | 56 | // STUBS 57 | 58 | extern "C" { 59 | // 60 | //bool feature(uint32_t mask) { 61 | // return (mask & testFeatureMask); 62 | //}s 63 | 64 | void delay(uint32_t) {} 65 | void cliEnter(serialPort_t *) {} 66 | void cliProcess(void) {} 67 | bool isSerialTransmitBufferEmpty(serialPort_t *) { 68 | return true; 69 | } 70 | void mspProcess(void) {} 71 | void systemResetToBootloader(void) {} 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/main/drivers/barometer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | enum mmode { FAST, NORMAL, ACCURATE, VERY_ACCURATE }; 25 | 26 | typedef void (*baroOpStartFuncPtr)(void); // baro start operation 27 | typedef uint32_t (*baroOpGetFuncPtr)(void); // baro start operation 28 | typedef uint32_t (*baroMeaStartFuncPtr)(mmode mode); // baro meaasurement start operation 29 | typedef bool (*baroReadFuncPtr)(uint32_t currentTime,float *pressure, float *temperature); // baro read operation 30 | typedef void (*baroCalculateFuncPtr)(float *pressure, float *temperature, uint32_t P, uint32_t T); // baro calculation (filled params are pressure and temperature) 31 | 32 | typedef struct baro_s { 33 | uint16_t ut_delay; 34 | uint16_t up_delay; 35 | baroOpStartFuncPtr start_ut; 36 | baroOpGetFuncPtr get_ut; 37 | baroOpStartFuncPtr start_up; 38 | baroOpGetFuncPtr get_up; 39 | baroMeaStartFuncPtr measurment_start; 40 | baroCalculateFuncPtr calculate; 41 | baroReadFuncPtr read; 42 | } baro_t; 43 | 44 | 45 | extern uint32_t baroRead; 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | -------------------------------------------------------------------------------- /src/main/io/flashfs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight and Magis. 3 | * 4 | * Cleanflight and Magis are free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight and Magis are distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | #include "drivers/flash.h" 27 | 28 | #define FLASHFS_WRITE_BUFFER_SIZE 128 29 | #define FLASHFS_WRITE_BUFFER_USABLE (FLASHFS_WRITE_BUFFER_SIZE - 1) 30 | 31 | // Automatically trigger a flush when this much data is in the buffer 32 | #define FLASHFS_WRITE_BUFFER_AUTO_FLUSH_LEN 64 33 | 34 | void flashfsEraseCompletely(); 35 | void flashfsEraseRange(uint32_t start, uint32_t end); 36 | 37 | uint32_t flashfsGetSize(); 38 | uint32_t flashfsGetOffset(); 39 | uint32_t flashfsGetWriteBufferFreeSpace(); 40 | uint32_t flashfsGetWriteBufferSize(); 41 | int flashfsIdentifyStartOfFreeSpace(); 42 | const flashGeometry_t* flashfsGetGeometry(); 43 | 44 | void flashfsSeekAbs(uint32_t offset); 45 | void flashfsSeekRel(int32_t offset); 46 | 47 | void flashfsWriteByte(uint8_t byte); 48 | void flashfsWrite(const uint8_t *data, unsigned int len, bool sync); 49 | 50 | int flashfsReadAbs(uint32_t offset, uint8_t *data, unsigned int len); 51 | 52 | bool flashfsFlushAsync(); 53 | void flashfsFlushSync(); 54 | 55 | void flashfsInit(); 56 | 57 | bool flashfsIsReady(); 58 | bool flashfsIsEOF(); 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | -------------------------------------------------------------------------------- /src/main/API/Localisation.cpp: -------------------------------------------------------------------------------- 1 | #include "Localisation.h" 2 | #include "Localisation.h" 3 | 4 | #include "API-Utils.h" 5 | #include "command/localisationCommand.h" 6 | #include "flight/posEstimate.h" 7 | 8 | void Localisation_P::init(localisation_type localisation) 9 | { 10 | 11 | localisationType = localisation; 12 | 13 | } 14 | 15 | int16_t Localisation_P::get(axis_e AXIS) 16 | { 17 | 18 | switch (AXIS) { 19 | 20 | case X: 21 | 22 | return posX; 23 | 24 | case Y: 25 | 26 | return posY; 27 | 28 | case Z: 29 | 30 | return posZ; 31 | 32 | } 33 | 34 | } 35 | 36 | /* 37 | 38 | void Localisation_P::setCommand(localisation_cmd_type command) 39 | { 40 | 41 | 42 | if(command!=LC_GO_TO_WAY_POINT) 43 | { 44 | 45 | cmd_def cmd= {(cmd_type)command,0,0,0}; 46 | 47 | 48 | 49 | command_add(cmd); 50 | 51 | } 52 | 53 | } 54 | 55 | 56 | void Localisation_P::setCommand(localisation_cmd_type command, int16_t desiredX, int16_t desiredY) 57 | { 58 | 59 | 60 | if(command==LC_GO_TO_WAY_POINT) 61 | { 62 | 63 | cmd_def cmd= {(cmd_type)command,desiredX,desiredY,0}; 64 | 65 | 66 | command_add(cmd); 67 | 68 | } 69 | 70 | } 71 | 72 | 73 | void Localisation_P::setCommand(localisation_cmd_type command, int16_t desiredX, int16_t desiredY, int16_t desiredZ) 74 | { 75 | 76 | 77 | if(command==LC_GO_TO_WAY_POINT) 78 | { 79 | 80 | cmd_def cmd= {(cmd_type)command,desiredX,desiredY,desiredZ}; 81 | 82 | 83 | command_add(cmd); 84 | 85 | } 86 | 87 | 88 | } 89 | 90 | 91 | void Localisation_P::startLocalisation() 92 | { 93 | 94 | 95 | isLocalisationOn=true; 96 | 97 | 98 | } 99 | 100 | 101 | 102 | void Localisation_P::stopLocalisation() 103 | { 104 | 105 | 106 | isLocalisationOn=false; 107 | 108 | 109 | } 110 | 111 | */ 112 | 113 | Localisation_P Localisation; 114 | 115 | -------------------------------------------------------------------------------- /src/main/telemetry/telemetry.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Cleanflight. 3 | * 4 | * Cleanflight is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Cleanflight is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Cleanflight. If not, see . 16 | */ 17 | 18 | /* 19 | * telemetry.h 20 | * 21 | * Created on: 6 Apr 2014 22 | * Author: Hydra 23 | */ 24 | #include "rx/rx.h" 25 | 26 | #ifndef TELEMETRY_COMMON_H_ 27 | #define TELEMETRY_COMMON_H_ 28 | 29 | typedef enum { 30 | FRSKY_FORMAT_DMS = 0, 31 | FRSKY_FORMAT_NMEA 32 | } frskyGpsCoordFormat_e; 33 | 34 | typedef enum { 35 | FRSKY_UNIT_METRICS = 0, 36 | FRSKY_UNIT_IMPERIALS 37 | } frskyUnit_e; 38 | 39 | typedef struct telemetryConfig_s { 40 | uint8_t telemetry_switch; // Use aux channel to change serial output & baudrate( MSP / Telemetry ). It disables automatic switching to Telemetry when armed. 41 | uint8_t telemetry_inversion; // also shared with smartport inversion 42 | float gpsNoFixLatitude; 43 | float gpsNoFixLongitude; 44 | frskyGpsCoordFormat_e frsky_coordinate_format; 45 | frskyUnit_e frsky_unit; 46 | uint8_t frsky_vfas_precision; 47 | uint8_t hottAlarmSoundInterval; 48 | } telemetryConfig_t; 49 | 50 | void telemetryCheckState(void); 51 | void telemetryProcess(rxConfig_t *rxConfig, uint16_t deadband3d_throttle); 52 | 53 | bool telemetryDetermineEnabledState(portSharing_e portSharing); 54 | 55 | void telemetryUseConfig(telemetryConfig_t *telemetryConfig); 56 | 57 | #endif /* TELEMETRY_COMMON_H_ */ 58 | -------------------------------------------------------------------------------- /src/main/flight/posControl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Magis. 3 | * 4 | * Magis is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Magis is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #include "common/axis.h" 25 | #include "io/rc_controls.h" 26 | #include "flight/pid.h"//PS2 27 | 28 | bool PositionController(int16_t desiredX, int16_t desiredY, int16_t desiredZ); 29 | void VelocityController(int16_t VdesiredX, int16_t VdesiredY); 30 | void PosVelController(int16_t desiredX, int16_t desiredY, int16_t desiredVel); 31 | bool SimpleController(int16_t desiredX, int16_t desiredY, int16_t desiredZ); 32 | void selectVelOrPosmode(void); 33 | 34 | 35 | int16_t getrcDataRoll(void); 36 | int16_t getrcDataPitch(void); 37 | int16_t getDesiredVelocityX(); 38 | int16_t getDesiredVelocityY(); 39 | 40 | void setdesiredHeight(int32_t desiredZ); 41 | int32_t getdesiredHeight(void); 42 | void configurePosHold(pidProfile_t *initialPidProfile,rcControlsConfig_t *rcControlsConfigPointer ); //PS2 43 | void resetPosIntegral(void); 44 | void resetPosController(void); 45 | 46 | extern uint8_t HeightAchieved; 47 | extern int16_t PID_x; 48 | extern int16_t PID_y; 49 | extern int16_t VdesiredX; 50 | extern int16_t VdesiredY; 51 | 52 | extern uint8_t velocityControlX; 53 | extern uint8_t velocityControlY; 54 | 55 | extern int32_t desiredPositionX; 56 | extern int32_t desiredPositionY; 57 | 58 | 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | 64 | -------------------------------------------------------------------------------- /lib/main/STM32_USB-FS-Device_Driver/inc/usb_int.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usb_int.h 4 | * @author MCD Application Team 5 | * @version V4.0.0 6 | * @date 28-August-2012 7 | * @brief Endpoint CTR (Low and High) interrupt's service routines prototypes 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __USB_INT_H 31 | #define __USB_INT_H 32 | 33 | /* Includes ------------------------------------------------------------------*/ 34 | /* Exported types ------------------------------------------------------------*/ 35 | /* Exported constants --------------------------------------------------------*/ 36 | /* Exported macro ------------------------------------------------------------*/ 37 | /* Exported functions ------------------------------------------------------- */ 38 | void CTR_LP(void); 39 | void CTR_HP(void); 40 | 41 | /* External variables --------------------------------------------------------*/ 42 | 43 | #endif /* __USB_INT_H */ 44 | 45 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 46 | --------------------------------------------------------------------------------