1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-14 11:59:58 +03:00

Added DMA mapping (readonly for now), and enabled timer management for all F4 boards.

Converting the universal target as well.

Simplified timer management some.

Added F722 support for good measuer.

Fixed SITL, tests.

Cleanup after rebase.

Added support for all timer consumers and F7.

Fixed 'USE_DMA_SPEC' for F3, some cleanups.
This commit is contained in:
mikeller 2019-02-18 02:09:06 +13:00
parent 9f8ad1aa44
commit f8103b8c86
37 changed files with 904 additions and 484 deletions

View file

@ -4735,7 +4735,7 @@ static void printPeripheralDmaopt(dmaoptEntry_t *entry, int index, uint8_t dumpM
if (defaultConfig) {
if (defaultOpt != DMA_OPT_UNUSED) {
const dmaChannelSpec_t *dmaChannelSpec = dmaGetChannelSpec(entry->peripheral, index, defaultOpt);
const dmaChannelSpec_t *dmaChannelSpec = dmaGetChannelSpecByPeripheral(entry->peripheral, index, defaultOpt);
dmaCode_t dmaCode = 0;
if (dmaChannelSpec) {
dmaCode = dmaChannelSpec->code;
@ -4751,7 +4751,7 @@ static void printPeripheralDmaopt(dmaoptEntry_t *entry, int index, uint8_t dumpM
}
if (currentOpt != DMA_OPT_UNUSED) {
const dmaChannelSpec_t *dmaChannelSpec = dmaGetChannelSpec(entry->peripheral, index, currentOpt);
const dmaChannelSpec_t *dmaChannelSpec = dmaGetChannelSpecByPeripheral(entry->peripheral, index, currentOpt);
dmaCode_t dmaCode = 0;
if (dmaChannelSpec) {
dmaCode = dmaChannelSpec->code;
@ -4768,16 +4768,60 @@ static void printPeripheralDmaopt(dmaoptEntry_t *entry, int index, uint8_t dumpM
}
}
#if defined(USE_TIMER_MGMT)
static void printTimerDmaopt(const timerIOConfig_t *timerIoConfig, uint8_t dumpMask)
{
const char *format = "dmaopt %c%02d %d";
const ioTag_t ioTag = timerIoConfig->ioTag;
if (!ioTag) {
return;
}
const dmaoptValue_t dmaopt = timerIoConfig->dmaopt;
const timerHardware_t *timer = timerGetByTag(ioTag);
if (dmaopt != DMA_OPT_UNUSED && !(dumpMask & HIDE_UNUSED)) {
cliDumpPrintLinef(dumpMask, false, format,
IO_GPIOPortIdxByTag(ioTag) + 'A', IO_GPIOPinIdxByTag(ioTag),
dmaopt
);
const dmaChannelSpec_t *dmaChannelSpec = dmaGetChannelSpecByTimer(timer);
dmaCode_t dmaCode = 0;
if (dmaChannelSpec) {
dmaCode = dmaChannelSpec->code;
}
cliDumpPrintLinef(dumpMask, false,
"# %c%02d: DMA%d Stream %d Channel %d",
IO_GPIOPortIdxByTag(ioTag) + 'A', IO_GPIOPinIdxByTag(ioTag),
DMA_CODE_CONTROLLER(dmaCode), DMA_CODE_STREAM(dmaCode), DMA_CODE_CHANNEL(dmaCode)
);
} else {
if (!(dumpMask & HIDE_UNUSED)) {
cliDumpPrintLinef(dumpMask, false,
"dmaopt %c%02d NONE",
IO_GPIOPortIdxByTag(ioTag) + 'A', IO_GPIOPinIdxByTag(ioTag)
);
}
}
}
#endif
static void printDmaopt(uint8_t dumpMask)
{
UNUSED(dumpMask); // XXX For now
for (size_t i = 0; i < ARRAYLEN(dmaoptEntryTable); i++) {
dmaoptEntry_t *entry = &dmaoptEntryTable[i];
for (int index = 0; index < entry->maxIndex; index++) {
printPeripheralDmaopt(entry, index, dumpMask);
}
}
#if defined(USE_TIMER_MGMT)
for (unsigned i = 0; i < MAX_TIMER_PINMAP_COUNT; i++) {
printTimerDmaopt(timerIOConfig(i), dumpMask);
}
#endif
}
static void cliDmaopt(char *cmdline)
@ -4839,7 +4883,7 @@ static void cliDmaopt(char *cmdline)
} else if (strcasecmp(pch, "list") == 0) {
// Show possible opts
const dmaChannelSpec_t *dmaChannelSpec;
for (int opt = 0; (dmaChannelSpec = dmaGetChannelSpec(entry->peripheral, index, opt)); opt++) {
for (int opt = 0; (dmaChannelSpec = dmaGetChannelSpecByPeripheral(entry->peripheral, index, opt)); opt++) {
cliPrintLinef("# %d: DMA%d Stream %d channel %d", opt, DMA_CODE_CONTROLLER(dmaChannelSpec->code), DMA_CODE_STREAM(dmaChannelSpec->code), DMA_CODE_CHANNEL(dmaChannelSpec->code));
}
return;
@ -4899,7 +4943,7 @@ static void printTimer(uint8_t dumpMask)
}
if (timerIndex != 0 && !(dumpMask & HIDE_UNUSED)) {
cliDumpPrintLinef(dumpMask, false, format,
cliDumpPrintLinef(dumpMask, false, format,
IO_GPIOPortIdxByTag(ioTag) + 'A',
IO_GPIOPinIdxByTag(ioTag),
timerIndex - 1
@ -4954,12 +4998,12 @@ static void cliTimer(char *cmdline)
if (strcasecmp(pch, "list") == 0) {
/* output the list of available options */
uint8_t index = 0;
for (unsigned i = 0; i < USABLE_TIMER_CHANNEL_COUNT; i++) {
if (timerHardware[i].tag == ioTag) {
for (unsigned i = 0; i < TIMER_CHANNEL_COUNT; i++) {
if (TIMER_HARDWARE[i].tag == ioTag) {
cliPrintLinef("# %d. TIM%d CH%d",
index,
timerGetTIMNumber(timerHardware[i].tim),
CC_INDEX_FROM_CHANNEL(timerHardware[i].channel) + 1
timerGetTIMNumber(TIMER_HARDWARE[i].tim),
CC_INDEX_FROM_CHANNEL(TIMER_HARDWARE[i].channel) + 1
);
index++;
}