diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
deleted file mode 100755
index f4cb4b935d..0000000000
--- a/.github/ISSUE_TEMPLATE.md
+++ /dev/null
@@ -1,25 +0,0 @@
-### If your issue looks like a hardware fault or a configuration problem please don't raise an issue here.
-
-### Please consider using other user support options such as asking the manufacturer of the hardware you are using, [RCGroups](https://www.rcgroups.com/forums/showthread.php?t=2495732), [Slack](https://inavflight.signup.team) or other user support forums & groups (e.g. facebook).
-
-### Board and Version
-_Board name goes here. If you have a link where you've purchased the board - please include it_
-_Version of INAV used goes here_
-
-_Use CLI command `version` and put its output here_
-
-_If it's a custom-compiled firmware please mention this_
-
-### Behavior
-* _Describe the problem_
-* _Steps needed to reproduce the problem_
-* _Expected Results_
-* _Actual Results_
-
-_Is this a new feature request?_
-
-#### Blackbox logs/Config (.ZIP) where problem occurs
-_Go to CLI, execute `dump` command copy its output to [PasteBin](https://pastebin.com) and provide a link to a paste here.
-
-_Upload a zipped blackbox log (if available)_
-
diff --git a/.github/ISSUE_TEMPLATE/Bug_report.md b/.github/ISSUE_TEMPLATE/Bug_report.md
new file mode 100644
index 0000000000..9b5eb8b327
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/Bug_report.md
@@ -0,0 +1,32 @@
+---
+name: "\U0001F41B Bug report"
+about: Report an issue to help make INAV better
+
+---
+
+## Current Behavior
+
+
+## Steps to Reproduce
+
+1.
+2.
+3.
+4.
+
+## Expected behavior
+
+
+## Suggested solution(s)
+
+
+## Additional context
+
+
+
+---
+
+
+
+- FC Board name and vendor:
+- INAV version string:
diff --git a/.github/ISSUE_TEMPLATE/Feature_request.md b/.github/ISSUE_TEMPLATE/Feature_request.md
new file mode 100644
index 0000000000..28505816c5
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/Feature_request.md
@@ -0,0 +1,21 @@
+---
+name: "\U0001F680Feature request"
+about: Suggest a new feature for INAV
+
+---
+
+## Current Behavior
+
+
+## Desired Behavior
+
+
+## Suggested Solution
+
+
+
+## Who does this impact? Who is this for?
+
+
+## Additional context
+
diff --git a/.github/ISSUE_TEMPLATE/Question.md b/.github/ISSUE_TEMPLATE/Question.md
new file mode 100644
index 0000000000..1e2fa8c825
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/Question.md
@@ -0,0 +1,20 @@
+---
+name: "\U00002753Question"
+about: Have a question?
+
+---
+
+For immediate help, just ask your question on one of the following platforms:
+
+* [Telegram channel](https://t.me/INAVFlight)
+* [Facebook group](https://www.facebook.com/groups/INAVOfficial)
+* [RC Groups thread](https://www.rcgroups.com/forums/showthread.php?2495732-Cleanflight-iNav-%28navigation-rewrite%29-project)
+* [IRC channel](irc://irc.freenode.net/#inavflight)
+* [Slack channel](https://publicslack.com/slacks/inavflight/invites/new)
+
+You can also read public documentations or watch video tutorials:
+
+* [Official documentation](https://github.com/iNavFlight/inav/tree/master/docs)
+* [Official Wiki](https://github.com/iNavFlight/inav/wiki)
+* [Video series by Painless360](https://www.youtube.com/playlist?list=PLYsWjANuAm4qdXEGFSeUhOZ10-H8YTSnH)
+* [Video series by Paweł Spychalski](https://www.youtube.com/playlist?list=PLOUQ8o2_nCLloACrA6f1_daCjhqY2x0fB)
diff --git a/.travis.yml b/.travis.yml
index 18182d074f..4229593d89 100755
--- a/.travis.yml
+++ b/.travis.yml
@@ -28,7 +28,7 @@ before_install:
install:
- ./install-toolchain.sh
- - export TOOLCHAINPATH=$PWD/gcc-arm-none-eabi-6-2017-q2-update/bin
+ - export TOOLCHAINPATH=$PWD/gcc-arm-none-eabi-7-2018-q2-update/bin
- export PATH=$TOOLCHAINPATH:$PATH
before_script:
@@ -41,7 +41,7 @@ script: ./.travis.sh
cache:
apt: true
directories:
- - $PWD/gcc-arm-none-eabi-6-2017-q2-update
+ - $PWD/gcc-arm-none-eabi-7-2018-q2-update
notifications:
#slack: inavflight:UWRoWFJ4cbbpHXT8HJJlAPXa
diff --git a/CREDITS b/AUTHORS
similarity index 92%
rename from CREDITS
rename to AUTHORS
index de85d956d3..d9650a8421 100644
--- a/CREDITS
+++ b/AUTHORS
@@ -3,9 +3,11 @@ If you believe you should be on this list - feel free to open a PR updating it.
inclusion into this list please provide information about which part of code belongs to you.
Albert Kravcov
+Alberto GarcÃa Hierro
Alex Gorbatchev
Alex Zaitsev
Alexander Fedorov
+Alexey Stankevich
Andre Bernet
Andreas Tacke
Andrew Payne
@@ -30,6 +32,7 @@ Fredrik Steen
Gareth Wilkins
Gaël James
Gregor Ottmann
+Google LLC
Hyon Lim
James Harrison
Jan Staal
@@ -56,10 +59,12 @@ Max Winterstein
Michael Corcoran
Michael Hope
Michael Jakob
+Michel Pastor
Miha Valencic
Mikael Blomqvist
Moritz Ulrich
Moshen Chan
+Nathan Tsoi
Nicholas Sherlock
Paul Fertser
Paul Rogalinski
@@ -77,8 +82,10 @@ Samuel Brucksch
Scott Shawcroft
Sean Vig
Stefan Grufman
+Stefan Haubold
Steve Amor
Thomas Buck
+Tim Eckel
Trey Marc
Tuomas Kuosmanen
-Zap Andersson
\ No newline at end of file
+Zap Andersson
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000000..9da50525b6
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,46 @@
+# Contributor Covenant Code of Conduct
+
+## Our Pledge
+
+In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
+
+## Our Standards
+
+Examples of behavior that contributes to creating a positive environment include:
+
+* Using welcoming and inclusive language
+* Being respectful of differing viewpoints and experiences
+* Gracefully accepting constructive criticism
+* Focusing on what is best for the community
+* Showing empathy towards other community members
+
+Examples of unacceptable behavior by participants include:
+
+* The use of sexualized language or imagery and unwelcome sexual attention or advances
+* Trolling, insulting/derogatory comments, and personal or political attacks
+* Public or private harassment
+* Publishing others' private information, such as a physical or electronic address, without explicit permission
+* Other conduct which could reasonably be considered inappropriate in a professional setting
+
+## Our Responsibilities
+
+Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
+
+Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
+
+## Scope
+
+This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
+
+## Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
+
+Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
+
+[homepage]: http://contributor-covenant.org
+[version]: http://contributor-covenant.org/version/1/4/
\ No newline at end of file
diff --git a/Makefile b/Makefile
index ab74b50e35..093d2bd5ca 100644
--- a/Makefile
+++ b/Makefile
@@ -118,7 +118,7 @@ else
$(error Unknown target MCU specified.)
endif
-GROUP_1_TARGETS := ALIENFLIGHTF3 ALIENFLIGHTF4 AIRHEROF3 AIRHEROF3_QUAD COLIBRI_RACE LUX_RACE SPARKY REVO SPARKY2 COLIBRI FALCORE FF_F35_LIGHTNING FF_FORTINIF4 FF_PIKOF4 FF_PIKOF4OSD
+GROUP_1_TARGETS := ALIENFLIGHTF3 ALIENFLIGHTF4 AIRHEROF3 AIRHEROF3_QUAD COLIBRI_RACE LUX_RACE SPARKY REVO SPARKY2 COLIBRI KISSFC FALCORE FF_F35_LIGHTNING FF_FORTINIF4 FF_PIKOF4 FF_PIKOF4OSD
GROUP_2_TARGETS := SPRACINGF3 SPRACINGF3EVO SPRACINGF3EVO_1SS SPRACINGF3MINI SPRACINGF3NEO SPRACINGF4EVO CLRACINGF4AIR CLRACINGF4AIRV2 BEEROTORF4 BETAFLIGHTF3 BETAFLIGHTF4 PIKOBLX
GROUP_3_TARGETS := OMNIBUS AIRBOTF4 BLUEJAYF4 OMNIBUSF4 OMNIBUSF4PRO OMNIBUSF4V3 FIREWORKSV2 SPARKY2 MATEKF405 OMNIBUSF7 DYSF4PRO OMNIBUSF4PRO_LEDSTRIPM5 OMNIBUSF7NXT OMNIBUSF7V2 ASGARD32F4
GROUP_4_TARGETS := ANYFC ANYFCF7 ANYFCF7_EXTERNAL_BARO ANYFCM7 ALIENFLIGHTNGF7 PIXRACER YUPIF4 YUPIF4MINI YUPIF4R2 YUPIF7 MATEKF405SE MATEKF411 MATEKF722 MATEKF405OSD MATEKF405_SERVOS6
@@ -224,6 +224,7 @@ CFLAGS += $(ARCH_FLAGS) \
-Werror=switch \
-ffunction-sections \
-fdata-sections \
+ -fno-common \
$(DEVICE_FLAGS) \
-DUSE_STDPERIPH_DRIVER \
$(TARGET_FLAGS) \
diff --git a/docs/Cli.md b/docs/Cli.md
index 42199cde8d..41c19cdb38 100644
--- a/docs/Cli.md
+++ b/docs/Cli.md
@@ -205,16 +205,17 @@ After restoring it's always a good idea to `dump` or `diff` the settings once ag
| spektrum_sat_bind | 0 | 0 = disabled. Used to bind the spektrum satellite to RX |
| telemetry_switch | OFF | Which aux channel to use to change serial output & baud rate (MSP / Telemetry). It disables automatic switching to Telemetry when armed. |
| telemetry_inverted | OFF | Determines if the telemetry protocol default signal inversion is reversed. This should be OFF in most cases unless a custom or hacked RX is used. |
-| frsky_default_latitude | 0.000 | OpenTX needs a valid set of coordinates to show compass value. A fake value defined in this setting is sent while no fix is acquired. |
-| frsky_default_longitude | 0.000 | OpenTX needs a valid set of coordinates to show compass value. A fake value defined in this setting is sent while no fix is acquired. |
-| frsky_coordinates_format | 0 | FRSKY_FORMAT_DMS (default), FRSKY_FORMAT_NMEA |
-| frsky_unit | METRIC | METRIC , IMPERIAL |
-| frsky_vfas_precision | 0 | Set to 1 to send raw VBat value in 0.1V resolution for receivers that can handle it, or 0 (default) to use the standard method |
-| frsky_pitch_roll | OFF | Send pitch and roll degrees*10 instead of raw accelerometer telemetry for S.Port and FrSky D-Series telemetry |
-| report_cell_voltage | OFF | |
+| frsky_unit | METRIC | Not used? [METRIC/IMPERIAL] |
+| frsky_default_latitude | 0.000 | D-Series telemetry only: OpenTX needs a valid set of coordinates to show compass value. A fake value defined in this setting is sent while no fix is acquired. |
+| frsky_default_longitude | 0.000 | D-Series telemetry only: OpenTX needs a valid set of coordinates to show compass value. A fake value defined in this setting is sent while no fix is acquired. |
+| frsky_coordinates_format | 0 | D-Series telemetry only: FRSKY_FORMAT_DMS (default), FRSKY_FORMAT_NMEA |
+| frsky_vfas_precision | 0 | D-Series telemetry only: Set to 1 to send raw VBat value in 0.1V resolution for receivers that can handle it, or 0 (default) to use the standard method |
+| frsky_pitch_roll | OFF | S.Port and D-Series telemetry: Send pitch and roll degrees*10 instead of raw accelerometer data |
+| smartport_fuel_unit | MAH | S.Port telemetry only: Unit of the value sent with the `FUEL` ID (FrSky D-Series always sends precent). [PERCENT/MAH/MWH] |
+| smartport_uart_unidir | OFF | S.Port telemetry only: Turn UART into UNIDIR for usage on F1 and F4 target. See Telemetry.md for details |
+| report_cell_voltage | OFF | S.Port, D-Series, and IBUS telemetry: Send the average cell voltage if set to ON |
| hott_alarm_sound_interval | 5 | Battery alarm delay in seconds for Hott telemetry |
-| smartport_uart_unidir | OFF | Turn UART into UNIDIR for smartport telemetry for usage on F1 and F4 target. See Telemetry.md for details |
-| smartport_fuel_unit | MAH | Unit of the value sent with the `FUEL` ID through the S.Port and FrSky D-Series telemetry. [PERCENT/MAH/MWH] |
+| smartport_fuel_unit | MAH | S.Port and D-Series telemetry: Unit of the value sent with the `FUEL` ID. [PERCENT/MAH/MWH] |
| ibus_telemetry_type | 0 | Type compatibility ibus telemetry for transmitters. See Telemetry.md label IBUS for details. |
| ltm_update_rate | NORMAL | Defines the LTM update rate (use of bandwidth [NORMAL/MEDIUM/SLOW]). See Telemetry.md, LTM section for details. |
| battery_capacity | 0 | Battery capacity in mAH. This value is used in conjunction with the current meter to determine remaining battery capacity. |
@@ -300,6 +301,7 @@ After restoring it's always a good idea to `dump` or `diff` the settings once ag
| osd_alt_alarm | 100 | Value above which to make the OSD relative altitude indicator blink (meters) |
| osd_neg_alt_alarm | 5 | Value bellow which (negative altitude) to make the OSD relative altitude indicator blink (meters) |
| osd_estimations_wind_compensation | ON | Use wind estimation for remaining flight time/distance estimation |
+| display_force_sw_blink | OFF | OFF = OSD hardware blink / ON = OSD software blink. If OSD warning text/values are invisible, try setting this to ON |
| magzero_x | 0 | Magnetometer calibration X offset. If its 0 none offset has been applied and calibration is failed. |
| magzero_y | 0 | Magnetometer calibration Y offset. If its 0 none offset has been applied and calibration is failed. |
| magzero_z | 0 | Magnetometer calibration Z offset. If its 0 none offset has been applied and calibration is failed. |
@@ -421,5 +423,3 @@ After restoring it's always a good idea to `dump` or `diff` the settings once ag
| motor_decel_time | 0 | Minimum time for the motor(s) to deccelerate from 100 to 0% throttle (ms) [0-1000] |
| thr_comp_weight | 0.692 | Weight used for the throttle compensation based on battery voltage. See the [battery documentation](Battery.md#automatic-throttle-compensation-based-on-battery-voltage) |
-This Markdown table is made by MarkdwonTableMaker addon for google spreadsheet.
-Original Spreadsheet used to make this table can be found here https://docs.google.com/spreadsheets/d/1ubjYdMGmZ2aAMUNYkdfe3hhIF7wRfIjcuPOi_ysmp00/edit?usp=sharing
diff --git a/docs/Telemetry.md b/docs/Telemetry.md
index df5435ffab..768224dd7f 100644
--- a/docs/Telemetry.md
+++ b/docs/Telemetry.md
@@ -98,11 +98,11 @@ The following sensors are transmitted
* **VFAS** : actual vbat value.
* **Curr** : actual current comsuption, in amps.
* **Alt** : barometer based altitude, relative to home location.
-* **Fuel** : if `battery_capacity` variable set and variable `smartport_fuel_percent = ON` remaining battery percentage, mAh drawn otherwise.
+* **Fuel** : if `smartport_fuel_unit = PERCENT` remaining battery percentage sent, MAH drawn otherwise.
* **GPS** : GPS coordinates.
* **VSpd** : vertical speed, unit is cm/s.
* **Hdg** : heading, North is 0°, South is 180°.
-* **AccX,Y,Z** : accelerometer values.
+* **AccX,Y,Z** : accelerometer values (not sent if `frsky_pitch_roll = ON`).
* **Tmp1** : flight mode, sent as 5 digits. Number is sent as **ABCDE** detailed below. The numbers are additives (for example: if digit C is 6, it means both position hold and altitude hold are active) :
* **A** : 1 = flaperon mode, 2 = auto tune mode, 4 = failsafe mode
* **B** : 1 = return to home, 2 = waypoint mode, 4 = headfree mode
@@ -118,6 +118,8 @@ The following sensors are transmitted
* **ASpd** : true air speed, from pitot sensor.
* **A4** : average cell value. Warning : unlike FLVSS and MLVSS sensors, you do not get actual lowest value of a cell, but an average : (total lipo voltage) / (number of cells)
* **0420** : distance to GPS home fix, in meters
+* **0430** : if `frsky_pitch_roll = ON` set this will be pitch degrees*10
+* **0440** : if `frsky_pitch_roll = ON` set this will be roll degrees*10
### Compatible SmartPort/INAV telemetry flight status
@@ -160,10 +162,10 @@ This is new setting which supports VFAS resolution of 0.1 volts and is supported
### Notes
+Many of the same SmartPort telemetry values listed above are also sent with FrSky D-Series telemetry.
+
RPM shows throttle output when armed.
RPM shows when disarmed.
-TEMP2 shows Satellite Signal Quality when GPS is enabled.
-
RPM requires that the 'blades' setting is set to 12 on your receiver/display - tested with Taranis/OpenTX.
## HoTT telemetry
diff --git a/install-toolchain.sh b/install-toolchain.sh
index 7e1cb6f8e4..d3bda40c27 100755
--- a/install-toolchain.sh
+++ b/install-toolchain.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-if [ ! -d $PWD/gcc-arm-none-eabi-6_2-2016q4/bin ] ; then
- curl --retry 10 --retry-max-time 120 -L "https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/6-2017q2/gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2" | tar xfj -
+if [ ! -d $PWD/gcc-arm-none-eabi-7-2018-q2-update/bin ] ; then
+ curl --retry 10 --retry-max-time 120 -L "https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/7-2018q2/gcc-arm-none-eabi-7-2018-q2-update-linux.tar.bz2" | tar xfj -
fi
diff --git a/lib/main/STM32F7/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_usb.c b/lib/main/STM32F7/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_usb.c
index c3ee209cc0..ffc4f247fe 100644
--- a/lib/main/STM32F7/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_usb.c
+++ b/lib/main/STM32F7/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_usb.c
@@ -5,21 +5,21 @@
* @version V1.2.2
* @date 14-April-2017
* @brief USB Low Layer HAL module driver.
- *
- * This file provides firmware functions to manage the following
+ *
+ * This file provides firmware functions to manage the following
* functionalities of the USB Peripheral Controller:
* + Initialization/de-initialization functions
* + I/O operation functions
- * + Peripheral Control functions
+ * + Peripheral Control functions
* + Peripheral State functions
- *
+ *
@verbatim
==============================================================================
##### How to use this driver #####
==============================================================================
[..]
(#) Fill parameters of Init structure in USB_OTG_CfgTypeDef structure.
-
+
(#) Call USB_CoreInit() API to initialize the USB Core peripheral.
(#) The upper HAL HCD/PCD driver will call the right routines for its internal processes.
@@ -53,7 +53,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
- */
+ */
/* Includes ------------------------------------------------------------------*/
#include "stm32f7xx_hal.h"
@@ -72,7 +72,7 @@
/* Private functions ---------------------------------------------------------*/
static HAL_StatusTypeDef USB_CoreReset(USB_OTG_GlobalTypeDef *USBx);
-#ifdef USB_HS_PHYC
+#ifdef USB_HS_PHYC
static HAL_StatusTypeDef USB_HS_PHYCInit(USB_OTG_GlobalTypeDef *USBx);
#endif
@@ -81,15 +81,15 @@ static HAL_StatusTypeDef USB_HS_PHYCInit(USB_OTG_GlobalTypeDef *USBx);
* @{
*/
-/** @defgroup LL_USB_Group1 Initialization/de-initialization functions
- * @brief Initialization and Configuration functions
+/** @defgroup LL_USB_Group1 Initialization/de-initialization functions
+ * @brief Initialization and Configuration functions
*
-@verbatim
+@verbatim
===============================================================================
##### Initialization/de-initialization functions #####
===============================================================================
[..] This section provides functions allowing to:
-
+
@endverbatim
* @{
*/
@@ -105,12 +105,12 @@ HAL_StatusTypeDef USB_CoreInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef c
{
if (cfg.phy_itface == USB_OTG_ULPI_PHY)
{
-
+
USBx->GCCFG &= ~(USB_OTG_GCCFG_PWRDWN);
/* Init The ULPI Interface */
USBx->GUSBCFG &= ~(USB_OTG_GUSBCFG_TSDPS | USB_OTG_GUSBCFG_ULPIFSLS | USB_OTG_GUSBCFG_PHYSEL);
-
+
/* Select vbus source */
USBx->GUSBCFG &= ~(USB_OTG_GUSBCFG_ULPIEVBUSD | USB_OTG_GUSBCFG_ULPIEVBUSI);
if(cfg.use_external_vbus == 1)
@@ -118,53 +118,53 @@ HAL_StatusTypeDef USB_CoreInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef c
USBx->GUSBCFG |= USB_OTG_GUSBCFG_ULPIEVBUSD;
}
/* Reset after a PHY select */
- USB_CoreReset(USBx);
+ USB_CoreReset(USBx);
}
-#ifdef USB_HS_PHYC
-
+#ifdef USB_HS_PHYC
+
else if (cfg.phy_itface == USB_OTG_HS_EMBEDDED_PHY)
{
USBx->GCCFG &= ~(USB_OTG_GCCFG_PWRDWN);
-
+
/* Init The UTMI Interface */
USBx->GUSBCFG &= ~(USB_OTG_GUSBCFG_TSDPS | USB_OTG_GUSBCFG_ULPIFSLS | USB_OTG_GUSBCFG_PHYSEL);
-
+
/* Select vbus source */
USBx->GUSBCFG &= ~(USB_OTG_GUSBCFG_ULPIEVBUSD | USB_OTG_GUSBCFG_ULPIEVBUSI);
-
+
/* Select UTMI Interace */
USBx->GUSBCFG &= ~ USB_OTG_GUSBCFG_ULPI_UTMI_SEL;
USBx->GCCFG |= USB_OTG_GCCFG_PHYHSEN;
-
+
/* Enables control of a High Speed USB PHY */
USB_HS_PHYCInit(USBx);
-
+
if(cfg.use_external_vbus == 1)
{
USBx->GUSBCFG |= USB_OTG_GUSBCFG_ULPIEVBUSD;
}
/* Reset after a PHY select */
- USB_CoreReset(USBx);
-
+ USB_CoreReset(USBx);
+
}
#endif
else /* FS interface (embedded Phy) */
{
/* Select FS Embedded PHY */
USBx->GUSBCFG |= USB_OTG_GUSBCFG_PHYSEL;
-
+
/* Reset after a PHY select and set Host mode */
USB_CoreReset(USBx);
-
+
/* Deactivate the power down*/
USBx->GCCFG = USB_OTG_GCCFG_PWRDWN;
}
-
+
if(cfg.dma_enable == ENABLE)
{
USBx->GAHBCFG |= USB_OTG_GAHBCFG_HBSTLEN_2;
USBx->GAHBCFG |= USB_OTG_GAHBCFG_DMAEN;
- }
+ }
return HAL_OK;
}
@@ -193,7 +193,7 @@ HAL_StatusTypeDef USB_DisableGlobalInt(USB_OTG_GlobalTypeDef *USBx)
USBx->GAHBCFG &= ~USB_OTG_GAHBCFG_GINT;
return HAL_OK;
}
-
+
/**
* @brief USB_SetCurrentMode : Set functional mode
* @param USBx : Selected device
@@ -201,28 +201,28 @@ HAL_StatusTypeDef USB_DisableGlobalInt(USB_OTG_GlobalTypeDef *USBx)
* This parameter can be one of these values:
* @arg USB_OTG_DEVICE_MODE: Peripheral mode
* @arg USB_OTG_HOST_MODE: Host mode
- * @arg USB_OTG_DRD_MODE: Dual Role Device mode
+ * @arg USB_OTG_DRD_MODE: Dual Role Device mode
* @retval HAL status
*/
HAL_StatusTypeDef USB_SetCurrentMode(USB_OTG_GlobalTypeDef *USBx , USB_OTG_ModeTypeDef mode)
{
- USBx->GUSBCFG &= ~(USB_OTG_GUSBCFG_FHMOD | USB_OTG_GUSBCFG_FDMOD);
-
+ USBx->GUSBCFG &= ~(USB_OTG_GUSBCFG_FHMOD | USB_OTG_GUSBCFG_FDMOD);
+
if ( mode == USB_OTG_HOST_MODE)
{
- USBx->GUSBCFG |= USB_OTG_GUSBCFG_FHMOD;
+ USBx->GUSBCFG |= USB_OTG_GUSBCFG_FHMOD;
}
else if ( mode == USB_OTG_DEVICE_MODE)
{
- USBx->GUSBCFG |= USB_OTG_GUSBCFG_FDMOD;
+ USBx->GUSBCFG |= USB_OTG_GUSBCFG_FDMOD;
}
HAL_Delay(50);
-
+
return HAL_OK;
}
/**
- * @brief USB_DevInit : Initializes the USB_OTG controller registers
+ * @brief USB_DevInit : Initializes the USB_OTG controller registers
* for device mode
* @param USBx : Selected device
* @param cfg : pointer to a USB_OTG_CfgTypeDef structure that contains
@@ -235,51 +235,51 @@ HAL_StatusTypeDef USB_DevInit (USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef c
/*Activate VBUS Sensing B */
USBx->GCCFG |= USB_OTG_GCCFG_VBDEN;
-
+
if (cfg.vbus_sensing_enable == 0)
{
/* Deactivate VBUS Sensing B */
USBx->GCCFG &= ~ USB_OTG_GCCFG_VBDEN;
-
- /* B-peripheral session valid override enable*/
+
+ /* B-peripheral session valid override enable*/
USBx->GOTGCTL |= USB_OTG_GOTGCTL_BVALOEN;
USBx->GOTGCTL |= USB_OTG_GOTGCTL_BVALOVAL;
}
-
+
/* Restart the Phy Clock */
USBx_PCGCCTL = 0;
/* Device mode configuration */
USBx_DEVICE->DCFG |= DCFG_FRAME_INTERVAL_80;
-
+
if(cfg.phy_itface == USB_OTG_ULPI_PHY)
{
if(cfg.speed == USB_OTG_SPEED_HIGH)
- {
+ {
/* Set High speed phy */
USB_SetDevSpeed (USBx , USB_OTG_SPEED_HIGH);
}
- else
+ else
{
/* set High speed phy in Full speed mode */
USB_SetDevSpeed (USBx , USB_OTG_SPEED_HIGH_IN_FULL);
}
}
-
+
else if(cfg.phy_itface == USB_OTG_HS_EMBEDDED_PHY)
{
if(cfg.speed == USB_OTG_SPEED_HIGH)
- {
+ {
/* Set High speed phy */
USB_SetDevSpeed (USBx , USB_OTG_SPEED_HIGH);
}
- else
+ else
{
/* set High speed phy in Full speed mode */
USB_SetDevSpeed (USBx , USB_OTG_SPEED_HIGH_IN_FULL);
}
}
-
+
else
{
/* Set Full speed phy */
@@ -289,13 +289,13 @@ HAL_StatusTypeDef USB_DevInit (USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef c
/* Flush the FIFOs */
USB_FlushTxFifo(USBx , 0x10); /* all Tx FIFOs */
USB_FlushRxFifo(USBx);
-
+
/* Clear all pending Device Interrupts */
USBx_DEVICE->DIEPMSK = 0;
USBx_DEVICE->DOEPMSK = 0;
USBx_DEVICE->DAINT = 0xFFFFFFFF;
USBx_DEVICE->DAINTMSK = 0;
-
+
for (i = 0; i < cfg.dev_endpoints; i++)
{
if ((USBx_INEP(i)->DIEPCTL & USB_OTG_DIEPCTL_EPENA) == USB_OTG_DIEPCTL_EPENA)
@@ -306,11 +306,11 @@ HAL_StatusTypeDef USB_DevInit (USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef c
{
USBx_INEP(i)->DIEPCTL = 0;
}
-
+
USBx_INEP(i)->DIEPTSIZ = 0;
USBx_INEP(i)->DIEPINT = 0xFF;
}
-
+
for (i = 0; i < cfg.dev_endpoints; i++)
{
if ((USBx_OUTEP(i)->DOEPCTL & USB_OTG_DOEPCTL_EPENA) == USB_OTG_DOEPCTL_EPENA)
@@ -321,40 +321,40 @@ HAL_StatusTypeDef USB_DevInit (USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef c
{
USBx_OUTEP(i)->DOEPCTL = 0;
}
-
+
USBx_OUTEP(i)->DOEPTSIZ = 0;
USBx_OUTEP(i)->DOEPINT = 0xFF;
}
-
+
USBx_DEVICE->DIEPMSK &= ~(USB_OTG_DIEPMSK_TXFURM);
-
+
if (cfg.dma_enable == 1)
{
/*Set threshold parameters */
USBx_DEVICE->DTHRCTL = (USB_OTG_DTHRCTL_TXTHRLEN_6 | USB_OTG_DTHRCTL_RXTHRLEN_6);
USBx_DEVICE->DTHRCTL |= (USB_OTG_DTHRCTL_RXTHREN | USB_OTG_DTHRCTL_ISOTHREN | USB_OTG_DTHRCTL_NONISOTHREN);
-
+
i= USBx_DEVICE->DTHRCTL;
}
-
+
/* Disable all interrupts. */
USBx->GINTMSK = 0;
-
+
/* Clear any pending interrupts */
USBx->GINTSTS = 0xBFFFFFFF;
/* Enable the common interrupts */
if (cfg.dma_enable == DISABLE)
{
- USBx->GINTMSK |= USB_OTG_GINTMSK_RXFLVLM;
+ USBx->GINTMSK |= USB_OTG_GINTMSK_RXFLVLM;
}
-
+
/* Enable interrupts matching to the Device mode ONLY */
USBx->GINTMSK |= (USB_OTG_GINTMSK_USBSUSPM | USB_OTG_GINTMSK_USBRST |\
USB_OTG_GINTMSK_ENUMDNEM | USB_OTG_GINTMSK_IEPINT |\
USB_OTG_GINTMSK_OEPINT | USB_OTG_GINTMSK_IISOIXFRM|\
USB_OTG_GINTMSK_PXFRM_IISOOXFRM | USB_OTG_GINTMSK_WUIM);
-
+
if(cfg.Sof_enable)
{
USBx->GINTMSK |= USB_OTG_GINTMSK_SOFM;
@@ -362,9 +362,9 @@ HAL_StatusTypeDef USB_DevInit (USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef c
if (cfg.vbus_sensing_enable == ENABLE)
{
- USBx->GINTMSK |= (USB_OTG_GINTMSK_SRQIM | USB_OTG_GINTMSK_OTGINT);
+ USBx->GINTMSK |= (USB_OTG_GINTMSK_SRQIM | USB_OTG_GINTMSK_OTGINT);
}
-
+
return HAL_OK;
}
@@ -380,9 +380,9 @@ HAL_StatusTypeDef USB_DevInit (USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef c
HAL_StatusTypeDef USB_FlushTxFifo (USB_OTG_GlobalTypeDef *USBx, uint32_t num )
{
uint32_t count = 0;
-
- USBx->GRSTCTL = ( USB_OTG_GRSTCTL_TXFFLSH |(uint32_t)( num << 6));
-
+
+ USBx->GRSTCTL = ( USB_OTG_GRSTCTL_TXFFLSH |(uint32_t)( num << 6));
+
do
{
if (++count > 200000)
@@ -391,7 +391,7 @@ HAL_StatusTypeDef USB_FlushTxFifo (USB_OTG_GlobalTypeDef *USBx, uint32_t num )
}
}
while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_TXFFLSH) == USB_OTG_GRSTCTL_TXFFLSH);
-
+
return HAL_OK;
}
@@ -404,9 +404,9 @@ HAL_StatusTypeDef USB_FlushTxFifo (USB_OTG_GlobalTypeDef *USBx, uint32_t num )
HAL_StatusTypeDef USB_FlushRxFifo(USB_OTG_GlobalTypeDef *USBx)
{
uint32_t count = 0;
-
+
USBx->GRSTCTL = USB_OTG_GRSTCTL_RXFFLSH;
-
+
do
{
if (++count > 200000)
@@ -415,12 +415,12 @@ HAL_StatusTypeDef USB_FlushRxFifo(USB_OTG_GlobalTypeDef *USBx)
}
}
while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_RXFFLSH) == USB_OTG_GRSTCTL_RXFFLSH);
-
+
return HAL_OK;
}
/**
- * @brief USB_SetDevSpeed :Initializes the DevSpd field of DCFG register
+ * @brief USB_SetDevSpeed :Initializes the DevSpd field of DCFG register
* depending the PHY type and the enumeration speed of the device.
* @param USBx : Selected device
* @param speed : device speed
@@ -438,7 +438,7 @@ HAL_StatusTypeDef USB_SetDevSpeed(USB_OTG_GlobalTypeDef *USBx , uint8_t speed)
}
/**
- * @brief USB_GetDevSpeed :Return the Dev Speed
+ * @brief USB_GetDevSpeed :Return the Dev Speed
* @param USBx : Selected device
* @retval speed : device speed
* This parameter can be one of these values:
@@ -449,7 +449,7 @@ HAL_StatusTypeDef USB_SetDevSpeed(USB_OTG_GlobalTypeDef *USBx , uint8_t speed)
uint8_t USB_GetDevSpeed(USB_OTG_GlobalTypeDef *USBx)
{
uint8_t speed = 0;
-
+
if((USBx_DEVICE->DSTS & USB_OTG_DSTS_ENUMSPD) == DSTS_ENUMSPD_HS_PHY_30MHZ_OR_60MHZ)
{
speed = USB_OTG_SPEED_HIGH;
@@ -463,7 +463,7 @@ uint8_t USB_GetDevSpeed(USB_OTG_GlobalTypeDef *USBx)
{
speed = USB_OTG_SPEED_LOW;
}
-
+
return speed;
}
@@ -478,23 +478,23 @@ HAL_StatusTypeDef USB_ActivateEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTy
if (ep->is_in == 1)
{
USBx_DEVICE->DAINTMSK |= USB_OTG_DAINTMSK_IEPM & ((1 << (ep->num)));
-
+
if (((USBx_INEP(ep->num)->DIEPCTL) & USB_OTG_DIEPCTL_USBAEP) == 0)
{
USBx_INEP(ep->num)->DIEPCTL |= ((ep->maxpacket & USB_OTG_DIEPCTL_MPSIZ ) | (ep->type << 18 ) |\
- ((ep->num) << 22 ) | (USB_OTG_DIEPCTL_SD0PID_SEVNFRM) | (USB_OTG_DIEPCTL_USBAEP));
- }
+ ((ep->num) << 22 ) | (USB_OTG_DIEPCTL_SD0PID_SEVNFRM) | (USB_OTG_DIEPCTL_USBAEP));
+ }
}
else
{
USBx_DEVICE->DAINTMSK |= USB_OTG_DAINTMSK_OEPM & ((1 << (ep->num)) << 16);
-
+
if (((USBx_OUTEP(ep->num)->DOEPCTL) & USB_OTG_DOEPCTL_USBAEP) == 0)
{
USBx_OUTEP(ep->num)->DOEPCTL |= ((ep->maxpacket & USB_OTG_DOEPCTL_MPSIZ ) | (ep->type << 18 ) |\
(USB_OTG_DIEPCTL_SD0PID_SEVNFRM)| (USB_OTG_DOEPCTL_USBAEP));
- }
+ }
}
return HAL_OK;
}
@@ -507,20 +507,20 @@ HAL_StatusTypeDef USB_ActivateEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTy
HAL_StatusTypeDef USB_ActivateDedicatedEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep)
{
static __IO uint32_t debug = 0;
-
+
/* Read DEPCTLn register */
if (ep->is_in == 1)
{
if (((USBx_INEP(ep->num)->DIEPCTL) & USB_OTG_DIEPCTL_USBAEP) == 0)
{
USBx_INEP(ep->num)->DIEPCTL |= ((ep->maxpacket & USB_OTG_DIEPCTL_MPSIZ ) | (ep->type << 18 ) |\
- ((ep->num) << 22 ) | (USB_OTG_DIEPCTL_SD0PID_SEVNFRM) | (USB_OTG_DIEPCTL_USBAEP));
- }
-
-
+ ((ep->num) << 22 ) | (USB_OTG_DIEPCTL_SD0PID_SEVNFRM) | (USB_OTG_DIEPCTL_USBAEP));
+ }
+
+
debug |= ((ep->maxpacket & USB_OTG_DIEPCTL_MPSIZ ) | (ep->type << 18 ) |\
- ((ep->num) << 22 ) | (USB_OTG_DIEPCTL_SD0PID_SEVNFRM) | (USB_OTG_DIEPCTL_USBAEP));
-
+ ((ep->num) << 22 ) | (USB_OTG_DIEPCTL_SD0PID_SEVNFRM) | (USB_OTG_DIEPCTL_USBAEP));
+
USBx_DEVICE->DEACHMSK |= USB_OTG_DAINTMSK_IEPM & ((1 << (ep->num)));
}
else
@@ -529,13 +529,13 @@ HAL_StatusTypeDef USB_ActivateDedicatedEndpoint(USB_OTG_GlobalTypeDef *USBx, USB
{
USBx_OUTEP(ep->num)->DOEPCTL |= ((ep->maxpacket & USB_OTG_DOEPCTL_MPSIZ ) | (ep->type << 18 ) |\
((ep->num) << 22 ) | (USB_OTG_DOEPCTL_USBAEP));
-
+
debug = (uint32_t)(((uint32_t )USBx) + USB_OTG_OUT_ENDPOINT_BASE + (0)*USB_OTG_EP_REG_SIZE);
debug = (uint32_t )&USBx_OUTEP(ep->num)->DOEPCTL;
debug |= ((ep->maxpacket & USB_OTG_DOEPCTL_MPSIZ ) | (ep->type << 18 ) |\
- ((ep->num) << 22 ) | (USB_OTG_DOEPCTL_USBAEP));
- }
-
+ ((ep->num) << 22 ) | (USB_OTG_DOEPCTL_USBAEP));
+ }
+
USBx_DEVICE->DEACHMSK |= USB_OTG_DAINTMSK_OEPM & ((1 << (ep->num)) << 16);
}
@@ -553,14 +553,14 @@ HAL_StatusTypeDef USB_DeactivateEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EP
if (ep->is_in == 1)
{
USBx_DEVICE->DEACHMSK &= ~(USB_OTG_DAINTMSK_IEPM & ((1 << (ep->num))));
- USBx_DEVICE->DAINTMSK &= ~(USB_OTG_DAINTMSK_IEPM & ((1 << (ep->num))));
- USBx_INEP(ep->num)->DIEPCTL &= ~ USB_OTG_DIEPCTL_USBAEP;
+ USBx_DEVICE->DAINTMSK &= ~(USB_OTG_DAINTMSK_IEPM & ((1 << (ep->num))));
+ USBx_INEP(ep->num)->DIEPCTL &= ~ USB_OTG_DIEPCTL_USBAEP;
}
else
{
USBx_DEVICE->DEACHMSK &= ~(USB_OTG_DAINTMSK_OEPM & ((1 << (ep->num)) << 16));
- USBx_DEVICE->DAINTMSK &= ~(USB_OTG_DAINTMSK_OEPM & ((1 << (ep->num)) << 16));
- USBx_OUTEP(ep->num)->DOEPCTL &= ~USB_OTG_DOEPCTL_USBAEP;
+ USBx_DEVICE->DAINTMSK &= ~(USB_OTG_DAINTMSK_OEPM & ((1 << (ep->num)) << 16));
+ USBx_OUTEP(ep->num)->DOEPCTL &= ~USB_OTG_DOEPCTL_USBAEP;
}
return HAL_OK;
}
@@ -581,7 +581,7 @@ HAL_StatusTypeDef USB_DeactivateDedicatedEndpoint(USB_OTG_GlobalTypeDef *USBx, U
}
else
{
- USBx_OUTEP(ep->num)->DOEPCTL &= ~USB_OTG_DOEPCTL_USBAEP;
+ USBx_OUTEP(ep->num)->DOEPCTL &= ~USB_OTG_DOEPCTL_USBAEP;
USBx_DEVICE->DAINTMSK &= ~(USB_OTG_DAINTMSK_OEPM & ((1 << (ep->num)) << 16));
}
return HAL_OK;
@@ -591,25 +591,25 @@ HAL_StatusTypeDef USB_DeactivateDedicatedEndpoint(USB_OTG_GlobalTypeDef *USBx, U
* @brief USB_EPStartXfer : setup and starts a transfer over an EP
* @param USBx : Selected device
* @param ep: pointer to endpoint structure
- * @param dma: USB dma enabled or disabled
+ * @param dma: USB dma enabled or disabled
* This parameter can be one of these values:
- * 0 : DMA feature not used
- * 1 : DMA feature used
+ * 0 : DMA feature not used
+ * 1 : DMA feature used
* @retval HAL status
*/
HAL_StatusTypeDef USB_EPStartXfer(USB_OTG_GlobalTypeDef *USBx , USB_OTG_EPTypeDef *ep, uint8_t dma)
{
uint16_t pktcnt = 0;
-
+
/* IN endpoint */
if (ep->is_in == 1)
{
/* Zero Length Packet? */
if (ep->xfer_len == 0)
{
- USBx_INEP(ep->num)->DIEPTSIZ &= ~(USB_OTG_DIEPTSIZ_PKTCNT);
+ USBx_INEP(ep->num)->DIEPTSIZ &= ~(USB_OTG_DIEPTSIZ_PKTCNT);
USBx_INEP(ep->num)->DIEPTSIZ |= (USB_OTG_DIEPTSIZ_PKTCNT & (1 << 19)) ;
- USBx_INEP(ep->num)->DIEPTSIZ &= ~(USB_OTG_DIEPTSIZ_XFRSIZ);
+ USBx_INEP(ep->num)->DIEPTSIZ &= ~(USB_OTG_DIEPTSIZ_XFRSIZ);
}
else
{
@@ -619,15 +619,15 @@ HAL_StatusTypeDef USB_EPStartXfer(USB_OTG_GlobalTypeDef *USBx , USB_OTG_EPTypeDe
* exist ? 1 : 0)
*/
USBx_INEP(ep->num)->DIEPTSIZ &= ~(USB_OTG_DIEPTSIZ_XFRSIZ);
- USBx_INEP(ep->num)->DIEPTSIZ &= ~(USB_OTG_DIEPTSIZ_PKTCNT);
+ USBx_INEP(ep->num)->DIEPTSIZ &= ~(USB_OTG_DIEPTSIZ_PKTCNT);
USBx_INEP(ep->num)->DIEPTSIZ |= (USB_OTG_DIEPTSIZ_PKTCNT & (((ep->xfer_len + ep->maxpacket -1)/ ep->maxpacket) << 19)) ;
- USBx_INEP(ep->num)->DIEPTSIZ |= (USB_OTG_DIEPTSIZ_XFRSIZ & ep->xfer_len);
-
+ USBx_INEP(ep->num)->DIEPTSIZ |= (USB_OTG_DIEPTSIZ_XFRSIZ & ep->xfer_len);
+
if (ep->type == EP_TYPE_ISOC)
{
- USBx_INEP(ep->num)->DIEPTSIZ &= ~(USB_OTG_DIEPTSIZ_MULCNT);
- USBx_INEP(ep->num)->DIEPTSIZ |= (USB_OTG_DIEPTSIZ_MULCNT & (1 << 29));
- }
+ USBx_INEP(ep->num)->DIEPTSIZ &= ~(USB_OTG_DIEPTSIZ_MULCNT);
+ USBx_INEP(ep->num)->DIEPTSIZ |= (USB_OTG_DIEPTSIZ_MULCNT & (1 << 29));
+ }
}
if (dma == 1)
@@ -656,42 +656,42 @@ HAL_StatusTypeDef USB_EPStartXfer(USB_OTG_GlobalTypeDef *USBx , USB_OTG_EPTypeDe
{
USBx_INEP(ep->num)->DIEPCTL |= USB_OTG_DIEPCTL_SD0PID_SEVNFRM;
}
- }
-
+ }
+
/* EP enable, IN data in FIFO */
USBx_INEP(ep->num)->DIEPCTL |= (USB_OTG_DIEPCTL_CNAK | USB_OTG_DIEPCTL_EPENA);
-
+
if (ep->type == EP_TYPE_ISOC)
{
- USB_WritePacket(USBx, ep->xfer_buff, ep->num, ep->xfer_len, dma);
- }
+ USB_WritePacket(USBx, ep->xfer_buff, ep->num, ep->xfer_len, dma);
+ }
}
else /* OUT endpoint */
{
/* Program the transfer size and packet count as follows:
* pktcnt = N
* xfersize = N * maxpacket
- */
- USBx_OUTEP(ep->num)->DOEPTSIZ &= ~(USB_OTG_DOEPTSIZ_XFRSIZ);
- USBx_OUTEP(ep->num)->DOEPTSIZ &= ~(USB_OTG_DOEPTSIZ_PKTCNT);
-
+ */
+ USBx_OUTEP(ep->num)->DOEPTSIZ &= ~(USB_OTG_DOEPTSIZ_XFRSIZ);
+ USBx_OUTEP(ep->num)->DOEPTSIZ &= ~(USB_OTG_DOEPTSIZ_PKTCNT);
+
if (ep->xfer_len == 0)
{
USBx_OUTEP(ep->num)->DOEPTSIZ |= (USB_OTG_DOEPTSIZ_XFRSIZ & ep->maxpacket);
- USBx_OUTEP(ep->num)->DOEPTSIZ |= (USB_OTG_DOEPTSIZ_PKTCNT & (1 << 19)) ;
+ USBx_OUTEP(ep->num)->DOEPTSIZ |= (USB_OTG_DOEPTSIZ_PKTCNT & (1 << 19)) ;
}
else
{
- pktcnt = (ep->xfer_len + ep->maxpacket -1)/ ep->maxpacket;
+ pktcnt = (ep->xfer_len + ep->maxpacket -1)/ ep->maxpacket;
USBx_OUTEP(ep->num)->DOEPTSIZ |= (USB_OTG_DOEPTSIZ_PKTCNT & (pktcnt << 19));
- USBx_OUTEP(ep->num)->DOEPTSIZ |= (USB_OTG_DOEPTSIZ_XFRSIZ & (ep->maxpacket * pktcnt));
+ USBx_OUTEP(ep->num)->DOEPTSIZ |= (USB_OTG_DOEPTSIZ_XFRSIZ & (ep->maxpacket * pktcnt));
}
if (dma == 1)
{
USBx_OUTEP(ep->num)->DOEPDMA = (uint32_t)ep->xfer_buff;
}
-
+
if (ep->type == EP_TYPE_ISOC)
{
if ((USBx_DEVICE->DSTS & ( 1 << 8 )) == 0)
@@ -713,10 +713,10 @@ HAL_StatusTypeDef USB_EPStartXfer(USB_OTG_GlobalTypeDef *USBx , USB_OTG_EPTypeDe
* @brief USB_EP0StartXfer : setup and starts a transfer over the EP 0
* @param USBx : Selected device
* @param ep: pointer to endpoint structure
- * @param dma: USB dma enabled or disabled
+ * @param dma: USB dma enabled or disabled
* This parameter can be one of these values:
- * 0 : DMA feature not used
- * 1 : DMA feature used
+ * 0 : DMA feature not used
+ * 1 : DMA feature used
* @retval HAL status
*/
HAL_StatusTypeDef USB_EP0StartXfer(USB_OTG_GlobalTypeDef *USBx , USB_OTG_EPTypeDef *ep, uint8_t dma)
@@ -727,9 +727,9 @@ HAL_StatusTypeDef USB_EP0StartXfer(USB_OTG_GlobalTypeDef *USBx , USB_OTG_EPTypeD
/* Zero Length Packet? */
if (ep->xfer_len == 0)
{
- USBx_INEP(ep->num)->DIEPTSIZ &= ~(USB_OTG_DIEPTSIZ_PKTCNT);
+ USBx_INEP(ep->num)->DIEPTSIZ &= ~(USB_OTG_DIEPTSIZ_PKTCNT);
USBx_INEP(ep->num)->DIEPTSIZ |= (USB_OTG_DIEPTSIZ_PKTCNT & (1 << 19)) ;
- USBx_INEP(ep->num)->DIEPTSIZ &= ~(USB_OTG_DIEPTSIZ_XFRSIZ);
+ USBx_INEP(ep->num)->DIEPTSIZ &= ~(USB_OTG_DIEPTSIZ_XFRSIZ);
}
else
{
@@ -739,20 +739,20 @@ HAL_StatusTypeDef USB_EP0StartXfer(USB_OTG_GlobalTypeDef *USBx , USB_OTG_EPTypeD
* exist ? 1 : 0)
*/
USBx_INEP(ep->num)->DIEPTSIZ &= ~(USB_OTG_DIEPTSIZ_XFRSIZ);
- USBx_INEP(ep->num)->DIEPTSIZ &= ~(USB_OTG_DIEPTSIZ_PKTCNT);
-
+ USBx_INEP(ep->num)->DIEPTSIZ &= ~(USB_OTG_DIEPTSIZ_PKTCNT);
+
if(ep->xfer_len > ep->maxpacket)
{
ep->xfer_len = ep->maxpacket;
}
USBx_INEP(ep->num)->DIEPTSIZ |= (USB_OTG_DIEPTSIZ_PKTCNT & (1 << 19)) ;
- USBx_INEP(ep->num)->DIEPTSIZ |= (USB_OTG_DIEPTSIZ_XFRSIZ & ep->xfer_len);
-
+ USBx_INEP(ep->num)->DIEPTSIZ |= (USB_OTG_DIEPTSIZ_XFRSIZ & ep->xfer_len);
+
}
-
+
/* EP enable, IN data in FIFO */
USBx_INEP(ep->num)->DIEPCTL |= (USB_OTG_DIEPCTL_CNAK | USB_OTG_DIEPCTL_EPENA);
-
+
if (dma == 1)
{
USBx_INEP(ep->num)->DIEPDMA = (uint32_t)(ep->dma_addr);
@@ -764,7 +764,7 @@ HAL_StatusTypeDef USB_EP0StartXfer(USB_OTG_GlobalTypeDef *USBx , USB_OTG_EPTypeD
{
USBx_DEVICE->DIEPEMPMSK |= 1U << (ep->num);
}
- }
+ }
}
else /* OUT endpoint */
{
@@ -772,79 +772,79 @@ HAL_StatusTypeDef USB_EP0StartXfer(USB_OTG_GlobalTypeDef *USBx , USB_OTG_EPTypeD
* pktcnt = N
* xfersize = N * maxpacket
*/
- USBx_OUTEP(ep->num)->DOEPTSIZ &= ~(USB_OTG_DOEPTSIZ_XFRSIZ);
- USBx_OUTEP(ep->num)->DOEPTSIZ &= ~(USB_OTG_DOEPTSIZ_PKTCNT);
-
+ USBx_OUTEP(ep->num)->DOEPTSIZ &= ~(USB_OTG_DOEPTSIZ_XFRSIZ);
+ USBx_OUTEP(ep->num)->DOEPTSIZ &= ~(USB_OTG_DOEPTSIZ_PKTCNT);
+
if (ep->xfer_len > 0)
{
ep->xfer_len = ep->maxpacket;
}
-
+
USBx_OUTEP(ep->num)->DOEPTSIZ |= (USB_OTG_DOEPTSIZ_PKTCNT & (1 << 19));
- USBx_OUTEP(ep->num)->DOEPTSIZ |= (USB_OTG_DOEPTSIZ_XFRSIZ & (ep->maxpacket));
-
+ USBx_OUTEP(ep->num)->DOEPTSIZ |= (USB_OTG_DOEPTSIZ_XFRSIZ & (ep->maxpacket));
+
if (dma == 1)
{
USBx_OUTEP(ep->num)->DOEPDMA = (uint32_t)(ep->xfer_buff);
}
-
+
/* EP enable */
- USBx_OUTEP(ep->num)->DOEPCTL |= (USB_OTG_DOEPCTL_CNAK | USB_OTG_DOEPCTL_EPENA);
+ USBx_OUTEP(ep->num)->DOEPCTL |= (USB_OTG_DOEPCTL_CNAK | USB_OTG_DOEPCTL_EPENA);
}
return HAL_OK;
}
/**
- * @brief USB_WritePacket : Writes a packet into the Tx FIFO associated
+ * @brief USB_WritePacket : Writes a packet into the Tx FIFO associated
* with the EP/channel
- * @param USBx : Selected device
+ * @param USBx : Selected device
* @param src : pointer to source buffer
* @param ch_ep_num : endpoint or host channel number
* @param len : Number of bytes to write
- * @param dma: USB dma enabled or disabled
+ * @param dma: USB dma enabled or disabled
* This parameter can be one of these values:
- * 0 : DMA feature not used
- * 1 : DMA feature used
+ * 0 : DMA feature not used
+ * 1 : DMA feature used
* @retval HAL status
*/
HAL_StatusTypeDef USB_WritePacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *src, uint8_t ch_ep_num, uint16_t len, uint8_t dma)
{
uint32_t count32b= 0 , i= 0;
-
+
if (dma == 0)
{
count32b = (len + 3) / 4;
for (i = 0; i < count32b; i++, src += 4)
{
- USBx_DFIFO(ch_ep_num) = *((__packed uint32_t *)src);
+ USBx_DFIFO(ch_ep_num) = *((uint32_t *)src);
}
}
return HAL_OK;
}
/**
- * @brief USB_ReadPacket : read a packet from the Tx FIFO associated
+ * @brief USB_ReadPacket : read a packet from the Tx FIFO associated
* with the EP/channel
- * @param USBx : Selected device
+ * @param USBx : Selected device
* @param src : source pointer
* @param ch_ep_num : endpoint or host channel number
* @param len : Number of bytes to read
- * @param dma: USB dma enabled or disabled
+ * @param dma: USB dma enabled or disabled
* This parameter can be one of these values:
- * 0 : DMA feature not used
- * 1 : DMA feature used
+ * 0 : DMA feature not used
+ * 1 : DMA feature used
* @retval pointer to destination buffer
*/
void *USB_ReadPacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *dest, uint16_t len)
{
uint32_t i=0;
uint32_t count32b = (len + 3) / 4;
-
+
for ( i = 0; i < count32b; i++, dest += 4 )
{
- *(__packed uint32_t *)dest = USBx_DFIFO(0);
-
+ *(uint32_t *)dest = USBx_DFIFO(0);
+
}
return ((void *)dest);
}
@@ -852,7 +852,7 @@ void *USB_ReadPacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *dest, uint16_t len)
/**
* @brief USB_EPSetStall : set a stall condition over an EP
* @param USBx : Selected device
- * @param ep: pointer to endpoint structure
+ * @param ep: pointer to endpoint structure
* @retval HAL status
*/
HAL_StatusTypeDef USB_EPSetStall(USB_OTG_GlobalTypeDef *USBx , USB_OTG_EPTypeDef *ep)
@@ -861,16 +861,16 @@ HAL_StatusTypeDef USB_EPSetStall(USB_OTG_GlobalTypeDef *USBx , USB_OTG_EPTypeDef
{
if (((USBx_INEP(ep->num)->DIEPCTL) & USB_OTG_DIEPCTL_EPENA) == 0)
{
- USBx_INEP(ep->num)->DIEPCTL &= ~(USB_OTG_DIEPCTL_EPDIS);
- }
+ USBx_INEP(ep->num)->DIEPCTL &= ~(USB_OTG_DIEPCTL_EPDIS);
+ }
USBx_INEP(ep->num)->DIEPCTL |= USB_OTG_DIEPCTL_STALL;
}
else
{
if (((USBx_OUTEP(ep->num)->DOEPCTL) & USB_OTG_DOEPCTL_EPENA) == 0)
{
- USBx_OUTEP(ep->num)->DOEPCTL &= ~(USB_OTG_DOEPCTL_EPDIS);
- }
+ USBx_OUTEP(ep->num)->DOEPCTL &= ~(USB_OTG_DOEPCTL_EPDIS);
+ }
USBx_OUTEP(ep->num)->DOEPCTL |= USB_OTG_DOEPCTL_STALL;
}
return HAL_OK;
@@ -880,7 +880,7 @@ HAL_StatusTypeDef USB_EPSetStall(USB_OTG_GlobalTypeDef *USBx , USB_OTG_EPTypeDef
/**
* @brief USB_EPClearStall : Clear a stall condition over an EP
* @param USBx : Selected device
- * @param ep: pointer to endpoint structure
+ * @param ep: pointer to endpoint structure
* @retval HAL status
*/
HAL_StatusTypeDef USB_EPClearStall(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep)
@@ -891,7 +891,7 @@ HAL_StatusTypeDef USB_EPClearStall(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDe
if (ep->type == EP_TYPE_INTR || ep->type == EP_TYPE_BULK)
{
USBx_INEP(ep->num)->DIEPCTL |= USB_OTG_DIEPCTL_SD0PID_SEVNFRM; /* DATA0 */
- }
+ }
}
else
{
@@ -899,7 +899,7 @@ HAL_StatusTypeDef USB_EPClearStall(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDe
if (ep->type == EP_TYPE_INTR || ep->type == EP_TYPE_BULK)
{
USBx_OUTEP(ep->num)->DOEPCTL |= USB_OTG_DOEPCTL_SD0PID_SEVNFRM; /* DATA0 */
- }
+ }
}
return HAL_OK;
}
@@ -912,7 +912,7 @@ HAL_StatusTypeDef USB_EPClearStall(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDe
HAL_StatusTypeDef USB_StopDevice(USB_OTG_GlobalTypeDef *USBx)
{
uint32_t i;
-
+
/* Clear Pending interrupt */
for (i = 0; i < 15 ; i++)
{
@@ -920,16 +920,16 @@ HAL_StatusTypeDef USB_StopDevice(USB_OTG_GlobalTypeDef *USBx)
USBx_OUTEP(i)->DOEPINT = 0xFF;
}
USBx_DEVICE->DAINT = 0xFFFFFFFF;
-
+
/* Clear interrupt masks */
USBx_DEVICE->DIEPMSK = 0;
USBx_DEVICE->DOEPMSK = 0;
USBx_DEVICE->DAINTMSK = 0;
-
+
/* Flush the FIFO */
USB_FlushRxFifo(USBx);
- USB_FlushTxFifo(USBx , 0x10 );
-
+ USB_FlushTxFifo(USBx , 0x10 );
+
return HAL_OK;
}
@@ -944,8 +944,8 @@ HAL_StatusTypeDef USB_SetDevAddress (USB_OTG_GlobalTypeDef *USBx, uint8_t addre
{
USBx_DEVICE->DCFG &= ~ (USB_OTG_DCFG_DAD);
USBx_DEVICE->DCFG |= (address << 4) & USB_OTG_DCFG_DAD ;
-
- return HAL_OK;
+
+ return HAL_OK;
}
/**
@@ -957,8 +957,8 @@ HAL_StatusTypeDef USB_DevConnect (USB_OTG_GlobalTypeDef *USBx)
{
USBx_DEVICE->DCTL &= ~USB_OTG_DCTL_SDIS ;
HAL_Delay(3);
-
- return HAL_OK;
+
+ return HAL_OK;
}
/**
@@ -970,8 +970,8 @@ HAL_StatusTypeDef USB_DevDisconnect (USB_OTG_GlobalTypeDef *USBx)
{
USBx_DEVICE->DCTL |= USB_OTG_DCTL_SDIS ;
HAL_Delay(3);
-
- return HAL_OK;
+
+ return HAL_OK;
}
/**
@@ -982,10 +982,10 @@ HAL_StatusTypeDef USB_DevDisconnect (USB_OTG_GlobalTypeDef *USBx)
uint32_t USB_ReadInterrupts (USB_OTG_GlobalTypeDef *USBx)
{
uint32_t v = 0;
-
+
v = USBx->GINTSTS;
v &= USBx->GINTMSK;
- return v;
+ return v;
}
/**
@@ -1039,7 +1039,7 @@ uint32_t USB_ReadDevOutEPInterrupt (USB_OTG_GlobalTypeDef *USBx , uint8_t epnum)
uint32_t USB_ReadDevInEPInterrupt (USB_OTG_GlobalTypeDef *USBx , uint8_t epnum)
{
uint32_t v, msk, emp;
-
+
msk = USBx_DEVICE->DIEPMSK;
emp = USBx_DEVICE->DIEPEMPMSK;
msk |= ((emp >> epnum) & 0x1) << 7;
@@ -1055,7 +1055,7 @@ uint32_t USB_ReadDevInEPInterrupt (USB_OTG_GlobalTypeDef *USBx , uint8_t epnum)
*/
void USB_ClearInterrupts (USB_OTG_GlobalTypeDef *USBx, uint32_t interrupt)
{
- USBx->GINTSTS |= interrupt;
+ USBx->GINTSTS |= interrupt;
}
/**
@@ -1063,7 +1063,7 @@ void USB_ClearInterrupts (USB_OTG_GlobalTypeDef *USBx, uint32_t interrupt)
* @param USBx : Selected device
* @retval return core mode : Host or Device
* This parameter can be one of these values:
- * 0 : Host
+ * 0 : Host
* 1 : Device
*/
uint32_t USB_GetMode(USB_OTG_GlobalTypeDef *USBx)
@@ -1081,7 +1081,7 @@ HAL_StatusTypeDef USB_ActivateSetup (USB_OTG_GlobalTypeDef *USBx)
{
/* Set the MPS of the IN EP based on the enumeration speed */
USBx_INEP(0)->DIEPCTL &= ~USB_OTG_DIEPCTL_MPSIZ;
-
+
if((USBx_DEVICE->DSTS & USB_OTG_DSTS_ENUMSPD) == DSTS_ENUMSPD_LS_PHY_6MHZ)
{
USBx_INEP(0)->DIEPCTL |= 3;
@@ -1095,10 +1095,10 @@ HAL_StatusTypeDef USB_ActivateSetup (USB_OTG_GlobalTypeDef *USBx)
/**
* @brief Prepare the EP0 to start the first control setup
* @param USBx : Selected device
- * @param dma: USB dma enabled or disabled
+ * @param dma: USB dma enabled or disabled
* This parameter can be one of these values:
- * 0 : DMA feature not used
- * 1 : DMA feature used
+ * 0 : DMA feature not used
+ * 1 : DMA feature used
* @param psetup : pointer to setup packet
* @retval HAL status
*/
@@ -1107,16 +1107,16 @@ HAL_StatusTypeDef USB_EP0_OutStart(USB_OTG_GlobalTypeDef *USBx, uint8_t dma, uin
USBx_OUTEP(0)->DOEPTSIZ = 0;
USBx_OUTEP(0)->DOEPTSIZ |= (USB_OTG_DOEPTSIZ_PKTCNT & (1 << 19)) ;
USBx_OUTEP(0)->DOEPTSIZ |= (3 * 8);
- USBx_OUTEP(0)->DOEPTSIZ |= USB_OTG_DOEPTSIZ_STUPCNT;
-
+ USBx_OUTEP(0)->DOEPTSIZ |= USB_OTG_DOEPTSIZ_STUPCNT;
+
if (dma == 1)
{
USBx_OUTEP(0)->DOEPDMA = (uint32_t)psetup;
/* EP enable */
USBx_OUTEP(0)->DOEPCTL = 0x80008000;
}
-
- return HAL_OK;
+
+ return HAL_OK;
}
@@ -1138,7 +1138,7 @@ static HAL_StatusTypeDef USB_CoreReset(USB_OTG_GlobalTypeDef *USBx)
}
}
while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_AHBIDL) == 0);
-
+
/* Core Soft Reset */
count = 0;
USBx->GRSTCTL |= USB_OTG_GRSTCTL_CSRST;
@@ -1151,24 +1151,24 @@ static HAL_StatusTypeDef USB_CoreReset(USB_OTG_GlobalTypeDef *USBx)
}
}
while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_CSRST) == USB_OTG_GRSTCTL_CSRST);
-
+
return HAL_OK;
}
-#ifdef USB_HS_PHYC
+#ifdef USB_HS_PHYC
/**
* @brief Enables control of a High Speed USB PHY’s
- * Init the low level hardware : GPIO, CLOCK, NVIC...
+ * Init the low level hardware : GPIO, CLOCK, NVIC...
* @param USBx : Selected device
* @retval HAL status
*/
static HAL_StatusTypeDef USB_HS_PHYCInit(USB_OTG_GlobalTypeDef *USBx)
{
uint32_t count = 0;
-
+
/* Enable LDO */
USB_HS_PHYC->USB_HS_PHYC_LDO |= USB_HS_PHYC_LDO_ENABLE;
-
+
/* wait for LDO Ready */
while((USB_HS_PHYC->USB_HS_PHYC_LDO & USB_HS_PHYC_LDO_STATUS) == RESET)
{
@@ -1191,7 +1191,7 @@ static HAL_StatusTypeDef USB_HS_PHYCInit(USB_OTG_GlobalTypeDef *USBx)
{
USB_HS_PHYC->USB_HS_PHYC_PLL = (uint32_t)(0x3 << 1);
}
-
+
else if (HSE_VALUE == 24000000) /* HSE = 24MHz */
{
USB_HS_PHYC->USB_HS_PHYC_PLL = (uint32_t)(0x4 << 1);
@@ -1204,23 +1204,23 @@ static HAL_StatusTypeDef USB_HS_PHYCInit(USB_OTG_GlobalTypeDef *USBx)
{
USB_HS_PHYC->USB_HS_PHYC_PLL = (uint32_t)(0x7 << 1);
}
-
+
/* Control the tuning interface of the High Speed PHY */
USB_HS_PHYC->USB_HS_PHYC_TUNE |= USB_HS_PHYC_TUNE_VALUE;
-
+
/* Enable PLL internal PHY */
USB_HS_PHYC->USB_HS_PHYC_PLL |= USB_HS_PHYC_PLL_PLLEN;
/* 2ms Delay required to get internal phy clock stable */
HAL_Delay(2);
-
+
return HAL_OK;
}
#endif /* USB_HS_PHYC */
/**
- * @brief USB_HostInit : Initializes the USB OTG controller registers
- * for Host mode
+ * @brief USB_HostInit : Initializes the USB OTG controller registers
+ * for Host mode
* @param USBx : Selected device
* @param cfg : pointer to a USB_OTG_CfgTypeDef structure that contains
* the configuration information for the specified USBx peripheral.
@@ -1229,22 +1229,22 @@ static HAL_StatusTypeDef USB_HS_PHYCInit(USB_OTG_GlobalTypeDef *USBx)
HAL_StatusTypeDef USB_HostInit (USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef cfg)
{
uint32_t i;
-
+
/* Restart the Phy Clock */
USBx_PCGCCTL = 0;
-
+
/*Activate VBUS Sensing B */
USBx->GCCFG |= USB_OTG_GCCFG_VBDEN;
-
+
/* Disable the FS/LS support mode only */
if((cfg.speed == USB_OTG_SPEED_FULL)&&
(USBx != USB_OTG_FS))
{
- USBx_HOST->HCFG |= USB_OTG_HCFG_FSLSS;
+ USBx_HOST->HCFG |= USB_OTG_HCFG_FSLSS;
}
else
{
- USBx_HOST->HCFG &= ~(USB_OTG_HCFG_FSLSS);
+ USBx_HOST->HCFG &= ~(USB_OTG_HCFG_FSLSS);
}
/* Make sure the FIFOs are flushed. */
@@ -1257,39 +1257,39 @@ HAL_StatusTypeDef USB_HostInit (USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef
USBx_HC(i)->HCINT = 0xFFFFFFFF;
USBx_HC(i)->HCINTMSK = 0;
}
-
+
/* Enable VBUS driving */
USB_DriveVbus(USBx, 1);
-
+
HAL_Delay(200);
-
+
/* Disable all interrupts. */
USBx->GINTMSK = 0;
-
+
/* Clear any pending interrupts */
USBx->GINTSTS = 0xFFFFFFFF;
-
+
if(USBx == USB_OTG_FS)
{
/* set Rx FIFO size */
- USBx->GRXFSIZ = (uint32_t )0x80;
+ USBx->GRXFSIZ = (uint32_t )0x80;
USBx->DIEPTXF0_HNPTXFSIZ = (uint32_t )(((0x60 << 16)& USB_OTG_NPTXFD) | 0x80);
USBx->HPTXFSIZ = (uint32_t )(((0x40 << 16)& USB_OTG_HPTXFSIZ_PTXFD) | 0xE0);
}
else
{
/* set Rx FIFO size */
- USBx->GRXFSIZ = (uint32_t )0x200;
+ USBx->GRXFSIZ = (uint32_t )0x200;
USBx->DIEPTXF0_HNPTXFSIZ = (uint32_t )(((0x100 << 16)& USB_OTG_NPTXFD) | 0x200);
USBx->HPTXFSIZ = (uint32_t )(((0xE0 << 16)& USB_OTG_HPTXFSIZ_PTXFD) | 0x300);
}
-
+
/* Enable the common interrupts */
if (cfg.dma_enable == DISABLE)
{
- USBx->GINTMSK |= USB_OTG_GINTMSK_RXFLVLM;
+ USBx->GINTMSK |= USB_OTG_GINTMSK_RXFLVLM;
}
-
+
/* Enable interrupts matching to the Host mode ONLY */
USBx->GINTMSK |= (USB_OTG_GINTMSK_PRTIM | USB_OTG_GINTMSK_HCIM |\
USB_OTG_GINTMSK_SOFM |USB_OTG_GINTSTS_DISCINT|\
@@ -1299,20 +1299,20 @@ HAL_StatusTypeDef USB_HostInit (USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef
}
/**
- * @brief USB_InitFSLSPClkSel : Initializes the FSLSPClkSel field of the
+ * @brief USB_InitFSLSPClkSel : Initializes the FSLSPClkSel field of the
* HCFG register on the PHY type and set the right frame interval
* @param USBx : Selected device
* @param freq : clock frequency
* This parameter can be one of these values:
- * HCFG_48_MHZ : Full Speed 48 MHz Clock
- * HCFG_6_MHZ : Low Speed 6 MHz Clock
+ * HCFG_48_MHZ : Full Speed 48 MHz Clock
+ * HCFG_6_MHZ : Low Speed 6 MHz Clock
* @retval HAL status
*/
HAL_StatusTypeDef USB_InitFSLSPClkSel(USB_OTG_GlobalTypeDef *USBx , uint8_t freq)
{
USBx_HOST->HCFG &= ~(USB_OTG_HCFG_FSLSPCS);
USBx_HOST->HCFG |= (freq & USB_OTG_HCFG_FSLSPCS);
-
+
if (freq == HCFG_48_MHZ)
{
USBx_HOST->HFIR = (uint32_t)48000;
@@ -1320,8 +1320,8 @@ HAL_StatusTypeDef USB_InitFSLSPClkSel(USB_OTG_GlobalTypeDef *USBx , uint8_t freq
else if (freq == HCFG_6_MHZ)
{
USBx_HOST->HFIR = (uint32_t)6000;
- }
- return HAL_OK;
+ }
+ return HAL_OK;
}
/**
@@ -1340,9 +1340,9 @@ HAL_StatusTypeDef USB_ResetPort(USB_OTG_GlobalTypeDef *USBx)
hprt0 &= ~(USB_OTG_HPRT_PENA | USB_OTG_HPRT_PCDET |
USB_OTG_HPRT_PENCHNG | USB_OTG_HPRT_POCCHNG);
- USBx_HPRT0 = (USB_OTG_HPRT_PRST | hprt0);
+ USBx_HPRT0 = (USB_OTG_HPRT_PRST | hprt0);
HAL_Delay (100); /* See Note #1 */
- USBx_HPRT0 = ((~USB_OTG_HPRT_PRST) & hprt0);
+ USBx_HPRT0 = ((~USB_OTG_HPRT_PRST) & hprt0);
HAL_Delay (10);
return HAL_OK;
@@ -1352,7 +1352,7 @@ HAL_StatusTypeDef USB_ResetPort(USB_OTG_GlobalTypeDef *USBx)
* @brief USB_DriveVbus : activate or de-activate vbus
* @param state : VBUS state
* This parameter can be one of these values:
- * 0 : VBUS Active
+ * 0 : VBUS Active
* 1 : VBUS Inactive
* @retval HAL status
*/
@@ -1367,13 +1367,13 @@ HAL_StatusTypeDef USB_DriveVbus (USB_OTG_GlobalTypeDef *USBx, uint8_t state)
if (((hprt0 & USB_OTG_HPRT_PPWR) == 0 ) && (state == 1 ))
{
- USBx_HPRT0 = (USB_OTG_HPRT_PPWR | hprt0);
+ USBx_HPRT0 = (USB_OTG_HPRT_PPWR | hprt0);
}
if (((hprt0 & USB_OTG_HPRT_PPWR) == USB_OTG_HPRT_PPWR) && (state == 0 ))
{
- USBx_HPRT0 = ((~USB_OTG_HPRT_PPWR) & hprt0);
+ USBx_HPRT0 = ((~USB_OTG_HPRT_PPWR) & hprt0);
}
- return HAL_OK;
+ return HAL_OK;
}
/**
@@ -1388,7 +1388,7 @@ HAL_StatusTypeDef USB_DriveVbus (USB_OTG_GlobalTypeDef *USBx, uint8_t state)
uint32_t USB_GetHostSpeed (USB_OTG_GlobalTypeDef *USBx)
{
__IO uint32_t hprt0;
-
+
hprt0 = USBx_HPRT0;
return ((hprt0 & USB_OTG_HPRT_PSPD) >> 17);
}
@@ -1427,7 +1427,7 @@ uint32_t USB_GetCurrentFrame (USB_OTG_GlobalTypeDef *USBx)
* This parameter can be a value from 0 to32K
* @retval HAL state
*/
-HAL_StatusTypeDef USB_HC_Init(USB_OTG_GlobalTypeDef *USBx,
+HAL_StatusTypeDef USB_HC_Init(USB_OTG_GlobalTypeDef *USBx,
uint8_t ch_num,
uint8_t epnum,
uint8_t dev_address,
@@ -1435,28 +1435,28 @@ HAL_StatusTypeDef USB_HC_Init(USB_OTG_GlobalTypeDef *USBx,
uint8_t ep_type,
uint16_t mps)
{
-
+
/* Clear old interrupt conditions for this host channel. */
USBx_HC(ch_num)->HCINT = 0xFFFFFFFF;
-
+
/* Enable channel interrupts required for this transfer. */
- switch (ep_type)
+ switch (ep_type)
{
case EP_TYPE_CTRL:
case EP_TYPE_BULK:
-
+
USBx_HC(ch_num)->HCINTMSK = USB_OTG_HCINTMSK_XFRCM |\
USB_OTG_HCINTMSK_STALLM |\
USB_OTG_HCINTMSK_TXERRM |\
USB_OTG_HCINTMSK_DTERRM |\
USB_OTG_HCINTMSK_AHBERR |\
USB_OTG_HCINTMSK_NAKM ;
-
- if (epnum & 0x80)
+
+ if (epnum & 0x80)
{
USBx_HC(ch_num)->HCINTMSK |= USB_OTG_HCINTMSK_BBERRM;
- }
- else
+ }
+ else
{
if(USBx != USB_OTG_FS)
{
@@ -1464,43 +1464,43 @@ HAL_StatusTypeDef USB_HC_Init(USB_OTG_GlobalTypeDef *USBx,
}
}
break;
-
+
case EP_TYPE_INTR:
-
+
USBx_HC(ch_num)->HCINTMSK = USB_OTG_HCINTMSK_XFRCM |\
USB_OTG_HCINTMSK_STALLM |\
USB_OTG_HCINTMSK_TXERRM |\
USB_OTG_HCINTMSK_DTERRM |\
USB_OTG_HCINTMSK_NAKM |\
USB_OTG_HCINTMSK_AHBERR |\
- USB_OTG_HCINTMSK_FRMORM ;
-
- if (epnum & 0x80)
+ USB_OTG_HCINTMSK_FRMORM ;
+
+ if (epnum & 0x80)
{
USBx_HC(ch_num)->HCINTMSK |= USB_OTG_HCINTMSK_BBERRM;
}
-
+
break;
case EP_TYPE_ISOC:
-
+
USBx_HC(ch_num)->HCINTMSK = USB_OTG_HCINTMSK_XFRCM |\
USB_OTG_HCINTMSK_ACKM |\
USB_OTG_HCINTMSK_AHBERR |\
- USB_OTG_HCINTMSK_FRMORM ;
-
- if (epnum & 0x80)
+ USB_OTG_HCINTMSK_FRMORM ;
+
+ if (epnum & 0x80)
{
- USBx_HC(ch_num)->HCINTMSK |= (USB_OTG_HCINTMSK_TXERRM | USB_OTG_HCINTMSK_BBERRM);
+ USBx_HC(ch_num)->HCINTMSK |= (USB_OTG_HCINTMSK_TXERRM | USB_OTG_HCINTMSK_BBERRM);
}
break;
}
-
+
/* Enable the top level host channel interrupt. */
USBx_HOST->HAINTMSK |= (1 << ch_num);
-
+
/* Make sure host channel interrupts are enabled. */
USBx->GINTMSK |= USB_OTG_GINTMSK_HCIM;
-
+
/* Program the HCCHAR register */
USBx_HC(ch_num)->HCCHAR = (((dev_address << 22) & USB_OTG_HCCHAR_DAD) |\
(((epnum & 0x7F)<< 11) & USB_OTG_HCCHAR_EPNUM)|\
@@ -1508,33 +1508,33 @@ HAL_StatusTypeDef USB_HC_Init(USB_OTG_GlobalTypeDef *USBx,
(((speed == HPRT0_PRTSPD_LOW_SPEED)<< 17) & USB_OTG_HCCHAR_LSDEV)|\
((ep_type << 18) & USB_OTG_HCCHAR_EPTYP)|\
(mps & USB_OTG_HCCHAR_MPSIZ));
-
+
if (ep_type == EP_TYPE_INTR)
{
USBx_HC(ch_num)->HCCHAR |= USB_OTG_HCCHAR_ODDFRM ;
}
- return HAL_OK;
+ return HAL_OK;
}
/**
* @brief Start a transfer over a host channel
* @param USBx : Selected device
* @param hc : pointer to host channel structure
- * @param dma: USB dma enabled or disabled
+ * @param dma: USB dma enabled or disabled
* This parameter can be one of these values:
- * 0 : DMA feature not used
- * 1 : DMA feature used
+ * 0 : DMA feature not used
+ * 1 : DMA feature used
* @retval HAL state
*/
HAL_StatusTypeDef USB_HC_StartXfer(USB_OTG_GlobalTypeDef *USBx, USB_OTG_HCTypeDef *hc, uint8_t dma)
{
static __IO uint32_t tmpreg = 0;
- uint8_t is_oddframe = 0;
- uint16_t len_words = 0;
+ uint8_t is_oddframe = 0;
+ uint16_t len_words = 0;
uint16_t num_packets = 0;
uint16_t max_hc_pkt_count = 256;
-
+
if((USBx != USB_OTG_FS) && (hc->speed == USB_OTG_SPEED_HIGH))
{
if((dma == 0) && (hc->do_ping == 1))
@@ -1548,12 +1548,12 @@ HAL_StatusTypeDef USB_HC_StartXfer(USB_OTG_GlobalTypeDef *USBx, USB_OTG_HCTypeDe
hc->do_ping = 0;
}
}
-
+
/* Compute the expected number of packets associated to the transfer */
if (hc->xfer_len > 0)
{
num_packets = (hc->xfer_len + hc->max_packet - 1) / hc->max_packet;
-
+
if (num_packets > max_hc_pkt_count)
{
num_packets = max_hc_pkt_count;
@@ -1568,40 +1568,40 @@ HAL_StatusTypeDef USB_HC_StartXfer(USB_OTG_GlobalTypeDef *USBx, USB_OTG_HCTypeDe
{
hc->xfer_len = num_packets * hc->max_packet;
}
-
+
/* Initialize the HCTSIZn register */
USBx_HC(hc->ch_num)->HCTSIZ = (((hc->xfer_len) & USB_OTG_HCTSIZ_XFRSIZ)) |\
((num_packets << 19) & USB_OTG_HCTSIZ_PKTCNT) |\
(((hc->data_pid) << 29) & USB_OTG_HCTSIZ_DPID);
-
+
if (dma)
{
/* xfer_buff MUST be 32-bits aligned */
USBx_HC(hc->ch_num)->HCDMA = (uint32_t)hc->xfer_buff;
}
-
+
is_oddframe = (USBx_HOST->HFNUM & 0x01) ? 0 : 1;
USBx_HC(hc->ch_num)->HCCHAR &= ~USB_OTG_HCCHAR_ODDFRM;
USBx_HC(hc->ch_num)->HCCHAR |= (is_oddframe << 29);
-
+
/* Set host channel enable */
tmpreg = USBx_HC(hc->ch_num)->HCCHAR;
tmpreg &= ~USB_OTG_HCCHAR_CHDIS;
tmpreg |= USB_OTG_HCCHAR_CHENA;
USBx_HC(hc->ch_num)->HCCHAR = tmpreg;
-
+
if (dma == 0) /* Slave mode */
- {
+ {
if((hc->ep_is_in == 0) && (hc->xfer_len > 0))
{
- switch(hc->ep_type)
+ switch(hc->ep_type)
{
/* Non periodic transfer */
case EP_TYPE_CTRL:
case EP_TYPE_BULK:
-
+
len_words = (hc->xfer_len + 3) / 4;
-
+
/* check if there is enough space in FIFO space */
if(len_words > (USBx->HNPTXSTS & 0xFFFF))
{
@@ -1617,19 +1617,19 @@ HAL_StatusTypeDef USB_HC_StartXfer(USB_OTG_GlobalTypeDef *USBx, USB_OTG_HCTypeDe
if(len_words > (USBx_HOST->HPTXSTS & 0xFFFF)) /* split the transfer */
{
/* need to process data in ptxfempty interrupt */
- USBx->GINTMSK |= USB_OTG_GINTMSK_PTXFEM;
+ USBx->GINTMSK |= USB_OTG_GINTMSK_PTXFEM;
}
break;
-
+
default:
break;
}
-
+
/* Write packet into the Tx FIFO. */
USB_WritePacket(USBx, hc->xfer_buff, hc->ch_num, hc->xfer_len, 0);
}
}
-
+
return HAL_OK;
}
@@ -1653,56 +1653,56 @@ uint32_t USB_HC_ReadInterrupt (USB_OTG_GlobalTypeDef *USBx)
HAL_StatusTypeDef USB_HC_Halt(USB_OTG_GlobalTypeDef *USBx , uint8_t hc_num)
{
uint32_t count = 0;
-
+
/* Check for space in the request queue to issue the halt. */
if (((((USBx_HC(hc_num)->HCCHAR) & USB_OTG_HCCHAR_EPTYP) >> 18) == HCCHAR_CTRL) ||
(((((USBx_HC(hc_num)->HCCHAR) & USB_OTG_HCCHAR_EPTYP) >> 18) == HCCHAR_BULK)))
{
USBx_HC(hc_num)->HCCHAR |= USB_OTG_HCCHAR_CHDIS;
-
+
if ((USBx->HNPTXSTS & 0xFFFF) == 0)
{
USBx_HC(hc_num)->HCCHAR &= ~USB_OTG_HCCHAR_CHENA;
- USBx_HC(hc_num)->HCCHAR |= USB_OTG_HCCHAR_CHENA;
+ USBx_HC(hc_num)->HCCHAR |= USB_OTG_HCCHAR_CHENA;
USBx_HC(hc_num)->HCCHAR &= ~USB_OTG_HCCHAR_EPDIR;
- do
+ do
{
- if (++count > 1000)
+ if (++count > 1000)
{
break;
}
- }
- while ((USBx_HC(hc_num)->HCCHAR & USB_OTG_HCCHAR_CHENA) == USB_OTG_HCCHAR_CHENA);
+ }
+ while ((USBx_HC(hc_num)->HCCHAR & USB_OTG_HCCHAR_CHENA) == USB_OTG_HCCHAR_CHENA);
}
else
{
- USBx_HC(hc_num)->HCCHAR |= USB_OTG_HCCHAR_CHENA;
+ USBx_HC(hc_num)->HCCHAR |= USB_OTG_HCCHAR_CHENA;
}
}
else
{
USBx_HC(hc_num)->HCCHAR |= USB_OTG_HCCHAR_CHDIS;
-
+
if ((USBx_HOST->HPTXSTS & 0xFFFF) == 0)
{
USBx_HC(hc_num)->HCCHAR &= ~USB_OTG_HCCHAR_CHENA;
- USBx_HC(hc_num)->HCCHAR |= USB_OTG_HCCHAR_CHENA;
+ USBx_HC(hc_num)->HCCHAR |= USB_OTG_HCCHAR_CHENA;
USBx_HC(hc_num)->HCCHAR &= ~USB_OTG_HCCHAR_EPDIR;
- do
+ do
{
- if (++count > 1000)
+ if (++count > 1000)
{
break;
}
- }
- while ((USBx_HC(hc_num)->HCCHAR & USB_OTG_HCCHAR_CHENA) == USB_OTG_HCCHAR_CHENA);
+ }
+ while ((USBx_HC(hc_num)->HCCHAR & USB_OTG_HCCHAR_CHENA) == USB_OTG_HCCHAR_CHENA);
}
else
{
- USBx_HC(hc_num)->HCCHAR |= USB_OTG_HCCHAR_CHENA;
+ USBx_HC(hc_num)->HCCHAR |= USB_OTG_HCCHAR_CHENA;
}
}
-
+
return HAL_OK;
}
@@ -1720,14 +1720,14 @@ HAL_StatusTypeDef USB_DoPing(USB_OTG_GlobalTypeDef *USBx , uint8_t ch_num)
USBx_HC(ch_num)->HCTSIZ = ((num_packets << 19) & USB_OTG_HCTSIZ_PKTCNT) |\
USB_OTG_HCTSIZ_DOPING;
-
+
/* Set host channel enable */
tmpreg = USBx_HC(ch_num)->HCCHAR;
tmpreg &= ~USB_OTG_HCCHAR_CHDIS;
tmpreg |= USB_OTG_HCCHAR_CHENA;
USBx_HC(ch_num)->HCCHAR = tmpreg;
-
- return HAL_OK;
+
+ return HAL_OK;
}
/**
@@ -1740,41 +1740,41 @@ HAL_StatusTypeDef USB_StopHost(USB_OTG_GlobalTypeDef *USBx)
uint8_t i;
uint32_t count = 0;
uint32_t value;
-
+
USB_DisableGlobalInt(USBx);
-
+
/* Flush FIFO */
USB_FlushTxFifo(USBx, 0x10);
USB_FlushRxFifo(USBx);
-
+
/* Flush out any leftover queued requests. */
for (i = 0; i <= 15; i++)
- {
+ {
value = USBx_HC(i)->HCCHAR ;
value |= USB_OTG_HCCHAR_CHDIS;
- value &= ~USB_OTG_HCCHAR_CHENA;
+ value &= ~USB_OTG_HCCHAR_CHENA;
value &= ~USB_OTG_HCCHAR_EPDIR;
USBx_HC(i)->HCCHAR = value;
}
-
- /* Halt all channels to put them into a known state. */
+
+ /* Halt all channels to put them into a known state. */
for (i = 0; i <= 15; i++)
{
value = USBx_HC(i)->HCCHAR ;
-
+
value |= USB_OTG_HCCHAR_CHDIS;
- value |= USB_OTG_HCCHAR_CHENA;
+ value |= USB_OTG_HCCHAR_CHENA;
value &= ~USB_OTG_HCCHAR_EPDIR;
-
+
USBx_HC(i)->HCCHAR = value;
- do
+ do
{
- if (++count > 1000)
+ if (++count > 1000)
{
break;
}
- }
+ }
while ((USBx_HC(i)->HCCHAR & USB_OTG_HCCHAR_CHENA) == USB_OTG_HCCHAR_CHENA);
}
@@ -1782,7 +1782,7 @@ HAL_StatusTypeDef USB_StopHost(USB_OTG_GlobalTypeDef *USBx)
USBx_HOST->HAINT = 0xFFFFFFFF;
USBx->GINTSTS = 0xFFFFFFFF;
USB_EnableGlobalInt(USBx);
- return HAL_OK;
+ return HAL_OK;
}
/**
* @}
diff --git a/make/release.mk b/make/release.mk
index 920725fcb2..f405b4dbe1 100644
--- a/make/release.mk
+++ b/make/release.mk
@@ -15,3 +15,5 @@ RELEASE_TARGETS += OMNIBUSF4 OMNIBUSF4PRO OMNIBUSF4V3 OMNIBUSF4PRO_LEDSTRIPM5 DY
RELEASE_TARGETS += OMNIBUSF7 OMNIBUSF7V2 OMNIBUSF7NXT YUPIF7
RELEASE_TARGETS += MATEKF405 MATEKF405_SERVOS6 MATEKF405OSD MATEKF722 MATEKF405SE MATEKF411
+
+RELEASE_TARGETS += SPEEDYBEEF4 FRSKYF3 FRSKYF4
diff --git a/src/main/build/version.c b/src/main/build/version.c
index b4a9ea928f..566f5b6c6f 100644
--- a/src/main/build/version.c
+++ b/src/main/build/version.c
@@ -18,6 +18,7 @@
#include "version.h"
const char * const targetName = __TARGET__;
+const char * const compilerVersion = __VERSION__;
const char * const shortGitRevision = __REVISION__;
const char * const buildDate = __DATE__;
-const char * const buildTime = __TIME__;
+const char * const buildTime = __TIME__;
\ No newline at end of file
diff --git a/src/main/build/version.h b/src/main/build/version.h
index 4457f578a0..a6fc172ff5 100644
--- a/src/main/build/version.h
+++ b/src/main/build/version.h
@@ -16,7 +16,7 @@
*/
#define FC_VERSION_MAJOR 2 // increment when a major release is made (big new feature, etc)
-#define FC_VERSION_MINOR 0 // increment when a minor release is made (small new feature, change etc)
+#define FC_VERSION_MINOR 1 // increment when a minor release is made (small new feature, change etc)
#define FC_VERSION_PATCH_LEVEL 0 // increment when a bug is fixed
#define STR_HELPER(x) #x
@@ -26,6 +26,7 @@
#define MW_VERSION 231
+extern const char* const compilerVersion;
extern const char* const targetName;
#define GIT_SHORT_REVISION_LENGTH 8 // lower case hexadecimal digits.
diff --git a/src/main/drivers/compass/compass_ak8963.c b/src/main/drivers/compass/compass_ak8963.c
index dc4ce5f4d2..58d100d9f7 100755
--- a/src/main/drivers/compass/compass_ak8963.c
+++ b/src/main/drivers/compass/compass_ak8963.c
@@ -139,7 +139,7 @@ static bool ak8963Read(magDev_t * mag)
}
mag->magADCRaw[X] = -parseMag(buf + 0, magGain[X]);
- mag->magADCRaw[Y] = -parseMag(buf + 2, magGain[Y]);
+ mag->magADCRaw[Y] = parseMag(buf + 2, magGain[Y]);
mag->magADCRaw[Z] = -parseMag(buf + 4, magGain[Z]);
return true;
diff --git a/src/main/drivers/compass/compass_ak8975.c b/src/main/drivers/compass/compass_ak8975.c
index e280da62a5..c30869c613 100644
--- a/src/main/drivers/compass/compass_ak8975.c
+++ b/src/main/drivers/compass/compass_ak8975.c
@@ -118,7 +118,7 @@ static bool ak8975Read(magDev_t * mag)
}
mag->magADCRaw[X] = -(int16_t)(buf[1] << 8 | buf[0]) * 4;
- mag->magADCRaw[Y] = -(int16_t)(buf[3] << 8 | buf[2]) * 4;
+ mag->magADCRaw[Y] = (int16_t)(buf[3] << 8 | buf[2]) * 4;
mag->magADCRaw[Z] = -(int16_t)(buf[5] << 8 | buf[4]) * 4;
ack = busWrite(mag->busDev, AK8975_MAG_REG_CNTL, 0x01); // start reading again
diff --git a/src/main/drivers/compass/compass_mpu9250.c b/src/main/drivers/compass/compass_mpu9250.c
index db0a7f3213..1e7d6aa178 100755
--- a/src/main/drivers/compass/compass_mpu9250.c
+++ b/src/main/drivers/compass/compass_mpu9250.c
@@ -269,7 +269,7 @@ static bool mpu9250CompassRead(magDev_t * mag)
}
mag->magADCRaw[X] = -parseMag(buf + 0, magGain[X]);
- mag->magADCRaw[Y] = -parseMag(buf + 2, magGain[Y]);
+ mag->magADCRaw[Y] = parseMag(buf + 2, magGain[Y]);
mag->magADCRaw[Z] = -parseMag(buf + 4, magGain[Z]);
memcpy(cachedMagData, &mag->magADCRaw, sizeof(cachedMagData));
diff --git a/src/main/fc/cli.c b/src/main/fc/cli.c
index cc5b44d43f..d246db6dc8 100755
--- a/src/main/fc/cli.c
+++ b/src/main/fc/cli.c
@@ -2547,6 +2547,9 @@ static void cliVersion(char *cmdline)
buildTime,
shortGitRevision
);
+ cliPrintLinef("# GCC-%s",
+ compilerVersion
+ );
}
static void cliMemory(char *cmdline)
diff --git a/src/main/fc/rc_modes.c b/src/main/fc/rc_modes.c
index b523970f9b..dfe2e5ec17 100755
--- a/src/main/fc/rc_modes.c
+++ b/src/main/fc/rc_modes.c
@@ -99,9 +99,12 @@ bool isRangeActive(uint8_t auxChannelIndex, const channelRange_t *range)
return false;
}
- uint16_t channelValue = constrain(rcData[auxChannelIndex + NON_AUX_CHANNEL_COUNT], CHANNEL_RANGE_MIN, CHANNEL_RANGE_MAX - 1);
- return (channelValue >= 900 + (range->startStep * 25) &&
- channelValue < 900 + (range->endStep * 25));
+ // No need to constrain() here, since we're testing for a closed range defined
+ // by the channelRange_t. If channelValue has an invalid value, the test will
+ // be false anyway.
+ uint16_t channelValue = rcData[auxChannelIndex + NON_AUX_CHANNEL_COUNT];
+ return (channelValue >= CHANNEL_RANGE_MIN + (range->startStep * CHANNEL_RANGE_STEP_WIDTH) &&
+ channelValue < CHANNEL_RANGE_MIN + (range->endStep * CHANNEL_RANGE_STEP_WIDTH));
}
void updateActivatedModes(void)
diff --git a/src/main/fc/rc_modes.h b/src/main/fc/rc_modes.h
index 30730ac663..6c55253dcc 100755
--- a/src/main/fc/rc_modes.h
+++ b/src/main/fc/rc_modes.h
@@ -72,11 +72,13 @@ typedef struct boxBitmask_s { BITARRAY_DECLARE(bits, CHECKBOX_ITEM_COUNT); } box
#define CHANNEL_RANGE_MIN 900
#define CHANNEL_RANGE_MAX 2100
-#define MODE_STEP_TO_CHANNEL_VALUE(step) (CHANNEL_RANGE_MIN + 25 * step)
-#define CHANNEL_VALUE_TO_STEP(channelValue) ((constrain(channelValue, CHANNEL_RANGE_MIN, CHANNEL_RANGE_MAX) - CHANNEL_RANGE_MIN) / 25)
+#define CHANNEL_RANGE_STEP_WIDTH 25
+
+#define MODE_STEP_TO_CHANNEL_VALUE(step) (CHANNEL_RANGE_MIN + CHANNEL_RANGE_STEP_WIDTH * step)
+#define CHANNEL_VALUE_TO_STEP(channelValue) ((constrain(channelValue, CHANNEL_RANGE_MIN, CHANNEL_RANGE_MAX) - CHANNEL_RANGE_MIN) / CHANNEL_RANGE_STEP_WIDTH)
#define MIN_MODE_RANGE_STEP 0
-#define MAX_MODE_RANGE_STEP ((CHANNEL_RANGE_MAX - CHANNEL_RANGE_MIN) / 25)
+#define MAX_MODE_RANGE_STEP ((CHANNEL_RANGE_MAX - CHANNEL_RANGE_MIN) / CHANNEL_RANGE_STEP_WIDTH)
#define IS_RANGE_USABLE(range) ((range)->startStep < (range)->endStep)
diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml
index 53927aa3bf..6db3e2c50f 100644
--- a/src/main/fc/settings.yaml
+++ b/src/main/fc/settings.yaml
@@ -1705,7 +1705,7 @@ groups:
- name: PG_VTX_SETTINGS_CONFIG
type: vtxSettingsConfig_t
headers: ["drivers/vtx_common.h", "io/vtx.h"]
- condition: defined(VTX_COMMON) || (defined(USE_CMS) && defined(USE_VTX_SMARTAUDIO))
+ condition: USE_VTX_COMMON
members:
- name: vtx_band
field: band
diff --git a/src/main/flight/failsafe.c b/src/main/flight/failsafe.c
index de0047030e..fd45ddc6f8 100644
--- a/src/main/flight/failsafe.c
+++ b/src/main/flight/failsafe.c
@@ -154,6 +154,7 @@ void failsafeReset(void)
failsafeState.receivingRxDataPeriodPreset = 0;
failsafeState.phase = FAILSAFE_IDLE;
failsafeState.rxLinkState = FAILSAFE_RXLINK_DOWN;
+ failsafeState.bypassNavigation = true;
failsafeState.lastGoodRcCommand[ROLL] = 0;
failsafeState.lastGoodRcCommand[PITCH] = 0;
@@ -171,7 +172,7 @@ void failsafeInit(void)
#ifdef USE_NAV
bool failsafeBypassNavigation(void)
{
- return failsafeState.active && failsafeState.controlling && failsafeProcedureLogic[failsafeConfig()->failsafe_procedure].bypassNavigation;
+ return failsafeState.active && failsafeState.controlling && failsafeState.bypassNavigation;
}
bool failsafeMayRequireNavigationMode(void)
@@ -227,6 +228,7 @@ static void failsafeActivate(failsafePhase_e newPhase)
failsafeState.active = true;
failsafeState.controlling = true;
failsafeState.phase = newPhase;
+ failsafeState.bypassNavigation = failsafeProcedureLogic[failsafeConfig()->failsafe_procedure].bypassNavigation;
ENABLE_FLIGHT_MODE(FAILSAFE_MODE);
failsafeState.landingShouldBeFinishedAt = millis() + failsafeConfig()->failsafe_off_delay * MILLIS_PER_TENTH_SECOND;
@@ -469,6 +471,7 @@ void failsafeUpdateState(void)
// This shouldn't happen. If RTH was somehow aborted during failsafe - fallback to FAILSAFE_LANDING procedure
abortForcedRTH();
failsafeActivate(FAILSAFE_LANDING);
+ failsafeState.bypassNavigation = true; // Force bypassing navigation
reprocessState = true;
break;
}
diff --git a/src/main/flight/failsafe.h b/src/main/flight/failsafe.h
index cf8a383b28..8de8a0062e 100644
--- a/src/main/flight/failsafe.h
+++ b/src/main/flight/failsafe.h
@@ -134,6 +134,7 @@ typedef struct failsafeState_s {
bool suspended; // Failsafe is temporary suspended. This happens when we temporary suspend RX system due to EEPROM write/read
bool active; // Failsafe is active (on RC link loss)
bool controlling; // Failsafe is driving the sticks instead of pilot
+ bool bypassNavigation;
timeMs_t rxDataFailurePeriod;
timeMs_t rxDataRecoveryPeriod;
timeMs_t validRxDataReceivedAt;
diff --git a/src/main/flight/servos.c b/src/main/flight/servos.c
index ca8b8ab428..6cc5629873 100755
--- a/src/main/flight/servos.c
+++ b/src/main/flight/servos.c
@@ -240,8 +240,8 @@ void servoMixer(float dT)
input[INPUT_FEATURE_FLAPS] = FLIGHT_MODE(FLAPERON) ? servoConfig()->flaperon_throw_offset : 0;
if (IS_RC_MODE_ACTIVE(BOXCAMSTAB)) {
- input[INPUT_GIMBAL_PITCH] = scaleRange(attitude.values.pitch, -1800, 1800, -360, +360);
- input[INPUT_GIMBAL_ROLL] = scaleRange(attitude.values.roll, -1800, 1800, -360, +360);
+ input[INPUT_GIMBAL_PITCH] = scaleRange(attitude.values.pitch, -1800, 1800, -1000, +1000);
+ input[INPUT_GIMBAL_ROLL] = scaleRange(attitude.values.roll, -1800, 1800, -1000, +1000);
} else {
input[INPUT_GIMBAL_PITCH] = 0;
input[INPUT_GIMBAL_ROLL] = 0;
@@ -415,4 +415,4 @@ bool isServoOutputEnabled(void)
bool isMixerUsingServos(void)
{
return mixerUsesServos;
-}
\ No newline at end of file
+}
diff --git a/src/main/flight/servos.h b/src/main/flight/servos.h
index c6fc0a2ad3..820ac430c1 100644
--- a/src/main/flight/servos.h
+++ b/src/main/flight/servos.h
@@ -22,7 +22,7 @@
#define MAX_SUPPORTED_SERVOS 8
// These must be consecutive, see 'reversedSources'
-enum {
+typedef enum {
INPUT_STABILIZED_ROLL = 0,
INPUT_STABILIZED_PITCH = 1,
INPUT_STABILIZED_YAW = 2,
diff --git a/src/main/io/osd.c b/src/main/io/osd.c
index 2807239cad..d9bcc5e466 100755
--- a/src/main/io/osd.c
+++ b/src/main/io/osd.c
@@ -1472,39 +1472,31 @@ static bool osdDrawSingleElement(uint8_t item)
{
char *p = "ACRO";
- if (isAirmodeActive()) {
- p = "AIR ";
- }
-
- if (FLIGHT_MODE(FAILSAFE_MODE)) {
+ if (FLIGHT_MODE(FAILSAFE_MODE))
p = "!FS!";
- } else if (FLIGHT_MODE(MANUAL_MODE)) {
+ else if (FLIGHT_MODE(MANUAL_MODE))
p = "MANU";
- } else if (FLIGHT_MODE(NAV_RTH_MODE)) {
+ else if (FLIGHT_MODE(NAV_RTH_MODE))
p = "RTH ";
- } else if (FLIGHT_MODE(NAV_POSHOLD_MODE)) {
- if (FLIGHT_MODE(NAV_ALTHOLD_MODE)) {
- // 3D HOLD
- p = "HOLD";
- } else {
- p = " PH ";
- }
- } else if (FLIGHT_MODE(NAV_CRUISE_MODE) && FLIGHT_MODE(NAV_ALTHOLD_MODE)) {
+ else if (FLIGHT_MODE(NAV_POSHOLD_MODE))
+ p = "HOLD";
+ else if (FLIGHT_MODE(NAV_CRUISE_MODE) && FLIGHT_MODE(NAV_ALTHOLD_MODE))
p = "3CRS";
- } else if (FLIGHT_MODE(NAV_CRUISE_MODE)) {
+ else if (FLIGHT_MODE(NAV_CRUISE_MODE))
p = "CRS ";
- } else if (FLIGHT_MODE(NAV_ALTHOLD_MODE) && navigationRequiresAngleMode()) {
+ else if (FLIGHT_MODE(NAV_ALTHOLD_MODE) && navigationRequiresAngleMode()) {
// If navigationRequiresAngleMode() returns false when ALTHOLD is active,
// it means it can be combined with ANGLE, HORIZON, ACRO, etc...
// and its display is handled by OSD_MESSAGES rather than OSD_FLYMODE.
p = " AH ";
- } else if (FLIGHT_MODE(NAV_WP_MODE)) {
+ } else if (FLIGHT_MODE(NAV_WP_MODE))
p = " WP ";
- } else if (FLIGHT_MODE(ANGLE_MODE)) {
+ else if (FLIGHT_MODE(ANGLE_MODE))
p = "ANGL";
- } else if (FLIGHT_MODE(HORIZON_MODE)) {
+ else if (FLIGHT_MODE(HORIZON_MODE))
p = "HOR ";
- }
+ else if (isAirmodeActive())
+ p = "AIR ";
displayWrite(osdDisplayPort, elemPosX, elemPosY, p);
return true;
diff --git a/src/main/io/rcdevice_cam.h b/src/main/io/rcdevice_cam.h
index c99cf97a62..0e61bec139 100644
--- a/src/main/io/rcdevice_cam.h
+++ b/src/main/io/rcdevice_cam.h
@@ -39,4 +39,4 @@ void rcdeviceUpdate(timeUs_t currentTimeUs);
bool rcdeviceIsEnabled(void);
// used for unit test
-rcdeviceSwitchState_t switchStates[BOXCAMERA3 - BOXCAMERA1 + 1];
+extern rcdeviceSwitchState_t switchStates[BOXCAMERA3 - BOXCAMERA1 + 1];
diff --git a/src/main/io/vtx_smartaudio.c b/src/main/io/vtx_smartaudio.c
index 7a39812507..aeda5748ad 100644
--- a/src/main/io/vtx_smartaudio.c
+++ b/src/main/io/vtx_smartaudio.c
@@ -670,7 +670,7 @@ bool vtxSmartAudioInit(void)
serialPortConfig_t *portConfig = findSerialPortConfig(FUNCTION_VTX_SMARTAUDIO);
if (portConfig) {
- portOptions_t portOptions = SERIAL_STOPBITS_2 | SERIAL_BIDIR_NOPULL;
+ portOptions_t portOptions = SERIAL_BIDIR_NOPULL;
#if defined(USE_VTX_COMMON)
portOptions = portOptions | (vtxConfig()->halfDuplex ? SERIAL_BIDIR | SERIAL_BIDIR_PP : SERIAL_UNIDIR);
#else
diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c
index 061467a5bd..0ffe30fcf5 100755
--- a/src/main/navigation/navigation.c
+++ b/src/main/navigation/navigation.c
@@ -373,6 +373,12 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = {
[NAV_FSM_EVENT_TIMEOUT] = NAV_STATE_CRUISE_2D_ADJUSTING,
[NAV_FSM_EVENT_ERROR] = NAV_STATE_IDLE,
[NAV_FSM_EVENT_SWITCH_TO_IDLE] = NAV_STATE_IDLE,
+ [NAV_FSM_EVENT_SWITCH_TO_ALTHOLD] = NAV_STATE_ALTHOLD_INITIALIZE,
+ [NAV_FSM_EVENT_SWITCH_TO_POSHOLD_3D] = NAV_STATE_POSHOLD_3D_INITIALIZE,
+ [NAV_FSM_EVENT_SWITCH_TO_CRUISE_3D] = NAV_STATE_CRUISE_3D_INITIALIZE,
+ [NAV_FSM_EVENT_SWITCH_TO_RTH] = NAV_STATE_RTH_INITIALIZE,
+ [NAV_FSM_EVENT_SWITCH_TO_WAYPOINT] = NAV_STATE_WAYPOINT_INITIALIZE,
+ [NAV_FSM_EVENT_SWITCH_TO_EMERGENCY_LANDING] = NAV_STATE_EMERGENCY_LANDING_INITIALIZE,
}
},
@@ -391,6 +397,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = {
[NAV_FSM_EVENT_SWITCH_TO_IDLE] = NAV_STATE_IDLE,
}
},
+
[NAV_STATE_CRUISE_3D_IN_PROGRESS] = {
.persistentId = NAV_PERSISTENT_ID_CRUISE_3D_IN_PROGRESS,
.onEntry = navOnEnteringState_NAV_STATE_CRUISE_3D_IN_PROGRESS,
@@ -412,7 +419,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = {
}
},
- [NAV_STATE_CRUISE_3D_ADJUSTING] = {
+ [NAV_STATE_CRUISE_3D_ADJUSTING] = {
.persistentId = NAV_PERSISTENT_ID_CRUISE_3D_ADJUSTING,
.onEntry = navOnEnteringState_NAV_STATE_CRUISE_3D_ADJUSTING,
.timeoutMs = 10,
@@ -425,6 +432,12 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = {
[NAV_FSM_EVENT_TIMEOUT] = NAV_STATE_CRUISE_3D_ADJUSTING,
[NAV_FSM_EVENT_ERROR] = NAV_STATE_IDLE,
[NAV_FSM_EVENT_SWITCH_TO_IDLE] = NAV_STATE_IDLE,
+ [NAV_FSM_EVENT_SWITCH_TO_ALTHOLD] = NAV_STATE_ALTHOLD_INITIALIZE,
+ [NAV_FSM_EVENT_SWITCH_TO_POSHOLD_3D] = NAV_STATE_POSHOLD_3D_INITIALIZE,
+ [NAV_FSM_EVENT_SWITCH_TO_CRUISE_2D] = NAV_STATE_CRUISE_2D_INITIALIZE,
+ [NAV_FSM_EVENT_SWITCH_TO_RTH] = NAV_STATE_RTH_INITIALIZE,
+ [NAV_FSM_EVENT_SWITCH_TO_WAYPOINT] = NAV_STATE_WAYPOINT_INITIALIZE,
+ [NAV_FSM_EVENT_SWITCH_TO_EMERGENCY_LANDING] = NAV_STATE_EMERGENCY_LANDING_INITIALIZE,
}
},
diff --git a/src/main/rx/nrf24_h8_3d.c b/src/main/rx/nrf24_h8_3d.c
index d9463b2cf5..25a7074c68 100644
--- a/src/main/rx/nrf24_h8_3d.c
+++ b/src/main/rx/nrf24_h8_3d.c
@@ -87,7 +87,7 @@ STATIC_UNIT_TESTED uint8_t payloadSize;
STATIC_UNIT_TESTED uint8_t rxTxAddrXN297[RX_TX_ADDR_LEN] = {0x41, 0xbd, 0x42, 0xd4, 0xc2}; // converted XN297 address
#define TX_ID_LEN 4
STATIC_UNIT_TESTED uint8_t txId[TX_ID_LEN];
-uint32_t *rxSpiIdPtr;
+static uint32_t *rxSpiIdPtr;
// radio channels for frequency hopping
#define H8_3D_RF_CHANNEL_COUNT 4
diff --git a/src/main/rx/nrf24_inav.c b/src/main/rx/nrf24_inav.c
index 2a0b09db4c..ee28e30564 100644
--- a/src/main/rx/nrf24_inav.c
+++ b/src/main/rx/nrf24_inav.c
@@ -135,7 +135,7 @@ uint8_t receivedPowerSnapshot;
#define RX_TX_ADDR_LEN 5
// set rxTxAddr to the bind address
STATIC_UNIT_TESTED uint8_t rxTxAddr[RX_TX_ADDR_LEN] = {0x4b,0x5c,0x6d,0x7e,0x8f};
-uint32_t *rxSpiIdPtr;
+static uint32_t *rxSpiIdPtr;
#define RX_TX_ADDR_4 0xD2 // rxTxAddr[4] always set to this value
// radio channels for frequency hopping
diff --git a/src/main/sensors/battery.c b/src/main/sensors/battery.c
index 13cf059175..d9ef1cb447 100644
--- a/src/main/sensors/battery.c
+++ b/src/main/sensors/battery.c
@@ -552,7 +552,7 @@ uint8_t calculateBatteryPercentage(void)
uint32_t capacityDiffBetweenFullAndEmpty = currentBatteryProfile->capacity.value - currentBatteryProfile->capacity.critical;
return constrain(batteryRemainingCapacity * 100 / capacityDiffBetweenFullAndEmpty, 0, 100);
} else
- return constrain((vbat - batteryCriticalVoltage) * 100L / (batteryFullVoltage - batteryCriticalVoltage), 0, 100);
+ return constrain((getBatteryVoltage() - batteryCriticalVoltage) * 100L / (batteryFullVoltage - batteryCriticalVoltage), 0, 100);
}
void batteryDisableProfileAutoswitch(void) {
diff --git a/src/main/sensors/compass.c b/src/main/sensors/compass.c
index d84431843f..62b1540d24 100644
--- a/src/main/sensors/compass.c
+++ b/src/main/sensors/compass.c
@@ -95,8 +95,8 @@ bool compassDetect(magDev_t *dev, magSensor_e magHardwareToUse)
case MAG_QMC5883:
#ifdef USE_MAG_QMC5883
if (qmc5883Detect(dev)) {
-#ifdef MAG_QMC5883L_ALIGN
- dev->magAlign.onBoard = MAG_QMC5883L_ALIGN;
+#ifdef MAG_QMC5883_ALIGN
+ dev->magAlign.onBoard = MAG_QMC5883_ALIGN;
#endif
magHardware = MAG_QMC5883;
break;
diff --git a/src/main/target/AIRBOTF4/target.h b/src/main/target/AIRBOTF4/target.h
index aaaf251c21..8204dad9d8 100644
--- a/src/main/target/AIRBOTF4/target.h
+++ b/src/main/target/AIRBOTF4/target.h
@@ -159,3 +159,5 @@
#define TARGET_IO_PORTB 0xffff
#define TARGET_IO_PORTC 0xffff
#define TARGET_IO_PORTD 0xffff
+
+#define PCA9685_I2C_BUS BUS_I2C2
\ No newline at end of file
diff --git a/src/main/target/ALIENFLIGHTF3/target.h b/src/main/target/ALIENFLIGHTF3/target.h
index 3c0b44e907..ce2e3d7ae2 100644
--- a/src/main/target/ALIENFLIGHTF3/target.h
+++ b/src/main/target/ALIENFLIGHTF3/target.h
@@ -69,7 +69,7 @@
#define USE_MAG
#define MAG_I2C_BUS BUS_I2C2
#define USE_MAG_MPU9250
-#define MAG_MPU9250_ALIGN CW180_DEG_FLIP
+#define MAG_MPU9250_ALIGN CW0_DEG
#define USE_MAG_AK8963
#define USE_MAG_AK8975
#define USE_MAG_HMC5883
@@ -142,3 +142,5 @@
#define TARGET_IO_PORTC 0xffff
#define TARGET_IO_PORTD (BIT(2))
#define TARGET_IO_PORTF (BIT(0)|BIT(1)|BIT(4))
+
+#define PCA9685_I2C_BUS BUS_I2C2
\ No newline at end of file
diff --git a/src/main/target/ALIENFLIGHTF4/target.h b/src/main/target/ALIENFLIGHTF4/target.h
index 6809178ea1..92afdbb512 100644
--- a/src/main/target/ALIENFLIGHTF4/target.h
+++ b/src/main/target/ALIENFLIGHTF4/target.h
@@ -68,7 +68,7 @@
#define USE_MAG_IST8308
#define USE_MAG_LIS3MDL
-#define MAG_MPU9250_ALIGN CW180_DEG_FLIP
+#define MAG_MPU9250_ALIGN CW0_DEG
#define USE_BARO
#define BARO_I2C_BUS BUS_I2C1
diff --git a/src/main/target/ALIENFLIGHTNGF7/target.h b/src/main/target/ALIENFLIGHTNGF7/target.h
index ae39f54ebd..918b4971de 100644
--- a/src/main/target/ALIENFLIGHTNGF7/target.h
+++ b/src/main/target/ALIENFLIGHTNGF7/target.h
@@ -66,8 +66,8 @@
#define USE_MAG_IST8308
#define USE_MAG_LIS3MDL
-#define MAG_AK9863_ALIGN CW180_DEG_FLIP
-#define MAG_MPU9250_ALIGN CW180_DEG_FLIP
+#define MAG_AK9863_ALIGN CW0_DEG
+#define MAG_MPU9250_ALIGN CW0_DEG
#define AK8963_CS_PIN PC15
#define AK8963_SPI_BUS BUS_SPI3
diff --git a/src/main/target/ANYFC/target.h b/src/main/target/ANYFC/target.h
index 32bdc7c4ba..f6fc3aa695 100644
--- a/src/main/target/ANYFC/target.h
+++ b/src/main/target/ANYFC/target.h
@@ -143,3 +143,5 @@
#define TARGET_IO_PORTB 0xffff
#define TARGET_IO_PORTC 0xffff
#define TARGET_IO_PORTD 0xffff
+
+#define PCA9685_I2C_BUS BUS_I2C2
\ No newline at end of file
diff --git a/src/main/target/ANYFCF7/target.h b/src/main/target/ANYFCF7/target.h
index 95fb709c01..dc981bda7c 100644
--- a/src/main/target/ANYFCF7/target.h
+++ b/src/main/target/ANYFCF7/target.h
@@ -206,3 +206,5 @@
#define TARGET_IO_PORTC 0xffff
#define TARGET_IO_PORTD 0xffff
#define TARGET_IO_PORTE 0xffff
+
+#define PCA9685_I2C_BUS BUS_I2C2
\ No newline at end of file
diff --git a/src/main/target/ANYFCM7/target.h b/src/main/target/ANYFCM7/target.h
index 246626f67b..4bcae331ae 100644
--- a/src/main/target/ANYFCM7/target.h
+++ b/src/main/target/ANYFCM7/target.h
@@ -140,3 +140,5 @@
#define TARGET_IO_PORTC 0xffff
#define TARGET_IO_PORTD 0xffff
#define TARGET_IO_PORTE 0xffff
+
+#define PCA9685_I2C_BUS BUS_I2C2
diff --git a/src/main/target/ASGARD32F4/target.h b/src/main/target/ASGARD32F4/target.h
index 0088b0ff8d..ab5081f129 100644
--- a/src/main/target/ASGARD32F4/target.h
+++ b/src/main/target/ASGARD32F4/target.h
@@ -172,3 +172,5 @@
#define TARGET_IO_PORTB 0xffff
#define TARGET_IO_PORTC 0xffff
#define TARGET_IO_PORTD 0xffff
+
+#define PCA9685_I2C_BUS BUS_I2C2
\ No newline at end of file
diff --git a/src/main/target/BETAFLIGHTF4/target.h b/src/main/target/BETAFLIGHTF4/target.h
index f198229d3b..209bfacba3 100755
--- a/src/main/target/BETAFLIGHTF4/target.h
+++ b/src/main/target/BETAFLIGHTF4/target.h
@@ -180,3 +180,5 @@
#define TARGET_IO_PORTD BIT(2)
#define MAX_PWM_OUTPUT_PORTS 4
+
+#define PCA9685_I2C_BUS BUS_I2C2
\ No newline at end of file
diff --git a/src/main/target/CLRACINGF4AIR/target.h b/src/main/target/CLRACINGF4AIR/target.h
index 7d5e3bbe0b..f69eb59f9f 100644
--- a/src/main/target/CLRACINGF4AIR/target.h
+++ b/src/main/target/CLRACINGF4AIR/target.h
@@ -54,6 +54,8 @@
#define ACC_MPU9250_ALIGN CW0_DEG
#define USE_MAG
#define USE_MAG_MPU9250
+#define MAG_MPU9250_ALIGN CW90_DEG
+
// MPU6 interrupts
#define USE_EXTI
#define GYRO_INT_EXTI PC4
diff --git a/src/main/target/COLIBRI_RACE/target.h b/src/main/target/COLIBRI_RACE/target.h
index 7390dc33d3..fd178eb5cc 100755
--- a/src/main/target/COLIBRI_RACE/target.h
+++ b/src/main/target/COLIBRI_RACE/target.h
@@ -134,3 +134,5 @@
#define TARGET_IO_PORTC 0xffff
#define TARGET_IO_PORTD (BIT(2))
#define TARGET_IO_PORTF (BIT(0)|BIT(1)|BIT(4))
+
+#define PCA9685_I2C_BUS BUS_I2C2
\ No newline at end of file
diff --git a/src/main/target/F4BY/target.h b/src/main/target/F4BY/target.h
index 117a1d1fa7..1513b781be 100644
--- a/src/main/target/F4BY/target.h
+++ b/src/main/target/F4BY/target.h
@@ -150,3 +150,5 @@
#define TARGET_IO_PORTC 0xffff
#define TARGET_IO_PORTD 0xffff
#define TARGET_IO_PORTE 0xffff
+
+#define PCA9685_I2C_BUS BUS_I2C2
\ No newline at end of file
diff --git a/src/main/target/FALCORE/target.h b/src/main/target/FALCORE/target.h
index b06e3cb94c..5e24a7839d 100755
--- a/src/main/target/FALCORE/target.h
+++ b/src/main/target/FALCORE/target.h
@@ -144,3 +144,5 @@
#define TARGET_IO_PORTC 0xFFFF
#define TARGET_IO_PORTD 0xFFFF
#define TARGET_IO_PORTF (BIT(0)|BIT(1)|BIT(4))
+
+#define PCA9685_I2C_BUS BUS_I2C2
\ No newline at end of file
diff --git a/src/main/target/FIREWORKSV2/target.h b/src/main/target/FIREWORKSV2/target.h
index 5fc2876c69..aded631dfa 100644
--- a/src/main/target/FIREWORKSV2/target.h
+++ b/src/main/target/FIREWORKSV2/target.h
@@ -184,3 +184,5 @@
#define TARGET_IO_PORTB 0xffff
#define TARGET_IO_PORTC 0xffff
#define TARGET_IO_PORTD 0xffff
+
+#define PCA9685_I2C_BUS BUS_I2C2
\ No newline at end of file
diff --git a/src/main/target/KISSFC/config.c b/src/main/target/KISSFC/config.c
new file mode 100644
index 0000000000..ac7edc5f43
--- /dev/null
+++ b/src/main/target/KISSFC/config.c
@@ -0,0 +1,33 @@
+/*
+ * 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 .
+ */
+
+#include
+#include
+
+#include "platform.h"
+
+#ifdef USE_TARGET_CONFIG
+
+#include "fc/config.h"
+
+#include "sensors/boardalignment.h"
+
+void targetConfiguration(void) { }
+#endif
diff --git a/src/main/target/KISSFC/target.c b/src/main/target/KISSFC/target.c
new file mode 100644
index 0000000000..d7dd821de9
--- /dev/null
+++ b/src/main/target/KISSFC/target.c
@@ -0,0 +1,43 @@
+/*
+ * 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 .
+ */
+
+#include
+#include
+
+#include
+#include "drivers/io.h"
+#include "drivers/pwm_mapping.h"
+#include "drivers/timer.h"
+
+const timerHardware_t timerHardware[] = {
+ { TIM1, IO_TAG(PA8), TIM_Channel_1, 1 | TIMER_OUTPUT_INVERTED, IOCFG_AF_PP, GPIO_AF_6, TIM_USE_MC_MOTOR | TIM_USE_FW_MOTOR }, // PWM1
+ { TIM1, IO_TAG(PB0), TIM_Channel_2, 1 | TIMER_OUTPUT_INVERTED | TIMER_OUTPUT_N_CHANNEL, IOCFG_AF_PP, GPIO_AF_6, TIM_USE_MC_MOTOR | TIM_USE_FW_MOTOR }, // PWM2
+ { TIM15, IO_TAG(PB14), TIM_Channel_1, 1 | TIMER_OUTPUT_INVERTED, IOCFG_AF_PP, GPIO_AF_1, TIM_USE_MC_MOTOR | TIM_USE_FW_SERVO }, // PWM3
+ { TIM15, IO_TAG(PB15), TIM_Channel_2, 1 | TIMER_OUTPUT_INVERTED, IOCFG_AF_PP, GPIO_AF_1, TIM_USE_MC_MOTOR | TIM_USE_FW_SERVO }, // PWM4
+ { TIM3, IO_TAG(PA6), TIM_Channel_1, 1 | TIMER_OUTPUT_INVERTED, IOCFG_AF_PP, GPIO_AF_2, TIM_USE_MC_MOTOR | TIM_USE_FW_SERVO }, // PWM5
+ { TIM3, IO_TAG(PA7), TIM_Channel_2, 1 | TIMER_OUTPUT_INVERTED, IOCFG_AF_PP, GPIO_AF_2, TIM_USE_MC_MOTOR | TIM_USE_FW_SERVO }, // PWM6
+ { TIM4, IO_TAG(PA13), TIM_Channel_3, 0, IOCFG_AF_PP, GPIO_AF_10, TIM_USE_PWM }, // AUX1
+ { TIM2, IO_TAG(PB3), TIM_Channel_2, 0, IOCFG_AF_PP, GPIO_AF_1, TIM_USE_PWM }, // TX2
+ { TIM8, IO_TAG(PA15), TIM_Channel_1, 0, IOCFG_AF_PP, GPIO_AF_2, TIM_USE_PWM }, // ROLL
+ { TIM2, IO_TAG(PA2), TIM_Channel_3, 0, IOCFG_AF_PP, GPIO_AF_1, TIM_USE_PWM }, // PITCH
+ { TIM2, IO_TAG(PB11), TIM_Channel_4, 0, IOCFG_AF_PP, GPIO_AF_1, TIM_USE_PWM }, // YAW
+};
+
+const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]);
diff --git a/src/main/target/KISSFC/target.h b/src/main/target/KISSFC/target.h
new file mode 100644
index 0000000000..bf37520717
--- /dev/null
+++ b/src/main/target/KISSFC/target.h
@@ -0,0 +1,90 @@
+/*
+ * 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 .
+ */
+
+#pragma once
+
+#define SBUS_PORT_OPTIONS (SERIAL_STOPBITS_2 | SERIAL_PARITY_EVEN | SERIAL_INVERTED | SERIAL_BIDIR)
+
+#define TARGET_BOARD_IDENTIFIER "KISSFC"
+
+#define LED0 PB1
+
+#define BEEPER PB13
+#define BEEPER_INVERTED
+
+#define USE_ACC
+#define USE_ACC_MPU6050
+#define ACC_MPU6050_ALIGN CW180_DEG
+#define MPU6050_I2C_BUS BUS_I2C1
+
+#define USE_GYRO
+#define USE_GYRO_MPU6050
+#define GYRO_MPU6050_ALIGN CW180_DEG
+
+#define USE_EXTI
+#define MPU_INT_EXTI PB2
+#define USE_MPU_DATA_READY_SIGNAL
+#define ENSURE_MPU_DATA_READY_IS_LOW
+
+#define USE_VCP
+#define USE_UART1
+#define USE_UART2
+#define USE_UART3
+//#define USE_SOFTSERIAL1
+//#define USE_SOFTSERIAL2
+
+#define SERIAL_PORT_COUNT 4
+
+#define UART1_TX_PIN PA9
+#define UART1_RX_PIN PA10
+
+#define UART2_TX_PIN PB3
+#define UART2_RX_PIN PB4
+
+#define UART3_TX_PIN PB10 // PB10 (AF7)
+#define UART3_RX_PIN PB11 // PB11 (AF7)
+
+//#define SOFTSERIAL1_TX_PIN PA13 // AUX1
+//#define SOFTSERIAL2_TX_PIN PA15 // ROLL
+
+#define USE_I2C
+#define USE_I2C_DEVICE_1
+#define I2C1_SCL PB6
+#define I2C1_SDA PB7
+
+#define USE_ADC
+#define VBAT_SCALE_DEFAULT 160
+#define ADC_INSTANCE ADC1
+#define VBAT_ADC_PIN PA0
+#define CURRENT_METER_ADC_PIN PA2
+
+#define DEFAULT_RX_FEATURE FEATURE_RX_SERIAL
+#define SERIALRX_PROVIDER SERIALRX_SBUS
+#define SERIALRX_UART SERIAL_PORT_USART2
+
+#define MAX_PWM_OUTPUT_PORTS 12
+
+#define AVOID_UART2_FOR_PWM_PPM
+
+#define TARGET_IO_PORTA 0xffff
+#define TARGET_IO_PORTB 0xffff
+#define TARGET_IO_PORTC 0xffff
+#define TARGET_IO_PORTD 0xffff
+#define TARGET_IO_PORTF (BIT(4))
diff --git a/src/main/target/KISSFC/target.mk b/src/main/target/KISSFC/target.mk
new file mode 100644
index 0000000000..a07094b526
--- /dev/null
+++ b/src/main/target/KISSFC/target.mk
@@ -0,0 +1,9 @@
+F3_TARGETS += $(TARGET)
+FEATURES = VCP
+
+TARGET_SRC = \
+ drivers/accgyro/accgyro_mpu.c \
+ drivers/accgyro/accgyro_mpu6050.c \
+ drivers/display_ug2864hsweg01.c \
+ drivers/serial_usb_vcp.c
+
diff --git a/src/main/target/LUX_RACE/target.h b/src/main/target/LUX_RACE/target.h
index 65ce6f8db1..ca13846a86 100644
--- a/src/main/target/LUX_RACE/target.h
+++ b/src/main/target/LUX_RACE/target.h
@@ -113,3 +113,5 @@
#define TARGET_IO_PORTC 0xffff
#define TARGET_IO_PORTD (BIT(2))
#define TARGET_IO_PORTF (BIT(0)|BIT(1)|BIT(4))
+
+#define PCA9685_I2C_BUS BUS_I2C2
\ No newline at end of file
diff --git a/src/main/target/MATEKF405/target.h b/src/main/target/MATEKF405/target.h
index 4576bad5cc..940b91c62f 100644
--- a/src/main/target/MATEKF405/target.h
+++ b/src/main/target/MATEKF405/target.h
@@ -154,7 +154,6 @@
#define DEFAULT_I2C_BUS BUS_I2C1
#endif
-
#define USE_BARO
#define BARO_I2C_BUS DEFAULT_I2C_BUS
#define USE_BARO_BMP280
@@ -214,3 +213,5 @@
#define TARGET_IO_PORTD (BIT(2))
#define MAX_PWM_OUTPUT_PORTS 6
+
+#define PCA9685_I2C_BUS DEFAULT_I2C_BUS
\ No newline at end of file
diff --git a/src/main/target/MATEKF405SE/target.h b/src/main/target/MATEKF405SE/target.h
index f78d50368e..af3b56c687 100644
--- a/src/main/target/MATEKF405SE/target.h
+++ b/src/main/target/MATEKF405SE/target.h
@@ -177,3 +177,5 @@
#define TARGET_IO_PORTD (BIT(2))
#define MAX_PWM_OUTPUT_PORTS 9
+
+#define PCA9685_I2C_BUS BUS_I2C2
\ No newline at end of file
diff --git a/src/main/target/MOTOLAB/target.h b/src/main/target/MOTOLAB/target.h
index 8a684ecba2..3ab28a0660 100644
--- a/src/main/target/MOTOLAB/target.h
+++ b/src/main/target/MOTOLAB/target.h
@@ -131,3 +131,5 @@
// #define TARGET_IO_PORTF (BIT(0)|BIT(1))
// !!TODO - check the following line is correct
#define TARGET_IO_PORTF (BIT(0)|BIT(1)|BIT(3)|BIT(4))
+
+#define PCA9685_I2C_BUS BUS_I2C2
\ No newline at end of file
diff --git a/src/main/target/OMNIBUS/target.h b/src/main/target/OMNIBUS/target.h
index cbdf61cc8a..5f36387656 100644
--- a/src/main/target/OMNIBUS/target.h
+++ b/src/main/target/OMNIBUS/target.h
@@ -59,6 +59,9 @@
#define USE_MAG_IST8308
#define USE_MAG_MAG3110
#define USE_MAG_LIS3MDL
+#define USE_MAG_AK8975
+
+#undef USE_GPS_PROTO_I2C_NAV //Save some flash space
#define USB_CABLE_DETECTION
#define USB_DETECT_PIN PB5
diff --git a/src/main/target/OMNIBUS/target.mk b/src/main/target/OMNIBUS/target.mk
index 4fc8af5c40..242885cc35 100644
--- a/src/main/target/OMNIBUS/target.mk
+++ b/src/main/target/OMNIBUS/target.mk
@@ -13,6 +13,7 @@ TARGET_SRC = \
drivers/compass/compass_ist8308.c \
drivers/compass/compass_mag3110.c \
drivers/compass/compass_lis3mdl.c \
+ drivers/compass/compass_ak8975.c \
drivers/pitotmeter_ms4525.c \
drivers/pitotmeter_adc.c \
drivers/light_ws2811strip.c \
diff --git a/src/main/target/OMNIBUSF4/target.h b/src/main/target/OMNIBUSF4/target.h
index bde540f94c..dd420f158e 100644
--- a/src/main/target/OMNIBUSF4/target.h
+++ b/src/main/target/OMNIBUSF4/target.h
@@ -262,3 +262,5 @@
#ifdef OMNIBUSF4PRO
#define CURRENT_METER_SCALE 265
#endif
+
+#define PCA9685_I2C_BUS BUS_I2C2
\ No newline at end of file
diff --git a/src/main/target/OMNIBUSF7/target.h b/src/main/target/OMNIBUSF7/target.h
index 7ca20bde03..ecff774e87 100644
--- a/src/main/target/OMNIBUSF7/target.h
+++ b/src/main/target/OMNIBUSF7/target.h
@@ -223,3 +223,5 @@
#define TARGET_IO_PORTC 0xffff
#define TARGET_IO_PORTD 0xffff
#define TARGET_IO_PORTE 0xffff
+
+#define PCA9685_I2C_BUS BUS_I2C2
\ No newline at end of file
diff --git a/src/main/target/RCEXPLORERF3/target.h b/src/main/target/RCEXPLORERF3/target.h
index 5e02db74fb..76a9233c8e 100644
--- a/src/main/target/RCEXPLORERF3/target.h
+++ b/src/main/target/RCEXPLORERF3/target.h
@@ -121,3 +121,5 @@
#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 PCA9685_I2C_BUS BUS_I2C2
diff --git a/src/main/target/REVO/target.h b/src/main/target/REVO/target.h
index 9857ccc55e..d0400ac33c 100644
--- a/src/main/target/REVO/target.h
+++ b/src/main/target/REVO/target.h
@@ -158,3 +158,5 @@
#define TARGET_IO_PORTB 0xffff
#define TARGET_IO_PORTC 0xffff
#define TARGET_IO_PORTD 0xffff
+
+#define PCA9685_I2C_BUS BUS_I2C2
\ No newline at end of file
diff --git a/src/main/target/SPARKY/target.h b/src/main/target/SPARKY/target.h
index 5f4f5e870a..ede88c4095 100644
--- a/src/main/target/SPARKY/target.h
+++ b/src/main/target/SPARKY/target.h
@@ -48,7 +48,7 @@
#define USE_MAG
#define MAG_I2C_BUS BUS_I2C2
-#define MAG_AK8975_ALIGN CW180_DEG_FLIP
+#define MAG_AK8975_ALIGN CW0_DEG
#define USE_MAG_AK8975
#define USE_MAG_HMC5883
#define USE_MAG_QMC5883
@@ -117,3 +117,5 @@
#define TARGET_IO_PORTA (BIT(1)|BIT(2)|BIT(3)|BIT(4)|BIT(5)|BIT(6)|BIT(7)|BIT(8)|BIT(9)|BIT(10)|BIT(11)|BIT(12)|BIT(13)|BIT(14)|BIT(15))
#define TARGET_IO_PORTB (BIT(0)|BIT(1)|BIT(6)|BIT(10)|BIT(11)|BIT(14)|BIT(15)|BIT(3)|BIT(4)|BIT(5)|BIT(6)|BIT(7)|BIT(8)|BIT(9)|BIT(12)|BIT(13))
#define TARGET_IO_PORTF (BIT(0)|BIT(1)|BIT(4))
+
+#define PCA9685_I2C_BUS BUS_I2C2
\ No newline at end of file
diff --git a/src/main/target/SPARKY2/target.h b/src/main/target/SPARKY2/target.h
index aac407ac62..ae771ebe6b 100644
--- a/src/main/target/SPARKY2/target.h
+++ b/src/main/target/SPARKY2/target.h
@@ -47,7 +47,7 @@
#define USE_MAG
#define USE_MAG_MPU9250
-#define MAG_MPU9250_ALIGN CW270_DEG
+#define MAG_MPU9250_ALIGN CW0_DEG
#define MAG_I2C_BUS BUS_I2C1
#define USE_MAG_HMC5883
@@ -114,7 +114,7 @@
#define USE_ADC
#define ADC_CHANNEL_1_PIN PC2
-#define ADC_CHANNEL_2_PIN PC1
+#define ADC_CHANNEL_2_PIN PC3
#define VBAT_ADC_CHANNEL ADC_CHN_2
#define CURRENT_METER_ADC_CHANNEL ADC_CHN_1
@@ -140,3 +140,5 @@
#define TARGET_IO_PORTA 0xffff
#define TARGET_IO_PORTB 0xffff
#define TARGET_IO_PORTC 0xffff
+
+#define PCA9685_I2C_BUS BUS_I2C2
\ No newline at end of file
diff --git a/src/main/target/SPRACINGF3EVO/target.h b/src/main/target/SPRACINGF3EVO/target.h
index a17a685637..031d42aec8 100755
--- a/src/main/target/SPRACINGF3EVO/target.h
+++ b/src/main/target/SPRACINGF3EVO/target.h
@@ -54,7 +54,7 @@
#define USE_MAG
#define MAG_I2C_BUS BUS_I2C1
-#define MAG_MPU9250_ALIGN CW90_DEG_FLIP
+#define MAG_MPU9250_ALIGN CW270_DEG
#define USE_MAG_MPU9250
#define USE_MAG_HMC5883
#define USE_MAG_QMC5883
diff --git a/src/main/target/SPRACINGF3MINI/target.h b/src/main/target/SPRACINGF3MINI/target.h
index fa613bcdca..e6ac0b50b4 100644
--- a/src/main/target/SPRACINGF3MINI/target.h
+++ b/src/main/target/SPRACINGF3MINI/target.h
@@ -54,7 +54,7 @@
#define USE_MAG
#define MAG_I2C_BUS BUS_I2C1
-#define MAG_AK8963_ALIGN CW270_DEG_FLIP
+#define MAG_AK8963_ALIGN CW270_DEG
#define USE_MAG_AK8963
#define USE_MAG_HMC5883
#define USE_MAG_QMC5883
diff --git a/src/main/target/YUPIF4/target.h b/src/main/target/YUPIF4/target.h
index 65c2bc43ad..a8b5db4f60 100644
--- a/src/main/target/YUPIF4/target.h
+++ b/src/main/target/YUPIF4/target.h
@@ -177,3 +177,5 @@
#define TARGET_IO_PORTB 0xffff
#define TARGET_IO_PORTC 0xffff
#define TARGET_IO_PORTD (BIT(2))
+
+#define PCA9685_I2C_BUS BUS_I2C2
\ No newline at end of file
diff --git a/src/main/target/common_hardware.c b/src/main/target/common_hardware.c
index fc968b3f24..c7c1983e22 100755
--- a/src/main/target/common_hardware.c
+++ b/src/main/target/common_hardware.c
@@ -159,7 +159,7 @@
#if !defined(MAG3110_I2C_BUS)
#define MAG3110_I2C_BUS MAG_I2C_BUS
#endif
- BUSDEV_REGISTER_I2C(busdev_mag3110, DEVHW_MAG3110, MAG3110_I2C_BUS, 0x0E, NONE, DEVFLAGS_NONE);
+ BUSDEV_REGISTER_I2C(busdev_mag3110, DEVHW_MAG3110, MAG3110_I2C_BUS, 0x0C, NONE, DEVFLAGS_NONE);
#endif
#if defined(USE_MAG_LIS3MDL)
@@ -175,7 +175,7 @@
#if !defined(IST8310_I2C_BUS)
#define IST8310_I2C_BUS MAG_I2C_BUS
#endif
- BUSDEV_REGISTER_I2C(busdev_ist8310, DEVHW_IST8310, IST8310_I2C_BUS, 0x0C, NONE, DEVFLAGS_NONE);
+ BUSDEV_REGISTER_I2C(busdev_ist8310, DEVHW_IST8310, IST8310_I2C_BUS, 0x0E, NONE, DEVFLAGS_NONE);
#endif
#if defined(USE_MAG_IST8308)
diff --git a/src/main/telemetry/frsky_d.c b/src/main/telemetry/frsky_d.c
index 7c0a19267e..457b760ba2 100644
--- a/src/main/telemetry/frsky_d.c
+++ b/src/main/telemetry/frsky_d.c
@@ -419,9 +419,13 @@ static void sendAmperage(void)
static void sendFuelLevel(void)
{
- sendDataHead(ID_FUEL_LEVEL);
-
- serialize16((uint16_t)calculateBatteryPercentage());
+ if (telemetryConfig()->smartportFuelUnit == SMARTPORT_FUEL_UNIT_PERCENT) {
+ sendDataHead(ID_FUEL_LEVEL);
+ serialize16((uint16_t)calculateBatteryPercentage());
+ } else if (isAmperageConfigured()) {
+ sendDataHead(ID_FUEL_LEVEL);
+ serialize16((uint16_t)telemetryConfig()->smartportFuelUnit == SMARTPORT_FUEL_UNIT_MAH ? getMAhDrawn() : getMWhDrawn());
+ }
}
static void sendHeading(void)
diff --git a/src/main/telemetry/smartport.c b/src/main/telemetry/smartport.c
index c06f93ec64..5e3ac73ad1 100755
--- a/src/main/telemetry/smartport.c
+++ b/src/main/telemetry/smartport.c
@@ -430,13 +430,13 @@ void processSmartPortTelemetry(smartPortPayload_t *payload, volatile bool *clear
smartPortSendPackage(id, attitude.values.yaw * 10); // given in 10*deg, requested in 10000 = 100 deg
*clearToSend = false;
break;
- case FSSP_DATAID_PITCH :
+ case FSSP_DATAID_PITCH :
if (telemetryConfig()->frsky_pitch_roll) {
smartPortSendPackage(id, attitude.values.pitch); // given in 10*deg
*clearToSend = false;
}
break;
- case FSSP_DATAID_ROLL :
+ case FSSP_DATAID_ROLL :
if (telemetryConfig()->frsky_pitch_roll) {
smartPortSendPackage(id, attitude.values.roll); // given in 10*deg
*clearToSend = false;
diff --git a/src/main/vcpf4/usbd_cdc_vcp.c b/src/main/vcpf4/usbd_cdc_vcp.c
index b9cdab30e6..2fc2da8b1d 100644
--- a/src/main/vcpf4/usbd_cdc_vcp.c
+++ b/src/main/vcpf4/usbd_cdc_vcp.c
@@ -63,6 +63,7 @@ static void *ctrlLineStateCbContext;
static void (*baudRateCb)(void *context, uint32_t baud);
static void *baudRateCbContext;
+__ALIGN_BEGIN USB_OTG_CORE_HANDLE USB_OTG_dev __ALIGN_END;
CDC_IF_Prop_TypeDef VCP_fops = {VCP_Init, VCP_DeInit, VCP_Ctrl, VCP_DataTx, VCP_DataRx };
diff --git a/src/main/vcpf4/usbd_cdc_vcp.h b/src/main/vcpf4/usbd_cdc_vcp.h
index 0a046ad1b7..fc27a6d98e 100644
--- a/src/main/vcpf4/usbd_cdc_vcp.h
+++ b/src/main/vcpf4/usbd_cdc_vcp.h
@@ -34,7 +34,7 @@
#include "usbd_usr.h"
#include "usbd_desc.h"
-__ALIGN_BEGIN USB_OTG_CORE_HANDLE USB_OTG_dev __ALIGN_END;
+extern USB_OTG_CORE_HANDLE USB_OTG_dev;
uint32_t CDC_Send_DATA(const uint8_t *ptrBuffer, uint32_t sendLength);
uint32_t CDC_Send_FreeBytes(void);