Implemented example usage
This commit is contained in:
parent
4f79d1d1d8
commit
74b337804b
2
adc/adc
2
adc/adc
@ -1 +1 @@
|
|||||||
Subproject commit 2f54f9217fdbc92658a03babeae14f3e97954887
|
Subproject commit bcae00c0f31f6dd2a479a58732b4d1d0e1a6d711
|
||||||
@ -179,9 +179,15 @@
|
|||||||
<Compile Include="adc\adc.hpp">
|
<Compile Include="adc\adc.hpp">
|
||||||
<SubType>compile</SubType>
|
<SubType>compile</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="adc\config.hpp">
|
||||||
|
<SubType>compile</SubType>
|
||||||
|
</Compile>
|
||||||
<Compile Include="adc\hardware.hpp">
|
<Compile Include="adc\hardware.hpp">
|
||||||
<SubType>compile</SubType>
|
<SubType>compile</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="io\io.hpp">
|
||||||
|
<SubType>compile</SubType>
|
||||||
|
</Compile>
|
||||||
<Compile Include="main.cpp">
|
<Compile Include="main.cpp">
|
||||||
<SubType>compile</SubType>
|
<SubType>compile</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|||||||
44
adc/main.cpp
44
adc/main.cpp
@ -1,18 +1,52 @@
|
|||||||
|
|
||||||
|
#define ADC_INT_VECTOR
|
||||||
#include "adc/adc.hpp"
|
#include "adc/adc.hpp"
|
||||||
|
|
||||||
void adcTest()
|
static void adcReadCallback(uint16_t adcSample)
|
||||||
|
{
|
||||||
|
static_cast<void>(adcSample);
|
||||||
|
}
|
||||||
|
|
||||||
|
void adcTest1()
|
||||||
{
|
{
|
||||||
using namespace adc;
|
using namespace adc;
|
||||||
|
|
||||||
using adc_conf = Config<>;
|
using mode = AutoMode<TriggerSource::TIMER0_COMP_A>;
|
||||||
|
using adc_conf = Config<mode>;
|
||||||
|
|
||||||
Adc<adc_conf, io::P::C5> adcPin;
|
Adc<adc_conf, io::P, io::P::C5> adcPin;
|
||||||
adcPin.read();
|
adcPin.init(adcReadCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
void adcTest2()
|
||||||
|
{
|
||||||
|
using namespace adc;
|
||||||
|
|
||||||
|
using mode = FreeRunningMode;
|
||||||
|
using adc_conf = Config<mode>;
|
||||||
|
|
||||||
|
Adc<adc_conf, InputSource, InputSource::VBG> adcPin;
|
||||||
|
adcPin.init(adcReadCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
void adcTest3()
|
||||||
|
{
|
||||||
|
using namespace adc;
|
||||||
|
|
||||||
|
using mode = SingleMode;
|
||||||
|
using adc_conf = Config<mode>;
|
||||||
|
|
||||||
|
Adc<adc_conf, InputSource, InputSource::VBG> adcPin;
|
||||||
|
adcPin.init();
|
||||||
|
auto adcSample = adcPin.read();
|
||||||
|
static_cast<void>(adcSample);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
adcTest();
|
adcTest1();
|
||||||
|
adcTest2();
|
||||||
|
adcTest3();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user