Author Topic: Who woke me up?  (Read 569 times)

Neko

  • Newbie
  • *
  • Posts: 34
  • Country: us
Who woke me up?
« on: April 17, 2017, 10:00:25 AM »
I am counting pulses during ListenMode using interrupts on D3. After ListenModeStart and SLEEP_FOREVER, when I wake up, I need to know if I woke up because of an interrupt on D3, or because of a wakeup burst. If it was an interrupt in D3, I simply go back to sleep.  If it was a wakeup burst, then I need to process the burst and listenModeEnd().

Currently, I determine who woke me up by looking at a counter associated with D3. The IRQ increments the counter, so if count is higher than it was before I went to SLEEP, I know it was a pulse on D3 that woke me up, and that the wakeup burst has not arrived yet. If the counts haven't changed, I know it was a wakeup burst.

I do the same thing while I am in listenmode delay (this thread).

All this seems to work well enough, but what if there is a count and the end of listenmode at the same time (rare, I suppose). Is there a way to tell more directly if I am still in listenmode (or delay mode) when I wake up? Is there a register I can read from the radio, or could I add something to the radio.delay IRQ that would be available for my program to read?

Code: [Select]
lastCount = count;
radio.listenModeStart(); // or enter radio.delay() here
LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
     
while (lastCount != count) {
   lastCount = count;
   LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
   }
// wake up, process BURST_REMAINING and get message here (or deal with end of radio.delay).

...

void countIRQ()
{
  count++;
}
« Last Edit: April 17, 2017, 11:49:36 AM by Neko »