-
Notifications
You must be signed in to change notification settings - Fork 12
/
RTCInt.h
executable file
·112 lines (85 loc) · 2.75 KB
/
RTCInt.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
RTC library for Arduino Zero.
Copyright (c) 2015 Arduino LLC. All right reserved.
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 2.1 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 library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef RTCInt_H
#define RTCInt_H
#define TIME_H24 1
#define TIME_H12 0
#define OFF RTC_MODE2_MASK_SEL_OFF
#define SEC RTC_MODE2_MASK_SEL_SS
#define MMSS RTC_MODE2_MASK_SEL_MMSS
#define HHMMSS RTC_MODE2_MASK_SEL_HHMMSS
#define DDHHMMSS RTC_MODE2_MASK_SEL_DDHHMMSS
#define MMDDHHMMSS RTC_MODE2_MASK_SEL_MMDDHHMMSS
#define YYMMDDHHMMSS RTC_MODE2_MASK_SEL_YYMMDDHHMMSS
#define ALARM_POLLED 0
#define ALARM_INTERRUPT 1
#define ANTI_MERIDIAN 0
#define POST_MERIDIAN 1
#include "Arduino.h"
typedef struct {
unsigned int hour;
unsigned int minute;
unsigned int second;
unsigned char Tmode;
}TIME;
typedef struct {
unsigned int day;
unsigned int month;
unsigned int year;
}DATE;
static voidFuncPtr _callback = NULL;
class RTCInt {
public:
RTCInt() {};
TIME local_time;
DATE local_date;
void begin(bool timeMode);
/* Get Time Functions */
unsigned int getHour(void);
unsigned int getMinute(void);
unsigned int getSecond(void);
void getTime(void);
unsigned char getMeridian(void);
/* Get Date Functions */
unsigned int getDay(void);
unsigned int getMonth(void);
unsigned int getYear(void);
void getDate(void);
/* Set Time Functions */
void setHour(unsigned int hour, unsigned char meridian);
void setMinute(unsigned int minute);
void setSecond(unsigned int second);
void setTime(unsigned int hour, unsigned char meridian, unsigned int minute, unsigned int second);
void setTime(void);
/* Set Date Functions */
void setDay(unsigned int day);
void setMonth(unsigned int month);
void setYear(unsigned int year);
void setDate(unsigned int day, unsigned int month, unsigned int year);
void setDate(void);
/* Alarm Functions */
void enableAlarm(unsigned int mode, unsigned int type, voidFuncPtr callback);
void setAlarm(void);
bool alarmMatch(void);
private:
unsigned int Alarm_Mode=0;
bool RTCSync(void);
void RTCdisable(void);
void RTCenable(void);
void RTCreset(void);
void RTCresetRemove(void);
};
#endif