LTlib LaurTec Library
4.0.0 Beta
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
DS1337.h
Go to the documentation of this file.
1
/*******************************************************************************
2
3
Author : Mauro Laurenti
4
Version : 1.2
5
Created on Date : 02/02/2013
6
Last update : 29/11/2015
7
8
CopyRight 2006-2015 all rights are reserved
9
10
********************************************************
11
SOFTWARE LICENSE AGREEMENT
12
********************************************************
13
14
The usage of the supplied software imply the acceptance of the following license.
15
16
The software supplied herewith by Mauro Laurenti (the Author) is intended for
17
use solely and exclusively on Microchip PIC Microcontroller (registered mark).
18
The software is owned by the Author, and is protected under applicable
19
copyright laws. All rights are reserved.
20
Any use in violation of the foregoing restrictions may subject the
21
user to criminal sanctions under applicable laws, as well as to civil liability
22
for the breach of the terms and conditions of this license.
23
Commercial use is forbidden without a written acknowledgement with the Author.
24
Personal or educational use is allowed if the application containing the
25
following software doesn't aim to commercial use or monetary earning of any kind.
26
27
THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES,
28
WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
29
TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
30
PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE AUTHOR SHALL NOT,
31
IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
32
CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
33
34
********************************************************
35
PURPOSES
36
********************************************************
37
38
This library supports the Real Time Clock Calendar DS1337 or compatible
39
devices. The library is kept compatible with the PCF8563
40
41
The following functions have been added:
42
43
set_seconds_alarm_RTCC (seconds associated to the first alarm)
44
45
The second alarm is not handled but it can be easily implemented.
46
47
*******************************************************************************/
48
49
50
#ifndef LTLIB_DS1337_H
51
#define LTLIB_DS1337_H
52
53
#ifdef __XC8
54
#include <xc.h>
55
#endif
56
57
//*****************************************
58
// Library Test
59
//*****************************************
60
#include "
LTlib.h
"
61
62
#ifndef LTLIB_I2C_MODULE_H
63
#error The DS1337 Library requires the "module_I2C" library to be included.
64
#endif
65
66
67
//*****************************************
68
// I2C Module Switch
69
//*****************************************
70
#define DS1337_I2C_MODULE_1
71
//#define DS1337_I2C_MODULE_2
72
73
#ifdef DS1337_I2C_MODULE_1
74
#define DS1337_I2C_open I2C1_open
75
#define DS1337_I2C_baud_rate I2C1_baud_rate
76
#define DS1337_I2C_write_byte_to_external_device I2C1_write_byte_to_external_device
77
#define DS1337_I2C_read_byte_from_external_device I2C1_read_byte_from_external_device
78
#endif
79
80
#ifdef DS1337_I2C_MODULE_2
81
#define DS1337_I2C_open I2C2_open
82
#define DS1337_I2C_baud_rate I2C2_baud_rate
83
#define DS1337_I2C_write_byte_to_external_device I2C2_write_byte_to_external_device
84
#define DS1337_I2C_read_byte_from_external_device I2C2_read_byte_from_external_device
85
#endif
86
87
88
//**************************************************
89
// you must change this address if
90
// you change the device.
91
//**************************************************
92
93
#define RTCC_WRITE_ADD 0xD0
94
95
//**************************************************
96
// Definition of Day constants (Italian, English)
97
//**************************************************
98
99
// Italian
100
#define RTCC_DO 0x00
101
#define RTCC_LU 0x01
102
#define RTCC_MA 0x02
103
#define RTCC_ME 0x03
104
#define RTCC_GI 0x04
105
#define RTCC_VE 0x05
106
#define RTCC_SA 0x06
107
108
// English
109
#define RTCC_SU 0x00
110
#define RTCC_MO 0x01
111
#define RTCC_TU 0x02
112
#define RTCC_WE 0x03
113
#define RTCC_TR 0x04
114
#define RTCC_FR 0x05
115
#define RTCC_SA 0x06
116
117
118
119
//**************************************************
120
// Standard Constants
121
// enable value for the alarm bit
122
//**************************************************
123
124
#define RTCC_ENABLE_ON 0b00000000
125
#define RTCC_ENABLE_OFF 0b10000000
126
127
#define RTCC_ALARM_ENABLED 0b00000000
128
#define RTCC_ALARM_DISABLED 0b10000000
129
130
131
//**************************************************
132
// Address constants
133
//**************************************************
134
135
#define RTCC_SECONDS_ADDR 0x00
136
#define RTCC_MINUTES_ADDR 0x01
137
#define RTCC_HOURS_ADDR 0x02
138
#define RTCC_DAYS_ADDR 0x04
139
#define RTCC_MONTHS_ADDR 0x05
140
#define RTCC_YEARS_ADDR 0x06
141
#define RTCC_SECONDS_ALARM_ADDR 0x07
142
#define RTCC_MINUTS_ALARM_ADDR 0x08
143
#define RTCC_HOURS_ALARM_ADDR 0x09
144
#define RTCC_DAYS_ALARM_ADDR 0x0A
145
#define RTCC_MINUTS_ALARM_2_ADDR 0x0B
146
#define RTCC_HOURS_ALARM_2_ADDR 0x0C
147
#define RTCC_DAYS_ALARM_2_ADDR 0x0D
148
#define RTCC_CONTROL_REG_1_ADDR 0x0E
149
#define RTCC_CONTROL_REG_2_ADDR 0x0F
150
151
//**************************************************
152
// Limits constants
153
//**************************************************
154
#define RTCC_MAX_MINUTES 0x60
155
#define RTCC_MAX_HOURS 0x24
156
#define RTCC_MAX_YEARS 0xA0
157
#define RTCC_MAX_MONTHS 0x13
158
#define RTCC_MAX_DAYS 0x32
159
172
void
RTCC_initialize
(
unsigned
int
baud_rate_KHz);
173
#define initialize_RTTC RTCC_initialize
174
175
188
signed
char
RTCC_set_seconds
(
unsigned
char
seconds);
189
#define set_seconds_RTCC RTCC_set_seconds
190
191
199
unsigned
char
RTCC_get_seconds
(
void
);
200
#define get_seconds_RTCC RTCC_get_seconds
201
202
215
signed
char
RTCC_set_minutes
(
unsigned
char
minutes);
216
#define set_minutes_RTCC RTCC_set_minutes
217
225
unsigned
char
get_minutes_RTCC
(
void
);
226
#define get_minutes_RTCC RTCC_get_minutes
227
228
241
signed
char
RTCC_set_hours
(
unsigned
char
hours);
242
#define set_hours_RTCC RTCC_set_hours
243
244
252
unsigned
char
RTCC_get_hours
(
void
);
253
#define get_hours_RTCC RTCC_get_hours
254
255
262
unsigned
char
*
RTCC_get_time_seconds
(
void
);
263
#define get_time_seconds_RTCC RTCC_get_time_seconds
264
265
272
unsigned
char
*
RTCC_get_time
(
void
);
273
#define get_time_RTCC RTCC_get_time
274
275
288
signed
char
RTCC_set_days
(
unsigned
char
days);
289
#define set_days_RTCC RTCC_set_days
290
291
299
unsigned
char
RTCC_get_days
(
void
);
300
#define get_days_RTCC RTCC_get_days
301
302
303
316
signed
char
RTCC_set_months
(
unsigned
char
months);
317
#define set_months_RTCC RTCC_set_months
318
319
327
unsigned
char
RTCC_get_months
(
void
);
328
#define get_months_RTCC RTCC_get_months
329
330
344
signed
char
RTCC_set_years
(
unsigned
char
years);
345
#define set_years_RTCC RTCC_set_years
346
347
355
unsigned
char
RTCC_get_years
(
void
);
356
#define get_years_RTCC RTCC_get_years
357
358
359
366
unsigned
char
*
RTCC_get_date
(
void
);
367
#define get_date_RTCC RTCC_get_date
368
369
386
signed
char
RTCC_set_seconds_alarm
(
unsigned
char
seconds,
unsigned
char
alarm_enable);
387
#define set_seconds_alarm_RTCC RTCC_set_seconds_alarm
388
405
signed
char
RTCC_set_minutes_alarm
(
unsigned
char
minutes,
unsigned
char
alarm_enable);
406
#define set_minutes_alarm_RTCC RTCC_set_minutes_alarm
407
408
425
signed
char
RTCC_set_hours_alarm
(
unsigned
char
hours,
unsigned
char
alarm_enable);
426
#define set_hours_alarm_RTCC RTCC_set_hours_alarm
427
444
signed
char
RTCC_set_days_alarm
(
unsigned
char
days,
unsigned
char
alarm_enable);
445
#define set_days_alarm_RTCC RTCC_set_days_alarm
446
447
458
signed
char
RTCC_enable_alarm_interrupt
(
void
);
459
#define enable_alarm_interrupt_RTCC RTCC_enable_alarm_interrupt
460
461
472
signed
char
RTCC_disable_alarm_interrupt
(
void
);
473
#define disable_alarm_interrupt_RTCC RTCC_disable_alarm_interrupt
474
475
484
unsigned
char
RTCC_is_alarm_ON
(
void
);
485
#define is_alarm_ON_RTCC RTCC_is_alarm_ON
486
487
499
signed
char
RTCC_increment_minutes
(
void
);
500
#define increment_minutes_RTCC RTCC_increment_minutes
501
502
514
signed
char
RTCC_increment_hours
(
void
);
515
#define increment_hours_RTCC RTCC_increment_hours
516
517
529
signed
char
RTCC_increment_years
(
void
);
530
#define increment_years_RTCC RTCC_increment_years
531
532
544
signed
char
RTCC_increment_months
(
void
);
545
#define increment_months_RTCC RTCC_increment_months
546
547
560
signed
char
RTCC_increment_days
(
void
);
561
#define increment_days_RTCC RTCC_increment_days
562
563
564
#endif
565
LTlib_v_4.0.0
inc
DS1337.h
Generated on Sun Feb 21 2016 13:52:59 for LTlib LaurTec Library by
1.8.3.1