-
Notifications
You must be signed in to change notification settings - Fork 712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add rv 3032 c7 support #258
Open
alx2009
wants to merge
52
commits into
adafruit:master
Choose a base branch
from
alx2009:add-RV-3032-C7-support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,159
−4
Open
Changes from 38 commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
cdae247
Added new class RTC_RV3032C7 (based on RTC_DS3231) to RTClib.h
alx2009 9a90bdf
Added RTC_RV3032C7.cpp (based on RTC_DS3231.cpp)
alx2009 37e69bc
Implemented basic functions in RTC_RV3032C7.cpp (set/get time, temp.,…
alx2009 204a393
Added basic example (tested, works)
alx2009 fa00641
Added enum RV3032C7AlarmMode
alx2009 b6cede3
Moved RTC_RV-3032-C7 class after PFC8523
alx2009 13e2c7b
Updated Alarm definition in RTC_RV3032C7 (only 1 alarm)
alx2009 57e7533
Added enum RV3032C7EventType
alx2009 3eee698
Added RV3032C7EventType param to RTC_RV3032C7::setAlarm
alx2009 822d767
Fix RTC_RV3032C7.getTemperature()
alx2009 c582d35
Fixed spelling of RTC_RV3032C7_EV_PollClock
alx2009 a6e2f96
Implemented RTC_RV3032C7 alarm handling in RTC_RV3032C7.cpp
alx2009 e8f83de
moved RTC_RV3032C7 class before RTC_Millis
alx2009 61b59f4
implemented enable/disable/query CLKOUT in RTC_RV3032C7 class
alx2009 5ccf131
disabled EEPROM autorefresh in RV3032C7.begin()
alx2009 54adea4
Improved Doxigen comments for RV3032C7.cpp
alx2009 83194c9
Commented out debug statements in RV3032C7.cpp
alx2009 8ebf2a6
removed unsupported RV3032C7.write/readSqwPinMode()
alx2009 7a5f9b9
comments and formatting cleaup
alx2009 b4840ed
Fixed RV3032C7 Alarms (CLKF was not handled correctly)
alx2009 4924b10
Fixed RV3032C7 Power On flag, comments
alx2009 0603424
RV3032C7, minor change to comments
alx2009 df3b75f
Added example RV3032C7_alarm
alx2009 ac4c722
Updatede keywords including RV3032C7
alx2009 01f8820
Mentioned RV3032C7 in library.properties
alx2009 5cccbd0
Improved doxygen
alx2009 a778d02
Fixed clang formatting RTC_RV3032C7.cpp
alx2009 55c0cba
Fixed clang formatting for RV3032C7 in RTClib.h
alx2009 9d55296
Doxygen fix in RTC_RV3032C7.cpp
alx2009 d153478
Update RTC_RV3032C7.cpp
alx2009 b1eb37a
RTC_RV3032C7.begin() now activates switchover to backup power
alx2009 9ff8a39
Minor improvement to doxygen for RTC_RV3032-C7.lostPower()
alx2009 67148a7
Minor update to RV3032C7_alarm.ino example
alx2009 2e617b9
fixed a bug in RTC_RV3032C7::disableAlarm() causing INT to remain active
alx2009 a01813a
Delete src.ino
alx2009 cd6216a
Retry autodetect in RV3032C7.begin() if chip unresponsive
alx2009 c203971
Minor update to comment text
alx2009 916c849
Removed unused variable
alx2009 54acc50
Update src/RTC_RV3032C7.cpp boolean -> bool
alx2009 3419921
Merge branch 'adafruit:master' into add-RV-3032-C7-support
alx2009 d4ed07b
RV3032C7: Add support for fetching alarm values
alx2009 d5446c4
Merge branch 'adafruit:master' into add-RV-3032-C7-support
alx2009 1d66ee3
RV3032C7: Initial implementation of Periodic Countdown Timer
alx2009 b80ef44
RTC_RV3032C7: complete support for Periodic Countdown Timer
alx2009 53a1f53
RTC_RV3032C7: Added deconfigureAllTimers()
alx2009 903f36a
Fixed Clang/Doxygen issues
alx2009 e415395
RV3032C7: spelling of RV3032C7TimerClockFreq enum
alx2009 9a33dfe
RV3032C7: Added new keywords
alx2009 87bff46
RV3032C7: correct initial capital for countdownTimerFired
alx2009 8ef285d
RV3032C7 Minor formatting correction in example
alx2009 3d79fd7
RV3032C7 Bug fixes affecting Timers
alx2009 eac0654
RV3032C7: new example showing timers usage
alx2009 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// Date and time functions using a RV3032C7 RTC connected via I2C and Wire lib | ||
#include "RTClib.h" | ||
|
||
RTC_RV3032C7 rtc; | ||
|
||
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; | ||
|
||
void setup () { | ||
Serial.begin(57600); | ||
|
||
#ifndef ESP8266 | ||
while (!Serial); // wait for serial port to connect. Needed for native USB | ||
#endif | ||
|
||
if (! rtc.begin()) { | ||
Serial.println("Couldn't find RTC"); | ||
Serial.flush(); | ||
while (1) delay(10); | ||
} | ||
|
||
if (rtc.lostPower()) { | ||
Serial.println("RTC lost power, let's set the time!"); | ||
// When time needs to be set on a new device, or after a power loss, the | ||
// following line sets the RTC to the date & time this sketch was compiled | ||
rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); | ||
// This line sets the RTC with an explicit date & time, for example to set | ||
// January 21, 2014 at 3am you would call: | ||
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0)); | ||
} | ||
|
||
// When time needs to be re-set on a previously configured device, the | ||
// following line sets the RTC to the date & time this sketch was compiled | ||
// rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); | ||
// This line sets the RTC with an explicit date & time, for example to set | ||
// January 21, 2014 at 3am you would call: | ||
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0)); | ||
} | ||
|
||
void loop () { | ||
DateTime now = rtc.now(); | ||
|
||
Serial.print(now.year(), DEC); | ||
Serial.print('/'); | ||
Serial.print(now.month(), DEC); | ||
Serial.print('/'); | ||
Serial.print(now.day(), DEC); | ||
Serial.print(" ("); | ||
Serial.print(daysOfTheWeek[now.dayOfTheWeek()]); | ||
Serial.print(") "); | ||
Serial.print(now.hour(), DEC); | ||
Serial.print(':'); | ||
Serial.print(now.minute(), DEC); | ||
Serial.print(':'); | ||
Serial.print(now.second(), DEC); | ||
Serial.println(); | ||
|
||
Serial.print(" since midnight 1/1/1970 = "); | ||
Serial.print(now.unixtime()); | ||
Serial.print("s = "); | ||
Serial.print(now.unixtime() / 86400L); | ||
Serial.println("d"); | ||
|
||
// calculate a date which is 7 days, 12 hours, 30 minutes, 6 seconds into the future | ||
DateTime future (now + TimeSpan(7,12,30,6)); | ||
|
||
Serial.print(" now + 7d + 12h + 30m + 6s: "); | ||
Serial.print(future.year(), DEC); | ||
Serial.print('/'); | ||
Serial.print(future.month(), DEC); | ||
Serial.print('/'); | ||
Serial.print(future.day(), DEC); | ||
Serial.print(' '); | ||
Serial.print(future.hour(), DEC); | ||
Serial.print(':'); | ||
Serial.print(future.minute(), DEC); | ||
Serial.print(':'); | ||
Serial.print(future.second(), DEC); | ||
Serial.println(); | ||
|
||
Serial.print("Temperature: "); | ||
Serial.print(rtc.getTemperature()); | ||
Serial.println(" C"); | ||
|
||
Serial.println(); | ||
delay(3000); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* Example implementation of an alarm using RV3032C7 | ||
* | ||
* VCC and GND of RTC should be connected to some power source | ||
* SDA, SCL of RTC should be connected to SDA, SCL of arduino | ||
* INT should be connected to RTC_INTERRUPT_PIN | ||
* RTC_INTERRUPT_PIN needs to work with interrupts | ||
*/ | ||
|
||
#include <RTClib.h> | ||
// #include <Wire.h> | ||
|
||
RTC_RV3032C7 rtc; | ||
|
||
// the pin that is connected to INT | ||
#define RTC_INTERRUPT_PIN 2 | ||
|
||
void setup() { | ||
Serial.begin(9600); | ||
|
||
// initializing the rtc | ||
if(!rtc.begin()) { | ||
Serial.println("Couldn't find RTC!"); | ||
Serial.flush(); | ||
while (1) delay(10); | ||
} | ||
|
||
if(rtc.lostPower()) { | ||
// this will adjust to the date and time at compilation | ||
rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); | ||
} | ||
|
||
//we don't need the CLKOUT Pin, so disable it | ||
rtc.disableClkOut(); | ||
|
||
// Making it so, that the alarm will trigger an interrupt | ||
pinMode(RTC_INTERRUPT_PIN, INPUT_PULLUP); // pullup is needed with RV3032C7 INT pin | ||
attachInterrupt(digitalPinToInterrupt(RTC_INTERRUPT_PIN), onAlarm, FALLING); | ||
|
||
// set alarm flag to false (so alarm didn't happen so far) | ||
// if not done, this easily leads to problems, as chip register aren't reset on reboot/recompile | ||
rtc.clearAlarm(); | ||
rtc.disableAlarm(); | ||
|
||
// schedule an alarm 60 seconds in the future | ||
if(!rtc.setAlarm( | ||
rtc.now() + TimeSpan(60), | ||
RV3032C7_A_Minute // this mode triggers the alarm when the minutes match. See Doxygen for other options | ||
)) { | ||
Serial.println("Error, alarm wasn't set!"); | ||
}else { | ||
Serial.println("Alarm will happen within 60 seconds!"); | ||
} | ||
} | ||
|
||
void loop() { | ||
// print current time | ||
char date[10] = "hh:mm:ss"; | ||
rtc.now().toString(date); | ||
Serial.print(date); | ||
// the value at INT-Pin (because of pullup 1 means no alarm) | ||
Serial.print(" INT: "); | ||
Serial.print(digitalRead(RTC_INTERRUPT_PIN)); | ||
// whether a alarm happened happened | ||
Serial.print(" Alarm: "); | ||
Serial.println(rtc.alarmFired()); | ||
// status register values (see https://www.microcrystal.com/fileadmin/Media/Products/RTC/App.Manual/RV-3028-C7_App-Manual.pdf page 22) | ||
// Serial.print(" Control: 0d"); | ||
// Serial.println(read_i2c_register(0x51, 0xd), BIN); | ||
|
||
// resetting INT and alarm 1 flag | ||
// using setAlarm, the next alarm could now be configured | ||
if(rtc.alarmFired()) { | ||
rtc.clearAlarm(); | ||
Serial.println(); Serial.println("Alarm cleared"); Serial.println(); | ||
} | ||
|
||
delay(2000); | ||
} | ||
|
||
void onAlarm() { | ||
Serial.println("Alarm occured!"); | ||
} | ||
|
||
/*static uint8_t read_i2c_register(uint8_t addr, uint8_t reg) { | ||
Wire.beginTransmission(addr); | ||
Wire.write((byte)reg); | ||
Wire.endTransmission(); | ||
|
||
Wire.requestFrom(addr, (byte)1); | ||
return Wire.read(); | ||
}*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the Arduino Library Specification, within keywords.txt
Oh, wait, the three keywords just above your addition already have this problem... This will have to be fixed, maybe in another pull request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, it was a copy/paste then modify... but I should have noticed that the keyword was not recognized in the Arduino GUI! I think I will correct that in the next update.