kopia lustrzana https://github.com/meshtastic/firmware
implement most of sleep handling for the new radio stack
rodzic
62a893c760
commit
d7d8188093
|
@ -67,7 +67,7 @@ class RadioInterface
|
|||
*
|
||||
* 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.
|
||||
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()
|
||||
{
|
||||
PendingISR wasPending = pending; // atomic read
|
||||
|
|
|
@ -88,6 +88,13 @@ class RadioLibInterface : public RadioInterface
|
|||
|
||||
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:
|
||||
/** start an immediate transmit */
|
||||
void startSend(MeshPacket *txp);
|
||||
|
|
|
@ -107,4 +107,15 @@ bool SX1262Interface::canSendImmediately()
|
|||
DEBUG_MSG("Can not set now, busyTx=%d, busyRx=%d\n", 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.
|
||||
virtual bool reconfigure();
|
||||
|
||||
/// Prepare hardware for sleep. Call this _only_ for deep sleep, not needed for light sleep.
|
||||
virtual bool sleep();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Glue functions called from ISR land
|
||||
|
|
Ładowanie…
Reference in New Issue