Subversion Repositories idreammicro-avr

Rev

Rev 18 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
18 jlesech 1
/**************************************************************************//**
2
 * \brief DS1307 RTC library
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
 * \headerfile ds1307.h
25
 ******************************************************************************/
26
 
27
#ifndef H__IDREAMMICRO__DS1307__H
28
#define H__IDREAMMICRO__DS1307__H
29
 
30
#ifdef _cplusplus
31
extern "C"{
32
#endif
33
 
34
/******************************************************************************
35
 * Header file inclusions.
36
 ******************************************************************************/
37
 
38
#include <useful/datetime.h>
39
 
40
/******************************************************************************
36 jlesech 41
 * Public macro definitions.
42
 ******************************************************************************/
43
 
44
/**************************************************************************//**
45
 * \def     DS1307__CLOCK_RATE
46
 * \brief   DS1307 frequency in Hertz.
47
 ******************************************************************************/
48
#define DS1307__CLOCK_RATE  100000
49
 
50
/******************************************************************************
18 jlesech 51
 * Public type definitions.
52
 ******************************************************************************/
53
 
54
/**************************************************************************//**
55
 * \typedef ds1307__hour_mode_t.
56
 * \bried RTC hour mode.
57
 ******************************************************************************/
58
/**************************************************************************//**
59
 * \enum ds1307__hour_modes.
60
 * \bried RTC hour modes.
61
 ******************************************************************************/
62
typedef enum ds1307__hour_modes
63
{
64
    DS1307__HOUR_MODE__24_HOUR = 0,     /*!< 24-hour mode. */
65
    DS1307__HOUR_MODE__12_HOUR = 1  /*!< 12-hour mode. */
66
} ds1307__hour_mode_t;
67
 
68
/******************************************************************************
69
 * Public function prototypes.
70
 ******************************************************************************/
71
 
72
/**************************************************************************//**
73
 * \fn void ds1307__initialize(void)
74
 *
75
 * \brief Initialize DS1307 RTC.
76
 ******************************************************************************/
77
void
78
ds1307__initialize
79
(
80
    void
81
);
82
 
83
/**************************************************************************//**
84
 * \fn void ds1307__get_time(
85
 * date_time__time_t*   p_time,
86
 * ds1307__hour_mode_t* p_hour_mode)
87
 *
88
 * \brief Get RTC time.
89
 *
90
 * \param p_time a pointer to fill with RTC time
91
 * \param p_hour_mode a pointer to fill with RTC hour mode
92
 ******************************************************************************/
93
void
94
ds1307__get_time
95
(
96
    datetime__time_t*      p_time,
97
    ds1307__hour_mode_t*    p_hour_mode
98
);
99
 
100
/**************************************************************************//**
101
 * \fn void ds1307__set_time(
102
 * date_time__time_t* p_time,
103
 * ds1307__hour_mode_t hour_mode)
104
 *
105
 * \brief Set RTC time.
106
 *
107
 * \param p_time time to set. p_time->meridiem isn't used in 12-hour mode.
108
 * \param hour_mode hour mode
109
 ******************************************************************************/
110
void
111
ds1307__set_time
112
(
113
    datetime__time_t*  p_time,
114
    ds1307__hour_mode_t hour_mode
115
);
116
 
117
/**************************************************************************//**
118
 * \fn void ds1307__get_date(date_time__date_t* p_date)
119
 *
120
 * \brief Get RTC date.
121
 *
122
 * \param p_date a pointer to fill with RTC date
123
 ******************************************************************************/
124
void
125
ds1307__get_date
126
(
127
    datetime__date_t* p_date
128
);
129
 
130
/**************************************************************************//**
131
 * \fn void ds1307__set_date(date_time__date_t* p_date)
132
 *
133
 * \brief Set RTC date.
134
 *
135
 * \param p_date date to set
136
 ******************************************************************************/
137
void
138
ds1307__set_date
139
(
140
    datetime__date_t* p_date
141
);
142
 
143
#ifdef _cplusplus
144
}
145
#endif
146
 
147
#endif /* H__IDREAMMICRO__DS1307__H */