Loading...
Searching...
No Matches
dac.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2014 Simon Brummer
3 * SPDX-FileCopyrightText: 2015-2016 Freie Universität Berlin
4 * SPDX-License-Identifier: LGPL-2.1-only
5 */
6
7#pragma once
8
48
49#include <stddef.h>
50#include <stdint.h>
51#include <limits.h>
52
53#include "periph_cpu.h"
54#include "periph_conf.h"
55
56#ifdef __cplusplus
57extern "C" {
58#endif
59
63#ifndef HAVE_DAC_T
64typedef uint_fast8_t dac_t;
65#endif
66
70enum {
71 DAC_OK = 0,
72 DAC_NOLINE = -1
73};
74
78#ifndef DAC_UNDEF
79#define DAC_UNDEF (UINT_FAST8_MAX)
80#endif
81
85#ifndef DAC_LINE
86#define DAC_LINE(x) (x)
87#endif
88
100int8_t dac_init(dac_t line);
101
113void dac_set(dac_t line, uint16_t value);
114
121
128
136uint32_t dac_get_freq(void);
137
142#define DAC_PLAY_LOOPED (1 << 0)
144
150typedef void (*dma_cb_t)(void *arg);
151
171int dac_play_setup(dac_t line, dma_cb_t cb, void *arg);
172
183void dac_play(dac_t line, const uint16_t *buf, size_t len, uint8_t flags);
184
193
194#ifdef __cplusplus
195}
196#endif
197
uint_fast8_t dac_t
Define default DAC type identifier.
Definition dac.h:64
void dac_set(dac_t line, uint16_t value)
Write a value onto DAC Device on a given Channel.
void dac_poweroff(dac_t line)
Disable the given DAC line.
int dac_play_setup(dac_t line, dma_cb_t cb, void *arg)
Configure DAC line for playing sample buffer.
uint32_t dac_get_freq(void)
Get the sample rate of the DAC in Hz.
void dac_play_teardown(dac_t line)
Release DAC line.
int8_t dac_init(dac_t line)
Initialize the given DAC line.
void dac_poweron(dac_t line)
Enable the given DAC line.
void dac_play(dac_t line, const uint16_t *buf, size_t len, uint8_t flags)
Start playing sample buffer.
void(* dma_cb_t)(void *arg)
Signature of event callback functions triggered from interrupts.