From 6280a74f1884d8e77a54361d0f93f54037d62f2a Mon Sep 17 00:00:00 2001 From: Adrian Miriuta Date: Mon, 11 May 2020 07:22:23 +0200 Subject: [PATCH] servoPwm only in _DEBUG_ --- src/main/build/version.h | 2 +- src/main/drivers/input.c | 43 ++++++++++++++++++++-------------------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/main/build/version.h b/src/main/build/version.h index 4669e1b..f162e1d 100644 --- a/src/main/build/version.h +++ b/src/main/build/version.h @@ -3,4 +3,4 @@ #define FW_FIRMWARE_NAME "nostromo" #define FW_VERSION_MAJOR 1 #define FW_VERSION_MINOR 12 -#define FW_VERSION_PATCH 2 +#define FW_VERSION_PATCH 3 diff --git a/src/main/drivers/input.c b/src/main/drivers/input.c index 644af5d..c3cac52 100644 --- a/src/main/drivers/input.c +++ b/src/main/drivers/input.c @@ -283,28 +283,27 @@ void inputProshot() { } } -// SERVOPWM (use only for thrust tests ...) +// SERVOPWM (used only for thrust tests ...) void inputServoPwm() { - __disable_irq(); - uint32_t pulseWidthBuffer = 0; - - for (int i = 0; i < (INPUT_DMA_BUFFER_SIZE_PWM - 1); i++) { - pulseWidthBuffer = inputDmaBuffer[i + 1] - inputDmaBuffer[i]; - - if ((pulseWidthBuffer >= (INPUT_PWM_WIDTH_MIN_US - 50 )) && (pulseWidthBuffer <= (INPUT_PWM_WIDTH_MAX_US + 100))) { - input.DataValid = true; - input.DataValidCounter++; - input.TimeoutCounter = 0; - input.Data = (pulseWidthBuffer - INPUT_PWM_WIDTH_MIN_US) << 2; - __enable_irq(); - motorInputUpdate(); - - return; - } else { - input.DataValid = false; - input.DataErrorCounter++; - __enable_irq(); + #if (defined(_DEBUG_)) + __disable_irq(); + uint32_t pulseWidthBuffer = 0; + + for (int i = 0; i < (INPUT_DMA_BUFFER_SIZE_PWM - 1); i++) { + pulseWidthBuffer = inputDmaBuffer[i + 1] - inputDmaBuffer[i]; + if ((pulseWidthBuffer >= (INPUT_PWM_WIDTH_MIN_US - 50 )) && (pulseWidthBuffer <= (INPUT_PWM_WIDTH_MAX_US + 100))) { + input.DataValid = true; + input.DataValidCounter++; + input.TimeoutCounter = 0; + input.Data = (pulseWidthBuffer - INPUT_PWM_WIDTH_MIN_US) << 2; + __enable_irq(); + motorInputUpdate(); + return; + } else { + input.DataValid = false; + input.DataErrorCounter++; + __enable_irq(); + } } - } - + #endif }