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

benpicco notifications at github.com
Wed May 27 21:37:41 CEST 2020


@benpicco commented on this pull request.



>      ctx[tim].dev->OCR[channel] = (uint16_t)value;
     *ctx[tim].flag &= ~(1 << (channel + OCF1A));
     *ctx[tim].mask |= (1 << (channel + OCIE1A));
+    irq_restore(state);
+
+    return 0;
+}
+
+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;
+    *ctx[tim].mask |= (1 << (channel + OCIE1A));

Now that you pointed out my mistake I must say I liked it better before…
Because now there is this random mask variable when everywhere else that shift pattern is used…
And if we can't reuse the mask, there is nothing to gain.

-- 
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#discussion_r431396994
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20200527/ab50f34f/attachment-0001.htm>


More information about the notifications mailing list