forked from nanoframework/Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
57 lines (45 loc) · 1.89 KB
/
Program.cs
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
using System;
using System.Device.Gpio;
using System.Diagnostics;
using System.Threading;
using GiantGecko = nanoFramework.Hardware.GiantGecko;
namespace PowerMode
{
public class Program
{
private static GpioController _gpioController;
public static void Main()
{
_gpioController = new GpioController();
// Silabs SLSTK3701A: LED1 PH14 is LLED1
GpioPin led = _gpioController.OpenPin(PinNumber('H', 14), PinMode.Output);
// start a thread blinking the LED to check that something is happening
new Thread(() => {
while (true)
{
Thread.Sleep(125);
led.Toggle();
}
}).Start();
// sleep here for 5 seconds to allow the LED to blink
Thread.Sleep(5_000);
Debug.WriteLine($"Going to standby mode now...");
//////////////////////////////////////
// *** these calls never return *** //
//////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
// Uncomment one of the following according to the power mode you want to test //
/////////////////////////////////////////////////////////////////////////////////
// after this the target will enter EM4 hibernate mode (RTC will be on and counting)
GiantGecko.Power.EnterHibernateMode();
// after this the target will enter EM4 shutoff mode: nothing is running on the device and everything is shutoff
// GiantGecko.Power.EnterShutoffMode();
}
static int PinNumber(char port, byte pin)
{
if (port < 'A' || port > 'J')
throw new ArgumentException();
return ((port - 'A') * 16) + pin;
}
}
}