LTlib LaurTec Library
4.0.3
Open Source C Library for Microchip Microcontrollers based on XC8 Compiler
Main Page
Data Structures
Files
File List
Globals
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.4
6
Created on Date : 4/9/2006
7
Last update : 19/06/2016
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
#ifndef LTLIB_DELAY_H
63
#error The PCF8563 Library requires the "delay" library to be included.
64
#endif
65
66
67
//*****************************************
68
// I2C Module Switch
69
//*****************************************
70
#if defined (PCF8563_I2C_MODULE_1) || defined (PCF8563_I2C_MODULE_2)
71
72
#else
73
#define PCF8563_I2C_MODULE_1
74
#endif
75
76
77
#ifdef PCF8563_I2C_MODULE_1
78
#define PCF8563_I2C_open I2C1_open
79
#define PCF8563_I2C_baud_rate I2C1_baud_rate
80
#define PCF8563_I2C_write_byte_to_external_device I2C1_write_byte_to_external_device
81
#define PCF8563_I2C_read_byte_from_external_device I2C1_read_byte_from_external_device
82
#endif
83
84
#ifdef PCF8563_I2C_MODULE_2
85
#define PCF8563_I2C_open I2C2_open
86
#define PCF8563_I2C_baud_rate I2C2_baud_rate
87
#define PCF8563_I2C_write_byte_to_external_device I2C2_write_byte_to_external_device
88
#define PCF8563_I2C_read_byte_from_external_device I2C2_read_byte_from_external_device
89
#endif
90
91
//**************************************************
92
// you must change this address if
93
// you change the device.
94
//**************************************************
95
96
#define RTCC_WRITE_ADD 0xA2
97
98
//**************************************************
99
// Definition of Day constants (Italian, English)
100
//**************************************************
101
102
// Italian
103
#define RTCC_DO 0x00
104
#define RTCC_LU 0x01
105
#define RTCC_MA 0x02
106
#define RTCC_ME 0x03
107
#define RTCC_GI 0x04
108
#define RTCC_VE 0x05
109
#define RTCC_SA 0x06
110
111
// English
112
#define RTCC_SU 0x00
113
#define RTCC_MO 0x01
114
#define RTCC_TU 0x02
115
#define RTCC_WE 0x03
116
#define RTCC_TR 0x04
117
#define RTCC_FR 0x05
118
#define RTCC_SA 0x06
119
120
121
122
//**************************************************
123
// Standard Constant
124
// enable value for the alarm bit (day,month,dayweek)
125
//**************************************************
126
127
#define RTCC_ENABLE_ON 0b00000000
128
#define RTCC_ENABLE_OFF 0b10000000
129
130
#define RTCC_ALARM_ENABLED 0b00000000
131
#define RTCC_ALARM_DISABLED 0b10000000
132
133
134
//**************************************************
135
// Address constants
136
//**************************************************
137
138
#define RTCC_CONTROL_REG_2_ADDR 0x01
139
#define RTCC_SECONDS_ADDR 0x02
140
#define RTCC_MINUTES_ADDR 0x03
141
#define RTCC_HOURS_ADDR 0x04
142
#define RTCC_DAYS_ADDR 0x05
143
#define RTCC_DAY_WEEK_ADDR 0x06
144
#define RTCC_MONTHS_ADDR 0x07
145
#define RTCC_YEARS_ADDR 0x08
146
#define RTCC_MINUTS_ALARM_ADDR 0x09
147
#define RTCC_HOURS_ALARM_ADDR 0x0A
148
#define RTCC_DAYS_ALARM_ADDR 0x0B
149
#define RTCC_DAY_WEEK_ALARM_ADDR 0x0C
150
151
152
//**************************************************
153
// Limits constants
154
//**************************************************
155
#define RTCC_MAX_MINUTES 0x60
156
#define RTCC_MAX_HOURS 0x24
157
#define RTCC_MAX_YEARS 0xA0
158
#define RTCC_MAX_MONTHS 0x13
159
#define RTCC_MAX_DAYS 0x32
160
176
void
RTCC_initialize
(
unsigned
int
baud_rate_KHz);
177
#define initialize_RTCC RTCC_initialize
178
179
180
193
signed
char
RTCC_set_seconds
(
unsigned
char
seconds);
194
#define set_seconds_RTCC RTCC_set_seconds
195
196
204
unsigned
char
RTCC_get_seconds
(
void
);
205
#define get_seconds_RTCC RTCC_get_seconds
206
207
220
signed
char
RTCC_set_minutes
(
unsigned
char
minutes);
221
#define set_minutes_RTCC RTCC_set_minutes
222
223
231
unsigned
char
RTCC_get_minutes
(
void
);
232
#define get_minutes_RTCC RTCC_get_minutes
233
234
247
signed
char
RTCC_set_hours
(
unsigned
char
hours);
248
#define set_hours_RTCC RTCC_set_hours
249
250
258
unsigned
char
RTCC_get_hours
(
void
);
259
#define get_hours_RTCC RTCC_get_hours
260
261
268
unsigned
char
*
RTCC_get_time_seconds
(
void
);
269
#define get_time_seconds_RTCC RTCC_get_time_seconds
270
271
278
unsigned
char
*
RTCC_get_time
(
void
);
279
#define get_time_RTCC RTCC_get_time
280
281
294
signed
char
RTCC_set_days
(
unsigned
char
days);
295
#define set_days_RTCC RTCC_set_days
296
297
305
unsigned
char
RTCC_get_days
(
void
);
306
#define get_days_RTCC RTCC_get_days
307
308
322
signed
char
RTCC_set_day_of_the_week
(
unsigned
char
day_of_the_week);
323
#define set_day_of_the_week_RTCC RTCC_set_day_of_the_week
324
325
334
signed
char
RTCC_get_day_of_the_week
(
void
);
335
#define get_day_of_the_week_RTCC RTCC_get_day_of_the_week
336
337
350
signed
char
RTCC_set_months
(
unsigned
char
months);
351
#define set_months_RTCC RTCC_set_months
352
353
361
unsigned
char
RTCC_get_months
(
void
);
362
#define get_months_RTCC RTCC_get_months
363
364
378
signed
char
RTCC_set_years
(
unsigned
char
years);
379
#define set_years_RTCC RTCC_set_years
380
381
389
unsigned
char
RTCC_get_years
(
void
);
390
#define get_years_RTCC RTCC_get_years
391
392
399
unsigned
char
*
RTCC_get_date
(
void
);
400
#define get_date_RTCC RTCC_get_date
401
402
419
signed
char
RTCC_set_minutes_alarm
(
unsigned
char
minutes,
unsigned
char
alarm_enable);
420
#define set_minutes_alarm_RTCC RTCC_set_minutes_alarm
421
422
439
signed
char
RTCC_set_hours_alarm
(
unsigned
char
hours,
unsigned
char
alarm_enable);
440
#define set_hours_alarm_RTCC RTCC_set_hours_alarm
441
442
459
signed
char
RTCC_set_days_alarm
(
unsigned
char
days,
unsigned
char
alarm_enable);
460
#define set_days_alarm_RTCC RTCC_set_days_alarm
461
462
480
signed
char
RTCC_set_day_of_the_week_alarm
(
unsigned
char
day_of_the_week,
unsigned
char
alarm_enable);
481
#define set_day_of_the_week_alarm_RTCC RTCC_set_day_of_the_week_alarm
482
483
494
signed
char
RTCC_enable_alarm_interrupt
(
void
);
495
#define enable_alarm_interrupt_RTCC RTCC_enable_alarm_interrupt
496
497
508
signed
char
RTCC_disable_alarm_interrupt
(
void
);
509
#define disable_alarm_interrupt_RTCC RTCC_disable_alarm_interrupt
510
511
520
unsigned
char
RTCC_is_alarm_ON
(
void
);
521
#define is_alarm_ON_RTCC RTCC_is_alarm_ON
522
523
535
signed
char
RTCC_increment_minutes
(
void
);
536
#define increment_minutes_RTCC RTCC_increment_minutes
537
538
550
signed
char
RTCC_increment_hours
(
void
);
551
#define increment_hours_RTCC RTCC_increment_hours
552
553
565
signed
char
RTCC_increment_years
(
void
);
566
#define increment_years_RTCC RTCC_increment_years
567
568
580
signed
char
RTCC_increment_months
(
void
);
581
#define increment_months_RTCC RTCC_increment_months
582
583
596
signed
char
RTCC_increment_days
(
void
);
597
#define increment_days_RTCC RTCC_increment_days
598
599
600
#endif
601
LTlib_v_4.0.3
inc
PCF8563.h
Generated on Wed Aug 3 2016 19:57:31 for LTlib LaurTec Library by
1.8.3.1