Add usage for new C++ driver

This commit is contained in:
BlackMark 2020-05-15 19:48:22 +02:00
parent f00a154e59
commit 4b3dd99ebc
3 changed files with 30 additions and 1 deletions

@ -1 +1 @@
Subproject commit 27680097203f1482ba61a9cceef689305d7eadc4
Subproject commit 54b8917705125bdea47f74e4c911650da5bb025f

View File

@ -218,6 +218,15 @@
<Compile Include="clock.hpp">
<SubType>compile</SubType>
</Compile>
<Compile Include="ds3231\ds3231.hpp">
<SubType>compile</SubType>
</Compile>
<Compile Include="ds3231\flags.hpp">
<SubType>compile</SubType>
</Compile>
<Compile Include="ds3231\registers.hpp">
<SubType>compile</SubType>
</Compile>
<Compile Include="ds3231\rtc.cpp">
<SubType>compile</SubType>
</Compile>

View File

@ -7,6 +7,7 @@
#include <avr/interrupt.h>
#include "ds3231/ds3231.hpp"
#include "uart/uart.hpp"
#include "systime.h"
@ -133,12 +134,31 @@ void setAlarm()
int main()
{
uart_t cSerial;
rtc::DS3231<i2c::I2c<i2c::Hardware<100'000>>> ds3231;
ds3231.init();
cSerial.init();
sei();
setup();
while (true) {
const auto date = ds3231.getDateTime();
cSerial.txNumber<uint16_t, 10, 4>(date.year);
cSerial << '-';
cSerial.txNumber<uint8_t, 10, 2>(date.month);
cSerial << '-';
cSerial.txNumber<uint8_t, 10, 2>(date.day);
cSerial << ' ';
cSerial.txNumber<uint8_t, 10, 2>(date.hour);
cSerial << ':';
cSerial.txNumber<uint8_t, 10, 2>(date.minute);
cSerial << ':';
cSerial.txNumber<uint8_t, 10, 2>(date.second);
cSerial << F("\r\n");
_delay_ms(1000);
}
constexpr auto BUFFER_SIZE = 32;
char szBuffer[BUFFER_SIZE];