[riot-notifications] [RIOT-OS/RIOT] cpu/atmega_common: Fix periph_timer (#14098)

benpicco notifications at github.com
Wed May 27 21:15:01 CEST 2020


@benpicco commented on this pull request.



> +
+int timer_set(tim_t tim, int channel, unsigned int timeout)
+{
+    if (channel >= TIMER_CHANNELS) {
+        return -1;
+    }
+
+    unsigned state = irq_disable();
+    unsigned absolute = ctx[tim].dev->CNT + timeout;
+    ctx[tim].dev->OCR[channel] = absolute;
+    uint8_t mask = 1 << (channel + OCIE1A);
+    *ctx[tim].mask |= mask;
+    if ((absolute - ctx[tim].dev->CNT) > timeout) {
+        /* Timer already expired. Make sure that interrupt is indeed triggered
+         */
+        while (!(*ctx[tim].flag & (1 << (OCF1A + channel)))) {

```suggestion
        while (!(*ctx[tim].flag & mask)) {
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/14098#pullrequestreview-419534310
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20200527/e69aed07/attachment.htm>


More information about the notifications mailing list