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
MCP7940.h
Go to the documentation of this file.
1
/*******************************************************************************
2
3
Author : Mauro Laurenti
4
Version : 1.0
5
Created on Date : 23/9/2015
6
Last update : 23/9/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 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
#define RTCC_WRITE_ADD 0b11011110
69
70
//**************************************************
71
// Definition of Day constants (Italian, English)
72
//**************************************************
73
74
// Italian
75
#define RTCC_DO 0x00
76
#define RTCC_LU 0x01
77
#define RTCC_MA 0x02
78
#define RTCC_ME 0x03
79
#define RTCC_GI 0x04
80
#define RTCC_VE 0x05
81
#define RTCC_SA 0x06
82
83
// English
84
#define RTCC_SU 0x00
85
#define RTCC_MO 0x01
86
#define RTCC_TU 0x02
87
#define RTCC_WE 0x03
88
#define RTCC_TR 0x04
89
#define RTCC_FR 0x05
90
#define RTCC_SA 0x06
91
92
93
94
//**************************************************
95
// Standard Constants
96
// enable value for the alarm bit
97
//**************************************************
98
99
#define RTCC_ENABLE_ON 0b00000000
100
#define RTCC_ENABLE_OFF 0b10000000
101
102
103
//**************************************************
104
// Address constants
105
//**************************************************
106
107
#define RTCC_SECONDS_ADDR 0x00
108
#define RTCC_MINUTES_ADDR 0x01
109
#define RTCC_HOURS_ADDR 0x02
110
#define RTCC_DAYS_ADDR 0x04
111
#define RTCC_MONTHS_ADDR 0x05
112
#define RTCC_YEARS_ADDR 0x06
113
#define RTCC_SECONDS_ALARM_ADDR 0x0A
114
#define RTCC_MINUTS_ALARM_ADDR 0x0B
115
#define RTCC_HOURS_ALARM_ADDR 0x0C
116
#define RTCC_DAYS_ALARM_ADDR 0x0E
117
#define RTCC_SECONDS_ALARM_2_ADDR 0x11
118
#define RTCC_MINUTS_ALARM_2_ADDR 0x12
119
#define RTCC_HOURS_ALARM_2_ADDR 0x13
120
#define RTCC_DAYS_ALARM_2_ADDR 0x15
121
#define RTCC_CONFIGURATION_REG_ADDR 0x07
122
#define RTCC_ALARM_CONTROL_REG_1_ADDR 0x0D
123
#define RTCC_ALARM_CONTROL_REG_2_ADDR 0x14
124
125
//**************************************************
126
// Limits constants
127
//**************************************************
128
#define RTCC_MAX_MINUTES 0x60
129
#define RTCC_MAX_HOURS 0x24
130
#define RTCC_MAX_YEARS 0xA0
131
#define RTCC_MAX_MONTHS 0x13
132
#define RTCC_MAX_DAYS 0x32
133
149
void
MCP7940_initialize
(
unsigned
char
crystal_frequency_MHz,
unsigned
int
baud_rate_KHz);
150
#define initialize_MCP7940 MCP7940_initialize
151
152
165
signed
char
RTCC_set_seconds
(
unsigned
char
seconds);
166
#define set_seconds_RTCC RTCC_set_seconds
167
168
176
unsigned
char
RTCC_get_seconds
(
void
);
177
#define get_seconds_RTCC RTCC_get_seconds
178
179
192
signed
char
RTCC_set_minutes
(
unsigned
char
minutes);
193
#define set_minutes_RTCC RTCC_set_minutes
194
202
unsigned
char
get_minutes_RTCC
(
void
);
203
#define get_minutes_RTCC RTCC_get_minutes
204
205
218
signed
char
RTCC_set_hours
(
unsigned
char
hours);
219
#define set_hours_RTCC RTCC_set_hours
220
221
229
unsigned
char
RTCC_get_hours
(
void
);
230
#define get_hours_RTCC RTCC_get_hours
231
232
239
unsigned
char
*
RTCC_get_time_seconds
(
void
);
240
#define get_time_seconds_RTCC RTCC_get_time_seconds
241
242
249
unsigned
char
*
RTCC_get_time
(
void
);
250
#define get_time_RTCC RTCC_get_time
251
252
265
signed
char
RTCC_set_days
(
unsigned
char
days);
266
#define set_days_RTCC RTCC_set_days
267
268
276
unsigned
char
RTCC_get_days
(
void
);
277
#define get_days_RTCC RTCC_get_days
278
279
280
293
signed
char
RTCC_set_months
(
unsigned
char
months);
294
#define set_months_RTCC RTCC_set_months
295
296
304
unsigned
char
RTCC_get_months
(
void
);
305
#define get_months_RTCC RTCC_get_months
306
307
321
signed
char
RTCC_set_years
(
unsigned
char
years);
322
#define set_years_RTCC RTCC_set_years
323
324
332
unsigned
char
RTCC_get_years
(
void
);
333
#define get_years_RTCC RTCC_get_years
334
335
336
343
unsigned
char
*
RTCC_get_date
(
void
);
344
#define get_date_RTCC RTCC_get_date
345
346
363
signed
char
RTCC_set_seconds_alarm
(
unsigned
char
seconds,
unsigned
char
alarm_enable);
364
#define set_seconds_alarm_RTCC RTCC_set_seconds_alarm
365
382
signed
char
RTCC_set_minutes_alarm
(
unsigned
char
minutes,
unsigned
char
alarm_enable);
383
#define set_minutes_alarm_RTCC RTCC_set_minutes_alarm
384
385
402
signed
char
RTCC_set_hours_alarm
(
unsigned
char
hours,
unsigned
char
alarm_enable);
403
#define set_hours_alarm_RTCC RTCC_set_hours_alarm
404
421
signed
char
RTCC_set_days_alarm
(
unsigned
char
days,
unsigned
char
alarm_enable);
422
#define set_days_alarm_RTCC RTCC_set_days_alarm
423
424
435
signed
char
RTCC_enable_alarm_interrupt
(
void
);
436
#define enable_alarm_interrupt_RTCC RTCC_enable_alarm_interrupt
437
438
449
signed
char
RTCC_disable_alarm_interrupt
(
void
);
450
#define disable_alarm_interrupt_RTCC RTCC_disable_alarm_interrupt
451
452
461
unsigned
char
RTCC_is_alarm_ON
(
void
);
462
#define is_alarm_ON_RTCC RTCC_is_alarm_ON
463
464
476
signed
char
RTCC_increment_minutes
(
void
);
477
#define increment_minutes_RTCC RTCC_increment_minutes
478
479
491
signed
char
RTCC_increment_hours
(
void
);
492
#define increment_hours_RTCC RTCC_increment_hours
493
494
506
signed
char
RTCC_increment_years
(
void
);
507
#define increment_years_RTCC RTCC_increment_years
508
509
521
signed
char
RTCC_increment_months
(
void
);
522
#define increment_months_RTCC RTCC_increment_months
523
524
537
signed
char
RTCC_increment_days
(
void
);
538
#define increment_days_RTCC RTCC_increment_days
539
540
541
#endif
542
LaurTec_PIC_libraries_v_3.3.1
inc
MCP7940.h
Generated on Mon Jan 25 2016 20:51:56 for PIC18 LaurTec Library by
1.8.3.1