gossamer 0.0.1
a very lightweight app framework for SAMD and SAML chips
Loading...
Searching...
No Matches
opamp.h
1
2/*
3 * MIT License
4 *
5 * Copyright (c) 2022 Joey Castillo
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in all
15 * copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 */
25
26#pragma once
27
28#include <stdint.h>
29#include <stdbool.h>
30
37#ifdef OPAMP
38
39#define OPAMP_MUXNEG_NEG (0)
40#define OPAMP_MUXNEG_LADDER (1)
41#define OPAMP_MUXNEG_OUT (2)
42#define OPAMP0_MUXNEG_DAC (3)
43#define OPAMP1_MUXNEG_DAC (3)
44#define OPAMP2_MUXNEG_DAC (5)
45#define OPAMP2_MUXNEG_NEG_0 (3)
46#define OPAMP2_MUXNEG_NEG_1 (4)
47
48#define OPAMP_MUXPOS_POS (0)
49#define OPAMP_MUXPOS_LADDER (1)
50#define OPAMP0_MUXPOS_DAC (2)
51#define OPAMP1_MUXPOS_OUT_0 (2)
52#define OPAMP2_MUXPOS_OUT_1 (2)
53#define OPAMP_MUXPOS_GND (3)
54#define OPAMP2_MUXPOS_POS_0 (4)
55#define OPAMP2_MUXPOS_POS_1 (5)
56#define OPAMP2_MUXPOS_LADDER_0 (6)
57
58#define OPAMP_POTMUX_RATIO_14_2 (0)
59#define OPAMP_POTMUX_RATIO_12_4 (1)
60#define OPAMP_POTMUX_RATIO_8_8 (2)
61#define OPAMP_POTMUX_RATIO_6_10 (3)
62#define OPAMP_POTMUX_RATIO_4_12 (4)
63#define OPAMP_POTMUX_RATIO_3_13 (5)
64#define OPAMP_POTMUX_RATIO_2_14 (6)
65#define OPAMP_POTMUX_RATIO_1_15 (7)
66
67#define OPAMP_RES1MUX_POS (0)
68#define OPAMP_RES1MUX_NEG (1)
69#define OPAMP0_RES1MUX_DAC (2)
70#define OPAMP1_RES1MUX_OUT_0 (2)
71#define OPAMP2_RES1MUX_OUT_1 (2)
72#define OPAMP_RES1MUX_GND (3)
73#define OPAMP_RES1MUX_NC (4)
74
75#define OPAMP_RES2MUX_VCC (0)
76#define OPAMP_RES2MUX_OUT (1)
77#define OPAMP_RES2MUX_NC (2)
78
82void opamp_init(void);
83
88void opamp_enable(uint16_t instance);
89
104void opamp_set_muxpos(uint16_t instance, uint8_t muxpos);
105
119void opamp_set_muxneg(uint16_t instance, uint8_t muxneg);
120
134void opamp_set_potmux(uint16_t instance, uint8_t potmux);
135
148void opamp_set_res1mux(uint16_t instance, uint8_t res1mux);
149
158void opamp_set_res2mux(uint16_t instance, uint8_t res2mux);
159
166void opamp_set_analog_connection(uint16_t instance, bool connected);
167
173void opamp_disable(uint16_t instance);
174
175#endif
176
void opamp_set_potmux(uint16_t instance, uint8_t potmux)
Sets the potentiometer (resistor ladder) mux for the given opamp.
Definition opamp.c:54
void opamp_disable(uint16_t instance)
Disables the given opamp.
Definition opamp.c:90
void opamp_init(void)
Initializes the OPAMP peripheral, but does not enable any opamps.
Definition opamp.c:32
void opamp_enable(uint16_t instance)
Enables the given opamp.
Definition opamp.c:38
void opamp_set_analog_connection(uint16_t instance, bool connected)
Sets or removes the connection from the opamp output to the ADC / AC.
Definition opamp.c:86
void opamp_set_muxneg(uint16_t instance, uint8_t muxneg)
Sets the negative input mux for the given opamp.
Definition opamp.c:50
void opamp_set_res2mux(uint16_t instance, uint8_t res2mux)
Sets the connection for the top of the resistor ladder for the given instance.
Definition opamp.c:68
void opamp_set_res1mux(uint16_t instance, uint8_t res1mux)
Sets the connection for the bottom of the resistor ladder for the given instance.
Definition opamp.c:59
void opamp_set_muxpos(uint16_t instance, uint8_t muxpos)
Sets the positive input mux for the given opamp.
Definition opamp.c:46