PIC18 LaurTec Library  3.3.1
Open Source C Library for PIC18 Microcontrollers based on C18 - XC8 Compilers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
PCF8563.h
Go to the documentation of this file.
1 
2 /*******************************************************************************
3 
4 Author : Mauro Laurenti
5 Version : 1.2
6 Created on Date : 4/9/2006
7 Last update : 15/12/2014
8 
9 CopyRight 2006-2014 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 acknowledgement 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 library supports the Real Time Clock Calendar PCF8563 or compatible
40 devices
41 
42 ******************************************************************************/
43 
44 
45 
46 #ifndef PCF8563_H
47 #define PCF8563_H
48 
49 #ifdef __XC8
50  #include <xc.h>
51  #ifndef _PIC18
52  #error The PCF8563 Library supports only PIC18 devices
53  #endif
54 #endif
55 
56 #include <i2c.h>
57 
58 
59 //**************************************************
60 // you must change this address if
61 // you change the device.
62 //**************************************************
63 
64 #define RTCC_WRITE_ADD 0xA2
65 
66 //**************************************************
67 // Definition of Day constants (Italian, English)
68 //**************************************************
69 
70 // Italian
71 #define RTCC_DO 0x00
72 #define RTCC_LU 0x01
73 #define RTCC_MA 0x02
74 #define RTCC_ME 0x03
75 #define RTCC_GI 0x04
76 #define RTCC_VE 0x05
77 #define RTCC_SA 0x06
78 
79 // English
80 #define RTCC_SU 0x00
81 #define RTCC_MO 0x01
82 #define RTCC_TU 0x02
83 #define RTCC_WE 0x03
84 #define RTCC_TR 0x04
85 #define RTCC_FR 0x05
86 #define RTCC_SA 0x06
87 
88 
89 
90 //**************************************************
91 // Standard Constant
92 // enable value for the alarm bit (day,month,dayweek)
93 //**************************************************
94 
95 #define RTCC_ENABLE_ON 0b00000000
96 #define RTCC_ENABLE_OFF 0b10000000
97 
98 
99 //**************************************************
100 // Address constants
101 //**************************************************
102 
103 #define RTCC_CONTROL_REG_2_ADDR 0x01
104 #define RTCC_SECONDS_ADDR 0x02
105 #define RTCC_MINUTES_ADDR 0x03
106 #define RTCC_HOURS_ADDR 0x04
107 #define RTCC_DAYS_ADDR 0x05
108 #define RTCC_DAY_WEEK_ADDR 0x06
109 #define RTCC_MONTHS_ADDR 0x07
110 #define RTCC_YEARS_ADDR 0x08
111 #define RTCC_MINUTS_ALARM_ADDR 0x09
112 #define RTCC_HOURS_ALARM_ADDR 0x0A
113 #define RTCC_DAYS_ALARM_ADDR 0x0B
114 #define RTCC_DAY_WEEK_ALARM_ADDR 0x0C
115 
116 
117 //**************************************************
118 // Limits constants
119 //**************************************************
120 #define RTCC_MAX_MINUTES 0x60
121 #define RTCC_MAX_HOURS 0x24
122 #define RTCC_MAX_YEARS 0xA0
123 #define RTCC_MAX_MONTHS 0x13
124 #define RTCC_MAX_DAYS 0x32
125 
141 void PCF8563_initialize (unsigned char crystal_frequency_MHz, unsigned int baud_rate_KHz);
142 #define initialize_PCF8563 PCF8563_initialize
143 
144 
145 
158 signed char RTCC_set_seconds (unsigned char seconds);
159 #define set_seconds_RTCC RTCC_set_seconds
160 
161 
169 unsigned char RTCC_get_seconds (void);
170 #define get_seconds_RTCC RTCC_get_seconds
171 
172 
185 signed char RTCC_set_minutes (unsigned char minutes);
186 #define set_minutes_RTCC RTCC_set_minutes
187 
188 
196 unsigned char RTCC_get_minutes (void);
197 #define get_minutes_RTCC RTCC_get_minutes
198 
199 
212 signed char RTCC_set_hours (unsigned char hours);
213 #define set_hours_RTCC RTCC_set_hours
214 
215 
223 unsigned char RTCC_get_hours (void);
224 #define get_hours_RTCC RTCC_get_hours
225 
226 
233 unsigned char* RTCC_get_time_seconds (void);
234 #define get_time_seconds_RTCC RTCC_get_time_seconds
235 
236 
243 unsigned char* RTCC_get_time (void);
244 #define get_time_RTCC RTCC_get_time
245 
246 
259 signed char RTCC_set_days (unsigned char days);
260 #define set_days_RTCC RTCC_set_days
261 
262 
270 unsigned char RTCC_get_days (void);
271 #define get_days_RTCC RTCC_get_days
272 
273 
287 signed char RTCC_set_day_of_the_week (unsigned char day_of_the_week);
288 #define set_day_of_the_week_RTCC RTCC_set_day_of_the_week
289 
290 
299 signed char RTCC_get_day_of_the_week (void);
300 #define get_day_of_the_week_RTCC RTCC_get_day_of_the_week
301 
302 
315 signed char RTCC_set_months (unsigned char months);
316 #define set_months_RTCC RTCC_set_months
317 
318 
326 unsigned char RTCC_get_months (void);
327 #define get_months_RTCC RTCC_get_months
328 
329 
343 signed char RTCC_set_years (unsigned char years);
344 #define set_years_RTCC RTCC_set_years
345 
346 
354 unsigned char RTCC_get_years (void);
355 #define get_years_RTCC RTCC_get_years
356 
357 
364 unsigned char* RTCC_get_date (void);
365 #define get_date_RTCC RTCC_get_date
366 
367 
384 signed char RTCC_set_minutes_alarm (unsigned char minutes, unsigned char alarm_enable);
385 #define set_minutes_alarm_RTCC RTCC_set_minutes_alarm
386 
387 
404 signed char RTCC_set_hours_alarm (unsigned char hours, unsigned char alarm_enable);
405 #define set_hours_alarm_RTCC RTCC_set_hours_alarm
406 
407 
424 signed char RTCC_set_days_alarm (unsigned char days, unsigned char alarm_enable);
425 #define set_days_alarm_RTCC RTCC_set_days_alarm
426 
427 
445 signed char RTCC_set_day_of_the_week_alarm (unsigned char day_of_the_week, unsigned char alarm_enable);
446 #define set_day_of_the_week_alarm_RTCC RTCC_set_day_of_the_week_alarm
447 
448 
459 signed char RTCC_enable_alarm_interrupt (void);
460 #define enable_alarm_interrupt_RTCC RTCC_enable_alarm_interrupt
461 
462 
473 signed char RTCC_disable_alarm_interrupt (void);
474 #define disable_alarm_interrupt_RTCC RTCC_disable_alarm_interrupt
475 
476 
485 unsigned char RTCC_is_alarm_ON (void);
486 #define is_alarm_ON_RTCC RTCC_is_alarm_ON
487 
488 
500 signed char RTCC_increment_minutes (void);
501 #define increment_minutes_RTCC RTCC_increment_minutes
502 
503 
515 signed char RTCC_increment_hours (void);
516 #define increment_hours_RTCC RTCC_increment_hours
517 
518 
530 signed char RTCC_increment_years (void);
531 #define increment_years_RTCC RTCC_increment_years
532 
533 
545 signed char RTCC_increment_months (void);
546 #define increment_months_RTCC RTCC_increment_months
547 
548 
561 signed char RTCC_increment_days (void);
562 #define increment_days_RTCC RTCC_increment_days
563 
564 
565 #endif
566