mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
cpu/stm32/periph_dac: support for internal V_REF+
For boards that have not connected the V_REF+ pin to an external reference voltage, the VREFBUF peripheral can be used as V_REF+ if supported by setting `VREFBUF_ENABLE=1`.
This commit is contained in:
parent
63b4da3e1f
commit
fb0a139eb9
@ -99,6 +99,16 @@ void dac_poweron(dac_t line)
|
||||
periph_clk_en(APB1, RCC_BIT);
|
||||
#endif
|
||||
|
||||
#if VREFBUF_ENABLE && defined(VREFBUF_CSR_ENVR)
|
||||
/* enable VREFBUF if needed and available (for example if the board doesn't
|
||||
* have an external reference voltage connected to V_REF+), wait until
|
||||
* it is ready */
|
||||
RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN;
|
||||
VREFBUF->CSR &= ~VREFBUF_CSR_HIZ;
|
||||
VREFBUF->CSR |= VREFBUF_CSR_ENVR;
|
||||
while (!(VREFBUF->CSR & VREFBUF_CSR_VRR)) { }
|
||||
#endif
|
||||
|
||||
/* enable corresponding DAC channel */
|
||||
dev(line)->CR |= (1 << (16 * (dac_config[line].chan & 0x01)));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user