34#ifdef LIBOPENCM3_DAC_H
36#ifndef LIBOPENCM3_DAC_COMMON_V2_H
37#define LIBOPENCM3_DAC_COMMON_V2_H
45#define DAC_CCR(dac) MMIO32((dac) + 0x38)
48#define DAC_MCR(dac) MMIO32((dac) + 0x3C)
51#define DAC_SHSR1(dac) MMIO32((dac) + 0x40)
54#define DAC_SHSR2(dac) MMIO32((dac) + 0x44)
57#define DAC_SHHR(dac) MMIO32((dac) + 0x48)
60#define DAC_SHRR(dac) MMIO32((dac) + 0x4C)
63#define DAC_STR1(dac) MMIO32((dac) + 0x58)
66#define DAC_STR2(dac) MMIO32((dac) + 0x5C)
69#define DAC_STMODR(dac) MMIO32((dac) + 0x60)
77#define DAC_CR_CEN2 (1 << 30)
80#define DAC_CR_TSEL2_SHIFT 18
103#define DAC_CR_TSEL2_SW (0x0 << DAC_CR_TSEL2_SHIFT)
104#define DAC_CR_TSEL2_T8 (0x1 << DAC_CR_TSEL2_SHIFT)
105#define DAC_CR_TSEL2_T7 (0x2 << DAC_CR_TSEL2_SHIFT)
106#define DAC_CR_TSEL2_T15 (0x3 << DAC_CR_TSEL2_SHIFT)
107#define DAC_CR_TSEL2_T2 (0x4 << DAC_CR_TSEL2_SHIFT)
108#define DAC_CR_TSEL2_T4 (0x5 << DAC_CR_TSEL2_SHIFT)
109#define DAC_CR_TSEL2_E9 (0x6 << DAC_CR_TSEL2_SHIFT)
110#define DAC_CR_TSEL2_T6 (0x7 << DAC_CR_TSEL2_SHIFT)
111#define DAC_CR_TSEL2_T3 (0x8 << DAC_CR_TSEL2_SHIFT)
112#define DAC_CR_TSEL2_HRR1 (0x9 << DAC_CR_TSEL2_SHIFT)
113#define DAC_CR_TSEL2_HRR2 (0xA << DAC_CR_TSEL2_SHIFT)
114#define DAC_CR_TSEL2_HRR3 (0xB << DAC_CR_TSEL2_SHIFT)
115#define DAC_CR_TSEL2_HRR4 (0xC << DAC_CR_TSEL2_SHIFT)
116#define DAC_CR_TSEL2_HRR5 (0xD << DAC_CR_TSEL2_SHIFT)
117#define DAC_CR_TSEL2_HRR6 (0xE << DAC_CR_TSEL2_SHIFT)
118#define DAC_CR_TSEL2_HR2 (0xF << DAC_CR_TSEL2_SHIFT)
122#define DAC_CR_TEN2 (1 << 17)
125#define DAC_CR_CEN1 (1 << 14)
128#define DAC_CR_TSEL1_SHIFT 2
151#define DAC_CR_TSEL1_CK (0x0 << DAC_CR_TSEL1_SHIFT)
152#define DAC_CR_TSEL1_T8 (0x1 << DAC_CR_TSEL1_SHIFT)
153#define DAC_CR_TSEL1_T7 (0x2 << DAC_CR_TSEL1_SHIFT)
154#define DAC_CR_TSEL1_T15 (0x3 << DAC_CR_TSEL1_SHIFT)
155#define DAC_CR_TSEL1_T2 (0x4 << DAC_CR_TSEL1_SHIFT)
156#define DAC_CR_TSEL1_T4 (0x5 << DAC_CR_TSEL1_SHIFT)
157#define DAC_CR_TSEL1_E9 (0x6 << DAC_CR_TSEL1_SHIFT)
158#define DAC_CR_TSEL1_T6 (0x7 << DAC_CR_TSEL1_SHIFT)
159#define DAC_CR_TSEL1_T3 (0x8 << DAC_CR_TSEL1_SHIFT)
160#define DAC_CR_TSEL1_HRR1 (0x9 << DAC_CR_TSEL1_SHIFT)
161#define DAC_CR_TSEL1_HRR2 (0xA << DAC_CR_TSEL1_SHIFT)
162#define DAC_CR_TSEL1_HRR3 (0xB << DAC_CR_TSEL1_SHIFT)
163#define DAC_CR_TSEL1_HRR4 (0xC << DAC_CR_TSEL1_SHIFT)
164#define DAC_CR_TSEL1_HRR5 (0xD << DAC_CR_TSEL1_SHIFT)
165#define DAC_CR_TSEL1_HRR6 (0xE << DAC_CR_TSEL1_SHIFT)
166#define DAC_CR_TSEL1_HR3 (0xF << DAC_CR_TSEL1_SHIFT)
170#define DAC_CR_TEN1 (1 << 1)
178#define DAC_SWTRIGR_SWTRIGB2 (1 << 17)
181#define DAC_SWTRIGR_SWTRIGB1 (1 << 16)
188#define DAC_DOR1_DACC1DORB_SHIFT 16
189#define DAC_DOR1_DACC1DORB_MASK 0xFFF
193#define DAC_DOR2_DACC2DORB_SHIFT 16
194#define DAC_DOR2_DACC2DORB_MASK 0xFFF
201#define DAC_SR_BWST2 (1 << 31)
204#define DAC_SR_CAL_FLAG2 (1 << 30)
207#define DAC_SR_DMAUDR2 (1 << 29)
210#define DAC_SR_DORSTAT2 (1 << 28)
213#define DAC_SR_DAC2RDY (1 << 27)
216#define DAC_SR_BWST1 (1 << 15)
219#define DAC_SR_CAL_FLAG1 (1 << 14)
222#define DAC_SR_DMAUDR1 (1 << 13)
225#define DAC_SR_DORSTAT1 (1 << 12)
228#define DAC_SR_DAC1RDY (1 << 11)
236#define DAC_CCR_OTRIM2_SHIFT 16
237#define DAC_CCR_OTRIM2_MASK 0x1F
240#define DAC_CCR_OTRIM1_SHIFT 0
241#define DAC_CCR_OTRIM1_MASK 0x1F
250#define DAC_MCR_SINFORMAT2 (1 << 25)
253#define DAC_MCR_DMADOUBLE2 (1 << 24)
256#define DAC_MCR_MODE2_SHIFT 16
269#define DAC_MCR_MODE2_E_BUFF (0x0 << DAC_MCR_MODE2_SHIFT)
270#define DAC_MCR_MODE2_EP_BUFF (0x1 << DAC_MCR_MODE2_SHIFT)
271#define DAC_MCR_MODE2_E (0x2 << DAC_MCR_MODE2_SHIFT)
272#define DAC_MCR_MODE2_EP (0x3 << DAC_MCR_MODE2_SHIFT)
273#define DAC_MCR_MODE2_SH_E_BUFF (0x4 << DAC_MCR_MODE2_SHIFT)
274#define DAC_MCR_MODE2_SH_EP_BUFF (0x5 << DAC_MCR_MODE2_SHIFT)
275#define DAC_MCR_MODE2_SH_E (0x6 << DAC_MCR_MODE2_SHIFT)
276#define DAC_MCR_MODE2_SH_EP (0x7 << DAC_MCR_MODE2_SHIFT)
279#define DAC_MCR_MODE2_PERIPHERAL (0x1 << DAC_MCR_MODE2_SHIFT)
280#define DAC_MCR_MODE2_UNBUFFERED (0x2 << DAC_MCR_MODE2_SHIFT)
281#define DAC_MCR_MODE2_SAMPLEHOLD (0x4 << DAC_MCR_MODE2_SHIFT)
284#define DAC_MCR_HFSEL_SHIFT 14
285#define DAC_MCR_HFSEL_MASK 0x3
293#define DAC_MCR_HFSEL_DIS (0x0 << DAC_MCR_HFSEL_SHIFT)
294#define DAC_MCR_HFSEL_AHB80 (0x1 << DAC_MCR_HFSEL_SHIFT)
295#define DAC_MCR_HFSEL_AHB160 (0x2 << DAC_MCR_HFSEL_SHIFT)
299#define DAC_MCR_SINFORMAT1 (1 << 9)
302#define DAC_MCR_DMADOUBLE1 (1 << 8)
305#define DAC_MCR_MODE1_SHIFT 0
318#define DAC_MCR_MODE1_E_BUFF (0x0 << DAC_MCR_MODE1_SHIFT)
319#define DAC_MCR_MODE1_EP_BUFF (0x1 << DAC_MCR_MODE1_SHIFT)
320#define DAC_MCR_MODE1_E (0x2 << DAC_MCR_MODE1_SHIFT)
321#define DAC_MCR_MODE1_EP (0x3 << DAC_MCR_MODE1_SHIFT)
322#define DAC_MCR_MODE1_SH_E_BUFF (0x4 << DAC_MCR_MODE1_SHIFT)
323#define DAC_MCR_MODE1_SH_EP_BUFF (0x5 << DAC_MCR_MODE1_SHIFT)
324#define DAC_MCR_MODE1_SH_E (0x6 << DAC_MCR_MODE1_SHIFT)
325#define DAC_MCR_MODE1_SH_EP (0x7 << DAC_MCR_MODE1_SHIFT)
328#define DAC_MCR_MODE1_PERIPHERAL (0x1 << DAC_MCR_MODE1_SHIFT)
329#define DAC_MCR_MODE1_UNBUFFERED (0x2 << DAC_MCR_MODE1_SHIFT)
330#define DAC_MCR_MODE1_SAMPLEHOLD (0x4 << DAC_MCR_MODE1_SHIFT)
336#define DAC_SHSR1_TSAMPLE1_SHIFT 0
337#define DAC_SHSR1_TSAMPLE1_MASK 0x1FF
342#define DAC_SHSR2_TSAMPLE2_SHIFT 0
343#define DAC_SHSR2_TSAMPLE2_MASK 0x1FF
348#define DAC_SHHSR_THOLD2_SHIFT 16
349#define DAC_SHHSR_THOLD2_MASK 0x1FF
352#define DAC_SHHSR_THOLD1_SHIFT 0
353#define DAC_SHHSR_THOLD1_MASK 0x1FF
358#define DAC_STR1_STINCDATA1_SHIFT 16
359#define DAC_STR1_STINCDATA1_MASK 0xFFFF
362#define DAC_STR1_STDIR1_SHIFT 12
369#define DAC_STR1_STDIR1_DEC (0x0 << DAC_STR_STDIR1_SHIFT)
370#define DAC_STR1_STDIR1_INC (0x1 << DAC_STR_STDIR1_SHIFT)
374#define DAC_STR1_STRSTDATA1_SHIFT 0
375#define DAC_STR1_STRSTDATA1_MASK 0xFFF
380#define DAC_STR2_STINCDATA2_SHIFT 16
381#define DAC_STR2_STINCDATA2_MASK 0xFFFF
384#define DAC_STR2_STDIR2_SHIFT 12
391#define DAC_STR2_STDIR2_DEC (0x0 << DAC_STR_STDIR2_SHIFT)
392#define DAC_STR2_STDIR2_INC (0x1 << DAC_STR_STDIR2_SHIFT)
396#define DAC_STR2_STRSTDATA2_SHIFT 0
397#define DAC_STR2_STRSTDATA2_MASK 0xFFF
402#define DAC_STMODR_STINCTRIGSEL2_SHIFT 24
425#define DAC_STMODR_STINCTRIGSEL2_SW (0x0 << DAC_STMODR_STINCTRIGSEL2_SHIFT)
426#define DAC_STMODR_STINCTRIGSEL2_T1 (0x1 << DAC_STMODR_STINCTRIGSEL2_SHIFT)
427#define DAC_STMODR_STINCTRIGSEL2_T2 (0x2 << DAC_STMODR_STINCTRIGSEL2_SHIFT)
428#define DAC_STMODR_STINCTRIGSEL2_T3 (0x3 << DAC_STMODR_STINCTRIGSEL2_SHIFT)
429#define DAC_STMODR_STINCTRIGSEL2_T4 (0x4 << DAC_STMODR_STINCTRIGSEL2_SHIFT)
430#define DAC_STMODR_STINCTRIGSEL2_T5 (0x5 << DAC_STMODR_STINCTRIGSEL2_SHIFT)
431#define DAC_STMODR_STINCTRIGSEL2_T6 (0x6 << DAC_STMODR_STINCTRIGSEL2_SHIFT)
432#define DAC_STMODR_STINCTRIGSEL2_T7 (0x7 << DAC_STMODR_STINCTRIGSEL2_SHIFT)
433#define DAC_STMODR_STINCTRIGSEL2_T8 (0x8 << DAC_STMODR_STINCTRIGSEL2_SHIFT)
434#define DAC_STMODR_STINCTRIGSEL2_T9 (0x9 << DAC_STMODR_STINCTRIGSEL2_SHIFT)
435#define DAC_STMODR_STINCTRIGSEL2_T10 (0xA << DAC_STMODR_STINCTRIGSEL2_SHIFT)
436#define DAC_STMODR_STINCTRIGSEL2_T11 (0xB << DAC_STMODR_STINCTRIGSEL2_SHIFT)
437#define DAC_STMODR_STINCTRIGSEL2_T12 (0xC << DAC_STMODR_STINCTRIGSEL2_SHIFT)
438#define DAC_STMODR_STINCTRIGSEL2_T13 (0xD << DAC_STMODR_STINCTRIGSEL2_SHIFT)
439#define DAC_STMODR_STINCTRIGSEL2_T14 (0xE << DAC_STMODR_STINCTRIGSEL2_SHIFT)
440#define DAC_STMODR_STINCTRIGSEL2_T15 (0xF << DAC_STMODR_STINCTRIGSEL2_SHIFT)
444#define DAC_STMODR_STRSTTRIGSEL2_SHIFT 16
467#define DAC_STMODR_STRSTTRIGSEL2_SW (0x0 << DAC_STMODR_STRSTTRIGSEL2_SHIFT)
468#define DAC_STMODR_STRSTTRIGSEL2_T1 (0x1 << DAC_STMODR_STRSTTRIGSEL2_SHIFT)
469#define DAC_STMODR_STRSTTRIGSEL2_T2 (0x2 << DAC_STMODR_STRSTTRIGSEL2_SHIFT)
470#define DAC_STMODR_STRSTTRIGSEL2_T3 (0x3 << DAC_STMODR_STRSTTRIGSEL2_SHIFT)
471#define DAC_STMODR_STRSTTRIGSEL2_T4 (0x4 << DAC_STMODR_STRSTTRIGSEL2_SHIFT)
472#define DAC_STMODR_STRSTTRIGSEL2_T5 (0x5 << DAC_STMODR_STRSTTRIGSEL2_SHIFT)
473#define DAC_STMODR_STRSTTRIGSEL2_T6 (0x6 << DAC_STMODR_STRSTTRIGSEL2_SHIFT)
474#define DAC_STMODR_STRSTTRIGSEL2_T7 (0x7 << DAC_STMODR_STRSTTRIGSEL2_SHIFT)
475#define DAC_STMODR_STRSTTRIGSEL2_T8 (0x8 << DAC_STMODR_STRSTTRIGSEL2_SHIFT)
476#define DAC_STMODR_STRSTTRIGSEL2_T9 (0x9 << DAC_STMODR_STRSTTRIGSEL2_SHIFT)
477#define DAC_STMODR_STRSTTRIGSEL2_T10 (0xA << DAC_STMODR_STRSTTRIGSEL2_SHIFT)
478#define DAC_STMODR_STRSTTRIGSEL2_T11 (0xB << DAC_STMODR_STRSTTRIGSEL2_SHIFT)
479#define DAC_STMODR_STRSTTRIGSEL2_T12 (0xC << DAC_STMODR_STRSTTRIGSEL2_SHIFT)
480#define DAC_STMODR_STRSTTRIGSEL2_T13 (0xD << DAC_STMODR_STRSTTRIGSEL2_SHIFT)
481#define DAC_STMODR_STRSTTRIGSEL2_T14 (0xE << DAC_STMODR_STRSTTRIGSEL2_SHIFT)
482#define DAC_STMODR_STRSTTRIGSEL2_T15 (0xF << DAC_STMODR_STRSTTRIGSEL2_SHIFT)
487#define DAC_STMODR_STINCTRIGSEL1_SHIFT 8
510#define DAC_STMODR_STINCTRIGSEL1_SW (0x0 << DAC_STMODR_STINCTRIGSEL1_SHIFT)
511#define DAC_STMODR_STINCTRIGSEL1_T1 (0x1 << DAC_STMODR_STINCTRIGSEL1_SHIFT)
512#define DAC_STMODR_STINCTRIGSEL1_T2 (0x2 << DAC_STMODR_STINCTRIGSEL1_SHIFT)
513#define DAC_STMODR_STINCTRIGSEL1_T3 (0x3 << DAC_STMODR_STINCTRIGSEL1_SHIFT)
514#define DAC_STMODR_STINCTRIGSEL1_T4 (0x4 << DAC_STMODR_STINCTRIGSEL1_SHIFT)
515#define DAC_STMODR_STINCTRIGSEL1_T5 (0x5 << DAC_STMODR_STINCTRIGSEL1_SHIFT)
516#define DAC_STMODR_STINCTRIGSEL1_T6 (0x6 << DAC_STMODR_STINCTRIGSEL1_SHIFT)
517#define DAC_STMODR_STINCTRIGSEL1_T7 (0x7 << DAC_STMODR_STINCTRIGSEL1_SHIFT)
518#define DAC_STMODR_STINCTRIGSEL1_T8 (0x8 << DAC_STMODR_STINCTRIGSEL1_SHIFT)
519#define DAC_STMODR_STINCTRIGSEL1_T9 (0x9 << DAC_STMODR_STINCTRIGSEL1_SHIFT)
520#define DAC_STMODR_STINCTRIGSEL1_T10 (0xA << DAC_STMODR_STINCTRIGSEL1_SHIFT)
521#define DAC_STMODR_STINCTRIGSEL1_T11 (0xB << DAC_STMODR_STINCTRIGSEL1_SHIFT)
522#define DAC_STMODR_STINCTRIGSEL1_T12 (0xC << DAC_STMODR_STINCTRIGSEL1_SHIFT)
523#define DAC_STMODR_STINCTRIGSEL1_T13 (0xD << DAC_STMODR_STINCTRIGSEL1_SHIFT)
524#define DAC_STMODR_STINCTRIGSEL1_T14 (0xE << DAC_STMODR_STINCTRIGSEL1_SHIFT)
525#define DAC_STMODR_STINCTRIGSEL1_T15 (0xF << DAC_STMODR_STINCTRIGSEL1_SHIFT)
529#define DAC_STMODR_STRSTTRIGSEL1_SHIFT 0
552#define DAC_STMODR_STRSTTRIGSEL1_SW (0x0 << DAC_STMODR_STRSTTRIGSEL1_SHIFT)
553#define DAC_STMODR_STRSTTRIGSEL1_T1 (0x1 << DAC_STMODR_STRSTTRIGSEL1_SHIFT)
554#define DAC_STMODR_STRSTTRIGSEL1_T2 (0x2 << DAC_STMODR_STRSTTRIGSEL1_SHIFT)
555#define DAC_STMODR_STRSTTRIGSEL1_T3 (0x3 << DAC_STMODR_STRSTTRIGSEL1_SHIFT)
556#define DAC_STMODR_STRSTTRIGSEL1_T4 (0x4 << DAC_STMODR_STRSTTRIGSEL1_SHIFT)
557#define DAC_STMODR_STRSTTRIGSEL1_T5 (0x5 << DAC_STMODR_STRSTTRIGSEL1_SHIFT)
558#define DAC_STMODR_STRSTTRIGSEL1_T6 (0x6 << DAC_STMODR_STRSTTRIGSEL1_SHIFT)
559#define DAC_STMODR_STRSTTRIGSEL1_T7 (0x7 << DAC_STMODR_STRSTTRIGSEL1_SHIFT)
560#define DAC_STMODR_STRSTTRIGSEL1_T8 (0x8 << DAC_STMODR_STRSTTRIGSEL1_SHIFT)
561#define DAC_STMODR_STRSTTRIGSEL1_T9 (0x9 << DAC_STMODR_STRSTTRIGSEL1_SHIFT)
562#define DAC_STMODR_STRSTTRIGSEL1_T10 (0xA << DAC_STMODR_STRSTTRIGSEL1_SHIFT)
563#define DAC_STMODR_STRSTTRIGSEL1_T11 (0xB << DAC_STMODR_STRSTTRIGSEL1_SHIFT)
564#define DAC_STMODR_STRSTTRIGSEL1_T12 (0xC << DAC_STMODR_STRSTTRIGSEL1_SHIFT)
565#define DAC_STMODR_STRSTTRIGSEL1_T13 (0xD << DAC_STMODR_STRSTTRIGSEL1_SHIFT)
566#define DAC_STMODR_STRSTTRIGSEL1_T14 (0xE << DAC_STMODR_STRSTTRIGSEL1_SHIFT)
567#define DAC_STMODR_STRSTTRIGSEL1_T15 (0xF << DAC_STMODR_STRSTTRIGSEL1_SHIFT)
584#warning "dac_common_v2.h should not be included explicitly, only via dac.h"
void dac_wait_on_ready(uint32_t dac, int channel)
Wait until DAC channel is ready to receive data.
void dac_set_mode(uint32_t dac, uint32_t mode)
DAC Channel Output Mode.
bool dac_is_ready(uint32_t dac, int channel)
Check if DAC channel is ready to receive data.
void dac_set_high_frequency_mode(uint32_t dac, uint32_t hfsel)
High frequency interface mode selection.