Skip to content

Commit

Permalink
servoPwm only in _DEBUG_
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianmiriuta committed May 11, 2020
1 parent a3ed393 commit 6280a74
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/main/build/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
43 changes: 21 additions & 22 deletions src/main/drivers/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 6280a74

Please sign in to comment.