forgot to commit everything...
This commit is contained in:
21
user/ADC.h
Executable file
21
user/ADC.h
Executable file
@@ -0,0 +1,21 @@
|
||||
#ifndef ADC_H
|
||||
#define ADC_H
|
||||
|
||||
class ADC {
|
||||
|
||||
public:
|
||||
static uint16_t getA0() {
|
||||
return 0xffff & system_adc_read();
|
||||
}
|
||||
|
||||
static uint16_t getVcc() {
|
||||
static constexpr float SCALER = 1.93; // divider of 10k / 10k -> * 2
|
||||
static constexpr int V_REF = 330; // 3.3 volt
|
||||
static constexpr int MUL = SCALER * V_REF;
|
||||
return getA0() * MUL / 1024;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // ADC_H
|
||||
Reference in New Issue
Block a user