-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathADC.hpp
More file actions
70 lines (57 loc) · 1.5 KB
/
Copy pathADC.hpp
File metadata and controls
70 lines (57 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef _EVT_ADC_
#define _EVT_ADC_
#include <stdint.h>
namespace core::io {
// Forward declarations:
// The different pins are hardware specific. Forward declarations to allow
// at compilation time the decision of which pins should be used.
enum class Pin;
enum class ADCPeriph;
class ADC {
public:
/**
* Setup the given pin for ADC (analog to digital) usage
*
* @param[in] pin The pin to setup for ADC
*/
ADC(Pin pin, ADCPeriph adcPeriph);
/**
* Reads the current voltage in volts on the ADC
*
* @return The voltage in volts
*/
virtual float read() = 0;
/**
* Read the raw value from the ADC
*
* @return The raw value from the ADC
*/
virtual uint32_t readRaw() = 0;
/**
* Read the value from the ADC as a percentage of the possible values
* from 0 to 1 This is based on the maximum possible valie the ADC
* can read.
*
* @return The ADC value as a percentage
*/
virtual float readPercentage() = 0;
/**
* Set the reference voltage for the ADC
*
* @param[in] vref The reference voltage in volts (e.g., 3.3, 5.0)
*/
virtual void setVref(float vref) = 0;
/**
* Get the current reference voltage for the ADC
*
* @return The reference voltage in volts
*/
virtual float getVref() const = 0;
protected:
/// The pin the ADC is attached to
Pin pin;
/// The internal ADC being used
ADCPeriph adcPeriph;
};
} // namespace core::io
#endif