Rev 24 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| Download
| RSS feed
/**************************************************************************//**
* \brief DS1307 RTC library - Demonstration program
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20090501
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
/**************************************************************************//**
* \file demo_ds1307.c
******************************************************************************/
/******************************************************************************
* Header file inclusions.
******************************************************************************/
#include "../ds1307.h"
#include <twi/twi.h>
#include <useful/datetime.h>
#include <util/delay.h>
#include <stdio.h>
/******************************************************************************
* Main function.
******************************************************************************/
/**************************************************************************//**
* \fn int main(void)
*
* \brief Main function.
*
* \return 0
******************************************************************************/
int main
(void)
{
// Initialize TWI.
twi__initialize
(DS1307__CLOCK_RATE
);
// Initialize RTC.
ds1307__initialize
();
// Declare some variables.
datetime__time_t
time =
{
.
seconds = 00,
.
minutes = 29,
.
hours = 19,
.
meridiem = 0
};
ds1307__hour_mode_t hour_mode
= DS1307__HOUR_MODE__24_HOUR
;
datetime__date_t date
=
{
.
day = 3,
.
date = 5,
.
month = 5,
.
year = 9
};
// Set time and hour mode.
ds1307__set_time
(&time, hour_mode
);
// Set date.
ds1307__set_date
(&date
);
for (;;)
{
// Get RTC time.
ds1307__get_time
(&time, &hour_mode
);
// Get RTC date.
ds1307__get_date
(&date
);
_delay_ms
(100);
}
return 0;
}