1 #include "../hardware_api.h"
5 #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega328PB__) || defined(__AVR_ATmega2560__) // if mcu is atmega328 or atmega2560
6 #define _ADC_VOLTAGE 5.0
7 #define _ADC_RESOLUTION 1024.0
9 #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
12 #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
14 #elif defined(__arm__) && defined(CORE_TEENSY) // or teensy
15 #define _ADC_VOLTAGE 3.3
16 #define _ADC_RESOLUTION 1024.0
17 #elif defined(__arm__) && defined(__SAM3X8E__) // or due
18 #define _ADC_VOLTAGE 3.3
19 #define _ADC_RESOLUTION 1024.0
20 #elif defined(ESP_H) // or esp32
21 #define _ADC_VOLTAGE 3.3
22 #define _ADC_RESOLUTION 4095.0
23 #elif defined(_STM32_DEF_) // or stm32
24 #define _ADC_VOLTAGE 3.3
25 #define _ADC_RESOLUTION 1024.0
27 #define _ADC_VOLTAGE 5.0
28 #define _ADC_RESOLUTION 1024.0
33 #define _ADC_CONV ( (_ADC_VOLTAGE) / (_ADC_RESOLUTION) )
37 uint32_t raw_adc = analogRead(pinA);
46 if(
_isset(pinC) ) pinMode(pinC, INPUT);
48 #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega328PB__) || defined(__AVR_ATmega2560__) // if mcu is atmega328 or atmega2560