From 0ff2d864b4cb4446e87df03c94c176d4f4217b32 Mon Sep 17 00:00:00 2001 From: jflyper Date: Mon, 17 Sep 2018 23:37:30 +0900 Subject: [PATCH] Fix origins for timer channel list Selection is zero origin Channel number is one origin for user I/O --- src/main/interface/cli.c | 8 ++++---- src/main/pg/timerio.h | 4 +--- src/main/target/common_defaults_post.h | 6 ++++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/interface/cli.c b/src/main/interface/cli.c index b75c9bdbe..e0233dc98 100644 --- a/src/main/interface/cli.c +++ b/src/main/interface/cli.c @@ -4109,7 +4109,7 @@ static void printTimer(uint8_t dumpMask) cliDumpPrintLinef(dumpMask, false, format, IO_GPIOPortIdxByTag(ioTag) + 'A', IO_GPIOPinIdxByTag(ioTag), - timerIndex + timerIndex - 1 ); } } @@ -4160,13 +4160,13 @@ static void cliTimer(char *cmdline) if (pch) { if (strcasecmp(pch, "list") == 0) { /* output the list of available options */ - uint8_t index = 1; + uint8_t index = 0; for (unsigned i = 0; i < USABLE_TIMER_CHANNEL_COUNT; i++) { if (timerHardware[i].tag == ioTag) { cliPrintLinef("# %d. TIM%d CH%d", index, timerGetTIMNumber(timerHardware[i].tim), - CC_INDEX_FROM_CHANNEL(timerHardware[i].channel) + CC_INDEX_FROM_CHANNEL(timerHardware[i].channel) + 1 ); index++; } @@ -4175,7 +4175,7 @@ static void cliTimer(char *cmdline) } else if (strcasecmp(pch, "none") == 0) { goto success; } else { - timerIndex = atoi(pch); + timerIndex = atoi(pch) + 1; } } else { goto error; diff --git a/src/main/pg/timerio.h b/src/main/pg/timerio.h index 859714de4..bf18f1306 100644 --- a/src/main/pg/timerio.h +++ b/src/main/pg/timerio.h @@ -27,8 +27,6 @@ #ifdef USE_TIMER_MGMT -#define MAX_TIMER_PINMAP_COUNT 10 - typedef struct timerIOConfig_s { ioTag_t ioTag; uint8_t index; @@ -36,4 +34,4 @@ typedef struct timerIOConfig_s { PG_DECLARE_ARRAY(timerIOConfig_t, MAX_TIMER_PINMAP_COUNT, timerIOConfig); -#endif \ No newline at end of file +#endif diff --git a/src/main/target/common_defaults_post.h b/src/main/target/common_defaults_post.h index fdc9dca04..9d675e526 100644 --- a/src/main/target/common_defaults_post.h +++ b/src/main/target/common_defaults_post.h @@ -269,3 +269,9 @@ #define MSC_BUTTON_IPU true #endif #endif + +#ifdef USE_TIMER_MGMT +#ifndef MAX_TIMER_PINMAP_COUNT +#define MAX_TIMER_PINMAP_COUNT 21 // Largest known for F405RG (OMNINXT) +#endif +#endif