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 © @endhtmlonly 2020 Ben Brewer <ben.brewer@codethink.co.uk>
5
6
LGPL 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
30
#include <
libopencm3/stm32/dac.h
>
31
32
/** @brief DAC Channel Output Buffer Enable.
33
34
Enable a digital to analog converter channel output drive buffer. This is an
35
optional amplifying buffer that provides additional drive for the output
36
signal. The buffer is enabled by default after a reset and needs to be
37
explicitly 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
*/
42
void
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
;
51
case
DAC_CHANNEL_BOTH
:
52
DAC_CR
(dac) &= ~(
DAC_CR_BOFF1
|
DAC_CR_BOFF2
);
53
break
;
54
}
55
}
56
57
/** @brief DAC Channel Output Buffer Disable.
58
59
Disable a digital to analog converter channel output drive buffer. Disabling
60
this will reduce power consumption slightly and will increase the output
61
impedance 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
*/
66
void
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
;
75
case
DAC_CHANNEL_BOTH
:
76
DAC_CR
(dac) |= (
DAC_CR_BOFF1
|
DAC_CR_BOFF2
);
77
break
;
78
}
79
}
80
/**@}*/
81
dac.h
DAC_CHANNEL1
#define DAC_CHANNEL1
Definition:
dac_common_all.h:231
DAC_CHANNEL_BOTH
#define DAC_CHANNEL_BOTH
Definition:
dac_common_all.h:233
DAC_CHANNEL2
#define DAC_CHANNEL2
Definition:
dac_common_all.h:232
DAC_CR_BOFF1
#define DAC_CR_BOFF1
Definition:
dac_common_v1.h:121
DAC_CR_BOFF2
#define DAC_CR_BOFF2
Definition:
dac_common_v1.h:82
dac_buffer_disable
void dac_buffer_disable(uint32_t dac, int channel)
DAC Channel Output Buffer Disable.
Definition:
dac_common_v1.c:66
dac_buffer_enable
void dac_buffer_enable(uint32_t dac, int channel)
DAC Channel Output Buffer Enable.
Definition:
dac_common_v1.c:42
DAC_CR
#define DAC_CR(dac)
DAC control register (DAC_CR)
Definition:
dac_common_all.h:46
lib
stm32
common
dac_common_v1.c
Generated on Tue Mar 7 2023 16:11:24 for libopencm3 by
1.9.4