Subversion Repositories idreammicro-avr

Rev

Rev 36 | 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
 
62 jlesech 40
#include <stdbool.h>
41
 
18 jlesech 42
/******************************************************************************
36 jlesech 43
 * Public macro definitions.
44
 ******************************************************************************/
45
 
46
/**************************************************************************//**
47
 * \def     DS1307__CLOCK_RATE
48
 * \brief   DS1307 frequency in Hertz.
49
 ******************************************************************************/
50
#define DS1307__CLOCK_RATE  100000
51
 
52
/******************************************************************************
18 jlesech 53
 * Public type definitions.
54
 ******************************************************************************/
55
 
56
/**************************************************************************//**
62 jlesech 57
 * \enum    ds1307__hour_modes.
58
 * \brief   RTC hour modes.
59
 *
18 jlesech 60
 * \typedef ds1307__hour_mode_t.
62 jlesech 61
 * \brief   RTC hour mode.
18 jlesech 62
 ******************************************************************************/
63
typedef enum ds1307__hour_modes
64
{
62 jlesech 65
    DS1307__HOUR_MODE__24_HOUR = 0, /*!< 24-hour mode. */
18 jlesech 66
    DS1307__HOUR_MODE__12_HOUR = 1  /*!< 12-hour mode. */
67
} ds1307__hour_mode_t;
68
 
62 jlesech 69
/**************************************************************************//**
70
 * \enum    ds1307__sqw_out_levels
71
 * \brief
72
 *
73
 * \typedef ds1307__sqw_out_level_t
74
 * \brief
75
 ******************************************************************************/
76
typedef enum ds1307__sqw_out_levels
77
{
78
    DS1307__SQW_LEVEL__LOW, /*!< Low level. */
79
    DS1307__SQW_LEVEL__HIGH /*!< High level. */
80
} ds1307__sqw_out_level_t;
81
 
82
/**************************************************************************//**
83
 * \enum    ds1307__sqw_out_frequencies
84
 * \brief
85
 *
86
 * \typedef ds1307__sqw_out__frequency_t
87
 * \brief
88
 ******************************************************************************/
89
typedef enum ds1307__sqw_out_frequencies
90
{
91
    DS1307__SQW_FREQUENCY__1_HZ,
92
    DS1307__SQW_FREQUENCY__4096_HZ,
93
    DS1307__SQW_FREQUENCY__8192_HZ,
94
    DS1307__SQW_FREQUENCY__32768_HZ
95
} ds1307__sqw_out__frequency_t;
96
 
18 jlesech 97
/******************************************************************************
98
 * Public function prototypes.
99
 ******************************************************************************/
100
 
101
/**************************************************************************//**
102
 * \fn void ds1307__initialize(void)
103
 *
104
 * \brief Initialize DS1307 RTC.
105
 ******************************************************************************/
106
void
107
ds1307__initialize
108
(
109
    void
110
);
111
 
112
/**************************************************************************//**
113
 * \fn void ds1307__get_time(
114
 * date_time__time_t*   p_time,
115
 * ds1307__hour_mode_t* p_hour_mode)
116
 *
117
 * \brief Get RTC time.
118
 *
119
 * \param p_time a pointer to fill with RTC time
120
 * \param p_hour_mode a pointer to fill with RTC hour mode
121
 ******************************************************************************/
122
void
123
ds1307__get_time
124
(
125
    datetime__time_t*      p_time,
126
    ds1307__hour_mode_t*    p_hour_mode
127
);
128
 
129
/**************************************************************************//**
130
 * \fn void ds1307__set_time(
131
 * date_time__time_t* p_time,
132
 * ds1307__hour_mode_t hour_mode)
133
 *
134
 * \brief Set RTC time.
135
 *
136
 * \param p_time time to set. p_time->meridiem isn't used in 12-hour mode.
137
 * \param hour_mode hour mode
138
 ******************************************************************************/
139
void
140
ds1307__set_time
141
(
142
    datetime__time_t*  p_time,
143
    ds1307__hour_mode_t hour_mode
144
);
145
 
146
/**************************************************************************//**
147
 * \fn void ds1307__get_date(date_time__date_t* p_date)
148
 *
149
 * \brief Get RTC date.
150
 *
151
 * \param p_date a pointer to fill with RTC date
152
 ******************************************************************************/
153
void
154
ds1307__get_date
155
(
156
    datetime__date_t* p_date
157
);
158
 
159
/**************************************************************************//**
160
 * \fn void ds1307__set_date(date_time__date_t* p_date)
161
 *
162
 * \brief Set RTC date.
163
 *
164
 * \param p_date date to set
165
 ******************************************************************************/
166
void
167
ds1307__set_date
168
(
169
    datetime__date_t* p_date
170
);
171
 
62 jlesech 172
/**************************************************************************//**
173
 * \fn void ds1307__set_square_wave_output_level(ds1307__sqw_out_level_t level)
174
 *
175
 * \brief Set square wave output pin level.
176
 *
177
 * \param level Level to set.
178
 ******************************************************************************/
179
void
180
ds1307__set_square_wave_output_level
181
(
182
    ds1307__sqw_out_level_t level
183
);
184
 
185
/**************************************************************************//**
186
 * \fn void ds1307__set_square_wave_output_signal(
187
 * ds1307__sqw_out__frequency_t    frequency,
188
 * bool                            enable)
189
 *
190
 * \brief Set Square-Wave output signal.
191
 *
192
 * \param   frequency   Frequency.
193
 * \param   enable      Status.
194
 ******************************************************************************/
195
void
196
ds1307__set_square_wave_output_signal
197
(
198
    ds1307__sqw_out__frequency_t    frequency,
199
    bool                            enable
200
);
201
 
18 jlesech 202
#ifdef _cplusplus
203
}
204
#endif
205
 
206
#endif /* H__IDREAMMICRO__DS1307__H */