source: rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/libraries/EnergySaving/examples/WakeUpOnRTCInterrupt/WakeUpOnRTCInterrupt.ino@ 224

Last change on this file since 224 was 224, checked in by ertl-honda, 8 years ago

1.7.10のファイルに更新

File size: 1.2 KB
Line 
1/***********************************************************************************************
2 This sketch demonstrates how to use sleep features and wake-up MCU with RTC alarm interrupt.
3 This sketch works only on cortex-m0+ based boards.
4************************************************************************************************/
5
6#include <EnergySaving.h>
7#include <RTCInt.h>
8
9EnergySaving nrgSave;
10RTCInt rtc;
11
12unsigned int i=0;
13
14void 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 nrgSave.begin(WAKE_RTC_ALARM); //standby setup for external interrupts
27 rtc.setAlarm();
28 SerialUSB.println("START");
29
30}
31
32void loop()
33{
34 for(i=0; i<20; i++)
35 {
36 digitalWrite(13,HIGH);
37 delay(500);
38 digitalWrite(13,LOW);
39 delay(500);
40 }
41
42 digitalWrite(30,LOW);
43 nrgSave.standby(); //now mcu go to standby
44
45}
46
47void rest_alarm_int(void) //interrupt routine
48{
49 //PORT->Group[1].OUTSET.reg = 0x1u<<3;
50 digitalWrite(30,HIGH);
51
52 Serial5.println("HELLO");
53}
Note: See TracBrowser for help on using the repository browser.