source: rtos_arduino/trunk/arduino_lib/libraries/RTC/src/RTCInt.h@ 136

Last change on this file since 136 was 136, checked in by ertl-honda, 8 years ago

ライブラリとOS及びベーシックなサンプルの追加.

File size: 2.8 KB
Line 
1/*
2 RTC library for Arduino Zero.
3 Copyright (c) 2015 Arduino LLC. All right reserved.
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18*/
19
20#ifndef RTCInt_H
21#define RTCInt_H
22
23#define TIME_H24 1
24#define TIME_H12 0
25
26#define OFF RTC_MODE2_MASK_SEL_OFF
27#define SEC RTC_MODE2_MASK_SEL_SS
28#define MMSS RTC_MODE2_MASK_SEL_MMSS
29#define HHMMSS RTC_MODE2_MASK_SEL_HHMMSS
30#define DDHHMMSS RTC_MODE2_MASK_SEL_DDHHMMSS
31#define MMDDHHMMSS RTC_MODE2_MASK_SEL_MMDDHHMMSS
32#define YYMMDDHHMMSS RTC_MODE2_MASK_SEL_YYMMDDHHMMSS
33
34#define ALARM_POLLED 0
35#define ALARM_INTERRUPT 1
36
37#define ANTI_MERIDIAN 0
38#define POST_MERIDIAN 1
39
40#include "Arduino.h"
41
42typedef struct {
43 unsigned int hour;
44 unsigned int minute;
45 unsigned int second;
46 unsigned char Tmode;
47}TIME;
48
49typedef struct {
50 unsigned int day;
51 unsigned int month;
52 unsigned int year;
53}DATE;
54
55static voidFuncPtr _callback = NULL;
56
57class RTCInt {
58public:
59
60 RTCInt() {};
61
62 TIME local_time;
63 DATE local_date;
64
65 void begin(bool timeMode);
66
67 /* Get Time Functions */
68
69 unsigned int getHour(void);
70 unsigned int getMinute(void);
71 unsigned int getSecond(void);
72 void getTime(void);
73 unsigned char getMeridian(void);
74
75 /* Get Date Functions */
76 unsigned int getDay(void);
77 unsigned int getMonth(void);
78 unsigned int getYear(void);
79 void getDate(void);
80
81 /* Set Time Functions */
82
83 void setHour(unsigned int hour, unsigned char meridian);
84 void setMinute(unsigned int minute);
85 void setSecond(unsigned int second);
86 void setTime(unsigned int hour, unsigned char meridian, unsigned int minute, unsigned int second);
87 void setTime(void);
88
89 /* Set Date Functions */
90 void setDay(unsigned int day);
91 void setMonth(unsigned int month);
92 void setYear(unsigned int year);
93 void setDate(unsigned int day, unsigned int month, unsigned int year);
94 void setDate(void);
95
96 /* Alarm Functions */
97 void enableAlarm(unsigned int mode, unsigned int type, voidFuncPtr callback);
98 void setAlarm(void);
99 bool alarmMatch(void);
100
101
102private:
103 unsigned int Alarm_Mode=0;
104 bool RTCSync(void);
105 void RTCdisable(void);
106 void RTCenable(void);
107 void RTCreset(void);
108 void RTCresetRemove(void);
109};
110
111
112#endif
Note: See TracBrowser for help on using the repository browser.