source: rtos_arduino/trunk/arduino_lib/libraries/Rest/examples/rest_rtc_alarm_interrupt/rest_rtc_alarm_interrupt.ino@ 136

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

ライブラリとOS及びベーシックなサンプルの追加.

File size: 1.3 KB
Line 
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
9rest mcu_std;
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 mcu_std.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(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
48void 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.