Rev 24 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
18 | jlesech | 1 | /**************************************************************************//** |
2 | * \brief DS1307 RTC library - Demonstration program |
||
3 | * \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com |
||
4 | * \version 1.0 |
||
5 | * \date 20090501 |
||
6 | * |
||
7 | * This file is part of the iDreamMicro library. |
||
8 | * |
||
9 | * This library is free software: you can redistribute it and/or modify it under |
||
10 | * the terms of the GNU Lesser General Public License as published by the Free |
||
11 | * Software Foundation, either version 3 of the License, or (at your option) any |
||
12 | * later version. |
||
13 | * |
||
14 | * This library is distributed in the hope that it will be useful, but WITHOUT |
||
15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
||
16 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
||
17 | * details. |
||
18 | * |
||
19 | * You should have received a copy of the GNU Lesser General Public License |
||
20 | * along with this program. If not, see http://www.gnu.org/licenses/ |
||
21 | ******************************************************************************/ |
||
22 | |||
23 | /**************************************************************************//** |
||
24 | * \file demo_ds1307.c |
||
25 | ******************************************************************************/ |
||
26 | |||
27 | /****************************************************************************** |
||
28 | * Header file inclusions. |
||
29 | ******************************************************************************/ |
||
30 | |||
31 | #include "../ds1307.h" |
||
32 | |||
33 | #include <useful/datetime.h> |
||
34 | |||
35 | #include <avr/io.h> |
||
36 | #include <util/delay.h> |
||
37 | |||
38 | #include <stdio.h> |
||
39 | |||
40 | /****************************************************************************** |
||
41 | * Main function. |
||
42 | ******************************************************************************/ |
||
43 | |||
44 | /**************************************************************************//** |
||
45 | * \fn int main(void) |
||
46 | * |
||
47 | * \brief Main function. |
||
48 | * |
||
49 | * \return 0 |
||
50 | ******************************************************************************/ |
||
51 | int main(void) |
||
52 | { |
||
53 | // Initialize RTC. |
||
54 | ds1307__initialize(); |
||
55 | |||
56 | // Declare some variables. |
||
57 | datetime__time_t time = |
||
58 | { |
||
59 | .seconds = 00, |
||
60 | .minutes = 29, |
||
61 | .hours = 19, |
||
62 | .meridiem = 0 |
||
63 | }; |
||
64 | ds1307__hour_mode_t hour_mode = DS1307__HOUR_MODE__24_HOUR; |
||
65 | |||
66 | datetime__date_t date = |
||
67 | { |
||
68 | .day = 3, |
||
69 | .date = 5, |
||
70 | .month = 5, |
||
71 | .year = 9 |
||
72 | }; |
||
73 | |||
74 | // Set time and hour mode. |
||
75 | ds1307__set_time(&time, hour_mode); |
||
76 | |||
77 | // Set date. |
||
78 | ds1307__set_date(&date); |
||
79 | |||
80 | while (1) |
||
81 | { |
||
82 | // Get RTC time. |
||
83 | ds1307__get_time(&time, &hour_mode); |
||
84 | |||
85 | // Get RTC date. |
||
86 | ds1307__get_date(&date); |
||
87 | |||
88 | _delay_ms(100); |
||
89 | } |
||
90 | |||
91 | return 0; |
||
92 | } |