1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-25 01:05:27 +03:00

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
This commit is contained in:
ke deng 2025-07-10 19:36:39 +08:00 committed by GitHub
parent 90d2503274
commit acbab53d13
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 101 additions and 60 deletions

View file

@ -29,6 +29,10 @@
#if defined(USE_TIMER_MGMT) && defined(USE_TIMER_UP_CONFIG)
#if defined(USED_TIMERS) && defined(TIMUP_TIMERS)
STATIC_ASSERT((~USED_TIMERS & TIMUP_TIMERS) == 0, "All TIMUP timers must be used");
#endif
typedef struct timerUpConfig_s {
int8_t dmaopt;
} timerUpConfig_t;