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

To enable display of pin mapping for config.h (#12363)

This commit is contained in:
J Blackman 2023-02-16 17:28:27 +11:00 committed by GitHub
parent 44abae2965
commit 17c7816a52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 2 deletions

View file

@ -5850,6 +5850,28 @@ static void alternateFunctionToString(const ioTag_t ioTag, const int index, char
}
}
#ifdef USE_TIMER_MAP_PRINT
static void showTimerMap(void)
{
cliPrintLinefeed();
cliPrintLine("Timer Mapping:");
for (unsigned int i = 0; i < MAX_TIMER_PINMAP_COUNT; i++) {
const ioTag_t ioTag = timerIOConfig(i)->ioTag;
if (!ioTag) {
continue;
}
cliPrintLinef(" TIMER_PIN_MAP(%d, P%c%d, %d, %d)",
i,
IO_GPIOPortIdxByTag(ioTag) + 'A', IO_GPIOPinIdxByTag(ioTag),
timerIOConfig(i)->index,
timerIOConfig(i)->dmaopt
);
}
}
#endif
static void showTimers(void)
{
cliPrintLinefeed();
@ -5901,6 +5923,12 @@ static void cliTimer(const char *cmdName, char *cmdline)
cliPrintErrorLinef(cmdName, "NOT IMPLEMENTED YET");
return;
#ifdef USE_TIMER_MAP_PRINT
} else if (strncasecmp(cmdline, "map", len) == 0) {
showTimerMap();
return;
#endif
} else if (strncasecmp(cmdline, "show", len) == 0) {
showTimers();

View file

@ -29,8 +29,16 @@
#include "timerio.h"
#define TIMER_PIN_MAP(idx, pin, pos, dmaOpt) \
{ config[idx].ioTag = IO_TAG(pin); config[idx].index = pos; config[idx].dmaopt = dmaOpt; }
/*
Details of the TIMER_PIN_MAP macro:
i => is the index in the PG timer IO config array,
p => is the hardware pin to be mapped,
o => is the hardware pin occurrence (1 based index) within timerHardware (full) that should be used
e.g. 1 = first occurence of the pin, 2 = second occurence, etc.
d => the configured dma opt for the pin
*/
#define TIMER_PIN_MAP(i, p, o, d) \
{ config[i].ioTag = IO_TAG(p); config[i].index = o; config[i].dmaopt = d; }
PG_REGISTER_ARRAY_WITH_RESET_FN(timerIOConfig_t, MAX_TIMER_PINMAP_COUNT, timerIOConfig, PG_TIMER_IO_CONFIG, 0);