From 4bce4a25357de3adf0c9f39f310f5ce7deecee47 Mon Sep 17 00:00:00 2001
From: Emilio Corigliano <emilio.corigliano@skywarder.eu>
Date: Fri, 6 Oct 2023 10:34:08 +0000
Subject: [PATCH] [CountedPWM] Now driver handles the corner case of
 pulseFrequency equal to zero

---
 src/shared/drivers/timer/CountedPWM.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/shared/drivers/timer/CountedPWM.cpp b/src/shared/drivers/timer/CountedPWM.cpp
index 8c49b3e85..9187f92bc 100644
--- a/src/shared/drivers/timer/CountedPWM.cpp
+++ b/src/shared/drivers/timer/CountedPWM.cpp
@@ -56,6 +56,10 @@ CountedPWM::~CountedPWM()
 void CountedPWM::setFrequency(unsigned int pulseFrequency)
 {
     this->pulseFrequency = pulseFrequency;
+
+    if (pulseFrequency == 0)
+        return;
+
     pulseTimer.setFrequency(pulseFrequency * dutyCycleResolution);
     pulseTimer.setAutoReloadRegister(
         TimerUtils::getFrequency(pulseTimer.getTimer()) / pulseFrequency);
-- 
GitLab