Loading...
Searching...
No Matches
dac_dds.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2020 Beuth Hochschule für Technik Berlin
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
9#pragma once
10
40
41#include <stddef.h>
42#include <stdint.h>
43#include <limits.h>
44
45#include "periph/dac.h"
46#include "periph/timer.h"
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
60typedef void (*dac_dds_cb_t)(void *arg);
61
66typedef struct {
69 uint32_t timer_hz;
71
72
76typedef uint8_t dac_dds_t;
77
81#ifndef DAC_FLAG_8BIT
82#define DAC_FLAG_8BIT (0x0)
83#endif
84
88#ifndef DAC_FLAG_16BIT
89#define DAC_FLAG_16BIT (0x1)
90#endif
91
104void dac_dds_init(dac_dds_t dac, uint16_t sample_rate, uint8_t flags,
105 dac_dds_cb_t cb, void *cb_arg);
106
122void dac_dds_set_cb(dac_dds_t dac, dac_dds_cb_t cb, void *cb_arg);
123
149bool dac_dds_play(dac_dds_t dac, const void *buf, size_t len);
150
157
158#ifdef __cplusplus
159}
160#endif
161
DAC peripheral driver interface definition.
Low-level timer peripheral driver interface definitions.
void dac_dds_init(dac_dds_t dac, uint16_t sample_rate, uint8_t flags, dac_dds_cb_t cb, void *cb_arg)
Initialize a DAC for playing audio samples A user defined callback can be provided that will be calle...
void dac_dds_stop(dac_dds_t dac)
Stop playback of the current sample buffer.
void(* dac_dds_cb_t)(void *arg)
The callback that will be called when the end of the current sample buffer has been reached.
Definition dac_dds.h:60
bool dac_dds_play(dac_dds_t dac, const void *buf, size_t len)
Play a buffer of (audio) samples on a DAC.
uint8_t dac_dds_t
Index of the DAC DDS channel.
Definition dac_dds.h:76
void dac_dds_set_cb(dac_dds_t dac, dac_dds_cb_t cb, void *cb_arg)
Change the 'buffer done' callback.
uint_fast8_t dac_t
Define default DAC type identifier.
Definition dac.h:66
uint_fast8_t tim_t
Default timer type.
Definition timer.h:70
Configuration struct for a DAC DDS channel.
Definition dac_dds.h:66
dac_t dac
The DAC used for playing the sample.
Definition dac_dds.h:67
uint32_t timer_hz
Timer frequency, must be at least 2x sample rate.
Definition dac_dds.h:69
tim_t timer
Timer used for periodic DAC events.
Definition dac_dds.h:68