cpu/sam0_common: DAC: wait for DAC to be ready
The DAC can have some start-up delay. If we try to write to it before it's ready, it will get stuck. This happens now that `tests/driver_dac_dds` immediately sets a DAC value after init. The samd2x class of MCUs doesn't have this bit, but a quick test on samd10 shows that it might not be nececary there - the DAC does not get stuck when writing to it immediately after init.
This commit is contained in:
parent
9a0243e062
commit
c5c46ba35b
@ -128,6 +128,12 @@ int8_t dac_init(dac_t line)
|
||||
DAC->CTRLA.bit.ENABLE = 1;
|
||||
_sync();
|
||||
|
||||
#ifdef DAC_STATUS_READY
|
||||
/* wait for DAC startup */
|
||||
const uint32_t mask = 1 << (DAC_STATUS_READY_Pos + line);
|
||||
while (!(DAC->STATUS.reg & mask)) {}
|
||||
#endif
|
||||
|
||||
return DAC_OK;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user