diff --git a/src/main/cli/cli.c b/src/main/cli/cli.c index f3c323d6de..da7bf75836 100644 --- a/src/main/cli/cli.c +++ b/src/main/cli/cli.c @@ -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(); diff --git a/src/main/pg/timerio.c b/src/main/pg/timerio.c index 84915868b0..118e83cc4f 100644 --- a/src/main/pg/timerio.c +++ b/src/main/pg/timerio.c @@ -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);