Skip to content

Commit d67cdb1

Browse files
committed
Added standby mode method
1 parent c7d65d2 commit d67cdb1

File tree

5 files changed

+75
-1
lines changed

5 files changed

+75
-1
lines changed
+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
Simple RTC Alarm for Arduino Zero
3+
4+
Demonstrates the use an alarm to wake up an Arduino zero from Standby mode
5+
6+
This example code is in the public domain
7+
8+
http://arduino.cc/en/Tutorial/SleepRTCAlarm
9+
10+
created by Arturo Guadalupi
11+
17 Nov 2015
12+
*/
13+
14+
#include <RTCZero.h>
15+
16+
/* Create an rtc object */
17+
RTCZero rtc;
18+
19+
/* Change these values to set the current initial time */
20+
const uint8_t seconds = 0;
21+
const uint8_t minutes = 00;
22+
const uint8_t hours = 17;
23+
24+
/* Change these values to set the current initial date */
25+
const uint8_t day = 17;
26+
const uint8_t month = 11;
27+
const uint8_t year = 15;
28+
29+
void setup()
30+
{
31+
Serial.begin(115200);
32+
33+
rtc.begin();
34+
35+
rtc.setTime(hours, minutes, seconds);
36+
rtc.setDate(day, month, year);
37+
38+
rtc.setAlarmTime(17, 00, 10);
39+
rtc.enableAlarm(rtc.MATCH_HHMMSS);
40+
41+
rtc.attachInterrupt(alarmMatch);
42+
43+
rtc.standbyMode();
44+
}
45+
46+
void loop()
47+
{
48+
49+
Serial.println("Awake!");
50+
51+
for (int i = 0; i < 10; i++)
52+
Serial.print(i);
53+
54+
Serial.println();
55+
56+
Serial.println("Done! Goodnight!");
57+
58+
rtc.standbyMode(); // Sleep until next alarm match
59+
}
60+
61+
void alarmMatch()
62+
{
63+
64+
}

keywords.txt

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ setAlarmTime KEYWORD2
4747
enableAlarm KEYWORD2
4848
disableAlarm KEYWORD2
4949

50+
standbyMode KEYWORD2
51+
5052
#######################################
5153
# Constants (LITERAL1)
5254
#######################################

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=RTCZero
2-
version=1.2.0
2+
version=1.3.0
33
author=Arduino
44
maintainer=Arduino <[email protected]>
55
sentence=Allows to use the RTC functionalities. For Arduino Zero only.

src/RTCZero.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ void RTCZero::detachInterrupt()
100100
RTC_callBack = NULL;
101101
}
102102

103+
void RTCZero::standbyMode()
104+
{
105+
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
106+
__WFI();
107+
}
108+
103109
/*
104110
* Get Functions
105111
*/

src/RTCZero.h

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ class RTCZero {
4949
void attachInterrupt(voidFuncPtr callback);
5050
void detachInterrupt();
5151

52+
void standbyMode();
53+
5254
/* Get Functions */
5355

5456
uint8_t getSeconds();

0 commit comments

Comments
 (0)