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

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

1.7.10のファイルに更新

File size: 910 bytes
Line 
1/*
2
3This sketch allows the users to manage the Tian and MCU power management.
4Users can power up or power down MIPS and MCU with an external interrupt.
5
6*/
7
8#include <EnergySaving.h>
9
10EnergySaving nrgSave;
11
12#define MIPS_PIN 32 //PA28 PIN 32
13
14void setup()
15{
16 pinMode(MIPS_PIN,OUTPUT);
17 digitalWrite(MIPS_PIN,HIGH);
18
19 nrgSave.begin(WAKE_EXT_INTERRUPT, 8, wakeUp); //standby setup for external interrupts
20}
21
22void loop()
23{
24 doSomething();
25 sleep();
26}
27
28void doSomething(){
29 //blink for 90 seconds
30 for(int i=0; i<90; i++)
31 {
32 digitalWrite(13,HIGH);
33 delay(500);
34 digitalWrite(13,LOW);
35 delay(500);
36 }
37}
38
39void sleep(void){
40 digitalWrite(MIPS_PIN, LOW);
41 nrgSave.standby(); //now mcu goes in standby mode
42}
43
44void wakeUp(void) //interrupt routine (isn't necessary to execute any tasks in this routine
45{
46 //mcu is waked-up by the interrupt
47
48 //wake up mips
49 digitalWrite(MIPS_PIN,HIGH);
50}
Note: See TracBrowser for help on using the repository browser.