forked from ee-quipment/ZeroPowerManager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zpm_example.ino
57 lines (44 loc) · 1.17 KB
/
zpm_example.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
Demo of ZeroPowerManager. See ZeroPowerManager.jpg for a
logarmithmic graph of current vs time for this demo.
Board target: Adafruit M0 WiFi
Measured power with
LiPo charger removed, LDO removed
Powered from a separate 3.3V supply
All ports + spi disabled
USB off
48 MHz: 7.5 mA
8 MHz: 1.5 mA
32 KHz: 200 uA
Sleep : 6 uA
*/
#include <ZeroPowerManager.h>
void setup()
{
zpmRTCInit();
/*
* To get to datasheet power levels the I/O must be disabled
*/
zpmPortDisableDigital();
zpmPortDisableSPI();
zpmPortDisableUSB();
}
void loop()
{
/*
* Stay in each power state for about a second.
*/
zpmCPUClk48M();
delay(1000);
zpmCPUClk8M();
delay(1000/6);
zpmCPUClk32K();
delay(1);
/*
* There is no interrupt handler (callback = NULL). Execution will
* resume from the sleep instruction.
*/
uint32_t now = zpmRTCGetClock();
zpmRTCInterruptAt(now + 1000, NULL);
zpmSleep();
}