1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-13 03:20:00 +03:00
Commit graph

4 commits

Author SHA1 Message Date
ke deng
acbab53d13
Fix incorrect TIMUP DMA configuration dump on H743 (#14502)
## Commit Summary: Fix incorrect TIMUP DMA configuration dump on H743

**Problem**: H743 platform had incorrect TIMUP DMA configuration dumping and parsing, causing errors when restoring dumped configurations.

**Solution**: This PR implements a comprehensive fix for TIMUP DMA handling across multiple areas:

### CLI DMA Option Handling (`src/main/cli/cli.c`)
- Added `getDmaOptDisplayNumber()` and `displayNumberToDmaOptIndex()` helper functions
- Properly translates between internal DMA option indices and user-facing display numbers
- Integrates presence mask validation for `DMA_PERIPH_TIMUP` peripheral
- Ensures only valid/present timer options are displayed and accepted

### Timer Definition Refactoring (Multiple Platforms)
- Replaced hardcoded `HARDWARE_TIMER_DEFINITION_COUNT` with dynamic `BITCOUNT(USED_TIMERS)` 
- Updated STM32H7/G4 `TIMUP_TIMERS` macros to use `TIM_N(x)` instead of `BIT(x)`
- Expanded AT32 `USED_TIMERS` to include timers 6 and 7
- Added static assertion to verify `TIMUP_TIMERS` bits are included in `USED_TIMERS`

### Timer Index Management (`src/main/drivers/timer.h` + platform implementations)
- Added `TIM_N(n)` macro for timer bitmask generation
- Added `TIMER_INDEX(i)` macro for proper index calculation
- Implemented `timerGetIndexByNumber()` function across all platforms (STM32, AT32, APM32)
- Provides bidirectional timer number ↔ index conversion

### DMA Request Mapping Updates
- Modified `REQMAP_TIMUP` macros to use `TIMER_INDEX(timno)` instead of `timno - 1`
- Ensures correct DMA request mapping for non-contiguous timer numbering

### Timer Configuration (`src/main/pg/timerup.c`)
- Replaced hardware timer count checks with `TIMUP_TIMERS` bitmask validation
- Added support for timers 6 and 7 that were previously omitted
- Uses computed `TIMER_INDEX()` for proper array indexing
2025-07-10 13:36:39 +02:00
J Blackman
2dbbd1882c
timerHardware removal - all targets use fullTimerHardware now. (#12349)
* Removing last items associated with old timerHardware

* target.c rename, to identify purpose (should probably move to drivers/sitl or similar)

* Removing timerHardware dependency from timerup.c
2023-02-14 16:47:44 +01:00
Dominic Clifton
5fbb0674c5 Fix missing ADC4 dma mapping for F3.
Fix incorrect count of dma options for F3.

Value was hardcoded to 3, but the F3 has 4 ADCs.

Fix dmaPeripheralMapping for F3.

The dmaPeripheralMapping table was using index numbers and not device
numbers.

This meant all the dma mappings were out by one, eg.

```

```

ADC 1 is on DMA1, channel 1, but the output from dma ADC 2 list shows
the possibilities for ADC 1, not ADC 2 and shows no possibilities for
dma ADC 1 list

Ensure there are defaults for ADC4 on F3.

Always use 4 ADC instances for the ADC PG.

* PG should not be target dependant.
* Add a static assert which will fail if anything is changed.

Fix dmaopt in ADC PG, it should be a int8_t, not uint8_t

Fix occurrences of -1 that should be `DMA_OPT_UNUSED`.

Fixing this meant that dma_reqmap.h needed to be included in a few
places.  When this was done there were errors because dma_reqmap.h was
included more than once and it's `#pragma once` was commented out.

Including dma_reqmap.h from every PG that uses `dmaopt` also caused
other compilation issues, fixed by this commit.
2019-10-21 20:10:50 +13:00
jflyper
8ceaed1072 [H7] Add pseudo peripheral TIMUP for TIMx_UP DMA management 2019-06-28 15:45:19 +09:00