PIC18 LaurTec Library
3.3.1
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.1
6
Created on Date : 02/02/2013
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 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 RTCC_WRITE_ADD 0xD0
70
71
//**************************************************
72
// Definition of Day constants (Italian, English)
73
//**************************************************
74
75
// Italian
76
#define RTCC_DO 0x00
77
#define RTCC_LU 0x01
78
#define RTCC_MA 0x02
79
#define RTCC_ME 0x03
80
#define RTCC_GI 0x04
81
#define RTCC_VE 0x05
82
#define RTCC_SA 0x06
83
84
// English
85
#define RTCC_SU 0x00
86
#define RTCC_MO 0x01
87
#define RTCC_TU 0x02
88
#define RTCC_WE 0x03
89
#define RTCC_TR 0x04
90
#define RTCC_FR 0x05
91
#define RTCC_SA 0x06
92
93
94
95
//**************************************************
96
// Standard Constants
97
// enable value for the alarm bit
98
//**************************************************
99
100
#define RTCC_ENABLE_ON 0b00000000
101
#define RTCC_ENABLE_OFF 0b10000000
102
103
104
//**************************************************
105
// Address constants
106
//**************************************************
107
108
#define RTCC_SECONDS_ADDR 0x00
109
#define RTCC_MINUTES_ADDR 0x01
110
#define RTCC_HOURS_ADDR 0x02
111
#define RTCC_DAYS_ADDR 0x04
112
#define RTCC_MONTHS_ADDR 0x05
113
#define RTCC_YEARS_ADDR 0x06
114
#define RTCC_SECONDS_ALARM_ADDR 0x07
115
#define RTCC_MINUTS_ALARM_ADDR 0x08
116
#define RTCC_HOURS_ALARM_ADDR 0x09
117
#define RTCC_DAYS_ALARM_ADDR 0x0A
118
#define RTCC_MINUTS_ALARM_2_ADDR 0x0B
119
#define RTCC_HOURS_ALARM_2_ADDR 0x0C
120
#define RTCC_DAYS_ALARM_2_ADDR 0x0D
121
#define RTCC_CONTROL_REG_1_ADDR 0x0E
122
#define RTCC_CONTROL_REG_2_ADDR 0x0F
123
124
//**************************************************
125
// Limits constants
126
//**************************************************
127
#define RTCC_MAX_MINUTES 0x60
128
#define RTCC_MAX_HOURS 0x24
129
#define RTCC_MAX_YEARS 0xA0
130
#define RTCC_MAX_MONTHS 0x13
131
#define RTCC_MAX_DAYS 0x32
132
148
void
DS1337_initialize
(
unsigned
char
crystal_frequency_MHz,
unsigned
int
baud_rate_KHz);
149
#define initialize_DS1337 DS1337_initialize
150
151
164
signed
char
RTCC_set_seconds
(
unsigned
char
seconds);
165
#define set_seconds_RTCC RTCC_set_seconds
166
167
175
unsigned
char
RTCC_get_seconds
(
void
);
176
#define get_seconds_RTCC RTCC_get_seconds
177
178
191
signed
char
RTCC_set_minutes
(
unsigned
char
minutes);
192
#define set_minutes_RTCC RTCC_set_minutes
193
201
unsigned
char
get_minutes_RTCC
(
void
);
202
#define get_minutes_RTCC RTCC_get_minutes
203
204
217
signed
char
RTCC_set_hours
(
unsigned
char
hours);
218
#define set_hours_RTCC RTCC_set_hours
219
220
228
unsigned
char
RTCC_get_hours
(
void
);
229
#define get_hours_RTCC RTCC_get_hours
230
231
238
unsigned
char
*
RTCC_get_time_seconds
(
void
);
239
#define get_time_seconds_RTCC RTCC_get_time_seconds
240
241
248
unsigned
char
*
RTCC_get_time
(
void
);
249
#define get_time_RTCC RTCC_get_time
250
251
264
signed
char
RTCC_set_days
(
unsigned
char
days);
265
#define set_days_RTCC RTCC_set_days
266
267
275
unsigned
char
RTCC_get_days
(
void
);
276
#define get_days_RTCC RTCC_get_days
277
278
279
292
signed
char
RTCC_set_months
(
unsigned
char
months);
293
#define set_months_RTCC RTCC_set_months
294
295
303
unsigned
char
RTCC_get_months
(
void
);
304
#define get_months_RTCC RTCC_get_months
305
306
320
signed
char
RTCC_set_years
(
unsigned
char
years);
321
#define set_years_RTCC RTCC_set_years
322
323
331
unsigned
char
RTCC_get_years
(
void
);
332
#define get_years_RTCC RTCC_get_years
333
334
335
342
unsigned
char
*
RTCC_get_date
(
void
);
343
#define get_date_RTCC RTCC_get_date
344
345
362
signed
char
RTCC_set_seconds_alarm
(
unsigned
char
seconds,
unsigned
char
alarm_enable);
363
#define set_seconds_alarm_RTCC RTCC_set_seconds_alarm
364
381
signed
char
RTCC_set_minutes_alarm
(
unsigned
char
minutes,
unsigned
char
alarm_enable);
382
#define set_minutes_alarm_RTCC RTCC_set_minutes_alarm
383
384
401
signed
char
RTCC_set_hours_alarm
(
unsigned
char
hours,
unsigned
char
alarm_enable);
402
#define set_hours_alarm_RTCC RTCC_set_hours_alarm
403
420
signed
char
RTCC_set_days_alarm
(
unsigned
char
days,
unsigned
char
alarm_enable);
421
#define set_days_alarm_RTCC RTCC_set_days_alarm
422
423
434
signed
char
RTCC_enable_alarm_interrupt
(
void
);
435
#define enable_alarm_interrupt_RTCC RTCC_enable_alarm_interrupt
436
437
448
signed
char
RTCC_disable_alarm_interrupt
(
void
);
449
#define disable_alarm_interrupt_RTCC RTCC_disable_alarm_interrupt
450
451
460
unsigned
char
RTCC_is_alarm_ON
(
void
);
461
#define is_alarm_ON_RTCC RTCC_is_alarm_ON
462
463
475
signed
char
RTCC_increment_minutes
(
void
);
476
#define increment_minutes_RTCC RTCC_increment_minutes
477
478
490
signed
char
RTCC_increment_hours
(
void
);
491
#define increment_hours_RTCC RTCC_increment_hours
492
493
505
signed
char
RTCC_increment_years
(
void
);
506
#define increment_years_RTCC RTCC_increment_years
507
508
520
signed
char
RTCC_increment_months
(
void
);
521
#define increment_months_RTCC RTCC_increment_months
522
523
536
signed
char
RTCC_increment_days
(
void
);
537
#define increment_days_RTCC RTCC_increment_days
538
539
540
#endif
541
LaurTec_PIC_libraries_v_3.3.1
inc
DS1337.h
Generated on Mon Jan 25 2016 20:51:56 for PIC18 LaurTec Library by
1.8.3.1