libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
opamp_common_v2.h
Go to the documentation of this file.
1/** @addtogroup opamp_defines
2 *
3 * @date 10 Dec 2020
4 *
5 *LGPL License Terms @ref lgpl_license
6 */
7/*
8 * This file is part of the libopencm3 project.
9 *
10 * This library is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this library. If not, see <http://www.gnu.org/licenses/>.
22 */
23
24/** @cond */
25#if defined(LIBOPENCM3_OPAMP_H)
26/** @endcond */
27#ifndef LIBOPENCM3_OPAMP_COMMON_V2_H
28#define LIBOPENCM3_OPAMP_COMMON_V2_H
29/**@{*/
30
32
33/* OpAmp registers */
34
35/* Timer controlled mode register (OPAMPx_TMCR) */
36#define OPAMP_TCMR(opamp_base) MMIO32((opamp_base) + 0x18)
37
38/* OPAMPx_CSR values */
39
40#define OPAMP_CSR_CALOUT_MASK (0x1)
41#define OPAMP_CSR_CALOUT_SHIFT (30)
42#define OPAMP_CSR_CALOUT_UNSUCC (0x0)
43#define OPAMP_CSR_CALOUT_SUCC (0x1)
44
45#define OPAMP_CSR_PGA_GAIN_MASK (0x1f)
46#define OPAMP_CSR_PGA_GAIN_SHIFT (14)
47
48/* Non-inverting gain*/
49#define OPAMP_CSR_PGA_GAIN_2 (0x00)
50#define OPAMP_CSR_PGA_GAIN_4 (0x01)
51#define OPAMP_CSR_PGA_GAIN_8 (0x02)
52#define OPAMP_CSR_PGA_GAIN_16 (0x03)
53#define OPAMP_CSR_PGA_GAIN_32 (0x04)
54#define OPAMP_CSR_PGA_GAIN_64 (0x05)
55/* Inverting gain -n/non-inverting gain y with VINM0 pin for input bias */
56#define OPAMP_CSR_PGA_INV_GAIN_MINUS_1_GAIN_2_VM0 (0x08)
57#define OPAMP_CSR_PGA_INV_GAIN_MINUS_3_GAIN_4_VM0 (0x09)
58#define OPAMP_CSR_PGA_INV_GAIN_MINUS_7_GAIN_8_VM0 (0x0A)
59#define OPAMP_CSR_PGA_INV_GAIN_MINUS_15_GAIN_16_VM0 (0x0B)
60#define OPAMP_CSR_PGA_INV_GAIN_MINUS_31_GAIN_32_VM0 (0x0C)
61#define OPAMP_CSR_PGA_INV_GAIN_MINUS_63_GAIN_64_VM0 (0x0D)
62/* Non-inverting gain with filtering on VINM0 */
63#define OPAMP_CSR_PGA_FILT_VM0_GAIN_2 (0x10)
64#define OPAMP_CSR_PGA_FILT_VM0_GAIN_4 (0x11)
65#define OPAMP_CSR_PGA_FILT_VM0_GAIN_8 (0x12)
66#define OPAMP_CSR_PGA_FILT_VM0_GAIN_16 (0x13)
67#define OPAMP_CSR_PGA_FILT_VM0_GAIN_32 (0x14)
68#define OPAMP_CSR_PGA_FILT_VM0_GAIN_64 (0x15)
69/* Inverting gain -x/non-inverting gain y with VINM0 pin for input bias
70 * VINM1 for filtering*/
71#define OPAMP_CSR_PGA_FILT_VM1_INV_GAIN_MINUS_1_GAIN_2_VM0 (0x18)
72#define OPAMP_CSR_PGA_FILT_VM1_INV_GAIN_MINUS_3_GAIN_4_VM0 (0x19)
73#define OPAMP_CSR_PGA_FILT_VM1_INV_GAIN_MINUS_7_GAIN_8_VM0 (0x1a)
74#define OPAMP_CSR_PGA_FILT_VM1_INV_GAIN_MINUS_15_GAIN_16_VM0 (0x1B)
75#define OPAMP_CSR_PGA_FILT_VM1_INV_GAIN_MINUS_31_GAIN_32_VM0 (0x1c)
76#define OPAMP_CSR_PGA_FILT_VM1_INV_GAIN_MINUS_63_GAIN_64_VM0 (0x1d)
77
78#define OPAMP_CSR_OPAINTOEN (0x1 << 8)
79
80#define OPAMP_CSR_OPAHSM (0x1 << 7)
81
82#define OPAMP_CSR_VM_SEL_VINM0_IN (0x0)
83#define OPAMP_CSR_VM_SEL_VINM1_IN (0x1)
84#define OPAMP_CSR_VM_SEL_PGA_MODE (0x2)
85#define OPAMP_CSR_VM_SEL_OUT_IN (0x3)
86
87#define OPAMP_CSR_USER_TRIM (0x1 << 4)
88
89#define OPAMP_CSR_VP_SEL_VINP0 (0x0)
90#define OPAMP_CSR_VP_SEL_VINP1 (0x1)
91#define OPAMP_CSR_VP_SEL_VINP2 (0x2)
92
94
95bool opamp_read_calout(uint32_t base);
96
97void opamp_high_speed_mode_enable(uint32_t base);
98void opamp_high_speed_mode_disable(uint32_t base);
99
100void opamp_output_set_internal(uint32_t base);
101void opamp_output_set_external(uint32_t base);
102
104/**@}*/
105
106#endif
107/** @cond */
108#else
109#warning "opamp_common_v2.h should not be included directly, only via opamp.h"
110#endif
111/** @endcond */
#define END_DECLS
Definition: common.h:34
#define BEGIN_DECLS
Definition: common.h:33
void opamp_output_set_internal(uint32_t base)
void opamp_output_set_external(uint32_t base)
bool opamp_read_calout(uint32_t base)
void opamp_high_speed_mode_enable(uint32_t base)
void opamp_high_speed_mode_disable(uint32_t base)