Commit Graph

19 Commits

Author SHA1 Message Date
Andy Piper 9f30d01561 AP_HAL_ChibiOS: bdshot for f103 iofirmware
add support to tell if shared DMA channel is actually shared
avoid starting and stopping the timer peripheral with bdshot
ensure that rcout DMA allocation and deallocation happens entirely within the lock
increase rcout thread working area for bdshot
fix mode mask that is sent to the iomcu
ensure iomcu rcout thread gets timeouts for callbacks
control bdshot input and output line levels on f103
use input capture channel pairs to read rising and falling edges of telemetry on f103
reset channel pairs together on iomcu
generalize the bdshot input path to support suitable buffer sizes for iomcu
generalize DMAR reading of CCR registers to read two at a time on iomcu
enable bi-directional dshot channels on PWM1-4 on iomcu
add methods to directly access erpm values from rcout
update erpm mask and esc telemetry correctly for firmware supporting dshot
add support for propagating bdmask to iomcu
dshot commands to all channels need to be aware of iomcu
ensure esc type is propagated to iomcu
cope with iomcu channel numbering when using EDT
ensure pwm driver is reset properly for dshot commands on iomcu
correctly reset pwm for dshot commands
correctly mask off bdshot bits going to iomcu
don't reset GPIO modes on disabled lines
don't reset pwm_started when sharing DMA channels
set thread name on iomcu rcout and reduce stack size on iomcu
ensure that bdshot pulses with no response are handled correctly
correctly setup DMA for input capture on f103
deal with out of order captured bytes when decoding bdshot telemetry
ensure DMA sharing on f103 does not pull lines low
only disable the timer peripheral when switching DMA channels on iomcu
add support for waiting for _UP to finish before proceeding with dshot
re-order iomcu dshot channels to let TIM4_UP go first
ensure that a cascading event will always come when expected on rcout
allow timeouts when using cascading dshot
always rotate telemetry channel after trying to capture input
cater for both in order and out-of-order bdshot telemetry packets
cope with reversed packets when decoding bdshot telemetry
ensure UP DMA channel is fully free on iomcu before starting next dshot cycle
refactor rcout for iofirmware into separate file
2023-12-18 19:02:52 +11:00
Peter Barker 13b03f79db AP_HAL_ChibiOS: move from HAL_NO_SHARED_DMA to AP_HAL_SHARED_DMA_ENABLED
This allows hwdef files to manipulate this value
2022-07-19 18:02:26 +10:00
Andrew Tridgell 39f44147b8 HAL_ChibiOS: reduce the impact of UART DMA contention
this changes the heuristics for UART TX DMA allocation to greatly
reduce the chances of DMA contention causing long delays on other
devices

This fixes issues with FETTec driver output and gimbal status messages
as reported by Amilcar and OlliW. The problem is particularly bad when
no GPS is connected to GPS1 on fmuv3 and derived boards (such as
CubeBlack)

key changes:

 - remember the contention_counter across begin() calls, as the GPS
   calls begin with new baudrates regularly

 - added a is_shared() API to Shared_DMA, allowing the UART driver to
   avoid TX DMA on shared streams when at low baudrates.
2021-08-31 07:55:27 +10:00
Andrew Tridgell 243cf2199d HAL_ChibiOS: disable shared DMA on IOMCU
this saves about 600 bytes of ram
2021-02-24 18:21:08 +11:00
Andy Piper f9c5f9be00 AP_HAL_ChibiOS: make dshot DMA unlock event driven in order to allow unlocking from rcout thread
refactor rcout into separate thread and process all dshot requests there
move uart DMA completion to event model
process dshot locks in strick reverse order when unlocking
convert Shared_DMA to use mutexes
move UART transmit to a thread-per-uart
do blocking UART DMA transactions
do blocking dshot DMA transactions
trim stack sizes
cancel dma transactions on dshot when timeout occurs
support contention stats on blocking locking
move thread supression into chibios_hwdef.py
invalidate DMA bounce buffer correctly
separate UART initialisation into two halves
cleanup UART transaction timeouts
add @SYS/uarts.txt
move half-duplex handling to TX thread
correct thread statistics after use of ExpandingString
set unbuffered TX thread priority owner + 1
correctly unlock serial_led_send()
don't share IMU RX on KakuteF7Mini
observe dshot pulse time more accurately.
set TRBUFF bit for UART DMA transfers
deal with UART DMA timeouts correctly
don't deadlock on reverse ordered DMA locks
change PORT_INT_REQUIRED_STACK to 128
2021-02-20 14:37:11 +11:00
Andrew Tridgell 42bc9adfb7 HAL_ChibiOS: use ExpandingString for @SYS buffers 2021-01-05 10:52:00 +11:00
Andy Piper cf2602f91d AP_HAL_ChibiOS: add support for @SYS/dma.txt for DMA contention 2020-12-02 18:17:23 +11:00
Mirko Denecke b84dcd483d AP_HAL_ChibiOS: remove unnecessary tabs and whitespaces 2019-10-21 08:01:56 +11:00
Andrew Tridgell 16bdaaa1af HAL_ChibiOS: added support for STM31F10x for AP_Periph 2019-08-27 10:29:56 +10:00
Andrew Tridgell 33699d4f4a HAL_ChibiOS: fixed shared_dma for H7
stream ID any doesn't need to be locked
2019-02-26 16:18:26 +11:00
Siddharth Purohit 87a2dea9d4 HAL_ChibiOS: disable features that require advanced dma 2018-09-19 12:14:15 +10:00
Andrew Tridgell c12d14d7a4 HAL_ChibiOS: check for ChibiOS features 2018-06-22 08:00:31 +10:00
Andrew Tridgell bc32276966 HAL_ChibiOS: support DShot output
use DMAR burst DMA to minimise number of DMA channels needed

thanks to betaflight for the great reference implementation!
2018-04-07 09:10:29 +10:00
Andrew Tridgell a86e85c6b2 HAL_ChibiOS: enable checking for DMA contention 2018-04-07 09:10:29 +10:00
Andrew Tridgell 91c741ef07 HAL_ChibiOS: use a non-blocking lock for UART shared DMA
we can have multiple UARTs on the same thread sharing the same DMA TX
channel. That can lead to deadlock with blocking locks on DMA. This
makes UART requests for DMA locks non-blocking to fix the issue
2018-03-02 21:39:38 +11:00
Andrew Tridgell 875008f2a6 HAL_ChibiOS: lock all DMA channels on reboot
this fixes a problem with the ICM-20789 on I2C where a reboot while the bus is active
leaves the IMU in a dead state where it can't be recovered without a power cycle.
2018-02-08 17:36:33 +11:00
Andrew Tridgell 41758348e5 HAL_ChibiOS: added checking of lock state in shared_dma
and use lock around check for tx completion in UART handler
2018-02-07 20:33:45 +11:00
Andrew Tridgell f14a847b97 HAL_ChibiOS: rename classes to remove 'Chibi'
it is redundent as all classes are in ChibiOS namespace, and makes the
code harder to read
2018-01-15 11:46:02 +11:00
Andrew Tridgell 8b6bab7b17 HAL_Chibios: added ChibiOS HAL
this is based on initial work by Sid, reset here for easier merging
2018-01-15 11:46:02 +11:00