diff options
Diffstat (limited to 'include/arch/lora32u4ii')
-rw-r--r-- | include/arch/lora32u4ii/driver/adc.h | 18 | ||||
-rw-r--r-- | include/arch/lora32u4ii/driver/gpio.h | 11 |
2 files changed, 28 insertions, 1 deletions
diff --git a/include/arch/lora32u4ii/driver/adc.h b/include/arch/lora32u4ii/driver/adc.h new file mode 100644 index 0000000..5f9189a --- /dev/null +++ b/include/arch/lora32u4ii/driver/adc.h @@ -0,0 +1,18 @@ +#ifndef ADC_H +#define ADC_H + +class AVRADC { + private: + AVRADC(AVRADC const ©); + + public: + AVRADC() {} + + int16_t getTemp_mdegC(int16_t offset = 205); + uint16_t getVCC_mV(); + uint16_t getVBat_mV(bool controlCharger); +}; + +extern AVRADC adc; + +#endif diff --git a/include/arch/lora32u4ii/driver/gpio.h b/include/arch/lora32u4ii/driver/gpio.h index ba044d0..61dc867 100644 --- a/include/arch/lora32u4ii/driver/gpio.h +++ b/include/arch/lora32u4ii/driver/gpio.h @@ -3,6 +3,14 @@ #include <avr/io.h> +/* + * lora32u4ii v1.3 pin map: + * + * PB0 -> Charger and Vbat/2 measurement voltage divider enable + * PB5 -> User LED + * PB5 <- Vbat/2 + */ + class GPIO { private: GPIO(const GPIO ©); @@ -40,7 +48,8 @@ class GPIO { }; inline void setup() { - DDRB = _BV(PB5); + // PB5 is both output (user LED) and input (Vbat/2 to ADC). + // Leave it as input by default. } inline volatile uint8_t * pinToPort(uint8_t pin) { if (pin <= pb7) { |