Add usage for new C++ driver
This commit is contained in:
Submodule ds3231/ds3231 updated: 2768009720...54b8917705
@@ -218,6 +218,15 @@
|
|||||||
<Compile Include="clock.hpp">
|
<Compile Include="clock.hpp">
|
||||||
<SubType>compile</SubType>
|
<SubType>compile</SubType>
|
||||||
</Compile>
|
</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">
|
<Compile Include="ds3231\rtc.cpp">
|
||||||
<SubType>compile</SubType>
|
<SubType>compile</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
|
|
||||||
|
#include "ds3231/ds3231.hpp"
|
||||||
#include "uart/uart.hpp"
|
#include "uart/uart.hpp"
|
||||||
|
|
||||||
#include "systime.h"
|
#include "systime.h"
|
||||||
@@ -133,12 +134,31 @@ void setAlarm()
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
uart_t cSerial;
|
uart_t cSerial;
|
||||||
|
rtc::DS3231<i2c::I2c<i2c::Hardware<100'000>>> ds3231;
|
||||||
|
ds3231.init();
|
||||||
|
|
||||||
cSerial.init();
|
cSerial.init();
|
||||||
sei();
|
sei();
|
||||||
|
|
||||||
setup();
|
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;
|
constexpr auto BUFFER_SIZE = 32;
|
||||||
char szBuffer[BUFFER_SIZE];
|
char szBuffer[BUFFER_SIZE];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user