From 700d921dc03c6632614d1a477a8dd167eb35fdb6 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Hell Date: Mon, 25 Jul 2022 22:40:49 +0200 Subject: [PATCH] Add a setting to disable the buzzer --- Inc/config.h | 5 +++++ Src/bldc.c | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Inc/config.h b/Inc/config.h index 12bd5646..9b8f6eef 100644 --- a/Inc/config.h +++ b/Inc/config.h @@ -261,6 +261,11 @@ // ########################### END OF DEBUG LCD ############################ +// ############################### BUZZER ENABLE / DISABLE ############################### +#define BUZZER_ENABLED // If enabled the buzzer will buzz, otherwise not. +// ########################### END OF BUZZER ENABLE / DISABLE ############################ + + // ################################# VARIANT_ADC SETTINGS ############################ #ifdef VARIANT_ADC diff --git a/Src/bldc.c b/Src/bldc.c index d5fb4c93..03677f9b 100644 --- a/Src/bldc.c +++ b/Src/bldc.c @@ -130,8 +130,9 @@ void DMA1_Channel1_IRQHandler(void) { RIGHT_TIM->BDTR |= TIM_BDTR_MOE; } - // Create square wave for buzzer + // Create square wave for buzzer and more buzzerTimer++; +#ifdef BUZZER_ENABLED if (buzzerFreq != 0 && (buzzerTimer / 5000) % (buzzerPattern + 1) == 0) { if (buzzerPrev == 0) { buzzerPrev = 1; @@ -146,6 +147,7 @@ void DMA1_Channel1_IRQHandler(void) { HAL_GPIO_WritePin(BUZZER_PORT, BUZZER_PIN, GPIO_PIN_RESET); buzzerPrev = 0; } +#endif // Adjust pwm_margin depending on the selected Control Type if (rtP_Left.z_ctrlTypSel == FOC_CTRL) {