-
Notifications
You must be signed in to change notification settings - Fork 164
Expand file tree
/
Copy pathmain.cpp
More file actions
57 lines (49 loc) · 1.46 KB
/
main.cpp
File metadata and controls
57 lines (49 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* Copyright (c) 2022, Nikolay Semenov
*
* 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.hpp>
#include <modm/platform.hpp>
int
main()
{
Board::initialize();
using Led = Board::LedGreen;
Led::setOutput(true);
Uart0::connect<GpioOutput0::Tx>();
Uart0::initialize<Board::SystemClock, 115200_Bd>();
modm::IODeviceWrapper<Uart0, modm::IOBuffer::BlockIfFull> loggerDevice;
modm::IOStream out(loggerDevice);
Adc::connect<GpioInput26::In0, GpioInput27::In1, GpioInput28::In2, GpioInput29::In3>();
Adc::initialize();
Adc::enableTemperatureSensor();
while (true)
{
out.printf("---\r\n");
for (uint8_t ch = 0; ch < (uint8_t)Adc::Channel::Ch3; ++ch)
{
auto value = Adc::readChannel((Adc::Channel)ch);
out.printf("ADC Channel %u %f V | 0x%04x %u\r\n", ch, Adc::convertToVoltage(value),
value, value);
}
{
auto value = Adc::readChannel(Adc::Channel::Ch3);
out.printf("ADC VSYS %f V | 0x%04x %u\r\n", 3.f * Adc::convertToVoltage(value),
value, value);
}
{
auto value = Adc::readChannel(Adc::Channel::Temperature);
out.printf("ADC Int Temp %.4f C | 0x%04x %u\r\n", Adc::convertToTemperature(value),
value, value);
}
modm::delay(250ms);
Led::toggle();
}
return 0;
}