mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
cpu/stm32/periph_dac: support of DAC mode register
If the DAC peripheral has a mode register (DAC_MCR), it is set to normal mode with buffer enabled and connected to external pin and on-chip peripherals. This allows to measure the current value of a DAC channel or to use the DAC channel also for other on-chip peripherals.
This commit is contained in:
parent
fb0a139eb9
commit
2a210c157b
@ -109,8 +109,14 @@ void dac_poweron(dac_t line)
|
||||
while (!(VREFBUF->CSR & VREFBUF_CSR_VRR)) { }
|
||||
#endif
|
||||
|
||||
#ifdef DAC_MCR_MODE1
|
||||
/* Normal mode with Buffer enabled and connected to external pin and on-chip
|
||||
* peripherals */
|
||||
dev(line)->MCR |= (DAC_MCR_MODE1_0 << (16 * (dac_config[line].chan & 0x01)));
|
||||
#endif
|
||||
|
||||
/* enable corresponding DAC channel */
|
||||
dev(line)->CR |= (1 << (16 * (dac_config[line].chan & 0x01)));
|
||||
dev(line)->CR |= (DAC_CR_EN1 << (16 * (dac_config[line].chan & 0x01)));
|
||||
}
|
||||
|
||||
void dac_poweroff(dac_t line)
|
||||
@ -118,7 +124,7 @@ void dac_poweroff(dac_t line)
|
||||
assert(line < DAC_NUMOF);
|
||||
|
||||
/* disable corresponding channel */
|
||||
dev(line)->CR &= ~(1 << (16 * (dac_config[line].chan & 0x01)));
|
||||
dev(line)->CR &= ~(DAC_CR_EN1 << (16 * (dac_config[line].chan & 0x01)));
|
||||
|
||||
/* disable the DAC's clock in case no channel is active anymore */
|
||||
if (!(dev(line)->CR & EN_MASK)) {
|
||||
|
Loading…
Reference in New Issue
Block a user