main.cpp
772 Bytes
#include "mbed.h"
#include "RTCDevice.h"
I2C i2c(D14, D15);
DigitalOut led1(LED1);
Serial pc(SERIAL_TX, SERIAL_RX);
char data[RTCDevice::length];
int main()
{
pc.printf("starting...");
RTCDevice rtcDevice(&pc, &i2c);
if(rtcDevice.find()){
while(1)
{
led1 = 1;
rtcDevice.read(data);
pc.printf("Time : %d%d:%d%d:%d%d\n", data[2] & 0x30 >> 4, data[2] & 0x0F, data[1] & 0x70 >> 4, data[1] & 0x0F, data[0] & 0x70 >> 4, data[0] & 0x0F);
pc.printf("Date : %d%d/%d%d/20%d%d\n", data[3] & 0x30 >> 4, data[3] & 0x0F, data[5] & 0x10 >> 4, data[5] & 0x0F, data[6] & 0xF0 >> 4, data[6] & 0x0F);
led1 = 0;
wait(0.5);
}
}
}