[beken-72xx] Implement deep sleep (#140)

* Initial support code for Deep Sleep

* Global functions

* Remove unnecessary override

* clang-format

* Support for multiple pins

* Fix math

* Add a way to unset GPIOs

* Clang format

* Update brief

---------

Co-authored-by: Kuba Szczodrzyński <kuba@szczodrzynski.pl>
This commit is contained in:
Péter Sárközi
2023-07-13 18:00:14 +02:00
committed by GitHub
parent 150c2ef26d
commit 93e0a5d066
6 changed files with 86 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
/* Copyright (c) Peter Sarkozi 2023-06-17. */
#include "lt_sleep.h"
__attribute__((weak)) void lt_deep_sleep_config_gpio(uint32_t gpio_index_map, bool on_high);
__attribute__((weak)) void lt_deep_sleep_unset_gpio(uint32_t gpio_index_map);
__attribute__((weak)) void lt_deep_sleep_config_timer(uint32_t sleep_duration);
__attribute__((weak)) void lt_deep_sleep_enter();

View File

@@ -0,0 +1,31 @@
/* Copyright (c) Peter Sarkozi 2023-06-17. */
#pragma once
#include <libretiny.h>
/**
* @brief Enable GPIO Wakeup from Deep Sleep.
*
* @param gpio_index_map bitMap of the pins we should wake up on
* @param on_high whether to wake up on High or Low state
*/
void lt_deep_sleep_config_gpio(uint32_t gpio_index_map, bool on_high);
/**
* @brief Disable GPIO Wakeup on given pins
*
* @param gpio_index_map bitMap of the pins we should disable wake up on
*/
void lt_deep_sleep_unset_gpio(uint32_t gpio_index_map);
/**
* @brief Set a sleep timer to wake up the device
* @param sleep_duration the time in seconds to sleep
*/
void lt_deep_sleep_config_timer(uint32_t sleep_duration);
/**
* @brief Start deep sleep
*/
void lt_deep_sleep_enter();

View File

@@ -16,6 +16,7 @@ extern "C" {
#include "api/lt_init.h"
#include "api/lt_mem.h"
#include "api/lt_ota.h"
#include "api/lt_sleep.h"
#include "api/lt_utils.h"
#include "api/lt_wdt.h"