gossamer 0.0.0
a very lightweight app framework for SAMD and SAML chips
Loading...
Searching...
No Matches
opamp.h
Go to the documentation of this file.
1
5/*
6 * MIT License
7 *
8 * Copyright (c) 2022 Joey Castillo
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a copy
11 * of this software and associated documentation files (the "Software"), to deal
12 * in the Software without restriction, including without limitation the rights
13 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the Software is
15 * furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be included in all
18 * copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 * SOFTWARE.
27 */
28
29#pragma once
30
31#include <stdint.h>
32#include <stdbool.h>
33
34#ifdef OPAMP
35
36#define OPAMP_MUXNEG_NEG (0)
37#define OPAMP_MUXNEG_LADDER (1)
38#define OPAMP_MUXNEG_OUT (2)
39#define OPAMP0_MUXNEG_DAC (3)
40#define OPAMP1_MUXNEG_DAC (3)
41#define OPAMP2_MUXNEG_DAC (5)
42#define OPAMP2_MUXNEG_NEG_0 (3)
43#define OPAMP2_MUXNEG_NEG_1 (4)
44
45#define OPAMP_MUXPOS_POS (0)
46#define OPAMP_MUXPOS_LADDER (1)
47#define OPAMP0_MUXPOS_DAC (2)
48#define OPAMP1_MUXPOS_OUT_0 (2)
49#define OPAMP2_MUXPOS_OUT_1 (2)
50#define OPAMP_MUXPOS_GND (3)
51#define OPAMP2_MUXPOS_POS_0 (4)
52#define OPAMP2_MUXPOS_POS_1 (5)
53#define OPAMP2_MUXPOS_LADDER_0 (6)
54
55#define OPAMP_POTMUX_RATIO_14_2 (0)
56#define OPAMP_POTMUX_RATIO_12_4 (1)
57#define OPAMP_POTMUX_RATIO_8_8 (2)
58#define OPAMP_POTMUX_RATIO_6_10 (3)
59#define OPAMP_POTMUX_RATIO_4_12 (4)
60#define OPAMP_POTMUX_RATIO_3_13 (5)
61#define OPAMP_POTMUX_RATIO_2_14 (6)
62#define OPAMP_POTMUX_RATIO_1_15 (7)
63
64#define OPAMP_RES1MUX_POS (0)
65#define OPAMP_RES1MUX_NEG (1)
66#define OPAMP0_RES1MUX_DAC (2)
67#define OPAMP1_RES1MUX_OUT_0 (2)
68#define OPAMP2_RES1MUX_OUT_1 (2)
69#define OPAMP_RES1MUX_GND (3)
70#define OPAMP_RES1MUX_NC (4)
71
72#define OPAMP_RES2MUX_VCC (0)
73#define OPAMP_RES2MUX_OUT (1)
74#define OPAMP_RES2MUX_NC (2)
75
79void opamp_init(void);
80
85void opamp_enable(uint16_t instance);
86
101void opamp_set_muxpos(uint16_t instance, uint8_t muxpos);
102
116void opamp_set_muxneg(uint16_t instance, uint8_t muxneg);
117
131void opamp_set_potmux(uint16_t instance, uint8_t potmux);
132
145void opamp_set_res1mux(uint16_t instance, uint8_t res1mux);
146
155void opamp_set_res2mux(uint16_t instance, uint8_t res2mux);
156
163void opamp_set_analog_connection(uint16_t instance, bool connected);
164
170void opamp_disable(uint16_t instance);
171
172#endif
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