LTlib LaurTec Library  4.0.1
Open Source C Library for Microchip Microcontrollers based on XC8 Compiler
 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 LTLIB_PCF8563_H
47 #define LTLIB_PCF8563_H
48 
49 #ifdef __XC8
50  #include <xc.h>
51 #endif
52 
53 //*****************************************
54 // Library Test
55 //*****************************************
56 #include "LTlib.h"
57 
58 #ifndef LTLIB_I2C_MODULE_H
59  #error The PCF8563 Library requires the "module_I2C" library to be included.
60 #endif
61 
62 //*****************************************
63 // I2C Module Switch
64 //*****************************************
65 #define PCF8563_I2C_MODULE_1
66 //#define PCF8563_I2C_MODULE_2
67 
68 #ifdef PCF8563_I2C_MODULE_1
69  #define PCF8563_I2C_open I2C1_open
70  #define PCF8563_I2C_baud_rate I2C1_baud_rate
71  #define PCF8563_I2C_write_byte_to_external_device I2C1_write_byte_to_external_device
72  #define PCF8563_I2C_read_byte_from_external_device I2C1_read_byte_from_external_device
73 #endif
74 
75 #ifdef PCF8563_I2C_MODULE_2
76  #define PCF8563_I2C_open I2C2_open
77  #define PCF8563_I2C_baud_rate I2C2_baud_rate
78  #define PCF8563_I2C_write_byte_to_external_device I2C2_write_byte_to_external_device
79  #define PCF8563_I2C_read_byte_from_external_device I2C2_read_byte_from_external_device
80 #endif
81 
82 //**************************************************
83 // you must change this address if
84 // you change the device.
85 //**************************************************
86 
87 #define RTCC_WRITE_ADD 0xA2
88 
89 //**************************************************
90 // Definition of Day constants (Italian, English)
91 //**************************************************
92 
93 // Italian
94 #define RTCC_DO 0x00
95 #define RTCC_LU 0x01
96 #define RTCC_MA 0x02
97 #define RTCC_ME 0x03
98 #define RTCC_GI 0x04
99 #define RTCC_VE 0x05
100 #define RTCC_SA 0x06
101 
102 // English
103 #define RTCC_SU 0x00
104 #define RTCC_MO 0x01
105 #define RTCC_TU 0x02
106 #define RTCC_WE 0x03
107 #define RTCC_TR 0x04
108 #define RTCC_FR 0x05
109 #define RTCC_SA 0x06
110 
111 
112 
113 //**************************************************
114 // Standard Constant
115 // enable value for the alarm bit (day,month,dayweek)
116 //**************************************************
117 
118 #define RTCC_ENABLE_ON 0b00000000
119 #define RTCC_ENABLE_OFF 0b10000000
120 
121 #define RTCC_ALARM_ENABLED 0b00000000
122 #define RTCC_ALARM_DISABLED 0b10000000
123 
124 
125 //**************************************************
126 // Address constants
127 //**************************************************
128 
129 #define RTCC_CONTROL_REG_2_ADDR 0x01
130 #define RTCC_SECONDS_ADDR 0x02
131 #define RTCC_MINUTES_ADDR 0x03
132 #define RTCC_HOURS_ADDR 0x04
133 #define RTCC_DAYS_ADDR 0x05
134 #define RTCC_DAY_WEEK_ADDR 0x06
135 #define RTCC_MONTHS_ADDR 0x07
136 #define RTCC_YEARS_ADDR 0x08
137 #define RTCC_MINUTS_ALARM_ADDR 0x09
138 #define RTCC_HOURS_ALARM_ADDR 0x0A
139 #define RTCC_DAYS_ALARM_ADDR 0x0B
140 #define RTCC_DAY_WEEK_ALARM_ADDR 0x0C
141 
142 
143 //**************************************************
144 // Limits constants
145 //**************************************************
146 #define RTCC_MAX_MINUTES 0x60
147 #define RTCC_MAX_HOURS 0x24
148 #define RTCC_MAX_YEARS 0xA0
149 #define RTCC_MAX_MONTHS 0x13
150 #define RTCC_MAX_DAYS 0x32
151 
167 void RTCC_initialize (unsigned int baud_rate_KHz);
168 #define initialize_RTCC RTCC_initialize
169 
170 
171 
184 signed char RTCC_set_seconds (unsigned char seconds);
185 #define set_seconds_RTCC RTCC_set_seconds
186 
187 
195 unsigned char RTCC_get_seconds (void);
196 #define get_seconds_RTCC RTCC_get_seconds
197 
198 
211 signed char RTCC_set_minutes (unsigned char minutes);
212 #define set_minutes_RTCC RTCC_set_minutes
213 
214 
222 unsigned char RTCC_get_minutes (void);
223 #define get_minutes_RTCC RTCC_get_minutes
224 
225 
238 signed char RTCC_set_hours (unsigned char hours);
239 #define set_hours_RTCC RTCC_set_hours
240 
241 
249 unsigned char RTCC_get_hours (void);
250 #define get_hours_RTCC RTCC_get_hours
251 
252 
259 unsigned char* RTCC_get_time_seconds (void);
260 #define get_time_seconds_RTCC RTCC_get_time_seconds
261 
262 
269 unsigned char* RTCC_get_time (void);
270 #define get_time_RTCC RTCC_get_time
271 
272 
285 signed char RTCC_set_days (unsigned char days);
286 #define set_days_RTCC RTCC_set_days
287 
288 
296 unsigned char RTCC_get_days (void);
297 #define get_days_RTCC RTCC_get_days
298 
299 
313 signed char RTCC_set_day_of_the_week (unsigned char day_of_the_week);
314 #define set_day_of_the_week_RTCC RTCC_set_day_of_the_week
315 
316 
325 signed char RTCC_get_day_of_the_week (void);
326 #define get_day_of_the_week_RTCC RTCC_get_day_of_the_week
327 
328 
341 signed char RTCC_set_months (unsigned char months);
342 #define set_months_RTCC RTCC_set_months
343 
344 
352 unsigned char RTCC_get_months (void);
353 #define get_months_RTCC RTCC_get_months
354 
355 
369 signed char RTCC_set_years (unsigned char years);
370 #define set_years_RTCC RTCC_set_years
371 
372 
380 unsigned char RTCC_get_years (void);
381 #define get_years_RTCC RTCC_get_years
382 
383 
390 unsigned char* RTCC_get_date (void);
391 #define get_date_RTCC RTCC_get_date
392 
393 
410 signed char RTCC_set_minutes_alarm (unsigned char minutes, unsigned char alarm_enable);
411 #define set_minutes_alarm_RTCC RTCC_set_minutes_alarm
412 
413 
430 signed char RTCC_set_hours_alarm (unsigned char hours, unsigned char alarm_enable);
431 #define set_hours_alarm_RTCC RTCC_set_hours_alarm
432 
433 
450 signed char RTCC_set_days_alarm (unsigned char days, unsigned char alarm_enable);
451 #define set_days_alarm_RTCC RTCC_set_days_alarm
452 
453 
471 signed char RTCC_set_day_of_the_week_alarm (unsigned char day_of_the_week, unsigned char alarm_enable);
472 #define set_day_of_the_week_alarm_RTCC RTCC_set_day_of_the_week_alarm
473 
474 
485 signed char RTCC_enable_alarm_interrupt (void);
486 #define enable_alarm_interrupt_RTCC RTCC_enable_alarm_interrupt
487 
488 
499 signed char RTCC_disable_alarm_interrupt (void);
500 #define disable_alarm_interrupt_RTCC RTCC_disable_alarm_interrupt
501 
502 
511 unsigned char RTCC_is_alarm_ON (void);
512 #define is_alarm_ON_RTCC RTCC_is_alarm_ON
513 
514 
526 signed char RTCC_increment_minutes (void);
527 #define increment_minutes_RTCC RTCC_increment_minutes
528 
529 
541 signed char RTCC_increment_hours (void);
542 #define increment_hours_RTCC RTCC_increment_hours
543 
544 
556 signed char RTCC_increment_years (void);
557 #define increment_years_RTCC RTCC_increment_years
558 
559 
571 signed char RTCC_increment_months (void);
572 #define increment_months_RTCC RTCC_increment_months
573 
574 
587 signed char RTCC_increment_days (void);
588 #define increment_days_RTCC RTCC_increment_days
589 
590 
591 #endif
592