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
39#ifndef DAC_DDS_H
40#define DAC_DDS_H
41
42#include <stddef.h>
43#include <stdint.h>
44#include <limits.h>
45
46#include "periph/dac.h"
47#include "periph/timer.h"
48
49#ifdef __cplusplus
50extern "C" {
51#endif
52
61typedef void (*dac_dds_cb_t)(void *arg);
62
67typedef struct {
70 uint32_t timer_hz;
77typedef uint8_t dac_dds_t;
78
82#ifndef DAC_FLAG_8BIT
83#define DAC_FLAG_8BIT (0x0)
84#endif
85
89#ifndef DAC_FLAG_16BIT
90#define DAC_FLAG_16BIT (0x1)
91#endif
92
105void dac_dds_init(dac_dds_t dac, uint16_t sample_rate, uint8_t flags,
106 dac_dds_cb_t cb, void *cb_arg);
107
123void dac_dds_set_cb(dac_dds_t dac, dac_dds_cb_t cb, void *cb_arg);
124
150bool dac_dds_play(dac_dds_t dac, const void *buf, size_t len);
151
158
159#ifdef __cplusplus
160}
161#endif
162
163#endif /* DAC_DDS_H */
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:61
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:77
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:67
uint_fast8_t tim_t
Default timer type.
Definition timer.h:71
Configuration struct for a DAC DDS channel.
Definition dac_dds.h:67
dac_t dac
The DAC used for playing the sample
Definition dac_dds.h:68
uint32_t timer_hz
Timer frequency, must be at least 2x sample rate.
Definition dac_dds.h:70
tim_t timer
Timer used for periodic DAC events
Definition dac_dds.h:69