PIC18 LaurTec Library
3.2.0
Open Source C Library for PIC18 Microcontrollers based on C18 - XC8 Compilers
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.1
6
Created on Date : 4/9/2006
7
Last update : 25/01/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 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 WRITE_ADD 0xA2
65
66
//**************************************************
67
// Definition of Day constants (Italian, English)
68
//**************************************************
69
70
// Italian
71
#define DO 0x00
72
#define LU 0x01
73
#define MA 0x02
74
#define ME 0x03
75
#define GI 0x04
76
#define VE 0x05
77
#define SA 0x06
78
79
// English
80
#define SU 0x00
81
#define MO 0x01
82
#define TU 0x02
83
#define WE 0x03
84
#define TR 0x04
85
#define FR 0x05
86
#define SA 0x06
87
88
89
90
//**************************************************
91
// Standard Constant
92
// enable value for the alarm bit (day,month,dayweek)
93
//**************************************************
94
95
#define ENABLE_ON 0b00000000
96
#define ENABLE_OFF 0b10000000
97
98
99
//**************************************************
100
// Address constants
101
//**************************************************
102
103
#define CONTROL_REG_2_ADDR 0x01
104
#define SECONDS_ADDR 0x02
105
#define MINUTES_ADDR 0x03
106
#define HOURS_ADDR 0x04
107
#define DAYS_ADDR 0x05
108
#define DAY_WEEK_ADDR 0x06
109
#define MONTHS_ADDR 0x07
110
#define YEARS_ADDR 0x08
111
#define MINUTS_ALARM_ADDR 0x09
112
#define HOURS_ALARM_ADDR 0x0A
113
#define DAYS_ALARM_ADDR 0x0B
114
#define DAY_WEEK_ALARM_ADDR 0x0C
115
116
117
//**************************************************
118
// Limits constants
119
//**************************************************
120
#define MAX_MINUTES 0x60
121
#define MAX_HOURS 0x24
122
#define MAX_YEARS 0xA0
123
#define MAX_MONTHS 0x13
124
#define MAX_DAYS 0x32
125
141
void
initialize_PCF8563
(
unsigned
char
crystal_frequency_MHz,
unsigned
int
baud_rate_KHz);
142
143
144
157
signed
char
set_seconds_RTCC
(
unsigned
char
seconds);
158
159
167
unsigned
char
get_seconds_RTCC
(
void
);
168
169
182
signed
char
set_minutes_RTCC
(
unsigned
char
minutes);
183
184
192
unsigned
char
get_minutes_RTCC
(
void
);
193
194
207
signed
char
set_hours_RTCC
(
unsigned
char
hours);
208
209
217
unsigned
char
get_hours_RTCC
(
void
);
218
219
226
unsigned
char
*
get_time_seconds_RTCC
(
void
);
227
228
235
unsigned
char
*
get_time_RTCC
(
void
);
236
237
250
signed
char
set_days_RTCC
(
unsigned
char
days);
251
252
260
unsigned
char
get_days_RTCC
(
void
);
261
262
276
signed
char
set_day_of_the_week_RTCC
(
unsigned
char
day_of_the_week);
277
278
287
signed
char
get_day_of_the_week_RTCC
(
void
);
288
289
302
signed
char
set_months_RTCC
(
unsigned
char
months);
303
304
312
unsigned
char
get_months_RTCC
(
void
);
313
314
328
signed
char
set_years_RTCC
(
unsigned
char
years);
329
330
338
unsigned
char
get_years_RTCC
(
void
);
339
340
341
348
unsigned
char
*
get_date_RTCC
(
void
);
349
350
367
signed
char
set_minutes_alarm_RTCC
(
unsigned
char
minutes,
unsigned
char
alarm_enable);
368
369
386
signed
char
set_hours_alarm_RTCC
(
unsigned
char
hours,
unsigned
char
alarm_enable);
387
388
405
signed
char
set_days_alarm_RTCC
(
unsigned
char
days,
unsigned
char
alarm_enable);
406
407
425
signed
char
set_day_of_the_week_alarm_RTCC
(
unsigned
char
day_of_the_week,
unsigned
char
alarm_enable);
426
427
438
signed
char
enable_alarm_interrupt_RTCC
(
void
);
439
440
451
signed
char
disable_alarm_interrupt_RTCC
(
void
);
452
453
462
unsigned
char
is_alarm_ON_RTCC
(
void
);
463
464
476
signed
char
increment_minutes_RTCC
(
void
);
477
478
490
signed
char
increment_hours_RTCC
(
void
);
491
492
504
signed
char
increment_years_RTCC
(
void
);
505
506
518
signed
char
increment_months_RTCC
(
void
);
519
520
533
signed
char
increment_days_RTCC
(
void
);
534
535
536
#endif
537
LaurTec_PIC_libraries_v_3.2.0
inc
PCF8563.h
Generated on Fri Mar 14 2014 19:47:30 for PIC18 LaurTec Library by
1.8.3.1