Firmware SDK
twr_dac.h
1 #ifndef _TWR_DAC_H
2 #define _TWR_DAC_H
3 
4 #include <twr_common.h>
5 #include <twr_dma.h>
6 
10 
12 
13 typedef enum
14 {
17 
19  TWR_DAC_DAC1 = 1
20 
22 
24 
25 typedef enum
26 {
29 
32 
35 
37 
39 
40 typedef enum
41 {
44 
47 
49 
51 
52 typedef enum
53 {
56 
59 
61 
63 
64 typedef enum
65 {
68 
71 
73 
75 
76 typedef enum
77 {
80 
83 
85 
87 
88 typedef struct
89 {
90  void *buffer;
91  uint16_t length;
92  twr_dac_data_size_t data_size;
93  twr_dac_sample_rate_t sample_rate;
94  twr_dac_mode_t mode;
95 
97 
100 
101 void twr_dac_init(twr_dac_channel_t channel);
102 
105 
106 void twr_dac_deinit(twr_dac_channel_t channel);
107 
112 
113 void twr_dac_set_output(twr_dac_channel_t channel, const void *raw, twr_dac_format_t format);
114 
119 
120 void twr_dac_set_event_handler(twr_dac_channel_t channel, void (*event_handler)(twr_dac_channel_t, twr_dac_event_t, void *), void *event_param);
121 
130 
132 
137 
139 
142 
144 
146 
147 #endif // _TWR_DAC_H
twr_dac_format_t
Raw value format.
Definition: twr_dac.h:26
void twr_dac_deinit(twr_dac_channel_t channel)
Deitialize DAC channel.
Definition: twr_dac.c:73
twr_dac_channel_t
DAC channel.
Definition: twr_dac.h:14
void twr_dac_async_stop(twr_dac_channel_t channel)
Stop asynchronous DAC channel operation.
Definition: twr_dac.c:264
void twr_dac_init(twr_dac_channel_t channel)
Initialize DAC channel.
Definition: twr_dac.c:43
twr_dac_event_t
DAC channel event.
Definition: twr_dac.h:77
twr_dac_data_size_t
Data size.
Definition: twr_dac.h:53
bool twr_dac_async_config(twr_dac_channel_t channel, twr_dac_config_t *config)
Configure image of DAC DMA channel.
Definition: twr_dac.c:143
twr_dac_mode_t
Mode.
Definition: twr_dac.h:65
void twr_dac_set_output(twr_dac_channel_t channel, const void *raw, twr_dac_format_t format)
Set DAC channel output as raw value.
Definition: twr_dac.c:104
bool twr_dac_async_run(twr_dac_channel_t channel)
Start asynchronous DAC channel operation.
Definition: twr_dac.c:191
void twr_dac_set_event_handler(twr_dac_channel_t channel, void(*event_handler)(twr_dac_channel_t, twr_dac_event_t, void *), void *event_param)
Set callback function.
Definition: twr_dac.c:137
twr_dac_sample_rate_t
Sample rate.
Definition: twr_dac.h:41
@ TWR_DAC_FORMAT_16_BIT
Raw value format is 16-bit.
Definition: twr_dac.h:31
@ TWR_DAC_FORMAT_VOLTAGE
Raw value format is float.
Definition: twr_dac.h:34
@ TWR_DAC_FORMAT_8_BIT
Raw value format is 8-bit.
Definition: twr_dac.h:28
@ TWR_DAC_DAC0
DAC channel DAC0.
Definition: twr_dac.h:16
@ TWR_DAC_DAC1
DAC channel DAC1.
Definition: twr_dac.h:19
@ TWR_DAC_EVENT_DONE
Event is done.
Definition: twr_dac.h:82
@ TWR_DAC_EVENT_HALF_DONE
Event is done.
Definition: twr_dac.h:79
@ TWR_DAC_DATA_SIZE_8
Data size is 8b.
Definition: twr_dac.h:55
@ TWR_DAC_DATA_SIZE_16
Data size is 16b.
Definition: twr_dac.h:58
@ TWR_DAC_MODE_SINGLE
Mode single.
Definition: twr_dac.h:67
@ TWR_DAC_MODE_CIRCULAR
Mode circular (repeate playing buffer)
Definition: twr_dac.h:70
@ TWR_DAC_SAMPLE_RATE_16K
Data sample-rate is 16kHz.
Definition: twr_dac.h:46
@ TWR_DAC_SAMPLE_RATE_8K
Data sample-rate is 8kHz.
Definition: twr_dac.h:43
DAC channel event.
Definition: twr_dac.h:89