[riot-notifications] [RIOT-OS/RIOT] drivers/periph_common: dac: add dac_play() (#13908)

benpicco notifications at github.com
Mon Nov 30 15:42:44 CET 2020


@benpicco commented on this pull request.



> +    dac_dds_cb_t cb;            /* Called when the current buffer is done   */
+    void *cb_arg;               /* Callback argument                        */
+    tim_t timer;                /* Timer used for DAC                       */
+    uint16_t sample_ticks;      /* Timer ticks per sample                   */
+    uint8_t cur;                /* Active sample buffer                     */
+    uint8_t playing;            /* DAC is playing                           */
+    uint8_t is_16bit;           /* Sample size is 16 instead of 8 bit       */
+} _ctx[DAC_NUMOF];
+
+static void _timer_cb(void *arg, int chan)
+{
+    (void)chan;
+
+    struct dac_ctx *ctx = arg;
+
+    const dac_t dac    = ctx - _ctx;

tbh it's also not immediately obvious why this pointer arithmetic works.
I just added the `dac` to the callback struct, it's only 4 additional bytes.

-- 
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/13908#discussion_r532646696
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20201130/266d1994/attachment.htm>


More information about the notifications mailing list