mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-14 00:52:05 +00:00
implement most of sleep handling for the new radio stack
This commit is contained in:
parent
62a893c760
commit
d7d8188093
@ -67,7 +67,7 @@ class RadioInterface
|
|||||||
*
|
*
|
||||||
* This method must be used before putting the CPU into deep or light sleep.
|
* This method must be used before putting the CPU into deep or light sleep.
|
||||||
*/
|
*/
|
||||||
bool canSleep() { return true; }
|
virtual bool canSleep() { return true; }
|
||||||
|
|
||||||
/// Prepare hardware for sleep. Call this _only_ for deep sleep, not needed for light sleep.
|
/// Prepare hardware for sleep. Call this _only_ for deep sleep, not needed for light sleep.
|
||||||
virtual bool sleep() { return true; }
|
virtual bool sleep() { return true; }
|
||||||
|
@ -89,6 +89,15 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RadioLibInterface::canSleep()
|
||||||
|
{
|
||||||
|
bool res = txQueue.isEmpty();
|
||||||
|
if (!res) // only print debug messages if we are vetoing sleep
|
||||||
|
DEBUG_MSG("radio wait to sleep, txEmpty=%d\n", txQueue.isEmpty());
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
void RadioLibInterface::loop()
|
void RadioLibInterface::loop()
|
||||||
{
|
{
|
||||||
PendingISR wasPending = pending; // atomic read
|
PendingISR wasPending = pending; // atomic read
|
||||||
|
@ -88,6 +88,13 @@ class RadioLibInterface : public RadioInterface
|
|||||||
|
|
||||||
virtual void loop(); // Idle processing
|
virtual void loop(); // Idle processing
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if we think the board can go to sleep (i.e. our tx queue is empty, we are not sending or receiving)
|
||||||
|
*
|
||||||
|
* This method must be used before putting the CPU into deep or light sleep.
|
||||||
|
*/
|
||||||
|
virtual bool canSleep();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** start an immediate transmit */
|
/** start an immediate transmit */
|
||||||
void startSend(MeshPacket *txp);
|
void startSend(MeshPacket *txp);
|
||||||
|
@ -108,3 +108,14 @@ bool SX1262Interface::canSendImmediately()
|
|||||||
|
|
||||||
return !busyTx && !busyRx;
|
return !busyTx && !busyRx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool SX1262Interface::sleep()
|
||||||
|
{
|
||||||
|
// we no longer care about interrupts from this device
|
||||||
|
// prepareDeepSleep();
|
||||||
|
|
||||||
|
// FIXME - put chipset into sleep mode
|
||||||
|
return false;
|
||||||
|
}
|
@ -19,6 +19,9 @@ class SX1262Interface : public RadioLibInterface
|
|||||||
/// \return true if initialisation succeeded.
|
/// \return true if initialisation succeeded.
|
||||||
virtual bool reconfigure();
|
virtual bool reconfigure();
|
||||||
|
|
||||||
|
/// Prepare hardware for sleep. Call this _only_ for deep sleep, not needed for light sleep.
|
||||||
|
virtual bool sleep();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* Glue functions called from ISR land
|
* Glue functions called from ISR land
|
||||||
|
Loading…
Reference in New Issue
Block a user