LTlib LaurTec Library
4.0.1
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
MCP7940.h
Go to the documentation of this file.
1
/*******************************************************************************
2
3
Author : Mauro Laurenti
4
Version : 1.0
5
Created on Date : 13/03/2015
6
Last update : 13/03/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 MCP7940 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
Some flexibility has been removed to keep compatibility with
46
the other RTCC libraries.
47
48
*******************************************************************************/
49
50
51
#ifndef LTLIB_MCP7940_H
52
#define LTLIB_MCP7940_H
53
54
55
#ifdef __XC8
56
#include <xc.h>
57
#endif
58
59
60
//*****************************************
61
// Library Test
62
//*****************************************
63
64
#include "
LTlib.h
"
65
66
#ifndef LTLIB_I2C_MODULE_H
67
#error The MCP7940 Library requires the "module_I2C" library to be included.
68
#endif
69
70
71
//*****************************************
72
// I2C Module Switch
73
//*****************************************
74
#define MCP7940_I2C_MODULE_1
75
//#define MCP7940_I2C_MODULE_2
76
77
#ifdef MCP7940_I2C_MODULE_1
78
#define MCP7940_I2C_open I2C1_open
79
#define MCP7940_I2C_baud_rate I2C1_baud_rate
80
#define MCP7940_I2C_write_byte_to_external_device I2C1_write_byte_to_external_device
81
#define MCP7940_I2C_read_byte_from_external_device I2C1_read_byte_from_external_device
82
#endif
83
84
#ifdef PCF8563_I2C_MODULE_2
85
#define MCP7940_I2C_open I2C2_open
86
#define MCP7940_I2C_baud_rate I2C2_baud_rate
87
#define MCP7940_I2C_write_byte_to_external_device I2C2_write_byte_to_external_device
88
#define MCP7940_I2C_read_byte_from_external_device I2C2_read_byte_from_external_device
89
#endif
90
91
92
//**************************************************
93
// you must change this address if
94
// you change the device.
95
//**************************************************
96
#define RTCC_WRITE_ADD 0b11011110
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 Constants
124
// enable value for the alarm bit
125
//**************************************************
126
127
#define RTCC_ENABLE_ON 0b00000000
128
#define RTCC_ENABLE_OFF 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 0x0A
142
#define RTCC_MINUTES_ALARM_ADDR 0x0B
143
#define RTCC_HOURS_ALARM_ADDR 0x0C
144
#define RTCC_DAYS_ALARM_ADDR 0x0E
145
#define RTCC_SECONDS_ALARM_2_ADDR 0x11
146
#define RTCC_MINUTES_ALARM_2_ADDR 0x12
147
#define RTCC_HOURS_ALARM_2_ADDR 0x13
148
#define RTCC_DAYS_ALARM_2_ADDR 0x15
149
#define RTCC_CONFIGURATION_REG_ADDR 0x07
150
#define RTCC_ALARM_CONTROL_REG_1_ADDR 0x0D
151
#define RTCC_ALARM_CONTROL_REG_2_ADDR 0x14
152
153
//**************************************************
154
// Limits constants
155
//**************************************************
156
#define RTCC_MAX_MINUTES 0x60
157
#define RTCC_MAX_HOURS 0x24
158
#define RTCC_MAX_YEARS 0xA0
159
#define RTCC_MAX_MONTHS 0x13
160
#define RTCC_MAX_DAYS 0x32
161
177
void
RTCC_initialize
(
unsigned
int
baud_rate_KHz);
178
#define initialize_RTCC RTCC_initialize
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
230
unsigned
char
get_minutes_RTCC
(
void
);
231
#define get_minutes_RTCC RTCC_get_minutes
232
233
246
signed
char
RTCC_set_hours
(
unsigned
char
hours);
247
#define set_hours_RTCC RTCC_set_hours
248
249
257
unsigned
char
RTCC_get_hours
(
void
);
258
#define get_hours_RTCC RTCC_get_hours
259
260
267
unsigned
char
*
RTCC_get_time_seconds
(
void
);
268
#define get_time_seconds_RTCC RTCC_get_time_seconds
269
270
277
unsigned
char
*
RTCC_get_time
(
void
);
278
#define get_time_RTCC RTCC_get_time
279
280
293
signed
char
RTCC_set_days
(
unsigned
char
days);
294
#define set_days_RTCC RTCC_set_days
295
296
304
unsigned
char
RTCC_get_days
(
void
);
305
#define get_days_RTCC RTCC_get_days
306
307
308
321
signed
char
RTCC_set_months
(
unsigned
char
months);
322
#define set_months_RTCC RTCC_set_months
323
324
332
unsigned
char
RTCC_get_months
(
void
);
333
#define get_months_RTCC RTCC_get_months
334
335
349
signed
char
RTCC_set_years
(
unsigned
char
years);
350
#define set_years_RTCC RTCC_set_years
351
352
360
unsigned
char
RTCC_get_years
(
void
);
361
#define get_years_RTCC RTCC_get_years
362
363
364
371
unsigned
char
*
RTCC_get_date
(
void
);
372
#define get_date_RTCC RTCC_get_date
373
374
391
signed
char
RTCC_set_seconds_alarm
(
unsigned
char
seconds,
unsigned
char
alarm_enable);
392
#define set_seconds_alarm_RTCC RTCC_set_seconds_alarm
393
410
signed
char
RTCC_set_minutes_alarm
(
unsigned
char
minutes,
unsigned
char
alarm_enable);
411
#define set_minutes_alarm_RTCC RTCC_set_minutes_alarm
412
413
430
signed
char
RTCC_set_hours_alarm
(
unsigned
char
hours,
unsigned
char
alarm_enable);
431
#define set_hours_alarm_RTCC RTCC_set_hours_alarm
432
449
signed
char
RTCC_set_days_alarm
(
unsigned
char
days,
unsigned
char
alarm_enable);
450
#define set_days_alarm_RTCC RTCC_set_days_alarm
451
452
463
signed
char
RTCC_enable_alarm_interrupt
(
void
);
464
#define enable_alarm_interrupt_RTCC RTCC_enable_alarm_interrupt
465
466
477
signed
char
RTCC_disable_alarm_interrupt
(
void
);
478
#define disable_alarm_interrupt_RTCC RTCC_disable_alarm_interrupt
479
480
489
unsigned
char
RTCC_is_alarm_ON
(
void
);
490
#define is_alarm_ON_RTCC RTCC_is_alarm_ON
491
492
504
signed
char
RTCC_increment_minutes
(
void
);
505
#define increment_minutes_RTCC RTCC_increment_minutes
506
507
519
signed
char
RTCC_increment_hours
(
void
);
520
#define increment_hours_RTCC RTCC_increment_hours
521
522
534
signed
char
RTCC_increment_years
(
void
);
535
#define increment_years_RTCC RTCC_increment_years
536
537
549
signed
char
RTCC_increment_months
(
void
);
550
#define increment_months_RTCC RTCC_increment_months
551
552
565
signed
char
RTCC_increment_days
(
void
);
566
#define increment_days_RTCC RTCC_increment_days
567
568
569
#endif
570
LTlib_v_4.0.1
inc
MCP7940.h
Generated on Sat Mar 12 2016 11:01:40 for LTlib LaurTec Library by
1.8.3.1