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
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 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 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 PCF1337 Library supports only PIC18 devices
58
#endif
59
#endif
60
61
#include <i2c.h>
62
63
64
//**************************************************
65
// you must change this address if
66
// you change the device.
67
//**************************************************
68
69
#define WRITE_ADD 0xD0
70
71
//**************************************************
72
// Definition of Day constants (Italian, English)
73
//**************************************************
74
75
// Italian
76
#define DO 0x00
77
#define LU 0x01
78
#define MA 0x02
79
#define ME 0x03
80
#define GI 0x04
81
#define VE 0x05
82
#define SA 0x06
83
84
// English
85
#define SU 0x00
86
#define MO 0x01
87
#define TU 0x02
88
#define WE 0x03
89
#define TR 0x04
90
#define FR 0x05
91
#define SA 0x06
92
93
94
95
//**************************************************
96
// Standard Constants
97
// enable value for the alarm bit
98
//**************************************************
99
100
#define ENABLE_ON 0b00000000
101
#define ENABLE_OFF 0b10000000
102
103
104
//**************************************************
105
// Address constants
106
//**************************************************
107
108
#define SECONDS_ADDR 0x00
109
#define MINUTES_ADDR 0x01
110
#define HOURS_ADDR 0x02
111
#define DAYS_ADDR 0x03
112
#define MONTHS_ADDR 0x05
113
#define YEARS_ADDR 0x06
114
#define SECONDS_ALARM_ADDR 0x07
115
#define MINUTS_ALARM_ADDR 0x08
116
#define HOURS_ALARM_ADDR 0x09
117
#define DAYS_ALARM_ADDR 0x0A
118
#define MINUTS_ALARM_2_ADDR 0x0B
119
#define HOURS_ALARM_2_ADDR 0x0C
120
#define DAYS_ALARM_2_ADDR 0x0D
121
#define CONTROL_REG_1_ADDR 0x0E
122
#define CONTROL_REG_2_ADDR 0x0F
123
124
//**************************************************
125
// Limits constants
126
//**************************************************
127
#define MAX_MINUTES 0x60
128
#define MAX_HOURS 0x24
129
#define MAX_YEARS 0xA0
130
#define MAX_MONTHS 0x13
131
#define MAX_DAYS 0x32
132
148
void
initialize_DS1337
(
unsigned
char
crystal_frequency_MHz,
unsigned
int
baud_rate_KHz);
149
150
151
164
signed
char
set_seconds_RTCC
(
unsigned
char
seconds);
165
166
174
unsigned
char
get_seconds_RTCC
(
void
);
175
176
189
signed
char
set_minutes_RTCC
(
unsigned
char
minutes);
190
191
199
unsigned
char
get_minutes_RTCC
(
void
);
200
201
214
signed
char
set_hours_RTCC
(
unsigned
char
hours);
215
216
224
unsigned
char
get_hours_RTCC
(
void
);
225
226
233
unsigned
char
*
get_time_seconds_RTCC
(
void
);
234
235
242
unsigned
char
*
get_time_RTCC
(
void
);
243
244
257
signed
char
set_days_RTCC
(
unsigned
char
days);
258
259
267
unsigned
char
get_days_RTCC
(
void
);
268
269
270
283
signed
char
set_months_RTCC
(
unsigned
char
months);
284
285
293
unsigned
char
get_months_RTCC
(
void
);
294
295
309
signed
char
set_years_RTCC
(
unsigned
char
years);
310
311
319
unsigned
char
get_years_RTCC
(
void
);
320
321
322
329
unsigned
char
*
get_date_RTCC
(
void
);
330
331
348
signed
char
set_seconds_alarm_RTCC
(
unsigned
char
seconds,
unsigned
char
alarm_enable);
349
366
signed
char
set_minutes_alarm_RTCC
(
unsigned
char
minutes,
unsigned
char
alarm_enable);
367
368
385
signed
char
set_hours_alarm_RTCC
(
unsigned
char
hours,
unsigned
char
alarm_enable);
386
387
404
signed
char
set_days_alarm_RTCC
(
unsigned
char
days,
unsigned
char
alarm_enable);
405
406
417
signed
char
enable_alarm_interrupt_RTCC
(
void
);
418
419
430
signed
char
disable_alarm_interrupt_RTCC
(
void
);
431
432
441
unsigned
char
is_alarm_ON_RTCC
(
void
);
442
443
455
signed
char
increment_minutes_RTCC
(
void
);
456
457
469
signed
char
increment_hours_RTCC
(
void
);
470
471
483
signed
char
increment_years_RTCC
(
void
);
484
485
497
signed
char
increment_months_RTCC
(
void
);
498
499
512
signed
char
increment_days_RTCC
(
void
);
513
514
515
#endif
516
LaurTec_PIC_libraries_v_3.2.0
inc
DS1337.h
Generated on Fri Mar 14 2014 19:47:30 for PIC18 LaurTec Library by
1.8.3.1