Vajnar commented on code in PR #16491:
URL: https://github.com/apache/nuttx/pull/16491#discussion_r2134586617


##########
arch/risc-v/src/common/espressif/esp_pcnt.c:
##########
@@ -642,8 +645,38 @@ static int esp_pcnt_unit_get_count(struct cap_lowerhalf_s 
*dev, int *ret)
     }
 
   flags = spin_lock_irqsave(&priv->lock);
-  *ret = pcnt_ll_get_count(ctx.dev, priv->unit_id) +
-      priv->accum_value;
+  tmp_count = pcnt_ll_get_count(ctx.dev, priv->unit_id);
+
+  intr_status = pcnt_ll_get_intr_status(ctx.dev);
+  if (intr_status & PCNT_LL_UNIT_WATCH_EVENT(priv->unit_id))
+    {
+      event_status = pcnt_ll_get_event_status(ctx.dev, priv->unit_id);
+      while (event_status)

Review Comment:
   I agree that currently only one of either High or Low limit event can occur. 
I would be worried if Threshold 0 or Threshold 1 events are added in future, 
that we may mistakenly take one of those events and consider them either High 
or Low and return wrong value. I would rather keep the explicit check for which 
event happened.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to