libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
comparator.c
Go to the documentation of this file.
1/** @addtogroup comp_file COMP peripheral API
2 * @ingroup peripheral_apis
3 *
4 * @brief <b>STM32F0xx comparator peripheral</b>
5 *
6 * @version 1.0.0
7 *
8 * @date 10 July 2013
9 *
10 * LGPL License Terms @ref lgpl_license
11 */
12
13/*
14 * This file is part of the libopencm3 project.
15 *
16 * This library is free software: you can redistribute it and/or modify
17 * it under the terms of the GNU Lesser General Public License as published by
18 * the Free Software Foundation, either version 3 of the License, or
19 * (at your option) any later version.
20 *
21 * This library is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU Lesser General Public License for more details.
25 *
26 * You should have received a copy of the GNU Lesser General Public License
27 * along with this library. If not, see <http://www.gnu.org/licenses/>.
28 */
29/**@{*/
30
32
33void comp_enable(uint8_t id)
34{
35 COMP_CSR(id) |= COMP_CSR_EN;
36}
37
38void comp_disable(uint8_t id)
39{
40 COMP_CSR(id) &= ~COMP_CSR_EN;
41}
42
43void comp_select_input(uint8_t id, uint32_t input)
44{
45 COMP_CSR(id) = (COMP_CSR(id) & ~COMP_CSR_INSEL) | input;
46}
47
48void comp_select_output(uint8_t id, uint32_t output)
49{
50 COMP_CSR(id) = (COMP_CSR(id) & ~COMP_CSR_OUTSEL) | output;
51}
52
53void comp_select_hyst(uint8_t id, uint32_t hyst)
54{
55 COMP_CSR(id) = (COMP_CSR(id) & ~COMP_CSR_HYST) | hyst;
56}
57
58void comp_select_speed(uint8_t id, uint32_t speed)
59{
60 COMP_CSR(id) = (COMP_CSR(id) & ~COMP_CSR_SPEED) | speed;
61}
62/**@}*/
63
#define COMP_CSR_EN
#define COMP_CSR(i)
Definition: f0/comparator.h:48
void comp_select_speed(uint8_t id, uint32_t speed)
Definition: comparator.c:58
void comp_enable(uint8_t id)
Definition: comparator.c:33
void comp_select_hyst(uint8_t id, uint32_t hyst)
Definition: comparator.c:53
void comp_select_input(uint8_t id, uint32_t input)
Definition: comparator.c:43
void comp_disable(uint8_t id)
Definition: comparator.c:38
void comp_select_output(uint8_t id, uint32_t output)
Definition: comparator.c:48