From 3042194aa19e71fa94a4757b30e817fad901e931 Mon Sep 17 00:00:00 2001 From: BlackMark Date: Sun, 29 Mar 2020 04:18:26 +0200 Subject: [PATCH] Add reading of ADC --- .gitmodules | 3 +++ thermistor/adc | 1 + thermistor/main.cpp | 16 ++++++++++++++++ thermistor/thermistor.cppproj | 10 ++++++++++ 4 files changed, 30 insertions(+) create mode 160000 thermistor/adc diff --git a/.gitmodules b/.gitmodules index 24afbde..6e527ed 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "thermistor/io"] path = thermistor/io url = git@git.blackmark.me:avr/io.git +[submodule "thermistor/adc"] + path = thermistor/adc + url = git@git.blackmark.me:avr/adc.git diff --git a/thermistor/adc b/thermistor/adc new file mode 160000 index 0000000..5d38b97 --- /dev/null +++ b/thermistor/adc @@ -0,0 +1 @@ +Subproject commit 5d38b97254e271e3e0fb48739a927be6eae26a7f diff --git a/thermistor/main.cpp b/thermistor/main.cpp index 9ddd3f8..d87c722 100644 --- a/thermistor/main.cpp +++ b/thermistor/main.cpp @@ -3,8 +3,12 @@ #include #include "flash/flash.hpp" +#include "io/io.hpp" #include "uart/uart.hpp" +#define ADC_INT_VECTOR +#include "adc/adc.hpp" + #define UART0_INT_VECTORS #include "uart/hardware0.hpp" @@ -15,6 +19,18 @@ int main() serial << F("Thermistor reader\r\n"); + using adc_conf = adc::Config; + + adc::Adc adcPin; + adcPin.init(); + + while (true) { + auto adcSample = adcPin.read(); + serial << F("Read ADC: ") << adcSample << F("\r\n"); + + _delay_ms(1000); + } + serial.flushTx(); return 0; diff --git a/thermistor/thermistor.cppproj b/thermistor/thermistor.cppproj index 830955b..21b9891 100644 --- a/thermistor/thermistor.cppproj +++ b/thermistor/thermistor.cppproj @@ -176,6 +176,15 @@ + + compile + + + compile + + + compile + compile @@ -213,6 +222,7 @@ +