Skip to content

Commit

Permalink
Update System.h with info about the deep sleep mode. (#2526)
Browse files Browse the repository at this point in the history
* Update System.h

* Check documentation output, revise

* Fix comments indentation.

Co-authored-by: mikee47 <[email protected]>
Co-authored-by: Slavey Karadzhov <[email protected]>
  • Loading branch information
3 people authored Jul 19, 2022
1 parent fa026fb commit b356d07
Showing 1 changed file with 29 additions and 18 deletions.
47 changes: 29 additions & 18 deletions Sming/Platform/System.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ISystemReadyHandler
}

/** @brief Handle <i>system ready</i> events
*/
*/
virtual void onSystemReady() = 0;
};

Expand Down Expand Up @@ -112,8 +112,8 @@ class SystemClass
static bool initialize();

/** @brief Check if system ready
* @retval bool True if system initialisation is complete and system is now ready
*/
* @retval bool True if system initialisation is complete and system is now ready
*/
bool isReady()
{
return state == eSS_Ready;
Expand All @@ -124,45 +124,56 @@ class SystemClass
* @note A delay is often required to allow network callback code to complete correctly.
* The restart is always deferred, either using the task queue (if deferMillis == 0)
* or using a timer. This method always returns immediately.
*/
*/
void restart(unsigned deferMillis = 0);

/** @brief Set the CPU frequency
* @param freq Frequency to set CPU
* @param freq Frequency to set CPU
* @retval bool true on success
*/
*/
bool setCpuFrequency(CpuFrequency freq)
{
return system_update_cpu_freq(freq);
}

/** @brief Get the CPU frequency
* @retval CpuFrequency The frequency of the CPU
*/
* @retval CpuFrequency The frequency of the CPU
*/
CpuFrequency getCpuFrequency()
{
return static_cast<CpuFrequency>(system_get_cpu_freq());
}

/** @brief Enter deep sleep mode
* @param timeMilliseconds Quantity of milliseconds to remain in deep sleep mode
* @param options Deep sleep options
*/
/** @brief Enter deep sleep mode.
* Deep sleep turns off processor and keeps only the RTC memory active.
* @param timeMilliseconds Quantity of milliseconds to remain in deep sleep mode
* @param options Deep sleep options
*
* @note Determine reset cause like this:
*
* auto info = system_get_rst_info();
* if(info->reason == REASON_DEEP_SLEEP_AWAKE) {
* // ...
* }
*
* @note ESP8266: Ensure GPIO 16 (XPD_DCDC) is connected to RST (EXT_RSTB).
* and call pinMode(16, WAKEUP_PULLUP) to enable wakeup from deep sleep.
*/
bool deepSleep(uint32_t timeMilliseconds, DeepSleepOptions options = eDSO_RF_CAL_BY_INIT_DATA);

/** @brief Set handler for <i>system ready</i> event
* @param readyHandler Function to handle event
* @note if system is ready, callback is executed immediately without deferral
*/
* @param readyHandler Function to handle event
* @note if system is ready, callback is executed immediately without deferral
*/
void onReady(SystemReadyDelegate readyHandler)
{
queueCallback(readyHandler);
}

/** @brief Set handler for <i>system ready</i> event
* @param readyHandler Function to handle event
* @note if system is ready, callback is executed immediately without deferral
*/
* @param readyHandler Function to handle event
* @note if system is ready, callback is executed immediately without deferral
*/
void onReady(ISystemReadyHandler* readyHandler)
{
if(readyHandler != nullptr) {
Expand Down

0 comments on commit b356d07

Please sign in to comment.