diff --git a/src/main/drivers/serial_escserial.c b/src/main/drivers/serial_escserial.c index 6736b6b0f..8ba484916 100644 --- a/src/main/drivers/serial_escserial.c +++ b/src/main/drivers/serial_escserial.c @@ -111,15 +111,14 @@ static void escSerialICConfig(TIM_TypeDef *tim, uint8_t channel, uint16_t polari void setTxSignalEsc(escSerial_t *escSerial, uint8_t state) { +#ifdef USE_ESCSERIAL_INVERSION + state ^= ENABLE; +#endif + if(escSerial->mode == PROTOCOL_KISSALL) { for (volatile uint8_t i = 0; i < escSerial->outputCount; i++) { - uint8_t state_temp = state; - if(escOutputs[i].inverted) { - state_temp ^= ENABLE; - } - - if (state_temp) { + if (state) { IOHi(escOutputs[i].io); } else { IOLo(escOutputs[i].io); @@ -128,10 +127,6 @@ void setTxSignalEsc(escSerial_t *escSerial, uint8_t state) } else { - if(escSerial->rxTimerHardware->output & TIMER_OUTPUT_INVERTED) { - state ^= ENABLE; - } - if (state) { IOHi(escSerial->txIO); } else { diff --git a/src/main/fc/cli.c b/src/main/fc/cli.c index 538cb1d42..d8ccbd7fc 100755 --- a/src/main/fc/cli.c +++ b/src/main/fc/cli.c @@ -2823,6 +2823,7 @@ static void cliEscPassthrough(char *cmdline) int i = 0; char *pch = NULL; char *saveptr; + uint8_t indexForProg = 0; if (isEmpty(cmdline)) { cliShowParseError(); @@ -2857,13 +2858,15 @@ static void cliEscPassthrough(char *cmdline) break; case 1: index = atoi(pch); + indexForProg = index; if(mode == 2 && index == 255) { printf("passthrough on all outputs enabled\r\n"); } else{ - if ((index >= 0) && (index < USABLE_TIMER_CHANNEL_COUNT)) { - printf("passthrough on output %d enabled\r\n", index); + indexForProg = index + 1; // Wonky timer mapping requires this to match the actual motor numberings + if ((index >= 1) && (index < USABLE_TIMER_CHANNEL_COUNT)) { + printf("passthrough on esc %d enabled\r\n", index); } else { printf("invalid output, range: 1 to %d\r\n", USABLE_TIMER_CHANNEL_COUNT); @@ -2875,7 +2878,7 @@ static void cliEscPassthrough(char *cmdline) i++; pch = strtok_r(NULL, " ", &saveptr); } - escEnablePassthrough(cliPort,index,mode); + escEnablePassthrough(cliPort,indexForProg,mode); } #endif diff --git a/src/main/target/KISSFC/target.c b/src/main/target/KISSFC/target.c index 638219238..3906ec0fa 100644 --- a/src/main/target/KISSFC/target.c +++ b/src/main/target/KISSFC/target.c @@ -25,6 +25,7 @@ #include "drivers/dma.h" const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { + DEF_TIM(TIM2, CH2, PB3, TIM_USE_PWM | TIM_USE_PPM, TIMER_INPUT_ENABLED), #ifdef KISSCC DEF_TIM(TIM1, CH2N,PB14, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED | TIMER_OUTPUT_INVERTED), DEF_TIM(TIM8, CH2N,PB0, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED | TIMER_OUTPUT_INVERTED), @@ -42,7 +43,6 @@ const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { DEF_TIM(TIM17,CH1, PA7, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED | TIMER_OUTPUT_INVERTED), DEF_TIM(TIM4, CH3, PA13, TIM_USE_PWM, TIMER_INPUT_ENABLED), // On KISSFC TIM16 did not work, using TIM4 works #endif - DEF_TIM(TIM2, CH2, PB3, TIM_USE_PWM | TIM_USE_PPM, TIMER_INPUT_ENABLED), DEF_TIM(TIM2, CH1, PA15, TIM_USE_PWM, TIMER_INPUT_ENABLED), DEF_TIM(TIM2, CH3, PA2, TIM_USE_PWM, TIMER_INPUT_ENABLED), DEF_TIM(TIM2, CH4, PB11, TIM_USE_PWM, TIMER_INPUT_ENABLED), diff --git a/src/main/target/KISSFC/target.h b/src/main/target/KISSFC/target.h index 81a5eade2..edafd456a 100644 --- a/src/main/target/KISSFC/target.h +++ b/src/main/target/KISSFC/target.h @@ -26,7 +26,10 @@ #define USE_ESC_SENSOR #define USE_ESCSERIAL -#define ESCSERIAL_TIMER_TX_HARDWARE 6 +#ifdef KISSFC +#define USE_ESCSERIAL_INVERSION +#endif +#define ESCSERIAL_TIMER_TX_HARDWARE 0 #define REMAP_TIM17_DMA #define LED0 PB1