Sleep doesn't wake up after 4m:15s
Closed this issue · 1 comments
Palomino34 commented
Palomino34 commented
Code below for testing this issue and could not preproduce
public class Program
{
const int LED1 = SC20260.GpioPin.PH11; // PB0
const int LDR1 = SC20260.GpioPin.PE3; // PE3;
const int APP = SC20260.GpioPin.PB7; // PE3;
static GpioPin led1;
static GpioPin buttonInterrupt;
static GpioPin buttonEnterSleep;
static void Main()
{
var controller = GpioController.GetDefault();
led1 = controller.OpenPin(LED1);
buttonInterrupt = controller.OpenPin(LDR1);
buttonEnterSleep = controller.OpenPin(APP);
led1.SetDriveMode(GpioPinDriveMode.Output);
buttonInterrupt.SetDriveMode(GpioPinDriveMode.InputPullUp);
buttonEnterSleep.SetDriveMode(GpioPinDriveMode.InputPullUp);
buttonInterrupt.ValueChanged += Ldr1_ValueChanged;
int cnt = 0;
while (buttonEnterSleep.Read() == GpioPinValue.High)
{
led1.Write(led1.Read() == GpioPinValue.Low ? GpioPinValue.High : GpioPinValue.Low);
var dt = DateTime.Now;
Thread.Sleep(25);
cnt++;
if (cnt % 10 == 0)
{
Debug.WriteLine("Press button APP to Enter sleep");
}
}
while (buttonEnterSleep.Read() == GpioPinValue.Low) ;
DoTestWakeup();
while (true)
{
Debug.WriteLine("Run from wakeup ");
Thread.Sleep(250);
led1.Write(led1.Read() == GpioPinValue.Low ? GpioPinValue.High : GpioPinValue.Low);
}
}
private static void Ldr1_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs e)
{
Debug.WriteLine("Found interrupt");
}
static void DoTestWakeup()
{
Debug.WriteLine("Entering wakeup ");
var st1 = new DateTime(2021, 1, 1, 0, 0, 0);
var rtc = RtcController.GetDefault();
var rtcDateTime = RtcDateTime.FromDateTime(st1);
rtc.SetTime(rtcDateTime);
SystemTime.SetTime(st1);
Power.WakeupEdge = WakeupEdge.Rising;
Power.Sleep(DateTime.Now.AddSeconds(4*60 + 20));
}
}