-
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 pcf8523 interrupts #124
Open
simzes
wants to merge
11
commits into
adafruit:master
Choose a base branch
from
simzes:add-pcf8523-interrupts
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.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ce012fe
Adding support for timers and their interrupts for the PCF8523.
2e573ff
Adding theory of operation documentation section to main README.md.
973a6ed
Adding examples for setting a timer, and for monitoring the INT pin.
cb2a7c1
Removed bit macro
8d1ef8b
Move of timer and interrupt details lookup table and macro to header
a402ae4
Updated moved table with const/extern
ae98b23
Moved CLKOUT_DIS to constants, renamed with pcf partname
963a154
Documentation fixes for doxygen compatibility
ac3f180
Removed clock frequency enum already defined in merge
948eb8e
Renaming register macros to match convention
8512770
Rephrased TimerState as class instead of struct
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
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
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,55 @@ | ||
/** | ||
* Sets a timer for 10 seconds, and watches a pin (MONITOR_PIN) for | ||
* its interrupt signal. | ||
* | ||
* The RTC's INT line is pulled down when the timer goes off and the | ||
* interrupt is active. | ||
*/ | ||
#include <Wire.h> | ||
#include "RTClib.h" | ||
|
||
#define MONITOR_PIN 5 | ||
|
||
RTC_PCF8523 rtc; | ||
|
||
void setup () { | ||
Serial.begin(9600); | ||
if (! rtc.begin()) { | ||
Serial.println("Couldn't find RTC"); | ||
while (1); | ||
} | ||
|
||
pinMode(MONITOR_PIN, INPUT_PULLUP); | ||
|
||
Pcf8523TimerState state = Pcf8523TimerState( | ||
10, // timer value | ||
PCF8523_FrequencySecond, // timer frequency | ||
true, // timer set to run | ||
false, // timer interrupt flag (when timer has gone off) | ||
true // timer flag -> signal enable | ||
); | ||
|
||
rtc.write_timer(PCF8523_Timer_Countdown_B, state); | ||
} | ||
|
||
void loop () { | ||
Pcf8523TimerState state = rtc.read_timer(PCF8523_Timer_Countdown_B); | ||
Serial.print("timer value: "); | ||
Serial.print(state.value, DEC); | ||
Serial.print(", enabled: "); | ||
Serial.print(state.enabled ? "yes": "no"); | ||
Serial.print(", freq: "); | ||
Serial.print(state.freq, DEC); | ||
Serial.println(); | ||
Serial.print("irupt flag: "); | ||
Serial.print(state.irupt_flag, DEC); | ||
Serial.print(", enabled: "); | ||
Serial.print(state.irupt_enabled, DEC); | ||
Serial.println(); | ||
|
||
Serial.print("Interrupt pin: "); | ||
Serial.println(digitalRead(MONITOR_PIN) ? "HIGH": "LOW"); | ||
|
||
Serial.println(); | ||
delay(1000); | ||
} |
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.
This is for consistency with the other examples and also, more importantly, in order to avoid undefined behavior.