SatNOGS-COMMS
4.1.0
A COMMS subsystem for CubeSats
Toggle main menu visibility
Loading...
Searching...
No Matches
adc.hpp
Go to the documentation of this file.
1
/*
2
* SatNOGS-COMMS control library
3
*
4
* Copyright (C) 2022-2024, Libre Space Foundation <http://libre.space>
5
*
6
* This program is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*
19
* SPDX-License-Identifier: GNU General Public License v3.0 or later
20
*/
21
22
#pragma once
23
24
#include <cstdint>
25
namespace
satnogs::comms::lib::bsp
26
{
38
class
adc
39
{
40
public
:
47
adc
(uint16_t
resolution
,
float
vref
) : m_resolution(
resolution
), m_vref(
vref
)
48
{
49
}
50
55
virtual
void
56
start
() = 0;
57
62
virtual
void
63
stop
() = 0;
64
70
virtual
uint32_t
71
read
() = 0;
72
78
virtual
float
79
voltage
()
80
{
81
return
read
() *
vref
() / (1UL << m_resolution);
82
}
83
89
uint32_t
90
resolution
()
const
91
{
92
return
m_resolution;
93
}
94
100
float
101
vref
()
const
102
{
103
return
m_vref;
104
}
105
106
private
:
107
const
uint32_t m_resolution;
108
const
float
m_vref;
109
};
110
118
class
dummy_adc
:
public
adc
119
{
120
};
121
122
}
// namespace satnogs::comms::lib::bsp
satnogs::comms::lib::bsp::adc::read
virtual uint32_t read()=0
Get the ADC value.
satnogs::comms::lib::bsp::adc::vref
float vref() const
Get the ADC voltage reference.
Definition
adc.hpp:101
satnogs::comms::lib::bsp::adc::start
virtual void start()=0
Starts the ADC.
satnogs::comms::lib::bsp::adc::adc
adc(uint16_t resolution, float vref)
Construct a new ADC object.
Definition
adc.hpp:47
satnogs::comms::lib::bsp::adc::stop
virtual void stop()=0
Stops the ADC.
satnogs::comms::lib::bsp::adc::resolution
uint32_t resolution() const
Get the ADC resolution.
Definition
adc.hpp:90
satnogs::comms::lib::bsp::adc::voltage
virtual float voltage()
Get the ADC voltage.
Definition
adc.hpp:79
satnogs::comms::lib::bsp::dummy_adc
An ADC device that does not perform any operation at all.
Definition
adc.hpp:119
satnogs::comms::lib::bsp
Definition
adc.hpp:26
libsatnogs-comms
include
satnogs-comms-lib
bsp
adc.hpp
Generated by
1.17.0