mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-12 19:10:32 +03:00
Replace timer number offset with TIMER_INDEX() for DMA TIMUP mapping
This commit is contained in:
parent
4e9fd6550b
commit
7e8bef33d4
3 changed files with 8 additions and 15 deletions
|
@ -5440,15 +5440,8 @@ static int displayNumberToDmaOptIndex(dmaoptEntry_t *entry, int dispNum)
|
||||||
return timerGetIndexByNumber(dispNum);
|
return timerGetIndexByNumber(dispNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
return dispNum > entry->maxIndex ? -1 : dispNum - 1;
|
const int index = dispNum - 1;
|
||||||
}
|
return (index < 0 || index >= entry->maxIndex) ? -1 : index;
|
||||||
|
|
||||||
static int dmaOptIndexToPeripheralMappingIndex(dmaoptEntry_t *entry, int index)
|
|
||||||
{
|
|
||||||
if (entry->peripheral == DMA_PERIPH_TIMUP) {
|
|
||||||
return timerGetNumberByIndex(index) - 1; // TIM1 = 0, TIM20 = 19
|
|
||||||
}
|
|
||||||
return index;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printPeripheralDmaoptDetails(dmaoptEntry_t *entry, int index, const dmaoptValue_t dmaopt, const bool equalsDefault, const dumpFlags_t dumpMask, printFn *printValue)
|
static void printPeripheralDmaoptDetails(dmaoptEntry_t *entry, int index, const dmaoptValue_t dmaopt, const bool equalsDefault, const dumpFlags_t dumpMask, printFn *printValue)
|
||||||
|
@ -5468,7 +5461,7 @@ static void printPeripheralDmaoptDetails(dmaoptEntry_t *entry, int index, const
|
||||||
"dma %s %d %d",
|
"dma %s %d %d",
|
||||||
entry->device, uiIndex, dmaopt);
|
entry->device, uiIndex, dmaopt);
|
||||||
|
|
||||||
const dmaChannelSpec_t *dmaChannelSpec = dmaGetChannelSpecByPeripheral(entry->peripheral, dmaOptIndexToPeripheralMappingIndex(entry, index), dmaopt);
|
const dmaChannelSpec_t *dmaChannelSpec = dmaGetChannelSpecByPeripheral(entry->peripheral, index, dmaopt);
|
||||||
dmaCode_t dmaCode = 0;
|
dmaCode_t dmaCode = 0;
|
||||||
if (dmaChannelSpec) {
|
if (dmaChannelSpec) {
|
||||||
dmaCode = dmaChannelSpec->code;
|
dmaCode = dmaChannelSpec->code;
|
||||||
|
@ -5717,7 +5710,7 @@ static void cliDmaopt(const char *cmdName, char *cmdline)
|
||||||
// Show possible opts
|
// Show possible opts
|
||||||
const dmaChannelSpec_t *dmaChannelSpec;
|
const dmaChannelSpec_t *dmaChannelSpec;
|
||||||
if (entry) {
|
if (entry) {
|
||||||
for (int opt = 0; (dmaChannelSpec = dmaGetChannelSpecByPeripheral(entry->peripheral, dmaOptIndexToPeripheralMappingIndex(entry, index), opt)); opt++) {
|
for (int opt = 0; (dmaChannelSpec = dmaGetChannelSpecByPeripheral(entry->peripheral, index, opt)); opt++) {
|
||||||
cliPrintLinef("# %d: " DMASPEC_FORMAT_STRING, opt, DMA_CODE_CONTROLLER(dmaChannelSpec->code), DMA_CODE_STREAM(dmaChannelSpec->code), DMA_CODE_CHANNEL(dmaChannelSpec->code));
|
cliPrintLinef("# %d: " DMASPEC_FORMAT_STRING, opt, DMA_CODE_CONTROLLER(dmaChannelSpec->code), DMA_CODE_STREAM(dmaChannelSpec->code), DMA_CODE_CHANNEL(dmaChannelSpec->code));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -5735,7 +5728,7 @@ static void cliDmaopt(const char *cmdName, char *cmdline)
|
||||||
optval = atoi(pch);
|
optval = atoi(pch);
|
||||||
|
|
||||||
if (entry) {
|
if (entry) {
|
||||||
if (!dmaGetChannelSpecByPeripheral(entry->peripheral, dmaOptIndexToPeripheralMappingIndex(entry, index), optval)) {
|
if (!dmaGetChannelSpecByPeripheral(entry->peripheral, index, optval)) {
|
||||||
cliPrintErrorLinef(cmdName, "INVALID DMA OPTION FOR %s %d: '%s'", entry->device, getDmaOptDisplayNumber(entry, index), pch);
|
cliPrintErrorLinef(cmdName, "INVALID DMA OPTION FOR %s %d: '%s'", entry->device, getDmaOptDisplayNumber(entry, index), pch);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -49,7 +49,7 @@ typedef struct dmaTimerMapping_s {
|
||||||
#define REQMAP_SGL(periph) { DMA_PERIPH_ ## periph, 0, DMA_REQUEST_ ## periph }
|
#define REQMAP_SGL(periph) { DMA_PERIPH_ ## periph, 0, DMA_REQUEST_ ## periph }
|
||||||
#define REQMAP(periph, device) { DMA_PERIPH_ ## periph, periph ## DEV_ ## device, DMA_REQUEST_ ## periph ## device }
|
#define REQMAP(periph, device) { DMA_PERIPH_ ## periph, periph ## DEV_ ## device, DMA_REQUEST_ ## periph ## device }
|
||||||
#define REQMAP_DIR(periph, device, dir) { DMA_PERIPH_ ## periph ## _ ## dir, periph ## DEV_ ## device, DMA_REQUEST_ ## periph ## device ## _ ## dir }
|
#define REQMAP_DIR(periph, device, dir) { DMA_PERIPH_ ## periph ## _ ## dir, periph ## DEV_ ## device, DMA_REQUEST_ ## periph ## device ## _ ## dir }
|
||||||
#define REQMAP_TIMUP(periph, timno) { DMA_PERIPH_TIMUP, timno - 1, DMAMUX_DMAREQ_ID_ ## TMR ## timno ## _OVERFLOW }
|
#define REQMAP_TIMUP(periph, timno) { DMA_PERIPH_TIMUP, TIMER_INDEX(timno), DMAMUX_DMAREQ_ID_ ## TMR ## timno ## _OVERFLOW }
|
||||||
|
|
||||||
#define DMA_REQUEST_UART1_RX DMAMUX_DMAREQ_ID_USART1_RX
|
#define DMA_REQUEST_UART1_RX DMAMUX_DMAREQ_ID_USART1_RX
|
||||||
#define DMA_REQUEST_UART1_TX DMAMUX_DMAREQ_ID_USART1_TX
|
#define DMA_REQUEST_UART1_TX DMAMUX_DMAREQ_ID_USART1_TX
|
||||||
|
|
|
@ -59,7 +59,7 @@ typedef struct dmaTimerMapping_s {
|
||||||
#define REQMAP_SGL(periph) { DMA_PERIPH_ ## periph, 0, DMA_REQUEST_ ## periph }
|
#define REQMAP_SGL(periph) { DMA_PERIPH_ ## periph, 0, DMA_REQUEST_ ## periph }
|
||||||
#define REQMAP(periph, device) { DMA_PERIPH_ ## periph, periph ## DEV_ ## device, DMA_REQUEST_ ## periph ## device }
|
#define REQMAP(periph, device) { DMA_PERIPH_ ## periph, periph ## DEV_ ## device, DMA_REQUEST_ ## periph ## device }
|
||||||
#define REQMAP_DIR(periph, device, dir) { DMA_PERIPH_ ## periph ## _ ## dir, periph ## DEV_ ## device, DMA_REQUEST_ ## periph ## device ## _ ## dir }
|
#define REQMAP_DIR(periph, device, dir) { DMA_PERIPH_ ## periph ## _ ## dir, periph ## DEV_ ## device, DMA_REQUEST_ ## periph ## device ## _ ## dir }
|
||||||
#define REQMAP_TIMUP(periph, timno) { DMA_PERIPH_TIMUP, timno - 1, DMA_REQUEST_ ## TIM ## timno ## _UP }
|
#define REQMAP_TIMUP(periph, timno) { DMA_PERIPH_TIMUP, TIMER_INDEX(timno), DMA_REQUEST_ ## TIM ## timno ## _UP }
|
||||||
|
|
||||||
// Resolve UART/USART mess
|
// Resolve UART/USART mess
|
||||||
#define DMA_REQUEST_UART1_RX DMA_REQUEST_USART1_RX
|
#define DMA_REQUEST_UART1_RX DMA_REQUEST_USART1_RX
|
||||||
|
@ -215,7 +215,7 @@ static dmaChannelSpec_t dmaChannelSpec[MAX_PERIPHERAL_DMA_OPTIONS] = {
|
||||||
#define REQMAP_SGL(periph) { DMA_PERIPH_ ## periph, 0, DMA_REQUEST_ ## periph }
|
#define REQMAP_SGL(periph) { DMA_PERIPH_ ## periph, 0, DMA_REQUEST_ ## periph }
|
||||||
#define REQMAP(periph, device) { DMA_PERIPH_ ## periph, periph ## DEV_ ## device, DMA_REQUEST_ ## periph ## device }
|
#define REQMAP(periph, device) { DMA_PERIPH_ ## periph, periph ## DEV_ ## device, DMA_REQUEST_ ## periph ## device }
|
||||||
#define REQMAP_DIR(periph, device, dir) { DMA_PERIPH_ ## periph ## _ ## dir, periph ## DEV_ ## device, DMA_REQUEST_ ## periph ## device ## _ ## dir }
|
#define REQMAP_DIR(periph, device, dir) { DMA_PERIPH_ ## periph ## _ ## dir, periph ## DEV_ ## device, DMA_REQUEST_ ## periph ## device ## _ ## dir }
|
||||||
#define REQMAP_TIMUP(periph, timno) { DMA_PERIPH_TIMUP, timno - 1, DMA_REQUEST_ ## TIM ## timno ## _UP }
|
#define REQMAP_TIMUP(periph, timno) { DMA_PERIPH_TIMUP, TIMER_INDEX(timno), DMA_REQUEST_ ## TIM ## timno ## _UP }
|
||||||
|
|
||||||
// Resolve UART/USART mess
|
// Resolve UART/USART mess
|
||||||
#define DMA_REQUEST_UART1_RX DMA_REQUEST_USART1_RX
|
#define DMA_REQUEST_UART1_RX DMA_REQUEST_USART1_RX
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue