Skip to content

Commit

Permalink
[example] Add SAMV71 ADC example
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-durand committed Dec 4, 2022
1 parent 58fa908 commit 7330500
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
37 changes: 37 additions & 0 deletions examples/samv71_xplained_ultra/adc/main.cpp
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2021, Jeff McBride
* Copyright (c) 2022, Christopher Durand
*
* This file is part of the modm project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

#include <modm/board.hpp>
#include <modm/io/iostream.hpp>

using namespace modm::platform;
using namespace modm::literals;

using Ad2 = GpioA19::Ad; // channel 0, pin AD2 on board
using Ad3 = GpioD30::Ad; // channel 8, pin AD3 on board

int main()
{
Board::initialize();

Afec0::initialize<Board::SystemClock>();
Afec0::connect<Ad2::Ad, Ad3::Ad>();

while (true)
{
MODM_LOG_INFO << "ADC Readings: ";
MODM_LOG_INFO.printf("%5d ", Afec0::readChannel(Afec0::getPinChannel<Ad2>()));
MODM_LOG_INFO.printf("%5d ", Afec0::readChannel(Afec0::getPinChannel<Ad3>()));
MODM_LOG_INFO << modm::endl;

modm::delay(500ms);
}
}
10 changes: 10 additions & 0 deletions examples/samv71_xplained_ultra/adc/project.xml
@@ -0,0 +1,10 @@
<library>
<extends>modm:samv71-xplained-ultra</extends>
<options>
<option name="modm:build:build.path">../../../build/samv71_xplained_ultra/adc</option>
</options>
<modules>
<module>modm:build:scons</module>
<module>modm:platform:adc:0</module>
</modules>
</library>

0 comments on commit 7330500

Please sign in to comment.