Rev | Line | |
---|
[136] | 1 | /*********************************************************************************************************************************************************************************
|
---|
| 2 | * This sketch demonstrates how to use sleep function and wake-up MCU with RTC alarm interrupt.
|
---|
| 3 | This sketch work only for M0 and M0PRO boards.
|
---|
| 4 | *********************************************************************************************************************************************************************************/
|
---|
| 5 |
|
---|
| 6 | #include <rest.h>
|
---|
| 7 | #include <RTCInt.h>
|
---|
| 8 |
|
---|
| 9 | rest mcu_std;
|
---|
| 10 | RTCInt rtc;
|
---|
| 11 |
|
---|
| 12 | unsigned int i=0;
|
---|
| 13 |
|
---|
| 14 | void setup()
|
---|
| 15 | {
|
---|
| 16 |
|
---|
| 17 | pinMode(30,OUTPUT); //led RX
|
---|
| 18 | Serial5.begin(9600); //serial settings
|
---|
| 19 | rtc.begin(TIME_H24);
|
---|
| 20 | rtc.setTime(12,48,0,0);
|
---|
| 21 | rtc.setDate(22,10,15);
|
---|
| 22 | rtc.enableAlarm(SEC,ALARM_INTERRUPT,rest_alarm_int);
|
---|
| 23 | rtc.local_time.hour=12;
|
---|
| 24 | rtc.local_time.minute=48;
|
---|
| 25 | rtc.local_time.second=30;
|
---|
| 26 | mcu_std.begin(WAKE_RTC_ALARM); //standby setup for external interrupts
|
---|
| 27 | rtc.setAlarm();
|
---|
| 28 | SerialUSB.println("START");
|
---|
| 29 |
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | void loop()
|
---|
| 33 | {
|
---|
| 34 | for(i=0; i<20; i++)
|
---|
| 35 | {
|
---|
| 36 | digitalWrite(13,HIGH);
|
---|
| 37 | delay(100);
|
---|
| 38 | digitalWrite(13,LOW);
|
---|
| 39 | delay(200);
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | digitalWrite(30,LOW);
|
---|
| 43 | mcu_std.standby(); //now mcu go to standby
|
---|
| 44 |
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 |
|
---|
| 48 | void rest_alarm_int(void) //interrupt routine
|
---|
| 49 | {
|
---|
| 50 | //PORT->Group[1].OUTSET.reg = 0x1u<<3;
|
---|
| 51 | digitalWrite(30,HIGH);
|
---|
| 52 |
|
---|
| 53 | Serial5.println("HELLO");
|
---|
| 54 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.