Skip to content

Commit 6cb06cd

Browse files
sgfeniexhenrikbrixandersen
authored andcommitted
drivers: sam0: dac: add sam0 dac support to samc21 processors
The SAMC21 has a different revision of the DAC peripheral. This change adds an ifdef to handle the changed SYNCBUSY register. Signed-off-by: Stefan Giroux <[email protected]>
1 parent eb9d5c2 commit 6cb06cd

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/dac/dac_sam0.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,26 @@ static int dac_sam0_init(const struct device *dev)
100100

101101
/* Reset then configure the DAC */
102102
regs->CTRLA.bit.SWRST = 1;
103+
#if defined(DAC_STATUS_SYNCBUSY)
103104
while (regs->STATUS.bit.SYNCBUSY) {
104105
}
106+
#else
107+
while (regs->SYNCBUSY.bit.SWRST) {
108+
}
109+
#endif
105110

106111
regs->CTRLB.bit.REFSEL = cfg->refsel;
107112
regs->CTRLB.bit.EOEN = 1;
108113

109114
/* Enable */
110115
regs->CTRLA.bit.ENABLE = 1;
116+
#if defined(DAC_STATUS_SYNCBUSY)
111117
while (regs->STATUS.bit.SYNCBUSY) {
112118
}
119+
#else
120+
while (regs->SYNCBUSY.bit.ENABLE) {
121+
}
122+
#endif
113123

114124
return 0;
115125
}

0 commit comments

Comments
 (0)