libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
dac_common_v1.c
Go to the documentation of this file.
1/** @addtogroup dac_file DAC peripheral API
2 * @ingroup peripheral_apis
3
4@author @htmlonly &copy; @endhtmlonly 2020 Ben Brewer <ben.brewer@codethink.co.uk>
5
6LGPL License Terms @ref lgpl_license
7 */
8
9/*
10 * This file is part of the libopencm3 project.
11 *
12 * Copyright (C) 2020 Ben Brewer
13 *
14 * This library is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * This library is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License for more details.
23 *
24 * You should have received a copy of the GNU Lesser General Public License
25 * along with this library. If not, see <http://www.gnu.org/licenses/>.
26 */
27
28/**@{*/
29
31
32/** @brief DAC Channel Output Buffer Enable.
33
34Enable a digital to analog converter channel output drive buffer. This is an
35optional amplifying buffer that provides additional drive for the output
36signal. The buffer is enabled by default after a reset and needs to be
37explicitly disabled if required.
38
39@param[in] dac the base address of the DAC. @ref dac_reg_base
40@param[in] channel with DAC mask. @ref dac_channel_id
41*/
42void dac_buffer_enable(uint32_t dac, int channel)
43{
44 switch (channel) {
45 case DAC_CHANNEL1:
46 DAC_CR(dac) &= ~DAC_CR_BOFF1;
47 break;
48 case DAC_CHANNEL2:
49 DAC_CR(dac) &= ~DAC_CR_BOFF2;
50 break;
52 DAC_CR(dac) &= ~(DAC_CR_BOFF1 | DAC_CR_BOFF2);
53 break;
54 }
55}
56
57/** @brief DAC Channel Output Buffer Disable.
58
59Disable a digital to analog converter channel output drive buffer. Disabling
60this will reduce power consumption slightly and will increase the output
61impedance of the DAC. The buffers are enabled by default after a reset.
62
63@param[in] dac the base address of the DAC. @ref dac_reg_base
64@param[in] channel with DAC mask. @ref dac_channel_id
65*/
66void dac_buffer_disable(uint32_t dac, int channel)
67{
68 switch (channel) {
69 case DAC_CHANNEL1:
70 DAC_CR(dac) |= DAC_CR_BOFF1;
71 break;
72 case DAC_CHANNEL2:
73 DAC_CR(dac) |= DAC_CR_BOFF2;
74 break;
77 break;
78 }
79}
80/**@}*/
81
#define DAC_CHANNEL1
#define DAC_CHANNEL_BOTH
#define DAC_CHANNEL2
#define DAC_CR_BOFF1
#define DAC_CR_BOFF2
Definition: dac_common_v1.h:82
void dac_buffer_disable(uint32_t dac, int channel)
DAC Channel Output Buffer Disable.
Definition: dac_common_v1.c:66
void dac_buffer_enable(uint32_t dac, int channel)
DAC Channel Output Buffer Enable.
Definition: dac_common_v1.c:42
#define DAC_CR(dac)
DAC control register (DAC_CR)