Changed 'timer' output to list timers based on alternate function.

This commit is contained in:
mikeller 2019-05-22 02:34:36 +12:00
parent 063f647027
commit b64b136780
1 changed files with 28 additions and 17 deletions

View File

@ -5108,27 +5108,28 @@ static void cliDmaopt(char *cmdline)
} }
char optvalString[DMA_OPT_STRING_BUFSIZE]; char optvalString[DMA_OPT_STRING_BUFSIZE];
char orgvalString[DMA_OPT_STRING_BUFSIZE];
optToString(optval, optvalString); optToString(optval, optvalString);
char orgvalString[DMA_OPT_STRING_BUFSIZE];
optToString(orgval, orgvalString); optToString(orgval, orgvalString);
if (optval != orgval) { if (optval != orgval) {
if (entry) { if (entry) {
*optaddr = optval; *optaddr = optval;
cliPrintLinef("dma %s %d: changed from %s to %s", entry->device, DMA_OPT_UI_INDEX(index), orgvalString, optvalString); cliPrintLinef("# dma %s %d: changed from %s to %s", entry->device, DMA_OPT_UI_INDEX(index), orgvalString, optvalString);
} else { } else {
#if defined(USE_TIMER_MGMT) #if defined(USE_TIMER_MGMT)
timerIoConfig->dmaopt = optval; timerIoConfig->dmaopt = optval;
#endif #endif
cliPrintLinef("dma pin %c%02d: changed from %s to %s", IO_GPIOPortIdxByTag(ioTag) + 'A', IO_GPIOPinIdxByTag(ioTag), orgvalString, optvalString); cliPrintLinef("# dma pin %c%02d: changed from %s to %s", IO_GPIOPortIdxByTag(ioTag) + 'A', IO_GPIOPinIdxByTag(ioTag), orgvalString, optvalString);
} }
} else { } else {
if (entry) { if (entry) {
cliPrintLinef("dma %s %d: no change: %s", entry->device, DMA_OPT_UI_INDEX(index), orgvalString); cliPrintLinef("# dma %s %d: no change: %s", entry->device, DMA_OPT_UI_INDEX(index), orgvalString);
} else { } else {
cliPrintLinef("dma %c%02d: no change: %s", IO_GPIOPortIdxByTag(ioTag) + 'A', IO_GPIOPinIdxByTag(ioTag),orgvalString); cliPrintLinef("# dma %c%02d: no change: %s", IO_GPIOPortIdxByTag(ioTag) + 'A', IO_GPIOPinIdxByTag(ioTag),orgvalString);
} }
} }
} }
@ -5250,17 +5251,17 @@ static void cliResource(char *cmdline)
#ifdef USE_TIMER_MGMT #ifdef USE_TIMER_MGMT
static void printTimerDetails(const ioTag_t ioTag, const unsigned timerIndex, const bool equalsDefault, const dumpFlags_t dumpMask, printFn *printValue) static void printTimerDetails(const ioTag_t ioTag, const unsigned timerIndex, const bool equalsDefault, const dumpFlags_t dumpMask, printFn *printValue)
{ {
const char *format = "timer %c%02d %d"; const char *format = "timer %c%02d af%d";
const char *emptyFormat = "timer %c%02d NONE"; const char *emptyFormat = "timer %c%02d NONE";
if (timerIndex > 0) { if (timerIndex > 0) {
const timerHardware_t *timer = timerGetByTagAndIndex(ioTag, timerIndex);
const bool printDetails = printValue(dumpMask, equalsDefault, format, const bool printDetails = printValue(dumpMask, equalsDefault, format,
IO_GPIOPortIdxByTag(ioTag) + 'A', IO_GPIOPortIdxByTag(ioTag) + 'A',
IO_GPIOPinIdxByTag(ioTag), IO_GPIOPinIdxByTag(ioTag),
timerIndex - 1 timer->alternateFunction
); );
if (printDetails) { if (printDetails) {
const timerHardware_t *timer = timerGetByTagAndIndex(ioTag, timerIndex);
printValue(dumpMask, false, printValue(dumpMask, false,
"# pin %c%02d: TIM%d CH%d%s (AF%d)", "# pin %c%02d: TIM%d CH%d%s (AF%d)",
IO_GPIOPortIdxByTag(ioTag) + 'A', IO_GPIOPinIdxByTag(ioTag), IO_GPIOPortIdxByTag(ioTag) + 'A', IO_GPIOPinIdxByTag(ioTag),
@ -5337,6 +5338,17 @@ static void printTimer(dumpFlags_t dumpMask, const char *headingStr)
} }
#define TIMER_INDEX_UNDEFINED -1 #define TIMER_INDEX_UNDEFINED -1
#define TIMER_AF_STRING_BUFSIZE 5
static void alternateFunctionToString(const ioTag_t ioTag, const int index, char *buf)
{
const timerHardware_t *timer = timerGetByTagAndIndex(ioTag, index + 1);
if (!timer) {
memcpy(buf, "NONE", TIMER_AF_STRING_BUFSIZE);
} else {
tfp_sprintf(buf, "af%d", timer->alternateFunction);
}
}
static void cliTimer(char *cmdline) static void cliTimer(char *cmdline)
{ {
@ -5401,12 +5413,11 @@ static void cliTimer(char *cmdline)
/* output the list of available options */ /* output the list of available options */
const timerHardware_t *timer; const timerHardware_t *timer;
for (unsigned index = 0; (timer = timerGetByTagAndIndex(ioTag, index + 1)); index++) { for (unsigned index = 0; (timer = timerGetByTagAndIndex(ioTag, index + 1)); index++) {
cliPrintLinef("# %d: TIM%d CH%d%s (AF%d)", cliPrintLinef("# af%d: TIM%d CH%d%s",
index, timer->alternateFunction,
timerGetTIMNumber(timer->tim), timerGetTIMNumber(timer->tim),
CC_INDEX_FROM_CHANNEL(timer->channel) + 1, CC_INDEX_FROM_CHANNEL(timer->channel) + 1,
timer->output & TIMER_OUTPUT_N_CHANNEL ? "N" : "", timer->output & TIMER_OUTPUT_N_CHANNEL ? "N" : ""
timer->alternateFunction
); );
} }
@ -5448,15 +5459,15 @@ static void cliTimer(char *cmdline)
timerIOConfigMutable(timerIOIndex)->dmaopt = DMA_OPT_UNUSED; timerIOConfigMutable(timerIOIndex)->dmaopt = DMA_OPT_UNUSED;
char optvalString[DMA_OPT_STRING_BUFSIZE]; char optvalString[DMA_OPT_STRING_BUFSIZE];
optToString(timerIndex, optvalString); alternateFunctionToString(ioTag, timerIndex, optvalString);
char orgvalString[DMA_OPT_STRING_BUFSIZE]; char orgvalString[DMA_OPT_STRING_BUFSIZE];
optToString(oldTimerIndex, orgvalString); alternateFunctionToString(ioTag, oldTimerIndex, orgvalString);
if (timerIndex == oldTimerIndex) { if (timerIndex == oldTimerIndex) {
cliPrintLinef("timer %c%02d: no change: %s", IO_GPIOPortIdxByTag(ioTag) + 'A', IO_GPIOPinIdxByTag(ioTag), orgvalString); cliPrintLinef("# timer %c%02d: no change: %s", IO_GPIOPortIdxByTag(ioTag) + 'A', IO_GPIOPinIdxByTag(ioTag), orgvalString);
} else { } else {
cliPrintLinef("timer %c%02d: changed from %s to %s", IO_GPIOPortIdxByTag(ioTag) + 'A', IO_GPIOPinIdxByTag(ioTag), orgvalString, optvalString); cliPrintLinef("# timer %c%02d: changed from %s to %s", IO_GPIOPortIdxByTag(ioTag) + 'A', IO_GPIOPinIdxByTag(ioTag), orgvalString, optvalString);
} }
return; return;
@ -5924,7 +5935,7 @@ const clicmd_t cmdTable[] = {
CLI_COMMAND_DEF("tasks", "show task stats", NULL, cliTasks), CLI_COMMAND_DEF("tasks", "show task stats", NULL, cliTasks),
#endif #endif
#ifdef USE_TIMER_MGMT #ifdef USE_TIMER_MGMT
CLI_COMMAND_DEF("timer", "show/set timers", "<> | <pin> list | <pin> [<option>|af<altenate function>|none] | list | show", cliTimer), CLI_COMMAND_DEF("timer", "show/set timers", "<> | <pin> list | <pin> [af<altenate function>|none|<option(deprecated)>] | list | show", cliTimer),
#endif #endif
CLI_COMMAND_DEF("version", "show version", NULL, cliVersion), CLI_COMMAND_DEF("version", "show version", NULL, cliVersion),
#ifdef USE_VTX_CONTROL #ifdef USE_VTX_CONTROL