Aruna
ADC.h
Go to the documentation of this file.
1 /*
2  * ADC.h
3  *
4  * Created on: 30 nov. 2020
5  * Author: noeel
6  */
7 
8 #ifndef ARUNA_ADC_H
9 #define ARUNA_ADC_H
10 
11 #include "aruna/arunaTypes.h"
12 
13 namespace aruna {
14  namespace driver {
15 
19  class ADC {
20  private:
24  size_t resolution = 0;
25 
29  uint16_t reference = 0;
30 
36  virtual err_t _read(int32_t &raw) = 0;
37 
38  protected:
44  err_t set_resolution(size_t bits);
45 
51  err_t set_reference(uint16_t mV);
52 
53  public:
54 
60  template<typename T>
61  err_t read_raw(T &raw);
62 
68  template<typename T>
69  err_t read_voltage(T &mV);
70 
76  size_t get_resolution() const;
77 
82  uint16_t get_reference() const;
83 
89  virtual int32_t raw_to_voltage(int32_t raw);
90  };
91 
92  } /* namespace driver */
93 } /* namespace aruna */
94 
95 #include "ADC.hpp"
96 
97 #endif /* ARUNA_ADC_H */
Definition: comm.cpp:14
err_t read_raw(T &raw)
Read raw value from ADC, convert to voltage yourself.
virtual int32_t raw_to_voltage(int32_t raw)
Convert raw data to voltage.
Definition: ADC.cpp:27
err_t read_voltage(T &mV)
Read voltage level of input.
uint16_t get_reference() const
Get the reference voltage in micro Voltage.
Definition: ADC.cpp:40
virtual err_t _read(int32_t &raw)=0
Read analogue value and convert to 32bit signed resolution.
size_t get_resolution() const
Get the resolution in bits of the ADC.
Definition: ADC.cpp:23
size_t resolution
resolution of the ADC in bits.
Definition: ADC.h:24
Link * driver
stores the driver.
Definition: comm.cpp:45
err_t set_reference(uint16_t mV)
set reference voltage, used to convert raw data to voltage.
Definition: ADC.cpp:18
Analogue digital converter.
Definition: ADC.h:19
err_t set_resolution(size_t bits)
Set resolution of ADC.
Definition: ADC.cpp:13
uint16_t reference
ADC voltage refrence, for convertage to voltage.
Definition: ADC.h:29