Merge branch 'master' into patch-1

This commit is contained in:
onelivesleft 2018-09-25 22:53:21 +01:00 committed by GitHub
commit de61371b17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
190 changed files with 1669 additions and 887 deletions

View File

@ -153,6 +153,7 @@ Module | Comments
-------|--------
U-blox Neo-M8N w/Compass | Pinout can be found in Pixfalcon manual. SDA and SCL can be attached to I2C bus for compass, TX and RX can be attached to UART for GPS. Power must be applied for either to function.
Reyax RY825AI | NEO-M8N, 18Hz UART USB interface GPS Glonass BeiDou QZSS antenna module flash. [eBay](http://www.ebay.com/itm/RY825AI-18Hz-UART-USB-interface-GPS-Glonass-BeiDou-QZSS-antenna-module-flash/181566850426)
mRo uGPS w/ LIS3MDL | Ultra compact and weights just 7.7 grams. Multiple constellation capabilities (GPS and GLONASS). Includes JST-GH pigtail. Available from [mRobotics](https://store.mrobotics.io/product-p/mro-ugps-samm8q-01.htm).
#### NEO-7
Module | Comments

View File

@ -20,46 +20,46 @@ Happy Props!
## Important information when upgrading
- A number of changes and improvements in this release require changes to the Betaflight configurator. These changes have been added to Betaflight configurator 10.3.1 (installation instructions [here](https://github.com/betaflight/betaflight-configurator#installation)). Please update your Betaflight configurator to version 10.3.1. If you are using the Blackbox Log Viewer, there is an updated version 3.1.0 to go with Betaflight 3.4 (installation instructions [here](https://github.com/betaflight/blackbox-log-viewer#installation));
- as part of the overhaul of the various filter stages, and improvements to the PID loop, the default settings have been re-evaluated and updated. The new default values are designed to make optimal use of the new filtering and improved PID loop, and be flyable with (almost) any hardware. Even if your current set up is working ok, it is probably worthwhile to try and only restore the non-filtering / PID loop settings, and have a go with the new default values (store your old `diff` in a safe place, just in case you don't like the new values :wink:). (#6036);
- also as part of the filtering overhaul, the names of the debug modes available to log filtering / tuning data have been improved `NOTCH` (gyro data after scaling, before filtering) is now `GYRO_SCALED`, `GYRO` (gyro data after all filtering has been applied) is now `GYRO_FILTERED` (#6059);
- the upper limit of `dterm_setpoint_weight` has been increased to 2000 (corresponding to a value of 20 for 'D Setpoint Weight' in Betaflight configurator). This means that pilots wanting a more 'locked in' stick feeling can increase this value beyond the previous maximum of 254. At the same time, an undocumented scaling change was reverted, and the scale is now again how it is described in the Betaflight configurator. If you are using a custom setting for `dterm_setpoint_weight`, divide your value by 1.27 to get the new value that will give you the same feeling as between 3.1.6 and 3.4.0 (#5945, #6052);
- Dshot beacon configuraton has been changed. Now the `beacon` CLI command can be used analogous to how the `beeper` command is used. This allows for the Dshot beacon to be disabled individually for the conditions that are supported by it (`RX_SET` and `RX_LOST` at the moment). The old way of disabling the Dshot beacon by setting `beeper_dshot_beacon_tone` to `0` is no longer supported. The Dshot beacon is disabled for all conditions by default, if you want to enable it, use `beacon <condition name|ALL>` in CLI (#5891, #6070);
- in previous versions of the firmware, there was a race condition that could cause Dshot commands (e.g. activation of crash flip) to be ignored by the ESC when the Dshot beacon was active. To prevent this, a timeout has been added to the Dshot beacon that prevents arming for 1.2 seconds after the Dshot beacon was active (#6079);
- validation has been added for the RSSI configuration. Unlike in previous versions, it is no longer possible to have multiple sources for RSSI configured simultaneously, since only one can be active at any one time. If you have got more than one of the supported RSSI sources (frame error count / ADC / RX channel) configured, all but the first on this list will be disabled (#5644);
- scaling has been added to all RSSI sources. If the RSSI mechanism that you are using does not give you the output range that you want for RSSI, you can now use the `rssi_scale` / `rssi_offset` CLI variables to set the scale and offset for RSSI (#6001, #6032);
- the functionality of the crash flip mode has been improved: In addition to the existing front / back / left / right spinning of 2 propellers, it now supports spinning only 1 propeller (by moving the roll / pitch stick diagonally), and spinning 2 props that are diagonally opposite (by moving yaw), in order to yaw the overturned craft. The largest stick deflection in any of these directions determines which properllers are spun (#5163);
- the setting `moron_threshold` for the acceptable noise limit during gyro calibration was renamed to `gyro_calib_noise_limit`. Additionally, a new setting `gyro_calib_duration` was added. This allows users to configure a longer minimum gyro calibration duration (in 1/10ths of seconds, default: 125). Using a larger setting here will result in reduced gyro drift, which is helpful when flying line of sight (#5932);
- as part of the overhaul of the various filter stages, and improvements to the PID loop, the default settings have been re-evaluated and updated. The new default values are designed to make optimal use of the new filtering and improved PID loop, and be flyable with (almost) any hardware. Even if your current set up is working ok, it is probably worthwhile to try and only restore the non-filtering / PID loop settings, and have a go with the new default values (store your old `diff` in a safe place, just in case you don't like the new values :wink:). ([#6036](https://github.com/betaflight/betaflight/pull/6036));
- also as part of the filtering overhaul, the names of the debug modes available to log filtering / tuning data have been improved `NOTCH` (gyro data after scaling, before filtering) is now `GYRO_SCALED`, `GYRO` (gyro data after all filtering has been applied) is now `GYRO_FILTERED` ([#6059](https://github.com/betaflight/betaflight/pull/6059));
- the upper limit of `dterm_setpoint_weight` has been increased to 2000 (corresponding to a value of 20 for 'D Setpoint Weight' in Betaflight configurator). This means that pilots wanting a more 'locked in' stick feeling can increase this value beyond the previous maximum of 254. At the same time, an undocumented scaling change was reverted, and the scale is now again how it is described in the Betaflight configurator. If you are using a custom setting for `dterm_setpoint_weight`, divide your value by 1.27 to get the new value that will give you the same feeling as between 3.1.6 and 3.4.0 ([#5945](https://github.com/betaflight/betaflight/pull/5945), [#6052](https://github.com/betaflight/betaflight/pull/6052));
- Dshot beacon configuraton has been changed. Now the `beacon` CLI command can be used analogous to how the `beeper` command is used. This allows for the Dshot beacon to be disabled individually for the conditions that are supported by it (`RX_SET` and `RX_LOST` at the moment). The old way of disabling the Dshot beacon by setting `beeper_dshot_beacon_tone` to `0` is no longer supported. The Dshot beacon is disabled for all conditions by default, if you want to enable it, use `beacon <condition name|ALL>` in CLI ([#5891](https://github.com/betaflight/betaflight/pull/5891), [#6070](https://github.com/betaflight/betaflight/pull/6070));
- in previous versions of the firmware, there was a race condition that could cause Dshot commands (e.g. activation of crash flip) to be ignored by the ESC when the Dshot beacon was active. To prevent this, a timeout has been added to the Dshot beacon that prevents arming for 1.2 seconds after the Dshot beacon was active ([#6079](https://github.com/betaflight/betaflight/pull/6079));
- validation has been added for the RSSI configuration. Unlike in previous versions, it is no longer possible to have multiple sources for RSSI configured simultaneously, since only one can be active at any one time. If you have got more than one of the supported RSSI sources (frame error count / ADC / RX channel) configured, all but the first on this list will be disabled ([#5644](https://github.com/betaflight/betaflight/pull/5644));
- scaling has been added to all RSSI sources. If the RSSI mechanism that you are using does not give you the output range that you want for RSSI, you can now use the `rssi_scale` / `rssi_offset` CLI variables to set the scale and offset for RSSI ([#6001](https://github.com/betaflight/betaflight/pull/6001), [#6032](https://github.com/betaflight/betaflight/pull/6032));
- the functionality of the crash flip mode has been improved: In addition to the existing front / back / left / right spinning of 2 propellers, it now supports spinning only 1 propeller (by moving the roll / pitch stick diagonally), and spinning 2 props that are diagonally opposite (by moving yaw), in order to yaw the overturned craft. The largest stick deflection in any of these directions determines which properllers are spun ([#5163](https://github.com/betaflight/betaflight/pull/5163));
- the setting `moron_threshold` for the acceptable noise limit during gyro calibration was renamed to `gyro_calib_noise_limit`. Additionally, a new setting `gyro_calib_duration` was added. This allows users to configure a longer minimum gyro calibration duration (in 1/10ths of seconds, default: 125). Using a larger setting here will result in reduced gyro drift, which is helpful when flying line of sight ([#5932](https://github.com/betaflight/betaflight/pull/5932));
- unfortunately bugfixes and improvements in the flight controller core functionality have led to an increase of the firmware size, causing it to overflow the available space on a number of F3 based flight controllers. As a result, some features have had to be removed from a number of F3 based flight controllers in order to make the firmware fit into flash. The following targets are affected: BETAFLIGHTF3, COLIBRI\_RACE, FRSKYF3, FURYF3OSD, LUX\_RACE, MIDELICF3, OMNIBUS, RCEXPLORERF3, RG\_SSD\_F3, SPRACINGF3EVO, SPRACINGF3NEO;
- the OSD elements `osd_crosshairs` (crosshairs) and `osd_ah_sbar` (artificial horizon sidebar) have been renamed in CLI to `osd_crosshairs_pos` and `osd_ah_sbar_pos` to make them consistent with the naming of OSD elements. If you are using these elements, please manually change the names in your backup before restoring (#5534);
- the range of the `vtx_band` parameter in CLI was extended to start at 0 instead of 1. Setting `vtx_band = 0` allows users of VTX using the SmartPort or Tramp protocols to set the desired frequency directly via the `vtx_freq` parameter. Since direct frequency setting is not supported by the RTC6705 (onboard) VTX driver `vtx_band = 0` does not work for these VTX, and should not be used (#5465).
- the OSD elements `osd_crosshairs` (crosshairs) and `osd_ah_sbar` (artificial horizon sidebar) have been renamed in CLI to `osd_crosshairs_pos` and `osd_ah_sbar_pos` to make them consistent with the naming of OSD elements. If you are using these elements, please manually change the names in your backup before restoring ([#5534](https://github.com/betaflight/betaflight/pull/5534));
- the range of the `vtx_band` parameter in CLI was extended to start at 0 instead of 1. Setting `vtx_band = 0` allows users of VTX using the SmartPort or Tramp protocols to set the desired frequency directly via the `vtx_freq` parameter. Since direct frequency setting is not supported by the RTC6705 (onboard) VTX driver `vtx_band = 0` does not work for these VTX, and should not be used ([#5465](https://github.com/betaflight/betaflight/pull/5465)).
## Major features:
- Overhauled and improved filtering (#5391, #5458);
- Optimised and massively improved the performance on F7 (#5674);
- Added GPS rescue mode (#5753, #5764);
- Added support for accessing SD card / onboard flash as USB mass storage device (MSC) (#5443, #5629, #5650);
- Added support for reading RC input as USB joystick (HID) (#5478, #5596);
- Added support for CMS configuration over CRSF (#5743);
- Added support for experimental filter based RC channel smoothing (#6017).
- Overhauled and improved filtering ([#5391](https://github.com/betaflight/betaflight/pull/5391), [#5458](https://github.com/betaflight/betaflight/pull/5458));
- Optimised and massively improved the performance on F7 ([#5674](https://github.com/betaflight/betaflight/pull/5674));
- Added GPS rescue mode ([#5753](https://github.com/betaflight/betaflight/pull/5753), [#5764](https://github.com/betaflight/betaflight/pull/5764));
- Added support for accessing SD card / onboard flash as USB mass storage device (MSC) ([#5443](https://github.com/betaflight/betaflight/pull/5443), [#5629](https://github.com/betaflight/betaflight/pull/5629), [#5650](https://github.com/betaflight/betaflight/pull/5650));
- Added support for reading RC input as USB joystick (HID) ([#5478](https://github.com/betaflight/betaflight/pull/5478), [#5596](https://github.com/betaflight/betaflight/pull/5596));
- Added support for CMS configuration over CRSF ([#5743](https://github.com/betaflight/betaflight/pull/5743));
- Added support for experimental filter based RC channel smoothing ([#6017](https://github.com/betaflight/betaflight/pull/6017)).
## Minor features:
- Added acro trainer mode (#5970);
- Added throttle boost mode (#5508);
- Added support for throttle limiting (#5608);
- Added PID loop improvements (#5968, #5963, #5962);
- Added support for accelerated [yaw spin recovery](https://github.com/betaflight/betaflight/wiki/Yaw-Spin-Recovery-and-Gyro-Overflow-Detect) (#5706);
- Added support for direct adjustment of PID values through an RC channel (#5584);
- Added support for multiple overclocking speeds (#5193);
- Added MCU temperature monitoring (#5322);
- Added paralyse mode (#5851);
- Added support for QMC5883L compass (#5309);
- Added support for W25M flash chips (#5722).
- Added acro trainer mode ([#5970](https://github.com/betaflight/betaflight/pull/5970));
- Added throttle boost mode ([#5508](https://github.com/betaflight/betaflight/pull/5508));
- Added support for throttle limiting ([#5608](https://github.com/betaflight/betaflight/pull/5608));
- Added PID loop improvements ([#5968](https://github.com/betaflight/betaflight/pull/5968), [#5963](https://github.com/betaflight/betaflight/pull/5963), [#5962](https://github.com/betaflight/betaflight/pull/5962));
- Added support for accelerated [yaw spin recovery](https://github.com/betaflight/betaflight/wiki/Yaw-Spin-Recovery-and-Gyro-Overflow-Detect) ([#5706](https://github.com/betaflight/betaflight/pull/5706));
- Added support for direct adjustment of PID values through an RC channel ([#5584](https://github.com/betaflight/betaflight/pull/5584));
- Added support for multiple overclocking speeds ([#5193](https://github.com/betaflight/betaflight/pull/5193));
- Added MCU temperature monitoring ([#5322](https://github.com/betaflight/betaflight/pull/5322));
- Added paralyse mode ([#5851](https://github.com/betaflight/betaflight/pull/5851));
- Added support for QMC5883L compass ([#5309](https://github.com/betaflight/betaflight/pull/5309));
- Added support for W25M flash chips ([#5722](https://github.com/betaflight/betaflight/pull/5722)).
## New targets:
- Added SPRACINGF7DUAL with dual gyro support (#5264).
- Added SPRACINGF7DUAL with dual gyro support ([#5264](https://github.com/betaflight/betaflight/pull/5264)).

View File

@ -19,17 +19,17 @@ Happy Props!
- A number of changes and improvements in this release require changes to the Betaflight configurator. These changes have been added to [Betaflight configurator 10.4.0](https://github.com/betaflight/betaflight-configurator/releases/tag/10.4.0)(installation instructions [here](https://github.com/betaflight/betaflight-configurator#installation)), please update your Betaflight configurator to at least this version;
- if you are using the Blackbox Log Viewer, there is an updated [version 3.2.0](https://github.com/betaflight/blackbox-log-viewer/releases/tag/3.2.0) to go with Betaflight 3.5 (installation instructions [here](https://github.com/betaflight/blackbox-log-viewer#installation)). Please update to at least version 3.2.0;
- a new 'Feed Forward PID' algorithm has been implemented, replacing setpoint weight (#6355). In addition to this, the dynamic notch filter (#6411) and anti-gravity (#6220) have been optimised for improved flight performance. For all of these changes, default values have been chosen that should result in good flight characteristics for most setups. It is recommended to start testing with default settings, incorporating tuned settings from previous versions if needed, where needed. For more in-depth instructions for tuning Betaflight 3.5, please consult [these notes](https://github.com/betaflight/betaflight/wiki/3.5-tuning-notes).
- unfortunately, bugfixes in the flight controller core functionality have led to an increase of the firmware size, causing it to overflow the available space on a number of F3 based flight controllers. As a result, some features have had to be removed from a number of F3 based flight controllers in order to make the firmware fit into flash. The following targets are affected: CRAZYBEEF3FR, CRAZYBEEF3FS, FRSKYF3, FURYF3, FURYF3OSD, OMNIBUS, SPRACINGF3, SPRACINGF3EVO, SPRACINGF3MINI, SPRACINGF3NEO (#6497, #6501);
- a new 'Feed Forward PID' algorithm has been implemented, replacing setpoint weight ([#6355](https://github.com/betaflight/betaflight/pull/6355)). In addition to this, the dynamic notch filter ([#6411](https://github.com/betaflight/betaflight/pull/6411)) and anti-gravity ([#6220](https://github.com/betaflight/betaflight/pull/6220)) have been optimised for improved flight performance. For all of these changes, default values have been chosen that should result in good flight characteristics for most setups. It is recommended to start testing with default settings, incorporating tuned settings from previous versions if needed, where needed. For more in-depth instructions for tuning Betaflight 3.5, please consult [these notes](https://github.com/betaflight/betaflight/wiki/3.5-tuning-notes).
- unfortunately, bugfixes in the flight controller core functionality have led to an increase of the firmware size, causing it to overflow the available space on a number of F3 based flight controllers. As a result, some features have had to be removed from a number of F3 based flight controllers in order to make the firmware fit into flash. The following targets are affected: CRAZYBEEF3FR, CRAZYBEEF3FS, FRSKYF3, FURYF3, FURYF3OSD, OMNIBUS, SPRACINGF3, SPRACINGF3EVO, SPRACINGF3MINI, SPRACINGF3NEO ([#6497](https://github.com/betaflight/betaflight/pull/6497), [#6501](https://github.com/betaflight/betaflight/pull/6501))
## Major features:
- Added support for feed forward to the PID controller (#6355);
- Improved the performance of the dynamic notch filter (#6411).
- Added support for feed forward to the PID controller ([#6355](https://github.com/betaflight/betaflight/pull/6355)).
- Improved the performance of the dynamic notch filter ([#6411](https://github.com/betaflight/betaflight/pull/6411)).
## Minor features:
- Improved the performance of anti-gravity (#6220);
- Added support for linking of modes (#6335);
- Added support for dynamic filter in dual gyro mode (#6428).
- Improved the performance of anti-gravity ([#6220](https://github.com/betaflight/betaflight/pull/6220));
- Added support for linking of modes ([#6335](https://github.com/betaflight/betaflight/pull/6335));
- Added support for dynamic filter in dual gyro mode ([#6428](https://github.com/betaflight/betaflight/pull/6428)).

View File

@ -0,0 +1,31 @@
# SPEDIX F4
## Description
One of the main considerations while designing the SPEDIX F4 was to provide users the maximum amount of UARTs, as well as motor outputs, while retaining maximum efficiency, a careful choice of pinmap allowed to run 6-8 DSHOT motors off just 2 timers, while breaking out all the 6 UARTs that the STM32F405 provides.
Timer design favors running multirotor and fixed wing alike.
Plug & play connectivity to SPEDIX and AIKON 4in1 ESCs,
## MCU, Sensors and Features
### Hardware
- MCU: STM32F405
- IMU: ICM-20602 or MPU-6000
- 6 DSHOT motors outputs, 8 by remapping UART6 as M7 & 8, using just 2 timers
- BMP280 SPI
- 6 hardware UARTs, UART5 with a controllable inverter for SBUS, USART1 with bidirectional inverter for FPORT/SPORT
- Onboard regulator supports up to 6S
- Dataflash blackbox
- External I2C port
- JST-SH 10 pin 4in1 ESC plug
## Designers
Kyle Lee (SPEDIX)
Andrey Mironov (@DieHertz)
## Maintainers
Andrey Mironov (@DieHertz)
![SPEDIX F4 top](images/spedixf4-top.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

View File

@ -1,6 +1,6 @@
# Building in Eclipse
How to build, test & debug Cleanflight in Eclipse on Linux, Windows & MacOS.
How to build, test & debug Betaflight in Eclipse on Linux, Windows & MacOS.
## Checklist
@ -17,7 +17,7 @@ Use this checklist to make sure you didn't miss a step. Versions mandated below
- [ ] Optionally [Download and Install](https://github.com/gnuarmeclipse/qemu/releases) the latest GNU ARM Eclipse QEMU [read more](#install-qemu)
- [ ] Add a new update site to Eclipse named "GNU ARM Eclipse Plugins" with the URL "http://gnuarmeclipse.sourceforge.net/updates" and install all the features offered
- [ ] Configure [the recommended workspace settings](http://gnuarmeclipse.github.io/eclipse/workspace/preferences/)
- [ ] Checkout the cleanflight source code [read more](#checkout-cleanflight)
- [ ] Checkout the betaflight source code [read more](#checkout-betaflight)
- [ ] *Windows platform only:* Add the msys or cygwin bin directory to the project path
- [ ] Build the code by going to *Project menu -> Build All* [read more](#build)
- [ ] Run the tests by creating and running a make target named "test"
@ -47,85 +47,85 @@ Retain the default installation directories so that the GNU ARM Plugins can loca
### Install OpenOCD
You should install OpenOCD If you will be debugging on real hardware, such as the STM32F3DISCOVERY dev board. It is not required to simply build Cleanflight or run the tests.
You should install OpenOCD If you will be debugging on real hardware, such as the STM32F3DISCOVERY dev board. It is not required to simply build Betaflight or run the tests.
### Install QEMU
No tests currently run on the QEMU emulator therefore this install is entirely optional. It is useful to test your installation, since you can compile and run a blinky demo.
### Checkout Cleanflight
### Checkout Betaflight
If you'll be submitting changes to cleanflight, [fork the repository](https://help.github.com/articles/fork-a-repo/) on GitHub and checkout your copy.
If you'll be submitting changes to betaflight, [fork the repository](https://help.github.com/articles/fork-a-repo/) on GitHub and checkout your copy.
In Eclipse go to *File -> Import* choose *Git -> Projects from Git*
![projects from git](assets/building-in-eclipse/checkout-cleanflight-001.PNG)
![projects from git](assets/building-in-eclipse/checkout-betaflight-001.PNG)
Choose *Clone URI*
![clone uri](assets/building-in-eclipse/checkout-cleanflight-002.PNG)
![clone uri](assets/building-in-eclipse/checkout-betaflight-002.PNG)
Enter the URI https://github.com/cleanflight/cleanflight or if you've forked the repo, enter your URI instead. With a fork, you will need to specify your authentication details
Enter the URI https://github.com/betaflight/betaflight or if you've forked the repo, enter your URI instead. With a fork, you will need to specify your authentication details
![enter uri](assets/building-in-eclipse/checkout-cleanflight-003.PNG)
![enter uri](assets/building-in-eclipse/checkout-betaflight-003.PNG)
On the branch selection dialog, de-select all branches and select only *master*
![choose branches to clone](assets/building-in-eclipse/checkout-cleanflight-004.PNG)
![choose branches to clone](assets/building-in-eclipse/checkout-betaflight-004.PNG)
Select the default destination directory
![destination](assets/building-in-eclipse/checkout-cleanflight-005.PNG)
![destination](assets/building-in-eclipse/checkout-betaflight-005.PNG)
When the download completes, choose *Use the New Project wizard* and click Finish
![finish](assets/building-in-eclipse/checkout-cleanflight-006.PNG)
![finish](assets/building-in-eclipse/checkout-betaflight-006.PNG)
Choose *C/C++ -> Makefile Project with Existing Code*
![makefile project](assets/building-in-eclipse/checkout-cleanflight-007.PNG)
![makefile project](assets/building-in-eclipse/checkout-betaflight-007.PNG)
Enter cleanflight as the project name and browse to your home directory -> git -> cleanflight for the existing code location. Ensure the C (cleanflight) and C++ (tests) languages are checked. Choose the Cross ARM GCC toolchain for the Indexer Settings. Click finish.
Enter betaflight as the project name and browse to your home directory -> git -> betaflight for the existing code location. Ensure the C (betaflight) and C++ (tests) languages are checked. Choose the Cross ARM GCC toolchain for the Indexer Settings. Click finish.
![finish checkout](assets/building-in-eclipse/checkout-cleanflight-008.PNG)
![finish checkout](assets/building-in-eclipse/checkout-betaflight-008.PNG)
Set your build and debug targets by going to project properties -> C/C++ Build and choose the Behaviour tab. Replace "all" in the build box with "TARGET=xxx DEBUG=GDB" where xxx is your platform such as NAZE
![build](assets/building-in-eclipse/checkout-cleanflight-012.PNG)
![build](assets/building-in-eclipse/checkout-betaflight-012.PNG)
On Windows only, add msys or cygwin bin directory to the project's path by right clicking the project and choosing properties
![properties](assets/building-in-eclipse/checkout-cleanflight-009.PNG)
![properties](assets/building-in-eclipse/checkout-betaflight-009.PNG)
Edit the path variable in *C/C++ Build -> Environment*
![edit path](assets/building-in-eclipse/checkout-cleanflight-010.PNG)
![edit path](assets/building-in-eclipse/checkout-betaflight-010.PNG)
Append the full path to the relevant bin dir
![append bin dir](assets/building-in-eclipse/checkout-cleanflight-011.PNG)
![append bin dir](assets/building-in-eclipse/checkout-betaflight-011.PNG)
### Build
Choose project -> build all
![build all](assets/building-in-eclipse/checkout-cleanflight-013.PNG)
![build all](assets/building-in-eclipse/checkout-betaflight-013.PNG)
### Configure Debugging
Choose debug -> debug configurations
![debug configurations](assets/building-in-eclipse/checkout-cleanflight-014.PNG)
![debug configurations](assets/building-in-eclipse/checkout-betaflight-014.PNG)
Create a new OpenOCD configuration for the obj\main\cleanflight_XXX.elf application (this file is generated by the build step above)
Create a new OpenOCD configuration for the obj\main\betaflight_XXX.elf application (this file is generated by the build step above)
![debug configurations](assets/building-in-eclipse/checkout-cleanflight-015.PNG)
![debug configurations](assets/building-in-eclipse/checkout-betaflight-015.PNG)
Add the appropriate openocd board configuration parameter for your dev platform
![openocd target](assets/building-in-eclipse/checkout-cleanflight-016.PNG)
![openocd target](assets/building-in-eclipse/checkout-betaflight-016.PNG)
Add the target to your debug menu favourites
![debug favs](assets/building-in-eclipse/checkout-cleanflight-017.PNG)
![debug favs](assets/building-in-eclipse/checkout-betaflight-017.PNG)

View File

@ -1,6 +1,6 @@
# Building in Fedora
Assuming you already have wget and git available, you should be able to build Cleanflight on a fresh install of Fedora with the following commands (tested on F18, F20 and Ubuntu 14.04):
Assuming you already have wget and git available, you should be able to build Betaflight on a fresh install of Fedora with the following commands (tested on F18, F20 and Ubuntu 14.04):
```
wget http://distribute.atmel.no/tools/opensource/Atmel-ARM-GNU-Toolchain/4.8.4/arm-gnu-toolchain-4.8.4.371-linux.any.x86_64.tar.gz
@ -8,9 +8,9 @@ wget http://distribute.atmel.no/tools/opensource/Atmel-ARM-GNU-Toolchain/4.8.4/a
tar xf arm-gnu-toolchain-4.8.4.371-linux.any.x86_64.tar.gz
export PATH=$PATH:$PWD/arm-none-eabi/bin
git clone https://github.com/cleanflight/cleanflight.git
cd cleanflight
git clone https://github.com/betaflight/betaflight.git
cd betaflight
TARGET=NAZE make
```
This will create cleanflight_NAZE.hex in the obj folder.
This will create betaflight_NAZE.hex in the obj folder.

View File

@ -4,7 +4,7 @@ Building in Mac OS X can be accomplished in just a few steps:
* Install general development tools (clang, make, git)
* Install ARM GCC 4.9 series compiler
* Checkout Cleanflight sourcecode through git
* Checkout Betaflight sourcecode through git
* Build the code
## Install general development tools (clang, make, git)
@ -37,7 +37,7 @@ installation, open up XCode and enter its preferences menu. Go to the "downloads
## Install ARM GCC 4.9 series compiler
Cleanflight is built using the 4.9 series GCC compiler provided by the [GNU Tools for ARM Embedded Processors project][].
Betaflight is built using the 4.9 series GCC compiler provided by the [GNU Tools for ARM Embedded Processors project][].
Hit the "all downloads" link on the right side of the GNU Tools for ARM page to view [the older releases][]. Grab the
Mac installation tarball for the latest version in the 4.9 series (e.g. 4.9-2015q2). Move it somewhere useful
@ -73,29 +73,29 @@ If `arm-none-eabi-gcc` couldn't be found, go back and check that you entered the
[GNU Tools for ARM Embedded Processors project]: https://launchpad.net/gcc-arm-embedded
[the older releases]: https://launchpad.net/gcc-arm-embedded/+download
## Checkout CleanFlight sourcecode through git
## Checkout Betaflight sourcecode through git
Enter your development directory and clone the [Cleanflight repository][] using the "HTTPS clone URL" which is shown on
the right side of the Cleanflight GitHub page, like so:
Enter your development directory and clone the [Betaflight repository][] using the "HTTPS clone URL" which is shown on
the right side of the Betaflight GitHub page, like so:
```
git clone https://github.com/cleanflight/cleanflight.git
git clone https://github.com/betaflight/betaflight.git
```
This will download the entire Cleanflight repository for you into a new folder called "cleanflight".
This will download the entire betaflight repository for you into a new folder called "betaflight".
[CleanFlight repository]: https://github.com/cleanflight/cleanflight
[Betaflight repository]: https://github.com/betaflight/betaflight
## Build the code
Enter the cleanflight directory and run `make TARGET=NAZE` to build firmware for the Naze32. When the build completes,
the .hex firmware should be available as `obj/cleanflight_NAZE.hex` for you to flash using the Cleanflight
Enter the betaflight directory and run `make TARGET=NAZE` to build firmware for the Naze32. When the build completes,
the .hex firmware should be available as `obj/betaflight_NAZE.hex` for you to flash using the Betaflight
Configurator.
## Updating to the latest source
If you want to erase your local changes and update to the latest version of the Cleanflight source, enter your
cleanflight directory and run these commands to first erase your local changes, fetch and merge the latest
If you want to erase your local changes and update to the latest version of the Betaflight source, enter your
betaflight directory and run these commands to first erase your local changes, fetch and merge the latest
changes from the repository, then rebuild the firmware:
```

View File

@ -1,7 +1,7 @@
# Building in Ubuntu
Building for Ubuntu platform is remarkably easy. The only trick to understand is that the Ubuntu toolchain,
which they are downstreaming from Debian, is not compatible with Cleanflight. We suggest that you take an
which they are downstreaming from Debian, is not compatible with Betaflight. We suggest that you take an
alternative PPA from Terry Guo, found here:
https://launchpad.net/~terry.guo/+archive/ubuntu/gcc-arm-embedded
@ -44,23 +44,23 @@ sudo apt-get install gcc-arm-none-eabi=4.9.3.2014q4-0precise12
After the ARM toolchain from Terry is installed, you should be able to build from source.
```bash
cd src
git clone git@github.com:cleanflight/cleanflight.git
cd cleanflight
git clone git@github.com:betaflight/betaflight.git
cd betaflight
make TARGET=NAZE
```
You'll see a set of files being compiled, and finally linked, yielding both an ELF and then a HEX:
```
...
arm-none-eabi-size ./obj/main/cleanflight_NAZE.elf
arm-none-eabi-size ./obj/main/betaflight_NAZE.elf
text data bss dec hex filename
97164 320 11080 108564 1a814 ./obj/main/cleanflight_NAZE.elf
arm-none-eabi-objcopy -O ihex --set-start 0x8000000 obj/main/cleanflight_NAZE.elf obj/cleanflight_NAZE.hex
$ ls -la obj/cleanflight_NAZE.hex
-rw-rw-r-- 1 pim pim 274258 Jan 12 21:45 obj/cleanflight_NAZE.hex
97164 320 11080 108564 1a814 ./obj/main/betaflight_NAZE.elf
arm-none-eabi-objcopy -O ihex --set-start 0x8000000 obj/main/betaflight_NAZE.elf obj/betaflight_NAZE.hex
$ ls -la obj/betaflight_NAZE.hex
-rw-rw-r-- 1 pim pim 274258 Jan 12 21:45 obj/betaflight_NAZE.hex
```
You can use the Cleanflight-Configurator to flash the `obj/cleanflight_NAZE.hex` file.
You can use the Betaflight-Configurator to flash the `obj/betaflight_NAZE.hex` file.
## Bricked/Bad build?
@ -78,10 +78,10 @@ Make sure to remove `obj/` and `make clean`, before building again.
## Updating and rebuilding
Navigate to the local cleanflight repository and use the following steps to pull the latest changes and rebuild your version of cleanflight:
Navigate to the local betaflight repository and use the following steps to pull the latest changes and rebuild your version of betaflight:
```bash
cd src/cleanflight
cd src/betaflight
git reset --hard
git pull
make clean TARGET=NAZE

View File

@ -5,7 +5,7 @@
A new feature in Windows 10 allows any developer to quickly and easily run an entire linux subsystem in windows and access it via a bash terminal. This gives developers full use of the entire linux OS and all of the great existing linux tools and programs. When Bash for Windows is up and running it feels like you sshed into a full linux box, except the linux distro is actually running alongside windows locally.
If you use Bash on Windows you can easily build cleanflight exactly as you would for Ubuntu. (the linux distro running on Windows is Ubuntu Trusty)
If you use Bash on Windows you can easily build betaflight exactly as you would for Ubuntu. (the linux distro running on Windows is Ubuntu Trusty)
Setup for Bash on Windows is very easy and takes less than 5 minutes. [For instructions follow the official guide here.](https://msdn.microsoft.com/commandline/wsl/install_guide)
@ -61,24 +61,24 @@ add the "bin" subdirectory to the PATH Windows environment variable: ```%PATH%;C
![GNU ARM Toolchain Setup](assets/010.toolchain_path.png)
## Checkout and compile Cleanflight
## Checkout and compile Betaflight
Head over to the Cleanflight Github page and grab the URL of the GIT Repository: "https://github.com/cleanflight/cleanflight.git"
Head over to the Betaflight Github page and grab the URL of the GIT Repository: "https://github.com/betaflight/betaflight.git"
Open the Cygwin-Terminal, navigate to your development folder and use the git commandline to checkout the repository:
```bash
cd /cygdrive/c/dev
git clone https://github.com/cleanflight/cleanflight.git
git clone https://github.com/betaflight/betaflight.git
```
![GIT Checkout](assets/011.git_checkout.png)
![GIT Checkout](assets/012.git_checkout.png)
To compile your Cleanflight binaries, enter the cleanflight directory and build the project using the make command. You can append TARGET=[HARDWARE] if you want to build anything other than the default NAZE target:
To compile your Betaflight binaries, enter the Betaflight directory and build the project using the make command. You can append TARGET=[HARDWARE] if you want to build anything other than the default NAZE target:
```bash
cd cleanflight
cd betaflight
make TARGET=NAZE
```
@ -88,20 +88,20 @@ within few moments you should have your binary ready:
```bash
(...)
arm-none-eabi-size ./obj/main/cleanflight_NAZE.elf
arm-none-eabi-size ./obj/main/betaflight_NAZE.elf
text data bss dec hex filename
95388 308 10980 106676 1a0b4 ./obj/main/cleanflight_NAZE.elf
arm-none-eabi-objcopy -O ihex --set-start 0x8000000 obj/main/cleanflight_NAZE.elf obj/cleanflight_NAZE.hex
95388 308 10980 106676 1a0b4 ./obj/main/betaflight_NAZE.elf
arm-none-eabi-objcopy -O ihex --set-start 0x8000000 obj/main/betaflight_NAZE.elf obj/betaflight_NAZE.hex
```
You can use the Cleanflight-Configurator to flash the ```obj/cleanflight_NAZE.hex``` file.
You can use the Betaflight-Configurator to flash the ```obj/betaflight_NAZE.hex``` file.
## Updating and rebuilding
Navigate to the local cleanflight repository and use the following steps to pull the latest changes and rebuild your version of cleanflight:
Navigate to the local betaflight repository and use the following steps to pull the latest changes and rebuild your version of betaflight:
```bash
cd /cygdrive/c/dev/cleanflight
cd /cygdrive/c/dev/betaflight
git reset --hard
git pull
make clean TARGET=NAZE -j16 -l

View File

@ -255,6 +255,7 @@ SIZE_OPTIMISED_SRC := $(SIZE_OPTIMISED_SRC) \
drivers/compass/compass_fake.c \
drivers/compass/compass_hmc5883l.c \
drivers/compass/compass_qmc5883l.c \
drivers/compass/compass_lis3mdl.c \
drivers/display_ug2864hsweg01.c \
drivers/inverter.c \
drivers/light_ws2811strip.c \

View File

@ -448,7 +448,7 @@ static bool testBlackboxConditionUncached(FlightLogFieldCondition condition)
#endif
case FLIGHT_LOG_FIELD_CONDITION_RSSI:
return rxConfig()->rssi_channel > 0 || featureIsEnabled(FEATURE_RSSI_ADC);
return isRssiConfigured();
case FLIGHT_LOG_FIELD_CONDITION_NOT_LOGGING_EVERY_FRAME:
return blackboxConfig()->p_ratio != 1;

View File

@ -101,7 +101,9 @@ OSD_Entry menuOsdActiveElemsEntries[] =
{"PIT ANG", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_PITCH_ANGLE], 0},
{"ROL ANG", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_ROLL_ANGLE], 0},
{"HEADING", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_NUMERICAL_HEADING], 0},
#ifdef USE_VARIO
{"VARIO", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_NUMERICAL_VARIO], 0},
#endif
{"G-FORCE", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_G_FORCE], 0},
{"FLIP ARROW", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_FLIP_ARROW], 0},
{"BACK", OME_Back, NULL, NULL, 0},

View File

@ -50,9 +50,9 @@ bool unittest_outsideRealtimeGuardInterval;
float unittest_pidLuxFloat_lastErrorForDelta[3];
float unittest_pidLuxFloat_delta1[3];
float unittest_pidLuxFloat_delta2[3];
float unittest_pidLuxFloat_PTerm[3];
float unittest_pidLuxFloat_ITerm[3];
float unittest_pidLuxFloat_DTerm[3];
float unittest_pidLuxFloat_pterm[3];
float unittest_pidLuxFloat_iterm[3];
float unittest_pidLuxFloat_dterm[3];
#define SET_PID_LUX_FLOAT_LOCALS(axis) \
{ \
@ -66,15 +66,15 @@ float unittest_pidLuxFloat_DTerm[3];
unittest_pidLuxFloat_lastErrorForDelta[axis] = lastErrorForDelta[axis]; \
unittest_pidLuxFloat_delta1[axis] = delta1[axis]; \
unittest_pidLuxFloat_delta2[axis] = delta2[axis]; \
unittest_pidLuxFloat_PTerm[axis] = PTerm; \
unittest_pidLuxFloat_ITerm[axis] = ITerm; \
unittest_pidLuxFloat_DTerm[axis] = DTerm; \
unittest_pidLuxFloat_pterm[axis] = pterm; \
unittest_pidLuxFloat_iterm[axis] = iterm; \
unittest_pidLuxFloat_dterm[axis] = dterm; \
}
int32_t unittest_pidMultiWiiRewrite_lastErrorForDelta[3];
int32_t unittest_pidMultiWiiRewrite_PTerm[3];
int32_t unittest_pidMultiWiiRewrite_ITerm[3];
int32_t unittest_pidMultiWiiRewrite_DTerm[3];
int32_t unittest_pidMultiWiiRewrite_pterm[3];
int32_t unittest_pidMultiWiiRewrite_iterm[3];
int32_t unittest_pidMultiWiiRewrite_dterm[3];
#define SET_PID_MULTI_WII_REWRITE_LOCALS(axis) \
{ \
@ -84,9 +84,9 @@ int32_t unittest_pidMultiWiiRewrite_DTerm[3];
#define GET_PID_MULTI_WII_REWRITE_LOCALS(axis) \
{ \
unittest_pidMultiWiiRewrite_lastErrorForDelta[axis] = lastErrorForDelta[axis]; \
unittest_pidMultiWiiRewrite_PTerm[axis] = PTerm; \
unittest_pidMultiWiiRewrite_ITerm[axis] = ITerm; \
unittest_pidMultiWiiRewrite_DTerm[axis] = DTerm; \
unittest_pidMultiWiiRewrite_pterm[axis] = pterm; \
unittest_pidMultiWiiRewrite_iterm[axis] = iterm; \
unittest_pidMultiWiiRewrite_dterm[axis] = dterm; \
}
#else

View File

@ -225,14 +225,11 @@ static gyroSpiDetectFn_t gyroSpiDetectFnTable[] = {
static bool detectSPISensorsAndUpdateDetectionResult(gyroDev_t *gyro, const gyroDeviceConfig_t *config)
{
gyro->bus.bustype = BUSTYPE_SPI;
spiBusSetInstance(&gyro->bus, spiInstanceByDevice(SPI_CFG_TO_DEV(config->spiBus)));
// SPI instance may be NULL if the bus is non-existent
if (!gyro->bus.busdev_u.spi.instance) {
SPI_TypeDef *instance = spiInstanceByDevice(SPI_CFG_TO_DEV(config->spiBus));
if (!instance) {
return false;
}
spiBusSetInstance(&gyro->bus, instance);
gyro->bus.busdev_u.spi.csnPin = IOGetByTag(config->csnTag);
IOInit(gyro->bus.busdev_u.spi.csnPin, OWNER_GYRO_CS, RESOURCE_INDEX(config->index));

View File

@ -55,7 +55,7 @@ uint8_t icm20689SpiDetect(const busDevice_t *bus)
{
icm20689SpiInit(bus);
spiSetDivisor(bus->busdev_u.spi.instance, SPI_CLOCK_INITIALIZATON); //low speed
spiSetDivisor(bus->busdev_u.spi.instance, SPI_CLOCK_INITIALIZATION); //low speed
spiBusWriteRegister(bus, MPU_RA_PWR_MGMT_1, ICM20689_BIT_RESET);
@ -119,7 +119,7 @@ void icm20689GyroInit(gyroDev_t *gyro)
{
mpuGyroInit(gyro);
spiSetDivisor(gyro->bus.busdev_u.spi.instance, SPI_CLOCK_INITIALIZATON);
spiSetDivisor(gyro->bus.busdev_u.spi.instance, SPI_CLOCK_INITIALIZATION);
spiBusWriteRegister(&gyro->bus, MPU_RA_PWR_MGMT_1, ICM20689_BIT_RESET);
delay(100);

View File

@ -105,7 +105,7 @@ void mpu6000SpiGyroInit(gyroDev_t *gyro)
mpu6000AccAndGyroInit(gyro);
spiSetDivisor(gyro->bus.busdev_u.spi.instance, SPI_CLOCK_INITIALIZATON);
spiSetDivisor(gyro->bus.busdev_u.spi.instance, SPI_CLOCK_INITIALIZATION);
// Accel and Gyro DLPF Setting
spiBusWriteRegister(&gyro->bus, MPU6000_CONFIG, mpuGyroDLPF(gyro));
@ -128,7 +128,7 @@ void mpu6000SpiAccInit(accDev_t *acc)
uint8_t mpu6000SpiDetect(const busDevice_t *bus)
{
spiSetDivisor(bus->busdev_u.spi.instance, SPI_CLOCK_INITIALIZATON);
spiSetDivisor(bus->busdev_u.spi.instance, SPI_CLOCK_INITIALIZATION);
spiBusWriteRegister(bus, MPU_RA_PWR_MGMT_1, BIT_H_RESET);
@ -175,7 +175,7 @@ static void mpu6000AccAndGyroInit(gyroDev_t *gyro)
return;
}
spiSetDivisor(gyro->bus.busdev_u.spi.instance, SPI_CLOCK_INITIALIZATON);
spiSetDivisor(gyro->bus.busdev_u.spi.instance, SPI_CLOCK_INITIALIZATION);
// Device Reset
spiBusWriteRegister(&gyro->bus, MPU_RA_PWR_MGMT_1, BIT_H_RESET);

View File

@ -124,7 +124,7 @@ static void mpu9250AccAndGyroInit(gyroDev_t *gyro) {
return;
}
spiSetDivisor(gyro->bus.busdev_u.spi.instance, SPI_CLOCK_INITIALIZATON); //low speed for writing to slow registers
spiSetDivisor(gyro->bus.busdev_u.spi.instance, SPI_CLOCK_INITIALIZATION); //low speed for writing to slow registers
mpu9250SpiWriteRegister(&gyro->bus, MPU_RA_PWR_MGMT_1, MPU9250_BIT_RESET);
delay(50);
@ -152,7 +152,7 @@ static void mpu9250AccAndGyroInit(gyroDev_t *gyro) {
uint8_t mpu9250SpiDetect(const busDevice_t *bus)
{
spiSetDivisor(bus->busdev_u.spi.instance, SPI_CLOCK_INITIALIZATON); //low speed
spiSetDivisor(bus->busdev_u.spi.instance, SPI_CLOCK_INITIALIZATION); //low speed
mpu9250SpiWriteRegister(bus, MPU_RA_PWR_MGMT_1, MPU9250_BIT_RESET);
uint8_t attemptsRemaining = 20;

View File

@ -50,7 +50,7 @@
Flash M25p16 tolerates 20mhz, SPI_CLOCK_FAST should sit around 20 or less.
*/
typedef enum {
SPI_CLOCK_INITIALIZATON = 256,
SPI_CLOCK_INITIALIZATION = 256,
#if defined(STM32F4)
SPI_CLOCK_SLOW = 128, //00.65625 MHz
SPI_CLOCK_STANDARD = 8, //10.50000 MHz

View File

@ -0,0 +1,159 @@
/*
* This file is part of Cleanflight and Betaflight.
*
* Cleanflight and Betaflight are free software. You can redistribute
* this software and/or modify this software under the terms of the
* GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* Cleanflight and Betaflight are distributed in the hope that they
* will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software.
*
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdbool.h>
#include <stdint.h>
#include <math.h>
#include "platform.h"
#if defined(USE_MAG_LIS3MDL)
#include "compass.h"
#include "drivers/time.h"
#include "common/axis.h"
#define LIS3MDL_MAG_I2C_ADDRESS 0x1E
#define LIS3MDL_DEVICE_ID 0x3D
#define LIS3MDL_REG_WHO_AM_I 0x0F
#define LIS3MDL_REG_CTRL_REG1 0x20
#define LIS3MDL_REG_CTRL_REG2 0x21
#define LIS3MDL_REG_CTRL_REG3 0x22
#define LIS3MDL_REG_CTRL_REG4 0x23
#define LIS3MDL_REG_CTRL_REG5 0x24
#define LIS3MDL_REG_STATUS_REG 0x27
#define LIS3MDL_REG_OUT_X_L 0x28
#define LIS3MDL_REG_OUT_X_H 0x29
#define LIS3MDL_REG_OUT_Y_L 0x2A
#define LIS3MDL_REG_OUT_Y_H 0x2B
#define LIS3MDL_REG_OUT_Z_L 0x2C
#define LIS3MDL_REG_OUT_Z_H 0x2D
#define LIS3MDL_TEMP_OUT_L 0x2E
#define LIS3MDL_TEMP_OUT_H 0x2F
#define LIS3MDL_INT_CFG 0x30
#define LIS3MDL_INT_SRC 0x31
#define LIS3MDL_THS_L 0x32
#define LIS3MDL_THS_H 0x33
// CTRL_REG1
#define LIS3MDL_TEMP_EN 0x80 // Default 0
#define LIS3MDL_OM_LOW_POWER 0x00 // Default
#define LIS3MDL_OM_MED_PROF 0x20
#define LIS3MDL_OM_HI_PROF 0x40
#define LIS3MDL_OM_ULTRA_HI_PROF 0x60
#define LIS3MDL_DO_0_625 0x00
#define LIS3MDL_DO_1_25 0x04
#define LIS3MDL_DO_2_5 0x08
#define LIS3MDL_DO_5 0x0C
#define LIS3MDL_DO_10 0x10 // Default
#define LIS3MDL_DO_20 0x14
#define LIS3MDL_DO_40 0x18
#define LIS3MDL_DO_80 0x1C
#define LIS3MDL_FAST_ODR 0x02
// CTRL_REG2
#define LIS3MDL_FS_4GAUSS 0x00 // Default
#define LIS3MDL_FS_8GAUSS 0x20
#define LIS3MDL_FS_12GAUSS 0x40
#define LIS3MDL_FS_16GAUSS 0x60
#define LIS3MDL_REBOOT 0x08
#define LIS3MDL_SOFT_RST 0x04
// CTRL_REG3
#define LIS3MDL_LP 0x20 // Default 0
#define LIS3MDL_SIM 0x04 // Default 0
#define LIS3MDL_MD_CONTINUOUS 0x00 // Default
#define LIS3MDL_MD_SINGLE 0x01
#define LIS3MDL_MD_POWERDOWN 0x03
// CTRL_REG4
#define LIS3MDL_ZOM_LP 0x00 // Default
#define LIS3MDL_ZOM_MP 0x04
#define LIS3MDL_ZOM_HP 0x08
#define LIS3MDL_ZOM_UHP 0x0C
#define LIS3MDL_BLE 0x02 // Default 0
// CTRL_REG5
#define LIS3MDL_FAST_READ 0x80 // Default 0
#define LIS3MDL_BDU 0x40 // Default 0
static bool lis3mdlRead(magDev_t * mag, int16_t *magData)
{
uint8_t buf[6];
busDevice_t *busdev = &mag->busdev;
bool ack = busReadRegisterBuffer(busdev, LIS3MDL_REG_OUT_X_L, buf, 6);
if (!ack) {
return false;
}
magData[X] = (int16_t)(buf[1] << 8 | buf[0]) / 4;
magData[Y] = (int16_t)(buf[3] << 8 | buf[2]) / 4;
magData[Z] = (int16_t)(buf[5] << 8 | buf[4]) / 4;
return true;
}
static bool lis3mdlInit(magDev_t *mag)
{
busDevice_t *busdev = &mag->busdev;
busWriteRegister(busdev, LIS3MDL_REG_CTRL_REG2, LIS3MDL_FS_4GAUSS);
busWriteRegister(busdev, LIS3MDL_REG_CTRL_REG1, LIS3MDL_TEMP_EN | LIS3MDL_OM_ULTRA_HI_PROF | LIS3MDL_DO_80);
busWriteRegister(busdev, LIS3MDL_REG_CTRL_REG5, LIS3MDL_BDU);
busWriteRegister(busdev, LIS3MDL_REG_CTRL_REG4, LIS3MDL_ZOM_UHP);
busWriteRegister(busdev, LIS3MDL_REG_CTRL_REG3, 0x00);
delay(100);
return true;
}
bool lis3mdlDetect(magDev_t * mag)
{
busDevice_t *busdev = &mag->busdev;
uint8_t sig = 0;
if (busdev->bustype == BUSTYPE_I2C && busdev->busdev_u.i2c.address == 0) {
busdev->busdev_u.i2c.address = LIS3MDL_MAG_I2C_ADDRESS;
}
bool ack = busReadRegisterBuffer(&mag->busdev, LIS3MDL_REG_WHO_AM_I, &sig, 1);
if (!ack || sig != LIS3MDL_DEVICE_ID) {
return false;
}
mag->init = lis3mdlInit;
mag->read = lis3mdlRead;
return true;
}
#endif

View File

@ -0,0 +1,25 @@
/*
* This file is part of Cleanflight and Betaflight.
*
* Cleanflight and Betaflight are free software. You can redistribute
* this software and/or modify this software under the terms of the
* GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* Cleanflight and Betaflight are distributed in the hope that they
* will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software.
*
* If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "drivers/io_types.h"
bool lis3mdlDetect(magDev_t* mag);

View File

@ -50,6 +50,12 @@
#define SDCARD_TIMEOUT_INIT_MILLIS 200
#define SDCARD_MAX_CONSECUTIVE_FAILURES 8
/* SPI_CLOCK_INITIALIZATION (256) is the slowest (Spec calls for under 400KHz) */
#define SDCARD_SPI_INITIALIZATION_CLOCK_DIVIDER SPI_CLOCK_INITIALIZATION
/* Operational speed <= 25MHz */
#define SDCARD_SPI_FULL_SPEED_CLOCK_DIVIDER SPI_CLOCK_FAST
/* Break up 512-byte SD card sectors into chunks of this size when writing without DMA to reduce the peak overhead
* per call to sdcard_poll().
*/

View File

@ -30,9 +30,8 @@
#include "usb_io.h"
#include "sdcard.h"
#ifdef USE_USB_DETECT
static IO_t usbDetectPin = IO_NONE;
static IO_t usbDetectPin;
#endif
void usbCableDetectDeinit(void)
@ -47,9 +46,6 @@ void usbCableDetectDeinit(void)
void usbCableDetectInit(void)
{
#ifdef USE_USB_DETECT
#ifndef USB_DETECT_PIN
#define USB_DETECT_PIN NONE
#endif
usbDetectPin = IOGetByTag(IO_TAG(USB_DETECT_PIN));
IOInit(usbDetectPin, OWNER_USB_DETECT, 0);

View File

@ -577,16 +577,16 @@ bool processRx(timeUs_t currentTimeUs)
if (isAirmodeActive() && ARMING_FLAG(ARMED)) {
if (throttlePercent >= rxConfig()->airModeActivateThreshold) {
airmodeIsActivated = true; // Prevent Iterm from being reset
airmodeIsActivated = true; // Prevent iterm from being reset
}
} else {
airmodeIsActivated = false;
}
/* In airmode Iterm should be prevented to grow when Low thottle and Roll + Pitch Centered.
This is needed to prevent Iterm winding on the ground, but keep full stabilisation on 0 throttle while in air */
/* In airmode iterm should be prevented to grow when Low thottle and Roll + Pitch Centered.
This is needed to prevent iterm winding on the ground, but keep full stabilisation on 0 throttle while in air */
if (throttleStatus == THROTTLE_LOW && !airmodeIsActivated) {
pidResetITerm();
pidResetIterm();
if (currentPidProfile->pidAtMinThrottle)
pidStabilisationState(PID_STABILISATION_ON);
else
@ -725,7 +725,6 @@ bool processRx(timeUs_t currentTimeUs)
#endif
if (!cliMode) {
updateAdjustmentStates();
processRcAdjustments(currentControlRateProfile);
}

View File

@ -56,6 +56,8 @@
#include "rx/rx.h"
#define ADJUSTMENT_RANGE_COUNT_INVALID -1
PG_REGISTER_ARRAY(adjustmentRange_t, MAX_ADJUSTMENT_RANGE_COUNT, adjustmentRanges, PG_ADJUSTMENT_RANGE_CONFIG, 1);
uint8_t pidAudioPositionToModeMap[7] = {
@ -75,6 +77,11 @@ uint8_t pidAudioPositionToModeMap[7] = {
static pidProfile_t *pidProfile;
static int activeAdjustmentCount = ADJUSTMENT_RANGE_COUNT_INVALID;
static uint8_t activeAdjustmentArray[MAX_ADJUSTMENT_RANGE_COUNT];
static int activeAbsoluteAdjustmentCount;
static uint8_t activeAbsoluteAdjustmentArray[MAX_ADJUSTMENT_RANGE_COUNT];
static void blackboxLogInflightAdjustmentEvent(adjustmentFunction_e adjustmentFunction, int32_t newValue)
{
#ifndef USE_BLACKBOX
@ -664,6 +671,38 @@ static uint8_t applySelectAdjustment(adjustmentFunction_e adjustmentFunction, ui
return position;
}
static void calcActiveAdjustmentRanges(void)
{
adjustmentRange_t defaultAdjustmentRange;
memset(&defaultAdjustmentRange, 0, sizeof(defaultAdjustmentRange));
activeAdjustmentCount = 0;
activeAbsoluteAdjustmentCount = 0;
for (int i = 0; i < MAX_ADJUSTMENT_RANGE_COUNT; i++) {
const adjustmentRange_t * const adjustmentRange = adjustmentRanges(i);
if (memcmp(adjustmentRange, &defaultAdjustmentRange, sizeof(defaultAdjustmentRange)) != 0) {
if (adjustmentRange->adjustmentCenter == 0) {
activeAdjustmentArray[activeAdjustmentCount++] = i;
} else {
activeAbsoluteAdjustmentArray[activeAbsoluteAdjustmentCount++] = i;
}
}
}
}
static void updateAdjustmentStates(void)
{
for (int index = 0; index < activeAdjustmentCount; index++) {
const adjustmentRange_t * const adjustmentRange = adjustmentRanges(activeAdjustmentArray[index]);
// Only use slots if center value has not been specified, otherwise apply values directly (scaled) from aux channel
if (isRangeActive(adjustmentRange->auxChannelIndex, &adjustmentRange->range) &&
(adjustmentRange->adjustmentCenter == 0)) {
const adjustmentConfig_t *adjustmentConfig = &defaultAdjustmentConfigs[adjustmentRange->adjustmentFunction - ADJUSTMENT_FUNCTION_CONFIG_INDEX_OFFSET];
configureAdjustment(adjustmentRange->adjustmentIndex, adjustmentRange->auxSwitchChannelIndex, adjustmentConfig);
}
}
}
#define RESET_FREQUENCY_2HZ (1000 / 2)
void processRcAdjustments(controlRateConfig_t *controlRateConfig)
@ -674,6 +713,13 @@ void processRcAdjustments(controlRateConfig_t *controlRateConfig)
const bool canUseRxData = rxIsReceivingSignal();
// Recalculate the new active adjustments if required
if (activeAdjustmentCount == ADJUSTMENT_RANGE_COUNT_INVALID) {
calcActiveAdjustmentRanges();
}
updateAdjustmentStates();
// Process Increment/Decrement adjustments
for (int adjustmentIndex = 0; adjustmentIndex < MAX_SIMULTANEOUS_ADJUSTMENT_COUNT; adjustmentIndex++) {
adjustmentState_t *adjustmentState = &adjustmentStates[adjustmentIndex];
@ -741,9 +787,9 @@ void processRcAdjustments(controlRateConfig_t *controlRateConfig)
}
// Process Absolute adjustments
for (int index = 0; index < MAX_ADJUSTMENT_RANGE_COUNT; index++) {
for (int i = 0; i < activeAbsoluteAdjustmentCount; i++) {
static int16_t lastRcData[MAX_ADJUSTMENT_RANGE_COUNT] = { 0 };
int index = activeAbsoluteAdjustmentArray[i];
const adjustmentRange_t * const adjustmentRange = adjustmentRanges(index);
const uint8_t channelIndex = NON_AUX_CHANNEL_COUNT + adjustmentRange->auxSwitchChannelIndex;
const adjustmentConfig_t *adjustmentConfig = &defaultAdjustmentConfigs[adjustmentRange->adjustmentFunction - ADJUSTMENT_FUNCTION_CONFIG_INDEX_OFFSET];
@ -767,26 +813,14 @@ void resetAdjustmentStates(void)
memset(adjustmentStates, 0, sizeof(adjustmentStates));
}
void updateAdjustmentStates(void)
{
for (int index = 0; index < MAX_ADJUSTMENT_RANGE_COUNT; index++) {
const adjustmentRange_t * const adjustmentRange = adjustmentRanges(index);
// Only use slots if center value has not been specified, otherwise apply values directly (scaled) from aux channel
if (isRangeActive(adjustmentRange->auxChannelIndex, &adjustmentRange->range) &&
(adjustmentRange->adjustmentCenter == 0)) {
const adjustmentConfig_t *adjustmentConfig = &defaultAdjustmentConfigs[adjustmentRange->adjustmentFunction - ADJUSTMENT_FUNCTION_CONFIG_INDEX_OFFSET];
configureAdjustment(adjustmentRange->adjustmentIndex, adjustmentRange->auxSwitchChannelIndex, adjustmentConfig);
}
}
}
void useAdjustmentConfig(pidProfile_t *pidProfileToUse)
{
pidProfile = pidProfileToUse;
}
#if defined(USE_OSD) && defined(USE_OSD_ADJUSTMENTS)
const char *getAdjustmentsRangeName(void) {
const char *getAdjustmentsRangeName(void)
{
if (adjustmentRangeNameIndex > 0) {
return &adjustmentLabels[adjustmentRangeNameIndex - 1][0];
} else {
@ -794,7 +828,13 @@ const char *getAdjustmentsRangeName(void) {
}
}
int getAdjustmentsRangeValue(void) {
int getAdjustmentsRangeValue(void)
{
return adjustmentRangeValue;
}
#endif
void activeAdjustmentRangeReset(void)
{
activeAdjustmentCount = ADJUSTMENT_RANGE_COUNT_INVALID;
}

View File

@ -109,10 +109,10 @@ typedef struct adjustmentState_s {
#endif
void resetAdjustmentStates(void);
void updateAdjustmentStates(void);
struct controlRateConfig_s;
void processRcAdjustments(struct controlRateConfig_s *controlRateConfig);
struct pidProfile_s;
void useAdjustmentConfig(struct pidProfile_s *pidProfileToUse);
const char *getAdjustmentsRangeName(void);
int getAdjustmentsRangeValue(void);
void activeAdjustmentRangeReset(void);

View File

@ -111,14 +111,12 @@ quaternion offset = QUATERNION_INITIALIZE;
// absolute angle inclination in multiple of 0.1 degree 180 deg = 1800
attitudeEulerAngles_t attitude = EULER_INITIALIZE;
PG_REGISTER_WITH_RESET_TEMPLATE(imuConfig_t, imuConfig, PG_IMU_CONFIG, 0);
PG_REGISTER_WITH_RESET_TEMPLATE(imuConfig_t, imuConfig, PG_IMU_CONFIG, 1);
PG_RESET_TEMPLATE(imuConfig_t, imuConfig,
.dcm_kp = 2500, // 1.0 * 10000
.dcm_ki = 0, // 0.003 * 10000
.small_angle = 25,
.accDeadband = {.xy = 40, .z= 40},
.acc_unarmedcal = 1
);
STATIC_UNIT_TESTED void imuComputeRotationMatrix(void){
@ -159,7 +157,6 @@ void imuConfigure(uint16_t throttle_correction_angle, uint8_t throttle_correctio
{
imuRuntimeConfig.dcm_kp = imuConfig()->dcm_kp / 10000.0f;
imuRuntimeConfig.dcm_ki = imuConfig()->dcm_ki / 10000.0f;
imuRuntimeConfig.acc_unarmedcal = imuConfig()->acc_unarmedcal;
imuRuntimeConfig.small_angle = imuConfig()->small_angle;
fc_acc = calculateAccZLowPassFilterRCTimeConstant(5.0f); // Set to fix value

View File

@ -56,17 +56,10 @@ typedef union {
extern attitudeEulerAngles_t attitude;
typedef struct accDeadband_s {
uint8_t xy; // set the acc deadband for xy-Axis
uint8_t z; // set the acc deadband for z-Axis, this ignores small accelerations
} accDeadband_t;
typedef struct imuConfig_s {
uint16_t dcm_kp; // DCM filter proportional gain ( x 10000)
uint16_t dcm_ki; // DCM filter integral gain ( x 10000)
uint8_t small_angle;
uint8_t acc_unarmedcal; // turn automatic acc compensation on/off
accDeadband_t accDeadband;
} imuConfig_t;
PG_DECLARE(imuConfig_t, imuConfig);
@ -74,9 +67,7 @@ PG_DECLARE(imuConfig_t, imuConfig);
typedef struct imuRuntimeConfig_s {
float dcm_ki;
float dcm_kp;
uint8_t acc_unarmedcal;
uint8_t small_angle;
accDeadband_t accDeadband;
} imuRuntimeConfig_t;
void imuConfigure(uint16_t throttle_correction_angle, uint8_t throttle_correction_value);

View File

@ -320,9 +320,7 @@ const mixer_t mixers[] = {
FAST_RAM_ZERO_INIT float motorOutputHigh, motorOutputLow;
static FAST_RAM_ZERO_INIT float disarmMotorOutput, deadbandMotor3dHigh, deadbandMotor3dLow;
static FAST_RAM_ZERO_INIT uint16_t rcCommand3dDeadBandLow;
static FAST_RAM_ZERO_INIT uint16_t rcCommand3dDeadBandHigh;
static FAST_RAM_ZERO_INIT float rcCommandThrottleRange, rcCommandThrottleRange3dLow, rcCommandThrottleRange3dHigh;
static FAST_RAM_ZERO_INIT float rcCommandThrottleRange;
uint8_t getMotorCount(void)
{
@ -401,12 +399,6 @@ void initEscEndpoints(void)
}
rcCommandThrottleRange = PWM_RANGE_MAX - rxConfig()->mincheck;
rcCommand3dDeadBandLow = rxConfig()->midrc - flight3DConfig()->deadband3d_throttle;
rcCommand3dDeadBandHigh = rxConfig()->midrc + flight3DConfig()->deadband3d_throttle;
rcCommandThrottleRange3dLow = rcCommand3dDeadBandLow - PWM_RANGE_MIN;
rcCommandThrottleRange3dHigh = PWM_RANGE_MAX - rcCommand3dDeadBandHigh;
}
void mixerInit(mixerMode_e mixerMode)
@ -528,10 +520,28 @@ static void calculateThrottleAndCurrentMotorEndpoints(timeUs_t currentTimeUs)
float currentThrottleInputRange = 0;
if (featureIsEnabled(FEATURE_3D)) {
uint16_t rcCommand3dDeadBandLow;
uint16_t rcCommand3dDeadBandHigh;
if (!ARMING_FLAG(ARMED)) {
rcThrottlePrevious = rxConfig()->midrc; // When disarmed set to mid_rc. It always results in positive direction after arming.
}
if (IS_RC_MODE_ACTIVE(BOX3D) || flight3DConfig()->switched_mode3d) {
// The min_check range is halved because the output throttle is scaled to 500us.
// So by using half of min_check we maintain the same low-throttle deadband
// stick travel as normal non-3D mode.
const int mincheckOffset = (rxConfig()->mincheck - PWM_RANGE_MIN) / 2;
rcCommand3dDeadBandLow = rxConfig()->midrc - mincheckOffset;
rcCommand3dDeadBandHigh = rxConfig()->midrc + mincheckOffset;
} else {
rcCommand3dDeadBandLow = rxConfig()->midrc - flight3DConfig()->deadband3d_throttle;
rcCommand3dDeadBandHigh = rxConfig()->midrc + flight3DConfig()->deadband3d_throttle;
}
const float rcCommandThrottleRange3dLow = rcCommand3dDeadBandLow - PWM_RANGE_MIN;
const float rcCommandThrottleRange3dHigh = PWM_RANGE_MAX - rcCommand3dDeadBandHigh;
if (rcCommand[THROTTLE] <= rcCommand3dDeadBandLow) {
// INVERTED
motorRangeMin = motorOutputLow;
@ -596,8 +606,8 @@ static void calculateThrottleAndCurrentMotorEndpoints(timeUs_t currentTimeUs)
currentThrottleInputRange = rcCommandThrottleRange3dHigh;
}
if (currentTimeUs - reversalTimeUs < 250000) {
// keep ITerm zero for 250ms after motor reversal
pidResetITerm();
// keep iterm zero for 250ms after motor reversal
pidResetIterm();
}
} else {
throttle = rcCommand[THROTTLE] - rxConfig()->mincheck + throttleAngleCorrection;

View File

@ -117,7 +117,7 @@ void resetPidProfile(pidProfile_t *pidProfile)
.pid = {
[PID_ROLL] = { 46, 45, 25, 60 },
[PID_PITCH] = { 50, 50, 27, 60 },
[PID_YAW] = { 65, 45, 0 , 60 },
[PID_YAW] = { 45, 100, 0, 100 },
[PID_LEVEL] = { 50, 50, 75, 0 },
[PID_MAG] = { 40, 0, 0, 0 },
},
@ -130,12 +130,12 @@ void resetPidProfile(pidProfile_t *pidProfile)
.dterm_notch_hz = 0,
.dterm_notch_cutoff = 0,
.dterm_filter_type = FILTER_PT1,
.itermWindupPointPercent = 100,
.itermWindupPointPercent = 40,
.vbatPidCompensation = 0,
.pidAtMinThrottle = PID_STABILISATION_ON,
.levelAngleLimit = 55,
.feedForwardTransition = 0,
.yawRateAccelLimit = 100,
.yawRateAccelLimit = 0,
.rateAccelLimit = 0,
.itermThrottleThreshold = 250,
.itermAcceleratorGain = 5000,
@ -150,7 +150,7 @@ void resetPidProfile(pidProfile_t *pidProfile)
.horizon_tilt_effect = 75,
.horizon_tilt_expert_mode = false,
.crash_limit_yaw = 200,
.itermLimit = 150,
.itermLimit = 300,
.throttle_boost = 5,
.throttle_boost_cutoff = 15,
.iterm_rotation = true,
@ -368,7 +368,7 @@ static FAST_RAM_ZERO_INIT pidCoefficient_t pidCoefficient[XYZ_AXIS_COUNT];
static FAST_RAM_ZERO_INIT float maxVelocity[XYZ_AXIS_COUNT];
static FAST_RAM_ZERO_INIT float feedForwardTransition;
static FAST_RAM_ZERO_INIT float levelGain, horizonGain, horizonTransition, horizonCutoffDegrees, horizonFactorRatio;
static FAST_RAM_ZERO_INIT float ITermWindupPointInv;
static FAST_RAM_ZERO_INIT float itermWindupPointInv;
static FAST_RAM_ZERO_INIT uint8_t horizonTiltExpertMode;
static FAST_RAM_ZERO_INIT timeDelta_t crashTimeLimitUs;
static FAST_RAM_ZERO_INIT timeDelta_t crashTimeDelayUs;
@ -389,13 +389,13 @@ static FAST_RAM_ZERO_INIT bool itermRotation;
static FAST_RAM_ZERO_INIT bool smartFeedforward;
#endif
#if defined(USE_ABSOLUTE_CONTROL)
static FAST_RAM_ZERO_INIT float axisError[XYZ_AXIS_COUNT];
STATIC_UNIT_TESTED FAST_RAM_ZERO_INIT float axisError[XYZ_AXIS_COUNT];
static FAST_RAM_ZERO_INIT float acGain;
static FAST_RAM_ZERO_INIT float acLimit;
static FAST_RAM_ZERO_INIT float acErrorLimit;
#endif
void pidResetITerm(void)
void pidResetIterm(void)
{
for (int axis = 0; axis < 3; axis++) {
pidData[axis].I = 0.0f;
@ -443,12 +443,10 @@ void pidInitConfig(const pidProfile_t *pidProfile)
horizonFactorRatio = (100 - pidProfile->horizon_tilt_effect) * 0.01f;
maxVelocity[FD_ROLL] = maxVelocity[FD_PITCH] = pidProfile->rateAccelLimit * 100 * dT;
maxVelocity[FD_YAW] = pidProfile->yawRateAccelLimit * 100 * dT;
ITermWindupPointInv = 0.0f;
itermWindupPointInv = 1.0f;
if (pidProfile->itermWindupPointPercent < 100) {
float ITermWindupPoint = (float)pidProfile->itermWindupPointPercent / 100.0f;
ITermWindupPointInv = 1.0f / (1.0f - ITermWindupPoint);
} else {
ITermWindupPointInv = 0.0f;
const float itermWindupPoint = pidProfile->itermWindupPointPercent / 100.0f;
itermWindupPointInv = 1.0f / (1.0f - itermWindupPoint);
}
itermAcceleratorGain = pidProfile->itermAcceleratorGain;
crashTimeLimitUs = pidProfile->crash_time * 1000;
@ -524,7 +522,7 @@ void pidCopyProfile(uint8_t dstPidProfileIndex, uint8_t srcPidProfileIndex)
}
// calculates strength of horizon leveling; 0 = none, 1.0 = most leveling
static float calcHorizonLevelStrength(void)
STATIC_UNIT_TESTED float calcHorizonLevelStrength(void)
{
// start with 1.0 at center stick, 0.0 at max stick deflection:
float horizonLevelStrength = 1.0f - MAX(getRcDeflectionAbs(FD_ROLL), getRcDeflectionAbs(FD_PITCH));
@ -579,7 +577,7 @@ static float calcHorizonLevelStrength(void)
return constrainf(horizonLevelStrength, 0, 1);
}
static float pidLevel(int axis, const pidProfile_t *pidProfile, const rollAndPitchTrims_t *angleTrim, float currentPidSetpoint) {
STATIC_UNIT_TESTED float pidLevel(int axis, const pidProfile_t *pidProfile, const rollAndPitchTrims_t *angleTrim, float currentPidSetpoint) {
// calculate error angle and limit the angle to the max inclination
// rcDeflection is in range [-1.0, 1.0]
float angle = pidProfile->levelAngleLimit * getRcDeflection(axis);
@ -634,8 +632,8 @@ static void handleCrashRecovery(
*errorRate = *currentPidSetpoint - gyroRate;
}
}
// reset ITerm, since accumulated error before crash is now meaningless
// and ITerm windup during crash recovery can be extreme, especially on yaw axis
// reset iterm, since accumulated error before crash is now meaningless
// and iterm windup during crash recovery can be extreme, especially on yaw axis
pidData[axis].I = 0.0f;
if (cmpTimeUs(currentTimeUs, crashDetectedAtUs) > crashTimeLimitUs
|| (getMotorMixRange() < 1.0f
@ -684,7 +682,7 @@ static void detectAndSetCrashRecovery(
}
}
static void rotateVector(float v[XYZ_AXIS_COUNT], float rotation[XYZ_AXIS_COUNT])
static void rotateVector(float v[XYZ_AXIS_COUNT], float rotation[XYZ_AXIS_COUNT])
{
// rotate v around rotation vector rotation
// rotation in radians, all elements must be small
@ -697,7 +695,7 @@ static void rotateVector(float v[XYZ_AXIS_COUNT], float rotation[XYZ_AXIS_COUNT]
}
}
static void rotateITermAndAxisError()
STATIC_UNIT_TESTED void rotateItermAndAxisError()
{
if (itermRotation
#if defined(USE_ABSOLUTE_CONTROL)
@ -841,7 +839,7 @@ void FAST_CODE applySmartFeedforward(int axis)
#endif // USE_SMART_FEEDFORWARD
#if defined(USE_ABSOLUTE_CONTROL)
static void applyAbsoluteControl(const int axis, const float gyroRate, const bool itermRelaxIsEnabled,
STATIC_UNIT_TESTED void applyAbsoluteControl(const int axis, const float gyroRate, const bool itermRelaxIsEnabled,
const float setpointLpf, const float setpointHpf,
float *currentPidSetpoint, float *itermErrorRate)
{
@ -883,7 +881,7 @@ static void applyAbsoluteControl(const int axis, const float gyroRate, const boo
#endif
#if defined(USE_ITERM_RELAX)
static void applyItermRelax(const int axis, const float ITerm,
STATIC_UNIT_TESTED void applyItermRelax(const int axis, const float iterm,
const float gyroRate, float *itermErrorRate, float *currentPidSetpoint)
{
const float setpointLpf = pt1FilterApply(&windupLpf[axis], *currentPidSetpoint);
@ -897,7 +895,7 @@ static void applyItermRelax(const int axis, const float ITerm,
const float itermRelaxFactor = 1 - setpointHpf / ITERM_RELAX_SETPOINT_THRESHOLD;
const bool isDecreasingI =
((ITerm > 0) && (*itermErrorRate < 0)) || ((ITerm < 0) && (*itermErrorRate > 0));
((iterm > 0) && (*itermErrorRate < 0)) || ((iterm < 0) && (*itermErrorRate > 0));
if ((itermRelax >= ITERM_RELAX_RP_INC) && isDecreasingI) {
// Do Nothing, use the precalculed itermErrorRate
} else if (itermRelaxType == ITERM_RELAX_SETPOINT && setpointHpf < ITERM_RELAX_SETPOINT_THRESHOLD) {
@ -931,7 +929,6 @@ void FAST_CODE pidController(const pidProfile_t *pidProfile, const rollAndPitchT
static float previousPidSetpoint[XYZ_AXIS_COUNT];
const float tpaFactor = getThrottlePIDAttenuation();
const float motorMixRange = getMotorMixRange();
#ifdef USE_YAW_SPIN_RECOVERY
const bool yawSpinActive = gyroYawSpinDetected();
@ -946,8 +943,8 @@ void FAST_CODE pidController(const pidProfile_t *pidProfile, const rollAndPitchT
// gradually scale back integration when above windup point
float dynCi = dT * itermAccelerator;
if (ITermWindupPointInv > 0) {
dynCi *= constrainf((1.0f - motorMixRange) * ITermWindupPointInv, 0.0f, 1.0f);
if (itermWindupPointInv > 1.0f) {
dynCi *= constrainf((1.0f - getMotorMixRange()) * itermWindupPointInv, 0.0f, 1.0f);
}
// Precalculate gyro deta for D-term here, this allows loop unrolling
@ -958,7 +955,7 @@ void FAST_CODE pidController(const pidProfile_t *pidProfile, const rollAndPitchT
gyroRateDterm[axis] = dtermLowpass2ApplyFn((filter_t *) &dtermLowpass2[axis], gyroRateDterm[axis]);
}
rotateITermAndAxisError();
rotateItermAndAxisError();
// ----------PID controller----------
for (int axis = FD_ROLL; axis <= FD_YAW; ++axis) {
@ -993,25 +990,25 @@ void FAST_CODE pidController(const pidProfile_t *pidProfile, const rollAndPitchT
pidProfile->crash_recovery, angleTrim, axis, currentTimeUs, gyroRate,
&currentPidSetpoint, &errorRate);
const float ITerm = pidData[axis].I;
const float iterm = pidData[axis].I;
float itermErrorRate = errorRate;
#if defined(USE_ITERM_RELAX)
applyItermRelax(axis, ITerm, gyroRate, &itermErrorRate, &currentPidSetpoint);
applyItermRelax(axis, iterm, gyroRate, &itermErrorRate, &currentPidSetpoint);
#endif
// --------low-level gyro-based PID based on 2DOF PID controller. ----------
// 2-DOF PID controller with optional filter on derivative term.
// b = 1 and only c (feedforward weight) can be tuned (amount derivative on measurement or error).
// -----calculate P component and add Dynamic Part based on stick input
// -----calculate P component
pidData[axis].P = pidCoefficient[axis].Kp * errorRate * tpaFactor;
if (axis == FD_YAW) {
pidData[axis].P = ptermYawLowpassApplyFn((filter_t *) &ptermYawLowpass, pidData[axis].P);
}
// -----calculate I component
pidData[axis].I = constrainf(ITerm + pidCoefficient[axis].Ki * itermErrorRate * dynCi, -itermLimit, itermLimit);
pidData[axis].I = constrainf(iterm + pidCoefficient[axis].Ki * itermErrorRate * dynCi, -itermLimit, itermLimit);
// -----calculate D component
if (pidCoefficient[axis].Kd > 0) {

View File

@ -23,6 +23,7 @@
#include <stdbool.h>
#include "common/time.h"
#include "common/filter.h"
#include "common/axis.h"
#include "pg/pg.h"
#define MAX_PID_PROCESS_DENOM 16
@ -105,7 +106,7 @@ typedef struct pidProfile_s {
pidf_t pid[PID_ITEM_COUNT];
uint8_t dterm_filter_type; // Filter selection for dterm
uint8_t itermWindupPointPercent; // Experimental ITerm windup threshold, percent motor saturation
uint8_t itermWindupPointPercent; // iterm windup threshold, percent motor saturation
uint16_t pidSumLimit;
uint16_t pidSumLimitYaw;
uint8_t pidAtMinThrottle; // Disable/Enable pids on zero throttle. Normally even without airmode P and D would be active.
@ -181,7 +182,7 @@ extern uint32_t targetPidLooptime;
extern float throttleBoost;
extern pt1Filter_t throttleLpf;
void pidResetITerm(void);
void pidResetIterm(void);
void pidStabilisationState(pidStabilisationState_e pidControllerState);
void pidSetItermAccelerator(float newItermAccelerator);
void pidInitFilters(const pidProfile_t *pidProfile);
@ -198,3 +199,17 @@ bool pidOsdAntiGravityActive(void);
bool pidOsdAntiGravityMode(void);
void pidSetAntiGravityState(bool newState);
bool pidAntiGravityEnabled(void);
#ifdef UNIT_TEST
#include "sensors/acceleration.h"
extern float axisError[XYZ_AXIS_COUNT];
void applyItermRelax(const int axis, const float iterm,
const float gyroRate, float *itermErrorRate, float *currentPidSetpoint);
void applyAbsoluteControl(const int axis, const float gyroRate, const bool itermRelaxIsEnabled,
const float setpointLpf, const float setpointHpf,
float *currentPidSetpoint, float *itermErrorRate);
void rotateItermAndAxisError();
float pidLevel(int axis, const pidProfile_t *pidProfile,
const rollAndPitchTrims_t *angleTrim, float currentPidSetpoint);
float calcHorizonLevelStrength(void);
#endif

View File

@ -22,6 +22,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include "build/debug.h"
@ -42,6 +43,28 @@ static int32_t estimatedAltitudeCm = 0; // in cm
#define BARO_UPDATE_FREQUENCY_40HZ (1000 * 25)
#ifdef USE_VARIO
static int16_t estimatedVario = 0; // in cm/s
int16_t calculateEstimatedVario(int32_t baroAlt, const uint32_t dTime) {
static float vel = 0;
static int32_t lastBaroAlt = 0;
int32_t baroVel = 0;
baroVel = (baroAlt - lastBaroAlt) * 1000000.0f / dTime;
lastBaroAlt = baroAlt;
baroVel = constrain(baroVel, -1500.0f, 1500.0f);
baroVel = applyDeadband(baroVel, 10.0f);
vel = vel * CONVERT_PARAMETER_TO_FLOAT(barometerConfig()->baro_cf_vel) + baroVel * (1.0f - CONVERT_PARAMETER_TO_FLOAT(barometerConfig()->baro_cf_vel));
int32_t vel_tmp = lrintf(vel);
vel_tmp = applyDeadband(vel_tmp, 5.0f);
return constrain(vel_tmp, SHRT_MIN, SHRT_MAX);
}
#endif
#if defined(USE_BARO) || defined(USE_GPS)
static bool altitudeOffsetSet = false;
@ -100,10 +123,16 @@ if (sensors(SENSOR_GPS) && STATE(GPS_FIX)) {
if (haveGpsAlt && haveBaroAlt) {
estimatedAltitudeCm = gpsAlt * gpsTrust + baroAlt * (1 - gpsTrust);
#ifdef USE_VARIO
estimatedVario = calculateEstimatedVario(baroAlt, dTime);
#endif
} else if (haveGpsAlt) {
estimatedAltitudeCm = gpsAlt;
} else if (haveBaroAlt) {
estimatedAltitudeCm = baroAlt;
#ifdef USE_VARIO
estimatedVario = calculateEstimatedVario(baroAlt, dTime);
#endif
}
DEBUG_SET(DEBUG_ALTITUDE, 0, (int32_t)(100 * gpsTrust));
@ -125,5 +154,9 @@ int32_t getEstimatedAltitudeCm(void)
// This should be removed or fixed, but it would require changing a lot of other things to get rid of.
int16_t getEstimatedVario(void)
{
#ifdef USE_VARIO
return estimatedVario;
#else
return 0;
#endif
}

View File

@ -25,4 +25,4 @@
bool isAltitudeOffset(void);
void calculateEstimatedAltitude(timeUs_t currentTimeUs);
int32_t getEstimatedAltitudeCm(void);
int16_t getEstimatedVario(void);
int16_t getEstimatedVario(void);

View File

@ -377,14 +377,18 @@ static void cliPrintLinef(const char *format, ...)
static void cliPrintErrorLinef(const char *format, ...)
{
cliPrint("###ERROR### ");
cliPrint("###");
va_list va;
va_start(va, format);
cliPrintfva(format, va);
va_end(va);
cliPrintLinefeed();
cliPrintLine("###");
}
static void cliPrintCorruptMessage(int value)
{
cliPrintf("%d ###CORRUPTED CONFIG###", value);
}
static void printValuePointer(const clivalue_t *var, const void *valuePointer, bool full)
{
@ -440,13 +444,21 @@ static void printValuePointer(const clivalue_t *var, const void *valuePointer, b
switch (var->type & VALUE_MODE_MASK) {
case MODE_DIRECT:
cliPrintf("%d", value);
if (full) {
cliPrintf(" %d %d", var->config.minmax.min, var->config.minmax.max);
if ((value < var->config.minmax.min) || (value > var->config.minmax.max)) {
cliPrintCorruptMessage(value);
} else {
cliPrintf("%d", value);
if (full) {
cliPrintf(" %d %d", var->config.minmax.min, var->config.minmax.max);
}
}
break;
case MODE_LOOKUP:
cliPrint(lookupTables[var->config.lookup.tableIndex].values[value]);
if (value < lookupTables[var->config.lookup.tableIndex].valueCount) {
cliPrint(lookupTables[var->config.lookup.tableIndex].values[value]);
} else {
cliPrintCorruptMessage(value);
}
break;
case MODE_BITSET:
if (value & 1 << var->config.bitpos) {
@ -689,12 +701,12 @@ static void cliPrompt(void)
static void cliShowParseError(void)
{
cliPrintErrorLinef("Parse error");
cliPrintErrorLinef("PARSE ERROR");
}
static void cliShowArgumentRangeError(char *name, int min, int max)
{
cliPrintErrorLinef("%s not between %d and %d", name, min, max);
cliPrintErrorLinef("%s NOT BETWEEN %d AND %d", name, min, max);
}
static const char *nextArg(const char *currentArg)
@ -845,7 +857,7 @@ static void cliRxFailsafe(char *cmdline)
);
}
} else {
cliShowArgumentRangeError("channel", 0, MAX_SUPPORTED_RC_CHANNEL_COUNT - 1);
cliShowArgumentRangeError("CHANNEL", 0, MAX_SUPPORTED_RC_CHANNEL_COUNT - 1);
}
}
}
@ -955,7 +967,7 @@ static void cliAux(char *cmdline)
mac->linkedTo
);
} else {
cliShowArgumentRangeError("index", 0, MAX_MODE_ACTIVATION_CONDITION_COUNT - 1);
cliShowArgumentRangeError("INDEX", 0, MAX_MODE_ACTIVATION_CONDITION_COUNT - 1);
}
}
}
@ -1318,6 +1330,9 @@ static void cliAdjustmentRange(char *cmdline)
ar->adjustmentScale = val;
validArgumentCount++;
}
activeAdjustmentRangeReset();
cliDumpPrintLinef(0, false, format,
i,
ar->adjustmentIndex,
@ -1331,7 +1346,7 @@ static void cliAdjustmentRange(char *cmdline)
);
} else {
cliShowArgumentRangeError("index", 0, MAX_ADJUSTMENT_RANGE_COUNT - 1);
cliShowArgumentRangeError("INDEX", 0, MAX_ADJUSTMENT_RANGE_COUNT - 1);
}
}
}
@ -1398,7 +1413,7 @@ static void cliMotorMix(char *cmdline)
len = strlen(ptr);
for (uint32_t i = 0; ; i++) {
if (mixerNames[i] == NULL) {
cliPrintErrorLinef("Invalid name");
cliPrintErrorLinef("INVALID NAME");
break;
}
if (strncasecmp(ptr, mixerNames[i], len) == 0) {
@ -1439,7 +1454,7 @@ static void cliMotorMix(char *cmdline)
printMotorMix(DUMP_MASTER, customMotorMixer(0), NULL);
}
} else {
cliShowArgumentRangeError("index", 0, MAX_SUPPORTED_MOTORS - 1);
cliShowArgumentRangeError("INDEX", 0, MAX_SUPPORTED_MOTORS - 1);
}
}
#endif
@ -1510,7 +1525,7 @@ static void cliRxRange(char *cmdline)
}
} else {
cliShowArgumentRangeError("channel", 0, NON_AUX_CHANNEL_COUNT - 1);
cliShowArgumentRangeError("CHANNEL", 0, NON_AUX_CHANNEL_COUNT - 1);
}
}
}
@ -1556,7 +1571,7 @@ static void cliLed(char *cmdline)
cliShowParseError();
}
} else {
cliShowArgumentRangeError("index", 0, LED_MAX_STRIP_LENGTH - 1);
cliShowArgumentRangeError("INDEX", 0, LED_MAX_STRIP_LENGTH - 1);
}
}
}
@ -1593,7 +1608,7 @@ static void cliColor(char *cmdline)
cliShowParseError();
}
} else {
cliShowArgumentRangeError("index", 0, LED_CONFIGURABLE_COLOR_COUNT - 1);
cliShowArgumentRangeError("INDEX", 0, LED_CONFIGURABLE_COLOR_COUNT - 1);
}
}
}
@ -1867,7 +1882,7 @@ static void cliServoMix(char *cmdline)
len = strlen(ptr);
for (uint32_t i = 0; ; i++) {
if (mixerNames[i] == NULL) {
cliPrintErrorLinef("Invalid name");
cliPrintErrorLinef("INVALID NAME");
break;
}
if (strncasecmp(ptr, mixerNames[i], len) == 0) {
@ -2223,7 +2238,7 @@ static void cliVtx(char *cmdline)
);
}
} else {
cliShowArgumentRangeError("index", 0, MAX_CHANNEL_ACTIVATION_CONDITION_COUNT - 1);
cliShowArgumentRangeError("INDEX", 0, MAX_CHANNEL_ACTIVATION_CONDITION_COUNT - 1);
}
}
}
@ -2250,13 +2265,13 @@ static void cliName(char *cmdline)
#if defined(USE_BOARD_INFO)
#define ERROR_MESSAGE "%s cannot be changed. Current value: '%s'"
#define ERROR_MESSAGE "%s CANNOT BE CHANGED. CURRENT VALUE: '%s'"
static void cliBoardName(char *cmdline)
{
const unsigned int len = strlen(cmdline);
if (len > 0 && boardInformationIsSet() && (len != strlen(getBoardName()) || strncmp(getBoardName(), cmdline, len))) {
cliPrintErrorLinef(ERROR_MESSAGE, "board_name", getBoardName());
cliPrintErrorLinef(ERROR_MESSAGE, "BOARD_NAME", getBoardName());
} else {
if (len > 0) {
setBoardName(cmdline);
@ -2270,7 +2285,7 @@ static void cliManufacturerId(char *cmdline)
{
const unsigned int len = strlen(cmdline);
if (len > 0 && boardInformationIsSet() && (len != strlen(getManufacturerId()) || strncmp(getManufacturerId(), cmdline, len))) {
cliPrintErrorLinef(ERROR_MESSAGE, "manufacturer_id", getManufacturerId());
cliPrintErrorLinef(ERROR_MESSAGE, "MANUFACTURER_ID", getManufacturerId());
} else {
if (len > 0) {
setManufacturerId(cmdline);
@ -2295,7 +2310,7 @@ static void cliSignature(char *cmdline)
uint8_t signature[SIGNATURE_LENGTH] = {0};
if (len > 0) {
if (len != 2 * SIGNATURE_LENGTH) {
cliPrintErrorLinef("Invalid length: %d (expected: %d)", len, 2 * SIGNATURE_LENGTH);
cliPrintErrorLinef("INVALID LENGTH: %d (EXPECTED: %d)", len, 2 * SIGNATURE_LENGTH);
return;
}
@ -2310,7 +2325,7 @@ static void cliSignature(char *cmdline)
if (end == &temp[BLOCK_SIZE]) {
signature[i] = result;
} else {
cliPrintErrorLinef("Invalid character found: %c", end[0]);
cliPrintErrorLinef("INVALID CHARACTER FOUND: %c", end[0]);
return;
}
@ -2321,7 +2336,7 @@ static void cliSignature(char *cmdline)
char signatureStr[SIGNATURE_LENGTH * 2 + 1] = {0};
if (len > 0 && signatureIsSet() && memcmp(signature, getSignature(), SIGNATURE_LENGTH)) {
writeSignature(signatureStr, getSignature());
cliPrintErrorLinef(ERROR_MESSAGE, "signature", signatureStr);
cliPrintErrorLinef(ERROR_MESSAGE, "SIGNATURE", signatureStr);
} else {
if (len > 0) {
setSignature(signature);
@ -2424,7 +2439,7 @@ static void cliFeature(char *cmdline)
for (uint32_t i = 0; ; i++) {
if (featureNames[i] == NULL) {
cliPrintErrorLinef("Invalid name");
cliPrintErrorLinef("INVALID NAME");
break;
}
@ -2505,7 +2520,7 @@ static void processBeeperCommand(char *cmdline, uint32_t *offFlags, const uint32
for (uint32_t i = 0; ; i++) {
if (i == beeperCount) {
cliPrintErrorLinef("Invalid name");
cliPrintErrorLinef("INVALID NAME");
break;
}
if (strncasecmp(cmdline, beeperNameForTableIndex(i), len) == 0 && beeperModeMaskForTableIndex(i) & (allowedFlags | BEEPER_GET_FLAG(BEEPER_ALL))) {
@ -2726,7 +2741,7 @@ static int parseOutputIndex(char *pch, bool allowAllEscs) {
} else if (allowAllEscs && outputIndex == ALL_MOTORS) {
cliPrintLinef("Using all outputs.");
} else {
cliPrintErrorLinef("Invalid output number. Range: 0 %d.", getMotorCount() - 1);
cliPrintErrorLinef("INVALID OUTPUT NUMBER. RANGE: 0 - %d.", getMotorCount() - 1);
return -1;
}
@ -2897,7 +2912,7 @@ void printEscInfo(const uint8_t *escInfoBuffer, uint8_t bytesRead)
}
}
} else {
cliPrintErrorLinef("Checksum Error.");
cliPrintErrorLinef("CHECKSUM ERROR.");
}
}
}
@ -2983,7 +2998,7 @@ static void cliDshotProg(char *cmdline)
cliPrintLinef("Command Sent: %d", command);
} else {
cliPrintErrorLinef("Invalid command. Range: 1 - %d.", DSHOT_MIN_THROTTLE - 1);
cliPrintErrorLinef("INVALID COMMAND. RANGE: 1 - %d.", DSHOT_MIN_THROTTLE - 1);
}
}
@ -3075,7 +3090,7 @@ static void cliMixer(char *cmdline)
for (uint32_t i = 0; ; i++) {
if (mixerNames[i] == NULL) {
cliPrintErrorLinef("Invalid name");
cliPrintErrorLinef("INVALID NAME");
return;
}
if (strncasecmp(cmdline, mixerNames[i], len) == 0) {
@ -3122,7 +3137,7 @@ static void cliMotor(char *cmdline)
if (index == 2) {
if (motorValue < PWM_RANGE_MIN || motorValue > PWM_RANGE_MAX) {
cliShowArgumentRangeError("value", 1000, 2000);
cliShowArgumentRangeError("VALUE", 1000, 2000);
} else {
uint32_t motorOutputValue = convertExternalToMotor(motorValue);
@ -3159,7 +3174,7 @@ static void cliPlaySound(char *cmdline)
if ((name=beeperNameForTableIndex(i)) != NULL)
break; //if name OK then play sound below
if (i == lastSoundIdx + 1) { //prevent infinite loop
cliPrintErrorLinef("Error playing sound");
cliPrintErrorLinef("ERROR PLAYING SOUND");
return;
}
}
@ -3349,7 +3364,7 @@ STATIC_UNIT_TESTED void cliGet(char *cmdline)
return;
}
cliPrintErrorLinef("Invalid name");
cliPrintErrorLinef("INVALID NAME");
}
static uint8_t getWordLength(char *bufBegin, char *bufEnd)
@ -3497,14 +3512,14 @@ STATIC_UNIT_TESTED void cliSet(char *cmdline)
cliPrintf("%s set to ", val->name);
cliPrintVar(val, 0);
} else {
cliPrintErrorLinef("Invalid value");
cliPrintErrorLinef("INVALID VALUE");
cliPrintVarRange(val);
}
return;
}
}
cliPrintErrorLinef("Invalid name");
cliPrintErrorLinef("INVALID NAME");
} else {
// no equals, check for matching variables.
cliGet(cmdline);
@ -3825,6 +3840,9 @@ const cliResourceValue_t resourceTable[] = {
DEFS( OWNER_RX_SPI_CS, PG_RX_SPI_CONFIG, rxSpiConfig_t, csnTag ),
#endif
DEFW( OWNER_GYRO_CS, PG_GYRO_DEVICE_CONFIG, gyroDeviceConfig_t, csnTag, 2 ),
#ifdef USE_USB_DETECT
DEFS( OWNER_USB_DETECT, PG_USB_CONFIG, usbDev_t, detectPin ),
#endif
};
#undef DEFS
@ -3982,7 +4000,7 @@ static void cliResource(char *cmdline)
pch = strtok_r(cmdline, " ", &saveptr);
for (resourceIndex = 0; ; resourceIndex++) {
if (resourceIndex >= ARRAYLEN(resourceTable)) {
cliPrintErrorLinef("Invalid");
cliPrintErrorLinef("INVALID");
return;
}
@ -3996,7 +4014,7 @@ static void cliResource(char *cmdline)
if (resourceTable[resourceIndex].maxIndex > 0 || index > 0) {
if (index <= 0 || index > MAX_RESOURCE_INDEX(resourceTable[resourceIndex].maxIndex)) {
cliShowArgumentRangeError("index", 1, MAX_RESOURCE_INDEX(resourceTable[resourceIndex].maxIndex));
cliShowArgumentRangeError("INDEX", 1, MAX_RESOURCE_INDEX(resourceTable[resourceIndex].maxIndex));
return;
}
index -= 1;
@ -4133,7 +4151,7 @@ static void cliTimer(char *cmdline)
}
if (timerIOIndex < 0) {
cliPrintErrorLinef("Index out of range.");
cliPrintErrorLinef("INDEX OUT OF RANGE.");
return;
}

View File

@ -23,6 +23,7 @@
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include "platform.h"
@ -889,7 +890,11 @@ static bool mspProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst)
#else
sbufWriteU32(dst, 0);
#endif
#ifdef USE_VARIO
sbufWriteU16(dst, getEstimatedVario());
#else
sbufWriteU16(dst, 0);
#endif
break;
case MSP_SONAR_ALTITUDE:
@ -1618,6 +1623,7 @@ static mspResult_e mspProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
} else {
return MSP_RESULT_ERROR;
}
activeAdjustmentRangeReset();
} else {
return MSP_RESULT_ERROR;
}

View File

@ -126,7 +126,7 @@ const char * const lookupTableBaroHardware[] = {
#if defined(USE_SENSOR_NAMES) || defined(USE_MAG)
// sync with magSensor_e
const char * const lookupTableMagHardware[] = {
"AUTO", "NONE", "HMC5883", "AK8975", "AK8963", "QMC5883"
"AUTO", "NONE", "HMC5883", "AK8975", "AK8963", "QMC5883", "LIS3MDL"
};
#endif
#if defined(USE_SENSOR_NAMES) || defined(USE_RANGEFINDER)
@ -763,9 +763,6 @@ const clivalue_t valueTable[] = {
{ "serial_update_rate_hz", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 100, 2000 }, PG_SERIAL_CONFIG, offsetof(serialConfig_t, serial_update_rate_hz) },
// PG_IMU_CONFIG
{ "accxy_deadband", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 100 }, PG_IMU_CONFIG, offsetof(imuConfig_t, accDeadband.xy) },
{ "accz_deadband", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 100 }, PG_IMU_CONFIG, offsetof(imuConfig_t, accDeadband.z) },
{ "acc_unarmedcal", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_IMU_CONFIG, offsetof(imuConfig_t, acc_unarmedcal) },
{ "imu_dcm_kp", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, 32000 }, PG_IMU_CONFIG, offsetof(imuConfig_t, dcm_kp) },
{ "imu_dcm_ki", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, 32000 }, PG_IMU_CONFIG, offsetof(imuConfig_t, dcm_ki) },
{ "small_angle", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 180 }, PG_IMU_CONFIG, offsetof(imuConfig_t, small_angle) },
@ -1012,7 +1009,9 @@ const clivalue_t valueTable[] = {
{ "osd_battery_usage_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_MAIN_BATT_USAGE]) },
{ "osd_disarmed_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_DISARMED]) },
{ "osd_nheading_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_NUMERICAL_HEADING]) },
#ifdef USE_VARIO
{ "osd_nvario_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_NUMERICAL_VARIO]) },
#endif
{ "osd_esc_tmp_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_ESC_TMP]) },
{ "osd_esc_rpm_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_ESC_RPM]) },
{ "osd_rtc_date_time_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_RTC_DATETIME]) },

View File

@ -968,7 +968,7 @@ static bool osdDrawSingleElement(uint8_t item)
tfp_sprintf(buff, "%c%03d", osdGetDirectionSymbolFromHeading(heading), heading);
break;
}
#ifdef USE_VARIO
case OSD_NUMERICAL_VARIO:
{
const int verticalSpeed = osdGetMetersToSelectedUnit(getEstimatedVario());
@ -976,6 +976,7 @@ static bool osdDrawSingleElement(uint8_t item)
tfp_sprintf(buff, "%c%01d.%01d", directionSymbol, abs(verticalSpeed / 100), abs((verticalSpeed % 100) / 10));
break;
}
#endif
#ifdef USE_ESC_SENSOR
case OSD_ESC_TMP:

View File

@ -20,28 +20,20 @@
#include "platform.h"
#if defined(USE_USB_ADVANCED_PROFILES)
#ifdef USE_VCP
#include "drivers/io.h"
#include "pg/pg_ids.h"
#include "usb.h"
#if !defined(USB_MSC_BUTTON_PIN)
#define USB_MSC_BUTTON_PIN NONE
#endif
#if defined(USE_USB_MSC_BUTTON_IPU)
#define MSC_BUTTON_IPU true
#else
#define MSC_BUTTON_IPU false
#endif
PG_REGISTER_WITH_RESET_TEMPLATE(usbDev_t, usbDevConfig, PG_USB_CONFIG, 0);
PG_RESET_TEMPLATE(usbDev_t, usbDevConfig,
.type = DEFAULT,
.mscButtonPin = IO_TAG(USB_MSC_BUTTON_PIN),
.mscButtonUsePullup = MSC_BUTTON_IPU,
.detectPin = IO_TAG(USB_DETECT_PIN),
);
#endif

View File

@ -33,6 +33,7 @@ typedef struct usbDev_s {
uint8_t type;
ioTag_t mscButtonPin;
uint8_t mscButtonUsePullup;
ioTag_t detectPin;
} usbDev_t;
PG_DECLARE(usbDev_t, usbDevConfig);

View File

@ -33,12 +33,10 @@
* Number of channels: 16
*
* Connect as follows:
* Jeti EX Bus -> Serial RX (connect directly)
* Serial TX -> Resistor(2k4) ->Serial RX
* In jeti pdf it is different, but if the resistor breaks, the receiver continues to operate.
*
* Jeti EX Bus -> Serial TX (connect directly)
*/
#include <stdbool.h>
#include <stdint.h>
@ -49,8 +47,6 @@
#include "build/build_config.h"
#include "build/debug.h"
#include "pg/rx.h"
#include "common/utils.h"
#include "drivers/time.h"
@ -278,9 +274,8 @@ bool jetiExBusInit(const rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfi
NULL,
JETIEXBUS_BAUDRATE,
MODE_RXTX,
JETIEXBUS_OPTIONS | (rxConfig->serialrx_inverted ? SERIAL_INVERTED : 0) | (rxConfig->halfDuplex ? SERIAL_BIDIR : 0)
JETIEXBUS_OPTIONS | (rxConfig->serialrx_inverted ? SERIAL_INVERTED : 0) | SERIAL_BIDIR
);
serialSetMode(jetiExBusPort, MODE_RX);
return jetiExBusPort != NULL;
}
#endif // SERIAL_RX
#endif // SERIAL_RX

View File

@ -697,3 +697,8 @@ uint16_t rxGetRefreshRate(void)
{
return rxRuntimeConfig.rxRefreshRate;
}
bool isRssiConfigured(void)
{
return rssiSource != RSSI_SOURCE_NONE;
}

View File

@ -166,6 +166,7 @@ void setRssiMsp(uint8_t newMspRssi);
void updateRSSI(timeUs_t currentTimeUs);
uint16_t getRssi(void);
uint8_t getRssiPercent(void);
bool isRssiConfigured(void);
void resetAllRxChannelRangeConfigurations(rxChannelRangeConfig_t *rxChannelRangeConfig);

View File

@ -38,6 +38,7 @@
#include "drivers/compass/compass_fake.h"
#include "drivers/compass/compass_hmc5883l.h"
#include "drivers/compass/compass_qmc5883l.h"
#include "drivers/compass/compass_lis3mdl.h"
#include "drivers/io.h"
#include "drivers/light_led.h"
@ -183,6 +184,22 @@ bool compassDetect(magDev_t *dev)
#endif
FALLTHROUGH;
case MAG_LIS3MDL:
#if defined(USE_MAG_LIS3MDL)
if (busdev->bustype == BUSTYPE_I2C) {
busdev->busdev_u.i2c.address = compassConfig()->mag_i2c_address;
}
if (lis3mdlDetect(dev)) {
#ifdef MAG_LIS3MDL_ALIGN
dev->magAlign = MAG_LIS3MDL_ALIGN;
#endif
magHardware = MAG_LIS3MDL;
break;
}
#endif
FALLTHROUGH;
case MAG_QMC5883:
#ifdef USE_MAG_QMC5883
if (busdev->bustype == BUSTYPE_I2C) {

View File

@ -34,7 +34,8 @@ typedef enum {
MAG_HMC5883 = 2,
MAG_AK8975 = 3,
MAG_AK8963 = 4,
MAG_QMC5883 = 5
MAG_QMC5883 = 5,
MAG_LIS3MDL = 6
} magSensor_e;
typedef struct mag_s {

View File

@ -38,7 +38,7 @@
#define LED0_PIN PC13
#define USE_BEEPER
#define BEEPER NONE
#define BEEPER_PIN NONE
#define BEEPER_INVERTED
#define USE_ACC
@ -67,6 +67,7 @@
#define USE_MAG
#define USE_MAG_HMC5883
#define USE_MAG_LIS3MDL
#define USE_BARO
#define USE_BARO_SPI_BMP280

View File

@ -17,4 +17,5 @@ TARGET_SRC = \
drivers/barometer/barometer_bmp280.c \
drivers/barometer/barometer_ms5611.c \
drivers/compass/compass_hmc5883l.c \
drivers/compass/compass_lis3mdl.c \
drivers/max7456.c

View File

@ -71,7 +71,6 @@
#define USE_UART1
#define UART1_RX_PIN PA10
#define UART1_AHB1_PERIPHERALS RCC_AHB1Periph_DMA2
#define USE_UART2
#define UART2_RX_PIN PA3

View File

@ -59,6 +59,7 @@
#define USE_MAG_HMC5883
#define USE_MAG_QMC5883
#define USE_MAG_AK8963
#define USE_MAG_LIS3MDL
#define MAG_AK8963_ALIGN CW180_DEG_FLIP
@ -67,18 +68,10 @@
#define USE_BARO_BMP280
#define USE_SDCARD
#define SDCARD_DETECT_INVERTED
#define SDCARD_DETECT_PIN PB11
#define SDCARD_SPI_INSTANCE SPI2
#define SDCARD_SPI_CS_PIN PB10
// SPI2 is on the APB1 bus whose clock runs at 84MHz. Divide to under 400kHz for init:
#define SDCARD_SPI_INITIALIZATION_CLOCK_DIVIDER 256 // 328kHz
// Divide to under 25MHz for normal operation:
#define SDCARD_SPI_FULL_SPEED_CLOCK_DIVIDER 4 // 21MHz
#define SDCARD_DMA_CHANNEL_TX DMA1_Stream4
#define SDCARD_DMA_CHANNEL 0

View File

@ -8,5 +8,6 @@ TARGET_SRC = \
drivers/barometer/barometer_ms5611.c \
drivers/compass/compass_ak8963.c \
drivers/compass/compass_hmc5883l.c \
drivers/compass/compass_qmc5883l.c
drivers/compass/compass_qmc5883l.c \
drivers/compass/compass_lis3mdl.c

View File

@ -59,6 +59,7 @@
#define USE_MAG_QMC5883
#define USE_MAG_AK8963
#define USE_MAG_SPI_AK8963
#define USE_MAG_LIS3MDL
#define HMC5883_CS_PIN PC15
#define HMC5883_SPI_INSTANCE SPI3
@ -81,18 +82,10 @@
#define BMP280_SPI_INSTANCE SPI3
#define USE_SDCARD
#define SDCARD_DETECT_INVERTED
#define SDCARD_DETECT_PIN PB11
#define SDCARD_SPI_INSTANCE SPI2
#define SDCARD_SPI_CS_PIN PB10
// SPI2 is on the APB1 bus whose clock runs at 84MHz. Divide to under 400kHz for init:
#define SDCARD_SPI_INITIALIZATION_CLOCK_DIVIDER 256 // 422kHz
// Divide to under 25MHz for normal operation:
#define SDCARD_SPI_FULL_SPEED_CLOCK_DIVIDER 8 // 27MHz
#define SDCARD_DMA_STREAM_TX_FULL DMA1_Stream4
#define SDCARD_DMA_CHANNEL 0

View File

@ -9,4 +9,5 @@ TARGET_SRC = \
drivers/compass/compass_ak8963.c \
drivers/compass/compass_hmc5883l.c \
drivers/compass/compass_qmc5883l.c \
drivers/compass/compass_lis3mdl.c \
drivers/max7456.c

View File

@ -131,6 +131,7 @@
// MAG
#define USE_MAG
#define USE_MAG_AK8963
#define USE_MAG_LIS3MDL
#define MAG_AK8963_ALIGN CW0_DEG
#define USE_MAG_DATA_READY_SIGNAL
#define ENSURE_MAG_DATA_READY_IS_HIGH

View File

@ -22,6 +22,7 @@ TARGET_SRC = \
drivers/accgyro/accgyro_spi_mpu6500.c \
drivers/barometer/barometer_bmp280.c \
drivers/compass/compass_ak8963.c \
drivers/compass/compass_lis3mdl.c \
drivers/flash_m25p16.c \
drivers/max7456.c \
io/osd.c

View File

@ -137,14 +137,8 @@
#define USE_SDCARD
#define SDCARD_DETECT_INVERTED
#define SDCARD_DETECT_PIN PD3
#define SDCARD_SPI_INSTANCE SPI4
#define SDCARD_SPI_CS_PIN SPI4_NSS_PIN
#define SDCARD_SPI_INITIALIZATION_CLOCK_DIVIDER 256 // 422kHz
// Divide to under 25MHz for normal operation:
#define SDCARD_SPI_FULL_SPEED_CLOCK_DIVIDER 8 // 27MHz
#define SDCARD_DMA_STREAM_TX_FULL DMA2_Stream1
#define SDCARD_DMA_CHANNEL 4
@ -156,7 +150,7 @@
#define USE_ADC
#define VBAT_ADC_PIN PC0
#define CURRENT_METER_ADC_PIN PC1
#define RSSI_ADC_GPIO_PIN PC2
#define RSSI_ADC_PIN PC2
#define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT

View File

@ -62,17 +62,10 @@
#define MAX7456_DMA_IRQ_HANDLER_ID DMA1_ST0_HANDLER
#define USE_SDCARD
#define SDCARD_DETECT_PIN PC3
#define SDCARD_DETECT_INVERTED
#define SDCARD_SPI_INSTANCE SPI2
#define SDCARD_SPI_CS_PIN SPI2_NSS_PIN
// SPI2 is on the APB1 bus whose clock runs at 84MHz. Divide to under 400kHz for init:
#define SDCARD_SPI_INITIALIZATION_CLOCK_DIVIDER 256 // 328kHz
// Divide to under 25MHz for normal operation:
#define SDCARD_SPI_FULL_SPEED_CLOCK_DIVIDER 4 // 21MHz
#define SDCARD_DMA_CHANNEL_TX DMA1_Stream4
#define SDCARD_DMA_CHANNEL 0
@ -83,7 +76,6 @@
#define USE_UART1
#define UART1_RX_PIN PA10
#define UART1_TX_PIN PA9
#define UART1_AHB1_PERIPHERALS RCC_AHB1Periph_DMA2
//SerialRX
#define USE_UART2

View File

@ -120,16 +120,10 @@
#define MAX7456_RESTORE_CLK (SPI_CLOCK_FAST)
#define USE_SDCARD
#define SDCARD_DETECT_INVERTED
#define SDCARD_DETECT_PIN PC14
#define SDCARD_SPI_INSTANCE SPI2
#define SDCARD_SPI_CS_PIN SPI2_NSS_PIN
#define SDCARD_SPI_INITIALIZATION_CLOCK_DIVIDER 128
#define SDCARD_SPI_FULL_SPEED_CLOCK_DIVIDER 2
#define SDCARD_DMA_CHANNEL_TX DMA1_Channel5
#define DEFAULT_VOLTAGE_METER_SOURCE VOLTAGE_METER_ADC

View File

@ -58,6 +58,7 @@
#define USE_MAG
#define USE_MAG_HMC5883
#define USE_MAG_QMC5883
#define USE_MAG_LIS3MDL
#define USE_MAX7456
#define MAX7456_SPI_INSTANCE SPI2
@ -79,7 +80,6 @@
#define USE_UART1
#define UART1_RX_PIN PA10
#define UART1_TX_PIN PA9
#define UART1_AHB1_PERIPHERALS RCC_AHB1Periph_DMA2
#define USE_UART2
#define UART2_RX_PIN PA3

View File

@ -9,4 +9,5 @@ TARGET_SRC = \
drivers/barometer/barometer_ms5611.c \
drivers/compass/compass_hmc5883l.c \
drivers/compass/compass_qmc5883l.c \
drivers/compass/compass_lis3mdl.c \
drivers/max7456.c

View File

@ -37,6 +37,8 @@
#include "hardware_revision.h"
#define UART1_INVERTER PC9
void targetPreInit(void)
{
switch (hardwareRevision) {

View File

@ -41,9 +41,7 @@
#define BEEPER_INVERTED
#define INVERTER_PIN_UART6 PB15
//#define INVERTER_PIN_UART1 PC9
#define UART1_INVERTER PC9
//#define INVERTER_PIN_UART1 PC9 // Polarity depends on revision; handled in config.c
// MPU6500 interrupt
#define USE_EXTI
@ -67,6 +65,7 @@
#define USE_MAG_HMC5883
#define USE_MAG_QMC5883
//#define USE_MAG_AK8963
#define USE_MAG_LIS3MDL
#define HMC5883_I2C_INSTANCE I2CDEV_1
#define USE_BARO
@ -74,18 +73,10 @@
#define MS5611_I2C_INSTANCE I2CDEV_1
#define USE_SDCARD
#define SDCARD_DETECT_INVERTED
#define SDCARD_DETECT_PIN PD2
#define SDCARD_SPI_INSTANCE SPI3
#define SDCARD_SPI_CS_PIN PA15
// SPI2 is on the APB1 bus whose clock runs at 84MHz. Divide to under 400kHz for init:
#define SDCARD_SPI_INITIALIZATION_CLOCK_DIVIDER 256 // 328kHz
// Divide to under 25MHz for normal operation:
#define SDCARD_SPI_FULL_SPEED_CLOCK_DIVIDER 4 // 21MHz
#define SDCARD_DMA_CHANNEL_TX DMA1_Stream5
#define SDCARD_DMA_CHANNEL 0

View File

@ -6,5 +6,5 @@ TARGET_SRC = \
drivers/accgyro/accgyro_mpu6500.c \
drivers/barometer/barometer_ms5611.c \
drivers/compass/compass_hmc5883l.c \
drivers/compass/compass_qmc5883l.c
drivers/compass/compass_qmc5883l.c \
drivers/compass/compass_lis3mdl.c

View File

@ -46,16 +46,10 @@
#define SPI2_MOSI_PIN PB15
#define USE_SDCARD
#define SDCARD_DETECT_PIN PC14
#define SDCARD_SPI_INSTANCE SPI2
#define SDCARD_SPI_CS_PIN SPI2_NSS_PIN
// SPI2 is on the APB1 bus whose clock runs at 36MHz. Divide to under 400kHz for init:
#define SDCARD_SPI_INITIALIZATION_CLOCK_DIVIDER 128
// Divide to under 25MHz for normal operation:
#define SDCARD_SPI_FULL_SPEED_CLOCK_DIVIDER 2
// Note, this is the same DMA channel as UART1_RX. Luckily we don't use DMA for USART Rx.
#define SDCARD_DMA_CHANNEL_TX DMA1_Channel5
@ -64,7 +58,6 @@
#define USE_GYRO_MPU6050
//#define L3GD20_SPI SPI1
//#define L3GD20_CS_GPIO_CLK_PERIPHERAL RCC_AHBPeriph_GPIOE
//#define L3GD20_CS_GPIO GPIOE
//#define L3GD20_CS_PIN PE3

View File

@ -73,10 +73,6 @@
#define SDCARD_DETECT_PIN PB7
#define SDCARD_SPI_INSTANCE SPI2
#define SDCARD_SPI_CS_PIN SPI2_NSS_PIN
// SPI2 is on the APB1 bus whose clock runs at 84MHz. Divide to under 400kHz for init:
#define SDCARD_SPI_INITIALIZATION_CLOCK_DIVIDER 256 // 328kHz
// Divide to under 25MHz for normal operation:
#define SDCARD_SPI_FULL_SPEED_CLOCK_DIVIDER 4 // 21MHz
#define SDCARD_DMA_CHANNEL_TX DMA1_Stream4
#define SDCARD_DMA_CHANNEL 0
@ -93,7 +89,6 @@
#define USE_UART1
#define UART1_RX_PIN PA10
#define UART1_TX_PIN PA9
#define UART1_AHB1_PERIPHERALS RCC_AHB1Periph_DMA2
#define USE_UART3
#define UART3_RX_PIN PB11

View File

@ -68,9 +68,6 @@
#define SDCARD_DETECT_PIN PA8
#define SDCARD_SPI_INSTANCE SPI2
#define SDCARD_SPI_CS_PIN SPI2_NSS_PIN
#define SDCARD_SPI_INITIALIZATION_CLOCK_DIVIDER 256 // 422kHz
// Divide to under 25MHz for normal operation:
#define SDCARD_SPI_FULL_SPEED_CLOCK_DIVIDER 8 // 27MHz
#define SDCARD_DMA_STREAM_TX_FULL DMA1_Stream4
#define SDCARD_DMA_CHANNEL 0

View File

@ -80,7 +80,6 @@
#define USE_UART1
#define UART1_RX_PIN PB7
#define UART1_TX_PIN PB6
#define UART1_AHB1_PERIPHERALS RCC_AHB1Periph_DMA2
#define USE_UART2
#define UART2_RX_PIN PA3

View File

@ -0,0 +1,28 @@
/*
* This file is part of Cleanflight and Betaflight.
*
* Cleanflight and Betaflight are free software. You can redistribute
* this software and/or modify this software under the terms of the
* GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* Cleanflight and Betaflight are distributed in the hope that they
* will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software.
*
* If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#define BST_DEVICE_NAME "COLIBRI RACE"
#define BST_DEVICE_NAME_LENGTH 12
#define BST_DEVICE (BSTDEV_1)
/* Configure the CRC peripheral to use the polynomial x8 + x7 + x6 + x4 + x2 + 1 */
#define BST_CRC_POLYNOM 0xD5

View File

@ -10,6 +10,8 @@
#include "platform.h"
#ifdef USE_BST
#include "build/build_config.h"
#include "drivers/nvic.h"
@ -17,10 +19,9 @@
#include "drivers/io_impl.h"
#include "drivers/rcc.h"
#include "bst.h"
#include "bus_bst.h"
#ifdef USE_BST
#define NVIC_PRIO_BST_READ_DATA NVIC_BUILD_PRIORITY(1, 1)
#define BST_SHORT_TIMEOUT ((uint32_t)0x1000)

View File

@ -0,0 +1,49 @@
/*
* This file is part of Cleanflight and Betaflight.
*
* Cleanflight and Betaflight are free software. You can redistribute
* this software and/or modify this software under the terms of the
* GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* Cleanflight and Betaflight are distributed in the hope that they
* will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software.
*
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <stdbool.h>
#include "platform.h"
#ifdef USE_BST
#include "bst.h"
#include "bus_bst.h"
#include "pg/bus_i2c.h"
#include "pg/bus_spi.h"
// XXX Requires some additional work here.
// XXX Can't do this now without proper semantics about I2C on this target.
void targetBusInit(void)
{
#ifdef USE_SPI
spiPinConfigure(spiPinConfig(0));
#ifdef USE_SPI_DEVICE_1
spiInit(SPIDEV_1);
#endif
#endif
i2cHardwareConfigure(i2cConfig(0));
i2cInit(I2CDEV_2);
bstInit(BST_DEVICE);
}
#endif

View File

@ -52,22 +52,3 @@ const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = {
DEF_TIM(TIM16, CH1, PA6, TIM_USE_LED, 0), // PWM11 - PB15
};
// XXX Requires some additional work here.
// XXX Can't do this now without proper semantics about I2C on this target.
#ifdef USE_BST
void targetBusInit(void)
{
#ifdef USE_SPI
spiPinConfigure(spiPinConfig(0));
#ifdef USE_SPI_DEVICE_1
spiInit(SPIDEV_1);
#endif
#endif
i2cHardwareConfigure(i2cConfig(0));
i2cInit(I2CDEV_2);
bstInit(BST_DEVICE);
}
#endif

View File

@ -25,10 +25,8 @@
#undef USE_RTC_TIME
#define TARGET_BOARD_IDENTIFIER "CLBR"
#define BST_DEVICE_NAME "COLIBRI RACE"
#define BST_DEVICE_NAME_LENGTH 12
#define TARGET_BUS_INIT
#define TARGET_BUS_INIT
#define LED0_PIN PC15
#define LED1_PIN PC14
@ -106,9 +104,6 @@
#define I2C2_SDA_PIN PA10
#define USE_BST
#define BST_DEVICE (BSTDEV_1)
/* Configure the CRC peripheral to use the polynomial x8 + x7 + x6 + x4 + x2 + 1 */
#define BST_CRC_POLYNOM 0xD5
#define USE_ADC
#define ADC_INSTANCE ADC1

View File

@ -34,4 +34,6 @@ const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = {
// TIM2_UP, DMA1_CH2
DEF_TIM(TIM2, CH4, PA3, TIM_USE_MOTOR, 0),
DEF_TIM(TIM2, CH3, PA2, TIM_USE_MOTOR, 0),
DEF_TIM(TIM4, CH1, PB6, TIM_USE_MOTOR, 0), //PB6 for servo
DEF_TIM(TIM3, CH1, PB4, TIM_USE_LED, 0), //LED_STRIP
};

View File

@ -23,7 +23,10 @@
#if defined(CRAZYBEEF3FS)
#define TARGET_BOARD_IDENTIFIER "CBFS"
#define USBD_PRODUCT_STRING "CrazyBee F3 FS"
#else //CRAZYBEEF3FS
#elif defined(CRAZYBEEF3DX)
#define TARGET_BOARD_IDENTIFIER "CBDX"
#define USBD_PRODUCT_STRING "CrazyBee F3 DX"
#else
#define TARGET_BOARD_IDENTIFIER "CBFR"
#define USBD_PRODUCT_STRING "CrazyBee F3 FR"
#endif
@ -57,6 +60,7 @@
#define ENABLE_DSHOT_DMAR true
#define USE_LED_STRIP
#define LED0_PIN PB3
#define USE_BEEPER
#define BEEPER_PIN PC15
@ -76,10 +80,20 @@
#define ACC_1_ALIGN CW90_DEG
#define USE_VCP
#if defined(CRAZYBEEF3DX)
#define USE_UART2
#define USE_UART3
#define SERIAL_PORT_COUNT 3
#define UART2_TX_PIN PA14
#define UART2_RX_PIN PA15
#define UART3_TX_PIN PB10
#define UART3_RX_PIN PB11
#else
#define USE_UART3
#define SERIAL_PORT_COUNT 2
#define UART3_TX_PIN PB10
#define UART3_RX_PIN PB11
#endif
#define USE_SPI
#define USE_SPI_DEVICE_1
@ -97,6 +111,8 @@
#if defined(CRAZYBEEF3FS)
#define USE_RX_SPI
#define USE_RX_FLYSKY
#define RX_CHANNELS_AETR
#define DEFAULT_RX_FEATURE FEATURE_RX_SPI
#define RX_SPI_DEFAULT_PROTOCOL RX_SPI_A7105_FLYSKY_2A
#define FLYSKY_2A_CHANNEL_COUNT 14
#define RX_SPI_INSTANCE SPI2
@ -105,6 +121,13 @@
#define BINDPLUG_PIN PA9
#define USE_RX_FLYSKY_SPI_LED
#define RX_FLYSKY_SPI_LED_PIN PA10
#define DEFAULT_FEATURES (FEATURE_TELEMETRY | FEATURE_OSD | FEATURE_MOTOR_STOP)
#elif defined(CRAZYBEEF3DX)
#define DEFAULT_RX_FEATURE FEATURE_RX_SERIAL
#define SERIALRX_PROVIDER SERIALRX_SPEKTRUM2048
#define SERIALRX_UART SERIAL_PORT_USART3
#define RX_CHANNELS_TAER
#define DEFAULT_FEATURES (FEATURE_OSD | FEATURE_MOTOR_STOP)
#else
#define USE_RX_SPI
#define USE_RX_FRSKY_SPI_D
@ -120,6 +143,7 @@
#define RX_FRSKY_SPI_GDO_0_PIN PA8
#define RX_FRSKY_SPI_LED_PIN PA10
#define BINDPLUG_PIN PA9
#define DEFAULT_FEATURES (FEATURE_TELEMETRY | FEATURE_OSD | FEATURE_MOTOR_STOP)
#endif
#define USE_MAX7456
@ -136,11 +160,10 @@
#define ADC_INSTANCE ADC1
#define CURRENT_METER_SCALE_DEFAULT 2350
#define DEFAULT_FEATURES (FEATURE_TELEMETRY | FEATURE_OSD | FEATURE_RX_SPI | FEATURE_MOTOR_STOP)
#define USE_SERIAL_4WAY_BLHELI_INTERFACE
#define TARGET_IO_PORTA 0xffff
#define TARGET_IO_PORTB 0xffff
#define TARGET_IO_PORTC (BIT(13)|BIT(14)|BIT(15))
#define TARGET_IO_PORTF (BIT(0)|BIT(1)|BIT(4))
#define USABLE_TIMER_CHANNEL_COUNT 4
#define USED_TIMERS (TIM_N(2) | TIM_N(8))
#define USABLE_TIMER_CHANNEL_COUNT 6
#define USED_TIMERS (TIM_N(2) |TIM_N(3) |TIM_N(4) | TIM_N(8))

View File

@ -76,6 +76,7 @@
#define USE_MAG_AK8975
#define USE_MAG_HMC5883
#define USE_MAG_QMC5883
#define USE_MAG_LIS3MDL
//ON BOARD FLASH -----------------------------------
#define USE_SPI_DEVICE_2

View File

@ -9,4 +9,5 @@ TARGET_SRC = \
drivers/compass/compass_ak8975.c \
drivers/compass/compass_hmc5883l.c \
drivers/compass/compass_qmc5883l.c \
drivers/compass/compass_lis3mdl.c \
drivers/max7456.c

View File

@ -70,6 +70,7 @@
#define USE_MAG
#define USE_MAG_HMC5883
#define USE_MAG_LIS3MDL
#define USE_VCP
#define USE_UART1

View File

@ -8,6 +8,7 @@ TARGET_SRC = \
drivers/barometer/barometer_bmp280.c \
drivers/barometer/barometer_ms5611.c \
drivers/compass/compass_hmc5883l.c \
drivers/compass/compass_lis3mdl.c \
drivers/max7456.c

View File

@ -62,7 +62,6 @@
//#define USE_UART1
//#define UART1_RX_PIN PA10
//#define UART1_TX_PIN PA9
//#define UART1_AHB1_PERIPHERALS RCC_AHB1Periph_DMA2
/* RX1 */
#define USE_UART2

View File

@ -54,26 +54,18 @@
#define USE_MAG
#define USE_MAG_HMC5883
#define USE_MAG_QMC5883
#define USE_MAG_LIS3MDL
#define MAG_HMC5883_ALIGN CW90_DEG
#define USE_BARO
#define USE_BARO_MS5611
#define USE_SDCARD
#define SDCARD_SPI_INSTANCE SPI2
#define SDCARD_SPI_CS_PIN PE15
// SPI2 is on the APB1 bus whose clock runs at 84MHz. Divide to under 400kHz for init:
#define SDCARD_SPI_INITIALIZATION_CLOCK_DIVIDER 256 // 328kHz
// Divide to under 25MHz for normal operation:
#define SDCARD_SPI_FULL_SPEED_CLOCK_DIVIDER 4 // 21MHz
#define SDCARD_DMA_CHANNEL_TX DMA1_Stream3
#define SDCARD_DMA_CHANNEL 0
#define USE_VCP
#define USE_USB_DETECT
#define USB_DETECT_PIN PA9
@ -81,7 +73,6 @@
#define USE_UART1
#define UART1_RX_PIN PB7
#define UART1_TX_PIN PB6
#define UART1_AHB1_PERIPHERALS RCC_AHB1Periph_DMA2
#define USE_UART2
#define UART2_RX_PIN PD6

View File

@ -5,4 +5,5 @@ TARGET_SRC = \
drivers/accgyro/accgyro_spi_mpu6000.c \
drivers/barometer/barometer_ms5611.c \
drivers/compass/compass_hmc5883l.c \
drivers/compass/compass_qmc5883l.c
drivers/compass/compass_qmc5883l.c \
drivers/compass/compass_lis3mdl.c

View File

@ -106,18 +106,10 @@
// *************** SDCARD *****************************
#define USE_SDCARD
#define SDCARD_DETECT_INVERTED
#define SDCARD_DETECT_PIN PB7
#define SDCARD_SPI_INSTANCE SPI3
#define SDCARD_SPI_CS_PIN PB9
// SPI3 is on the APB1 bus whose clock runs at 84MHz. Divide to under 400kHz for init:
#define SDCARD_SPI_INITIALIZATION_CLOCK_DIVIDER 256 // 328kHz
// Divide to under 25MHz for normal operation:
#define SDCARD_SPI_FULL_SPEED_CLOCK_DIVIDER 4 // 21MHz
#define SDCARD_DMA_CHANNEL_TX DMA1_Stream5
#define SDCARD_DMA_CHANNEL 0

View File

@ -127,15 +127,11 @@
#define SPI1_MOSI_PIN PA7
#define USE_SDCARD
#define SDCARD_DETECT_INVERTED
#define SDCARD_DETECT_PIN PB5
#define SDCARD_SPI_INSTANCE SPI1
#define SDCARD_SPI_CS_PIN SPI1_NSS_PIN
#define SDCARD_SPI_INITIALIZATION_CLOCK_DIVIDER 256
#define SDCARD_SPI_FULL_SPEED_CLOCK_DIVIDER 4
#define DEFAULT_VOLTAGE_METER_SOURCE VOLTAGE_METER_ADC
#define DEFAULT_CURRENT_METER_SOURCE CURRENT_METER_NONE

View File

@ -67,9 +67,6 @@
#define SDCARD_DETECT_PIN PB7
#define SDCARD_SPI_INSTANCE SPI2
#define SDCARD_SPI_CS_PIN SPI2_NSS_PIN
#define SDCARD_SPI_INITIALIZATION_CLOCK_DIVIDER 256 // 328kHz
#define SDCARD_SPI_FULL_SPEED_CLOCK_DIVIDER 4 // 21MHz
#define SDCARD_DMA_CHANNEL_TX DMA1_Stream4
#define SDCARD_DMA_CHANNEL 0
@ -80,7 +77,6 @@
#define USE_UART1
#define UART1_RX_PIN PA10
#define UART1_TX_PIN PA9
#define UART1_AHB1_PERIPHERALS RCC_AHB1Periph_DMA2
#define USE_UART3
#define UART3_RX_PIN PB11

Some files were not shown because too many files have changed in this diff Show More