Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
MCP79412RTC/src/MCP79412RTC.h at boxlambda · epsilon537/MCP79412RTC · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
epsilon537
/
MCP79412RTC
Public
forked from
JChristensen/MCP79412RTC
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Files
Expand file tree
boxlambda
Breadcrumbs
MCP79412RTC
/
src
/
MCP79412RTC.h
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
105 lines (93 loc) · 3.37 KB
boxlambda
Breadcrumbs
MCP79412RTC
/
src
/
MCP79412RTC.h
Copy path
Top
File metadata and controls
Code
Blame
105 lines (93 loc) · 3.37 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//
Arduino MCP79412RTC Library
//
https://github.com/JChristensen/MCP79412RTC
//
Copyright (C) 2018 by Jack Christensen and licensed under
//
GNU GPL v3.0, https://www.gnu.org/licenses/gpl.html
//
//
Arduino library for the Microchip MCP7941x Real-Time Clocks.
//
Requires PJRC's improved version of the Arduino Time Library,
//
https://playground.arduino.cc/Code/Time
//
https://github.com/PaulStoffregen/Time
//
//
For AVR architecture, an MCP79412RTC object named RTC is instantiated
//
by the library and I2C initialization occurs in the constructor;
//
this is for backwards compatibility.
//
For other architectures, the user needs to instantiate a MCP79412RTC
//
object and optionally initialize the I2C bus by calling
//
MCP79412RTC::begin(). The constructor has an optional bool parameter
//
to indicate whether I2C initialization should occur in the
//
constructor; this parameter defaults to true if not given.
#
ifndef
MCP79412RTC_H_INCLUDED
#
define
MCP79412RTC_H_INCLUDED
#
include
<
TimeLib.h
>
//
https://github.com/PaulStoffregen/Time
#
include
<
stdint.h
>
typedef
uint8_t
byte;
//
Alarm types for use with the enableAlarm() function
enum
{
ALM_MATCH_SECONDS
,
ALM_MATCH_MINUTES
,
ALM_MATCH_HOURS
,
ALM_MATCH_DAY
,
//
triggers alarm at midnight
ALM_MATCH_DATE
,
ALM_RESERVED_5
,
//
do not use
ALM_RESERVED_6
,
//
do not use
ALM_MATCH_DATETIME
,
ALM_DISABLE
};
//
Square-wave output frequencies for use with squareWave() function
enum
{
SQWAVE_1_HZ
,
SQWAVE_4096_HZ
,
SQWAVE_8192_HZ
,
SQWAVE_32768_HZ
,
SQWAVE_NONE
};
//
constants for use with alarm functions
#
define
ALARM_0
0
#
define
ALARM_1
1
class
MCP79412RTC
{
public:
MCP79412RTC
(
bool
initI2C =
true
);
void
begin
();
static
time_t
get
();
static
void
set
(
time_t
t);
static
bool
read
(tmElements_t &tm);
static
void
write
(tmElements_t &tm);
void
sramWrite
(byte addr, byte value);
void
sramWrite
(byte addr, byte *values, byte nBytes);
byte
sramRead
(byte addr);
void
sramRead
(byte addr, byte *values, byte nBytes);
void
eepromWrite
(byte addr, byte value);
void
eepromWrite
(byte addr, byte *values, byte nBytes);
byte
eepromRead
(byte addr);
void
eepromRead
(byte addr, byte *values, byte nBytes);
int
calibRead
();
void
calibWrite
(
int
value);
void
idRead
(byte *uniqueID);
void
getEUI64
(byte *uniqueID);
bool
powerFail
(
time_t
*powerDown,
time_t
*powerUp);
void
squareWave
(
uint8_t
freq);
void
setAlarm
(
uint8_t
alarmNumber,
time_t
alarmTime);
void
enableAlarm
(
uint8_t
alarmNumber,
uint8_t
alarmType);
bool
alarm
(
uint8_t
alarmNumber);
void
out
(
bool
level);
void
alarmPolarity
(
bool
polarity);
bool
isRunning
();
void
vbaten
(
bool
enable);
private:
static
void
ramWrite
(byte addr, byte value);
static
void
ramWrite
(byte addr, byte *values, byte nBytes);
static
byte
ramRead
(byte addr);
static
void
ramRead
(byte addr, byte *values, byte nBytes);
static
byte
eepromWait
();
static
uint8_t
dec2bcd
(
uint8_t
num);
static
uint8_t
bcd2dec
(
uint8_t
num);
};
extern
MCP79412RTC
RTC
;
#
ifndef
_BV
#
define
_BV
(
bit
) (
1
<< (bit))
#
endif
#
ifndef
BUFFER_LENGTH
//
a horrible and limiting kludge for samd (arduino zero)
#
define
BUFFER_LENGTH
32
#
endif
#
endif
You can’t perform that action at this time.