Add reading of ADC

This commit is contained in:
BlackMark 2020-03-29 04:18:26 +02:00
parent 100ba9c485
commit 3042194aa1
4 changed files with 30 additions and 0 deletions

3
.gitmodules vendored
View File

@ -7,3 +7,6 @@
[submodule "thermistor/io"] [submodule "thermistor/io"]
path = thermistor/io path = thermistor/io
url = git@git.blackmark.me:avr/io.git url = git@git.blackmark.me:avr/io.git
[submodule "thermistor/adc"]
path = thermistor/adc
url = git@git.blackmark.me:avr/adc.git

1
thermistor/adc Submodule

@ -0,0 +1 @@
Subproject commit 5d38b97254e271e3e0fb48739a927be6eae26a7f

View File

@ -3,8 +3,12 @@
#include <stdint.h> #include <stdint.h>
#include "flash/flash.hpp" #include "flash/flash.hpp"
#include "io/io.hpp"
#include "uart/uart.hpp" #include "uart/uart.hpp"
#define ADC_INT_VECTOR
#include "adc/adc.hpp"
#define UART0_INT_VECTORS #define UART0_INT_VECTORS
#include "uart/hardware0.hpp" #include "uart/hardware0.hpp"
@ -15,6 +19,18 @@ int main()
serial << F("Thermistor reader\r\n"); serial << F("Thermistor reader\r\n");
using adc_conf = adc::Config<adc::SingleMode>;
adc::Adc<adc_conf, io::P, io::P::C0> adcPin;
adcPin.init();
while (true) {
auto adcSample = adcPin.read();
serial << F("Read ADC: ") << adcSample << F("\r\n");
_delay_ms(1000);
}
serial.flushTx(); serial.flushTx();
return 0; return 0;

View File

@ -176,6 +176,15 @@
</ToolchainSettings> </ToolchainSettings>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="adc\adc.hpp">
<SubType>compile</SubType>
</Compile>
<Compile Include="adc\config.hpp">
<SubType>compile</SubType>
</Compile>
<Compile Include="adc\hardware.hpp">
<SubType>compile</SubType>
</Compile>
<Compile Include="clock.hpp"> <Compile Include="clock.hpp">
<SubType>compile</SubType> <SubType>compile</SubType>
</Compile> </Compile>
@ -213,6 +222,7 @@
<ItemGroup> <ItemGroup>
<Folder Include="flash" /> <Folder Include="flash" />
<Folder Include="io" /> <Folder Include="io" />
<Folder Include="adc" />
<Folder Include="uart" /> <Folder Include="uart" />
</ItemGroup> </ItemGroup>
<Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" /> <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />