mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-12 19:10:32 +03:00
## 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
42 lines
1.3 KiB
C
42 lines
1.3 KiB
C
/*
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "pg/pg.h"
|
|
#include "pg/pg_ids.h"
|
|
|
|
#include "drivers/dma_reqmap.h"
|
|
#include "drivers/io.h"
|
|
#include "drivers/timer.h" // For HARDWARE_TIMER_DEFINITION_COUNT
|
|
|
|
#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;
|
|
|
|
PG_DECLARE_ARRAY(timerUpConfig_t, HARDWARE_TIMER_DEFINITION_COUNT, timerUpConfig);
|
|
|
|
#endif
|