PIC18 LaurTec Library  3.1
Open Source C Library for PIC18 Microcontrollers based on C18 - XC8 Compilers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
DS1337.h
Go to the documentation of this file.
1 
2 /*******************************************************************************
3 
4 Author : Mauro Laurenti
5 Version : 1.0
6 Created on Date : 02/02/2013
7 Last update : 02/02/2013
8 
9 CopyRight 2006-2013 all rights are reserved
10 
11 ********************************************************
12 SOFTWARE LICENSE AGREEMENT
13 ********************************************************
14 
15 The usage of the supplied software imply the acceptance of the following license.
16 
17 The software supplied herewith by Mauro Laurenti (the Author) is intended for
18 use solely and exclusively on Microchip PIC Microcontroller (registered mark).
19 The software is owned by the Author, and is protected under applicable
20 copyright laws. All rights are reserved.
21 Any use in violation of the foregoing restrictions may subject the
22 user to criminal sanctions under applicable laws, as well as to civil liability
23 for the breach of the terms and conditions of this license.
24 Commercial use is forbidden without a written acknowledgment with the Author.
25 Personal or educational use is allowed if the application containing the
26 following software doesn't aim to commercial use or monetary earning of any kind.
27 
28 THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES,
29 WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
30 TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
31 PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE AUTHOR SHALL NOT,
32 IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
33 CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
34 
35 ********************************************************
36 PURPOSES
37 ********************************************************
38 
39 This libary supports the Real Time Clock Calendar DS1337 or compatible
40 devices. The library is kept compatible with the PCF8563
41 
42 The following functions have been added:
43 
44  set_seconds_alarm_RTCC (seconds associated to the first alarm)
45 
46  The second alarm is not handled but it can be easily implemented.
47 
48 *******************************************************************************/
49 
50 
51 #ifndef DS1337_H
52 #define DS1337_H
53 
54 #ifdef __XC8
55  #include <xc.h>
56  #ifndef _PIC18
57  #error "The PCF8563 Library supports only PIC18 devices"
58  #endif
59 #endif
60 
61 #ifdef __18CXX
62  #include <i2c.h>
63 #endif
64 
65 
66 //**************************************************
67 // you must change this address if
68 // you change the device.
69 //**************************************************
70 
71 #define WRITE_ADD 0xD0
72 
73 //**************************************************
74 // Definition of Day constants (Italian, English)
75 //**************************************************
76 
77 // Italian
78 #define DO 0x00
79 #define LU 0x01
80 #define MA 0x02
81 #define ME 0x03
82 #define GI 0x04
83 #define VE 0x05
84 #define SA 0x06
85 
86 // English
87 #define SU 0x00
88 #define MO 0x01
89 #define TU 0x02
90 #define WE 0x03
91 #define TR 0x04
92 #define FR 0x05
93 #define SA 0x06
94 
95 
96 
97 //**************************************************
98 // Standard Constants
99 // enable value for the allarm bit
100 //**************************************************
101 
102 #define ENABLE_ON 0b00000000
103 #define ENABLE_OFF 0b10000000
104 
105 
106 //**************************************************
107 // Address constants
108 //**************************************************
109 
110 #define SECONDS_ADDR 0x00
111 #define MINUTES_ADDR 0x01
112 #define HOURS_ADDR 0x02
113 #define DAYS_ADDR 0x03
114 #define MONTHS_ADDR 0x05
115 #define YEARS_ADDR 0x06
116 #define SECONDS_ALARM_ADDR 0x07
117 #define MINUTS_ALARM_ADDR 0x08
118 #define HOURS_ALARM_ADDR 0x09
119 #define DAYS_ALARM_ADDR 0x0A
120 #define MINUTS_ALARM_2_ADDR 0x0B
121 #define HOURS_ALARM_2_ADDR 0x0C
122 #define DAYS_ALARM_2_ADDR 0x0D
123 #define CONTROL_REG_1_ADDR 0x0E
124 #define CONTROL_REG_2_ADDR 0x0F
125 
126 //**************************************************
127 // Limits constants
128 //**************************************************
129 #define MAX_MINUTES 0x60
130 #define MAX_HOURS 0x24
131 #define MAX_YEARS 0xA0
132 #define MAX_MONTHS 0x13
133 #define MAX_DAYS 0x32
134 
135 
148 signed char set_seconds_RTCC (unsigned char seconds);
149 
150 
158 unsigned char get_seconds_RTCC (void);
159 
160 
173 signed char set_minutes_RTCC (unsigned char minutes);
174 
175 
183 unsigned char get_minutes_RTCC (void);
184 
185 
198 signed char set_hours_RTCC (unsigned char hours);
199 
200 
208 unsigned char get_hours_RTCC (void);
209 
210 
217 unsigned char* get_time_seconds_RTCC (void);
218 
219 
226 unsigned char* get_time_RTCC (void);
227 
228 
241 signed char set_days_RTCC (unsigned char days);
242 
243 
251 unsigned char get_days_RTCC (void);
252 
253 
254 
267 signed char set_months_RTCC (unsigned char months);
268 
269 
277 unsigned char get_months_RTCC (void);
278 
279 
293 signed char set_years_RTCC (unsigned char years);
294 
295 
303 unsigned char get_years_RTCC (void);
304 
305 
306 
313 unsigned char* get_date_RTCC (void);
314 
315 
332 signed char set_seconds_alarm_RTCC (unsigned char seconds, unsigned char alarm_enable);
333 
350 signed char set_minutes_alarm_RTCC (unsigned char minutes, unsigned char alarm_enable);
351 
352 
369 signed char set_hours_alarm_RTCC (unsigned char hours, unsigned char alarm_enable);
370 
371 
388 signed char set_days_alarm_RTCC (unsigned char days, unsigned char alarm_enable);
389 
390 
401 signed char enable_alarm_interrupt_RTCC (void);
402 
403 
414 signed char disable_alarm_interrupt_RTCC (void);
415 
416 
425 unsigned char is_alarm_ON_RTCC (void);
426 
427 
439 signed char increment_minutes_RTCC (void);
440 
441 
453 signed char increment_hours_RTCC (void);
454 
455 
467 signed char increment_years_RTCC (void);
468 
469 
481 signed char increment_months_RTCC (void);
482 
483 
496 signed char increment_days_RTCC (void);
497 
498 
499 #endif
500