#define F_CPU 8000000UL
#include "rtc.h"
#include "uart.h"
#include "delay.h"
#include <string.h>

int main() 
{
    rtc_t rtc; 
	uart_init();
    RTC_Init();
    rtc.hour = 0x10; //  10:40:20 am
    rtc.min =  0x40;
    rtc.sec =  0x00;

    rtc.date = 0x01; //1st Jan 2016
    rtc.month = 0x01;
    rtc.year = 0x16;
    rtc.weekDay = 5; // Friday: 5th day of week considering monday as first day.

    /*##### Set the time and Date only once. Once the Time and Date is set, comment these lines
         and reflash the code. Else the time will be set every time the controller is reset*/
    RTC_SetDateTime(&rtc);  //  10:40:20 am, 1st Jan 2016


    /* Display the Time and Date continuously */
    while(1)
    {
		uart_puts("Test");
        RTC_GetDateTime(&rtc);
		uart_puti(rtc.sec);
		uart_puti(rtc.min);		
		uart_puti(rtc.hour);
		uart_puti(rtc.date);
		uart_puti(rtc.month);
		uart_puti(rtc.year);
		uart_puti(rtc.weekDay);
		DELAY_ms(100);
    }

    return (0);
}