1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-16 04:45:24 +03:00
Commit graph

15100 commits

Author SHA1 Message Date
Mark Haslinghuis
56a3688d7d
Change default I2C adddress for IST8310 (#13995) 2024-11-08 20:14:33 +01:00
Petr Ledvina
4d697c2ce1
Serial refactor fix (#14007)
* VCP - zero-init USB port in usbVcpOpen

* Serial - serialPortIdentifier_e is signed

* UART - remove unused serialPortCount

* UART - allow compiling spectrum without UART

* UART - minor improvements

closeSerialPort tests for NULL,
no other functional changes
2024-11-06 22:58:10 +01:00
Steve Evans
6e79712906
Add PRBS checking of BB FLASH with USE_FLASH_TEST_PRBS (#13987)
* Add PRBS checking of BB FLASH with USE_FLASH_TEST_PRBS

* Update src/main/io/flashfs.c

Co-authored-by: Petr Ledvina <ledvinap@gmail.com>

---------

Co-authored-by: Petr Ledvina <ledvinap@gmail.com>
2024-11-06 20:33:32 +01:00
Petr Ledvina
246d04dc57
Refactor uart (#13585)
* serial - refactor serial resource handling

- port related resources (tx/rx/inverted,dma)
  - are stored sequentially, with space in place of ports that are not
  enabled (RESOURCE_UART_COUNT + RESOURCE_LPUART_COUNT +
     RESOURCE_SOFTSERIAL_COUNT)
  - RESOURCE_UART_OFFSET, RESOURCE_LPUART_OFFSET, RESOURCE_SOFTSERIAL_OFFSET
  - resource entries are pointing into this array (UART, LPUART, SOFTSERIAL)
    - both pins and DMA
    - inverter is supproted only for UART + LPUART (makes sense only
     for UART, to be removed)
  - softSerialPinConfig is removed, it is no longer necessary
- serialResourceIndex(identifier) is used universally to get correct
   index into resource array
- unified handling of resources where possible
- serialOwnerTxRx() + serialOwnerIndex() are used for displaying resources
   correctly to user.
- serialType(identifier) implemented
  - serialOwnerTxRx / serialOwnerIndex are trivial with it
  - large switch() statemens are greatly simplified

* serial - merge code duplicated in all UART implementations

- drivers/serial_uart_hw.c contains merged serialUART code.
  Code did not match exactly. Obvious cases are fixed, more complicated
  use #ifs
- pin inversion unified
- uartOpen is refactored a bit

* serial - refactor uartDevice

- use 'compressed' enum from uartDeviceIdx_e. Only enabled ports are
   in this enum.
- uartDeviceIdx directly indexes uartDevice (no search necessary, no
    wasted space)
- use `serialPortIdentifier_e identifier;` for uartHardware
- for DMA remap, define only entries for enabled ports (uartDeviceIdx_e
   does not exist disabled port)

* serial - apply changes to inverter

New implementation is trivial

* serial - HAL - rxIrq, txIrq replaces by irqn

There is only one IRQ for serial

* serial - serial_post.h

Generated code to normalize target configuration.
jinja2 template is used to generate header file. Port handling is
unified a lot.

SERIAL_<type><n>_USED 0/1 - always defined, value depends on target configuration
SERIAL_<type>_MASK        - bitmask of used ports or given type. <port>1 is BIT(0)
SERIAL_<type>_COUNT       - number of enabled ports of given type
SERIAL_<type>_MAX         - <index of highest used port> + 1, 0 when no port is enabled

* targets - remove automatically calculated valued from configs

serial_post.h generated it

* serial - remove definitions replaced by serial_post.h

* serial - change LPUART to UART_LP1 in places

LPUART is mostly handled as another UART port, this change reflects it

* serial - use ARRAYLEN / ARRAYEND in some places

replaces constant that may not match actual array size

* serial - adapt softserial to changes

* serial - whitespace, comments

* softserial - fix serialTimerConfigureTimebase

* serial - suspicious code

* serial - unittests

* serial - cleanup

* serial - simpler port names

Is this useful ?

* serial - no port count for SITL necessary

* serial - fix unittests

include serial_post.h, some ports are defined, so normalization will
work fine

* timers - remove obsolete defines from SITL and unittests

* serial - cosmetic improvements

comments, whitespace, minor refactoring

* serial - fix serialInit bug

serialPortToDisable was preventing further tests

* serial - fix possible NULL pointer dereference

* serial - move serialResourceIndex to drivers

* serial - refactor pp/od and pulldown/pullup/nopull

Centralize serial options handling, decouple it from MCU type

Move some code into new drivers/serial_impl.c

* serial - make port.identifier valid early in port initialization

* serial - fix unittest

Code is moved around a bit to make unittests implementation easier

* serial - bug - fix off-by-one error

uart1/softserial1/lpuart was not working properly because of this

* serial - whipespace + formating + style + comments

No functional changes

* utils - add popcount functions

Wrap __builtin_popcount for easier use. Refactor existing code using
it. Update code using BITCOUNT macro in dynamic context (BITCOUNT is
for compile-time use only)

* serial - inverter - simplify code

* pinio - prevent array access overflow

* serial - refactor SERIAL_BIDIR_*

SERIAL_BIDIR_OD / SERIAL_BIDIR_PP
SERIAL_PULL_DEFAULT / SERIAL_PULL_NONE / SERIAL_PULL_PD

* serial - simplify code

minor refactoring
- cleaner AVOID_UARTx_FOR_PWM_PPM (unused anyway)
- serialFindPortConfiguration* - remove code duplication
- use serialType in smartaudio

* serial - add port names

- const string is assiociated with each compiled-in port (easy to pass around)
- findSerialPortByName

* cli - improve serialpassthrough

- support port options (in current mode argument)
- support port names (`serialpassthrough uart1`)
- improve error handling; check more parse errors

* cli - resources - minor refactor

- prevent SERIAL_TX_NONSENSE when parsing resource type
- fix possible NULL pointer dereference
- store resource tag only after checking all conditions
- slighty better error reporting
- `resource serial_tx 1` will print resource assignment

* serial - remane pulldown to SERIAL_PULL_SMARTAUDIO

Make sure nobody uses it by
mistake. SERIAL_PULL_SMARTAUDIO_SUPER_DANGEROUS_USE_AT_YOUR_OWN_RISK_THIS_WILL_BREAK_EVERYTHING_AND_KILL_YOUR_PET_FISH
would be better choice, but try shorter version first.

* smartaudio - minor refactor/improvement

- Fix softserial on AT32
- make it easier to handle SA on per-cpu basis

* softserial - minor refactoring

no functional changes

* UART - move AF handling before MCU dependent code

* UART - adapt APM32 / APM32F4 code

- Modeled after F4 where possible
- come code moved from APM32 to APM32F4, possbily not necessary, but
   it improves similarity with STM32F4

* UART - APM32 - remove per-pin AF

* UART - APM32 - bugfix - fix pinswap #if conditions

* UART - apply some improvemnts from APM32 to STM32

* UART - add todo for F4 serial speed

* UART - fix typo

* UART - refactor support for USE_SMARTAUDIO_NOPULLDOWN

* UART - typos, comments, minor improvements

* UART - move code into enableRxIrq

TODO: split into mcu-specific filer (but in sepatate PR)

* UART - add UART_TRAIT_xx

makes #if test easier and more consistent
more traits shall follow

* UART - fix variable name

unused branch, would trigger compilation error otherwise

* UART - use tables instead of switch

* UART - smartaudio

minor style change + better comments

* UART - unify mspPorts iteration

* UART - fix spelling

* UART - another typo

* UART - fix serialResourceIndex

offset must be added, not subtracted
offset can be negative

* UART - fix typo

Bad day ...

* UART - use const table

GCC does optimize it better.
Should not cause functional change

* UART - use OwnerIndex for inverter

- 1 based
- only UART has inversion

* UART - refactor serial_resource a bit

Single table + helper function. New table is easier to read

* UART - serial_impl header is necessary

* UART - style-only changes

typos
unify whitespace
comment improvement
add some const modifiers
use cfg in uartConfigureDma
minor improvemnt of for loops

* UART - remove LPUART inverter

LPUART always supports internal inversion, code was incomplete and
unused

* UART - update jinja template, regenerate files

* UART - enable UART module RCC clk before configuring DMA

Does not change anything, UART RCCs are enabled unconditionally
2024-11-04 22:07:25 +01:00
Ivan Efimov
a659189bf0
Yaw type rudder/diff_thrust for TPA calculations (for wings) (#13929)
* Yaw type rudder or diff_thrust for TPA calculations (for wings)

* Added yaw_type to blackbox header

* KarateBrot review

* KarateBrot break

Co-authored-by: Jan Post <Rm2k-Freak@web.de>

---------

Co-authored-by: Jan Post <Rm2k-Freak@web.de>
2024-11-04 22:03:31 +01:00
Steve Evans
b819eceb86
Make three attempts to not only write to FLASH, but also validate it (#14001) 2024-10-31 14:45:16 +01:00
Mark Haslinghuis
954cc1da3a
Remove GYRO_SCALED debug mode (#13101)
Revert removing dual_gyro_scaled
2024-10-26 22:59:39 +02:00
Ivan Efimov
c545435f2e
removed RESCUE_COMPLETE from gps rescue since it's not used (#13993) 2024-10-25 22:21:03 +02:00
Mark Haslinghuis
3e7cbb53ad
Fix SmartAudio (STM32F4) (#13797)
* resubmit after rebase

* Add define for SA without PD

* Move logic to smartaudio
2024-10-25 08:04:36 +11:00
Mark Haslinghuis
2cc63b63a3
Allow configuration for ibat_lpf_period using DEFAULT_IBAT_LPF_PERIOD define (#13903)
Allow configuration for ibat_lpf_period
2024-10-23 21:58:21 +02:00
cvetaevvitaliy
715c1671a8
Add support external clock for gyro ICM42688P (#13912) 2024-10-24 06:49:18 +11:00
Petr Ledvina
866191dfad
Refactor gps (#13853) 2024-10-24 06:45:17 +11:00
J Blackman
2dd6f95aad
Adding RP2350 SDK and target framework (#13988)
* Adding RP2350 SDK and target framework

* Spacing

* Removing board definitions
2024-10-23 01:02:48 +02:00
mygodamn
462cb05930
add spi nor flash support winbond W25Q64JW (#13977)
* add spi nor flash support winbond W25Q64JW

* modify `W25Q64JW` subtype comment

* modify `W25Q64JW` max spi clk to 104MHz

- For none SPI-EBh (Fast Read Quad I/O) mode, max dual output / quad output read clk should be 104MHz
2024-10-23 00:55:47 +02:00
Mark Haslinghuis
a17d8c69d2
Fix SITL build (#13972)
* Fix SITL build

* Remove semicolons
2024-10-22 20:10:02 +02:00
ke deng
d5f899156d
Fixes #13930: fix timer based bidirectional dshot command not working issue (#13978)
* fix timer based bidirectional dshot command not working issue

* smaller scope of isBitbangActive
2024-10-22 16:13:06 +02:00
Mark Haslinghuis
69f75b55f6
Add CRSF baro altitude sensor (#13840)
* Add CRSF baro altitude sensor

* Thanks Ledvinap

* Fix parenthesis

* Review bkleiner

* Review karate

* Rename getVerticalSpeedPacked
2024-10-20 03:06:16 +02:00
Mark Haslinghuis
2c4d76c920
Update build options (#13974) 2024-10-20 11:04:25 +11:00
ctzsnooze
fc52b6b4ff
Use wasThrottleRaised in place of isAirmodeActivated where appropriate (#13968)
* use wasThrottleRaised in place of isAirmodeActivated where airmode isn't really needed

* fix unit test

* fix typo

* remove unnecessary check

* final changes and clarificartions

* Update src/main/flight/mixer.c

Co-authored-by: Ivan Efimov <gendalf44@yandex.ru>

---------

Co-authored-by: Mark Haslinghuis <mark@numloq.nl>
Co-authored-by: Ivan Efimov <gendalf44@yandex.ru>
2024-10-17 10:46:54 +02:00
ctzsnooze
58fc8bbbb8
Shared altitude control function in position_control.c (#13954)
* Altitude control code shared

fewer debugs
subtract D

* remove #include comments, simplify coding, restructuring

thanks JP and MH

* fix cms limits for throttle control

* Use altitude_control debug, fix throttle calculation

minor refactoring

* use AUTO_CONTROL_ALTITUDE debug in place of GPS Rescue throttle pid

* use autopilot for position control names

* fixes from reviews - thanks

* Re-organise included files and functions thanks Karate

* missed init and other typos

* remove old unused unit test file, tidy up thanks Mark

* fix indentation on one line
2024-10-16 23:17:44 +02:00
Ivan Efimov
1d9823b4cd
TPA air speed speed estimation instead of TPA delay (for wings) (#13895)
* tpa speed speed estimation (for wings)

* Some renaming based on Karatebrot review

* Fix with currentPidProfile

* Ledvinap's review

* minor fixes

* Karatebrot and ledvinap review

* Review by haslinghuis
2024-10-15 23:11:00 +02:00
J Blackman
b21cfe3282
Code re-organisation: src/platform/xxx for the MCU type (#13955) 2024-10-13 03:07:17 +11:00
Kevin Plaizier
7158ff7081
Fix pt2 and pt3 filter initialization in gyro_init.c (#13960)
fix pt1 and pt3 filter initialization
2024-10-08 23:34:25 +02:00
Mark Haslinghuis
7fb6ed39be
Move USE_SOFTSERIAL to build options (#13305) 2024-10-09 06:49:03 +11:00
Kevin Plaizier
ea30a11d1a
Make the imuGyroFilter actually filter (#13961) 2024-10-09 06:44:39 +11:00
ctzsnooze
5ffeea6ab1
refactor motor idle, rename dshot_idle_value to motor_idle (#13936)
* use idleOffset, simplify idle : check PWM idle

* remove get for dshot idle and calculate it once only

* fixes from reviews, thanks

* use motor_idle for CLI name

* use motorConfig->motorIdle not idleOffset

* rename dshotmotorIdle variable to motorIdlePercent

* small comment improvement
2024-10-08 18:31:08 +02:00
ke deng
10d5963d24
Fixes #13934: Fix motor(PWM protocol) spin while fc reset. (#13937)
* Fix motor(PWM protocol) spin while fc reset.

* move delay out to motorShutdown
2024-10-07 17:51:37 +02:00
Henry Warhurst
909ab19a1b
Log servos in blackbox (#13944)
* Log servos in blackbox

* Add hasServos helper
2024-10-06 22:48:17 +02:00
ctzsnooze
16c157e840
Shared altitude control parameters (#13884) 2024-10-05 16:32:50 +10:00
ctzsnooze
7156dc84a3
Update turtle / crashflip mode (#13905)
* stop motors after 90 degrees of rotation and with max rate

* handle no accelerometer data

* improve check for acc, although seems to be OK without it

* disable all attenuation if rate is set to zero

* refactoring thanks Karate

* use sensors.h

* remove unnecessary arming check

* exit crashFlip immediately switch is reverted if throttle is zero

* add Crashflip Rate to OSD

* Revert unnecessary changes in crashflip core.c code

and clarify comments about crashflip switch

* update / minimise comments, thanks Karate

* ensure all names say `crashflip` consistently

* Undo quick re-arm because motrors were not reversed

* fix issue with reversed motors, we must disarm

* ignore yaw rotation and set gyro limit to 1900 deg/s

* default attenuation to off (crashflip_rate = 0)

* refactoring, increase rate limit to allow stronger inhibition

* enable in race_pro mode

* don't attenuate on attitude until a significant change occurs

* no attenuation for small changes

* Updates from review by PL

* remove whitespace

* refactor motorOutput, update comments, renaming variables

thanks PL

* changes from review PL

* only permit fast re-arm if crashflip rate set and crashflip was successful

* properly exit turtle mode

* add crashFlipSuccessful to unit test extern c

* small updates from review

* improved crashflip switch handling

* remove unnecessary motors normal check
2024-10-05 07:58:33 +10:00
Mark Haslinghuis
95d55525ad
Make telemetry default for jeti (#13951) 2024-10-04 00:25:53 +02:00
J Blackman
c2900de5c1
Adding CLI command pass through for MSP (#13940) 2024-10-03 23:59:47 +10:00
Mark Haslinghuis
23e682c310
Fix build when using SRXL telemetry (#13947) 2024-10-03 16:27:34 +10:00
ctzsnooze
776e8c7b3c
Refactor Rx code and better support 25Hz links (#13435)
* RX task update rate to 22Hz, to improve 25Hz link stability

* modified Rx code

* add LQ to debug

* use max of frameAge or FrameDelta

* Require a dropouit of 200ms, not 100ms, before RXLOSS

* remove FrameAge, use 150ms timeout 50ms checks

* fix tests and tidy up the comments

* Handle NULL input as before, log frame time

* possible solutions to review comment about names

* Remove rxFrameTimeUs

- prepare for direct use of lastRcFrameTimeUs
- refactor rx_spi callback

* remove global currentRxRateHz

* simplify updateRcRefreshRate

* re-name to recheck interval, return frame time debug

* Calculate RxRate only once

* use rxReceivingSignal for consistency

* use signalReceived not rxDataReceived for consistency

* suggestions from review PL

* move defines, thanks K

* fixes from review, thanks MH

* review changes, undo task interval change

rename bool rxIsReceivingSignal to isRxReceivingSignal
thanks Steve for resolving that tasks changes are not needed
thanks PL for your feedback also

---------

Co-authored-by: Petr Ledvina <ledvinap@hp124.ekotip.cz>
2024-10-01 09:23:24 +10:00
Ivan Efimov
a37bd7c974
Always USE_TPA_MODE (#13942)
Always use TPA_MODES
2024-09-30 16:30:52 +02:00
Ivan Efimov
dfea2c8cbf
Some defines removed from USE_WING build that is not useful for planes (#13941) 2024-09-30 16:15:24 +02:00
Mark Haslinghuis
713ba21407
Fix custom box names (#13935)
* Fix custom box names

* Review ledvinap
2024-09-30 16:11:06 +02:00
Vladimir Demidov
a7672a0a1e
GPS Home altitude is added to blackbox logging (#13939)
added logging of gps homes altitude
2024-09-29 00:11:40 +02:00
ctzsnooze
4ed21bdd06
Fix DMax calculations (#13933)
Refactor DMax calculations
2024-09-29 00:00:11 +02:00
Ivan Efimov
983b510184
Fix: Hyperbolic TPA curve initialization (for wings) (#13932) 2024-09-27 20:24:34 +02:00
J Blackman
331801c7a2
Minor CLI update to give a noreboot option so save and exit (#13904)
* Give a -n option to exit CLI

- means you can set any serial port to MSP, and then activate CLI on it using #, with an "exit -n" to return to MSP mode without a reboot required.
- https://webserial.io is a great utility for using CLI outside the configurator.
- future changes will include possible multiple CLIs being active at the same time, along with debug printf from anywhere in the code to an active debug cli.

* Altered to strcasecmp, and changed param required to noreboot

* Adding additional details to the commands
2024-09-26 14:30:57 +02:00
ctzsnooze
6b5b5cfbdb
Use static idle value to set the initial dynamic idle limit before takeoff (#13906)
use static idle value in dynamic idle
2024-09-24 16:41:46 +02:00
MikeNomatter
908f9cc32d
Remove d min confusion (#13908)
* rename dMin, remove D_MIN_GAIN_MAX

* rename vars

* fix logic

* fix logic

* Revert "fix tests"

This reverts commit c518c9c444.

* Revert "add yaw and other adjustment cases"

This reverts commit 2cacd4b360.

* Revert "fix unit test"

This reverts commit 3d88f4158a.

* Revert "fix D adjustments change dmax instead of D"

This reverts commit 7ee4e7f8af.

* Revert "Fix telemetry for Spektrum/SRXL (#13814)"

This reverts commit 04fe4b4461.

* review adjustments and test fixes

* Reapply "Fix telemetry for Spektrum/SRXL (#13814)"

This reverts commit eb7f8ee0fd.

* fix logic

* Apply suggestions from code review

Co-authored-by: Jan Post <Rm2k-Freak@web.de>
Co-authored-by: Mark Haslinghuis <mark@numloq.nl>

* fix d_max slider

---------

Co-authored-by: Jan Post <Rm2k-Freak@web.de>
Co-authored-by: Mark Haslinghuis <mark@numloq.nl>
2024-09-24 11:28:25 +02:00
Steve Evans
c0c24d7f52
Don't consider a prior I2C NACK to indicate the bus to be busy (#13917) 2024-09-22 14:35:53 +02:00
Kiss Ultra
a6d70be96a
Fixes #13220: Fix kiss esc passthrough, Fix castle (escprog cc) command. (#13911)
* Fix kiss esc passthrough, Fix castle (escprog cc) command.

* Update src/main/drivers/serial_escserial.c

Thank you.

Co-authored-by: Mark Haslinghuis <mark@numloq.nl>

---------

Co-authored-by: Alex Fedorov <fedor@anuta.org>
Co-authored-by: Mark Haslinghuis <mark@numloq.nl>
2024-09-21 02:32:46 +02:00
ot0tot
e8f091a6f5
Update timer_at32f43x.c (#13909)
* Update timer_at32f43x.c

Adds missing timer defines from https://www.arterychip.com/download/RM/RM_AT32F435_437_EN_V2.06.pdf

* Update timer_def.h

* Update timer_def.h

* Fix alignment
2024-09-19 23:23:45 +02:00
Mark Haslinghuis
698b8616f9
CRSF Flight Mode Sensor Value update (#13854)
* CRSF Flight Mode Sensor Value update

* Fix FS FM

* Add ? for GPS not available

* Need to check define

* better name

* Update mode and test unit

* Fixes review CT

* Fixes review JimB40

* Apply ctz comment

* Update isAllowArmingWithoutFix

* Fix fs/resc sw

* Add required sats

* Update comments
2024-09-16 17:38:31 +02:00
Vladimir Demidov
654d18ced4
Fix: the wrong ability to turn on HORIZON_MODE without ACC sensors (#13892)
added check of acc sensor enabled condition by turn on horizon mode
2024-09-16 11:36:57 +02:00
Jan Post
f71170db1b
Vector library expansion (#12968) 2024-09-16 07:03:32 +10:00
Vladimir Demidov
fc4b7a0008
Added 'Storage mode' action in Blackbox part of OSD menu (#13899)
* added turn on 'storage device mode' action in OSD Blackbox menu

* Code style improvement

Co-authored-by: Mark Haslinghuis <mark@numloq.nl>

* Code style improvement

Co-authored-by: Mark Haslinghuis <mark@numloq.nl>

* text messages are edited in the usb mass storage osd menu

* The NO menu action is default by selecting ERASE or USB MASS STORAGE items in OSD menu

* improved cmsx_StorageDevice function code

* added check of define USE_USB_MSC for storage mass mode code

* USB mass storage OSD menu text messages placement improvement

* added return NULL after systemResetToMsc

* Code improvement

Co-authored-by: Mark Haslinghuis <mark@numloq.nl>

* Code style improvement src/main/cms/cms_menu_blackbox.c

Co-authored-by: Mark Haslinghuis <mark@numloq.nl>

---------

Co-authored-by: Mark Haslinghuis <mark@numloq.nl>
2024-09-14 23:04:36 +02:00