打印
[开发工具]

使用Arduino开发STM32F103能使用低功耗模式吗

[复制链接]
792|8
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
捉虫天师|  楼主 | 2024-4-19 17:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
不知道如何在Arduino中使用低功耗模式,有前辈分享一下吗

使用特权

评论回复
沙发
天灵灵地灵灵| | 2024-4-19 17:24 | 只看该作者
在Arduino开发环境中,你可以使用适当的库和函数来配置STM32F103的低功耗模式。例如,你可以使用STM32的库函数来设置特定的低功耗模式,然后通过在程序中调用相应的函数来进入和退出低功耗模式。例如,你可以使用 STM32F1 库中的 standby() 函数来使STM32F103进入待机模式。

使用特权

评论回复
板凳
天灵灵地灵灵| | 2024-4-19 17:25 | 只看该作者
#include <STM32LowPower.h>

const int buttonPin = PA0;  // Button connected to pin PA0
const int ledPin = PC13;    // LED connected to pin PC13

void setup() {
  pinMode(buttonPin, INPUT_PULLUP);
  pinMode(ledPin, OUTPUT);
}

void loop() {
  // Check if button is pressed
  if (digitalRead(buttonPin) == LOW) {
    // Button pressed, enter low power mode
    digitalWrite(ledPin, HIGH); // Turn on LED
    delay(100);  // Wait for button debounce
    while (digitalRead(buttonPin) == LOW) {}  // Wait for button release
    delay(100);  // Wait for button debounce
    digitalWrite(ledPin, LOW);  // Turn off LED
    STM32LowPower.standby();  // Enter standby mode
  }
}

使用特权

评论回复
地板
天灵灵地灵灵| | 2024-4-19 17:25 | 只看该作者
安装低功耗函数库就可以使用这个头文件了。

使用特权

评论回复
5
天灵灵地灵灵| | 2024-4-19 17:26 | 只看该作者
在此示例中,我们使用了 STM32LowPower 库来进入待机模式。当按钮按下时,LED亮起,然后等待按钮释放,并且进入待机模式。待机模式中,微控制器的大部分功能都被关闭以降低功耗。当再次按下按钮时,LED灭掉,微控制器唤醒并从 standby() 函数返回,继续执行 loop() 函数中的代码。

使用特权

评论回复
6
天灵灵地灵灵| | 2024-4-19 17:26 | 只看该作者
/**
******************************************************************************
* [url=home.php?mod=space&uid=288409]@file[/url]    STM32LowPower.h
* [url=home.php?mod=space&uid=187600]@author[/url]  Frederic Pillon
* [url=home.php?mod=space&uid=247401]@brief[/url]   Provides a STM32 Low Power interface with Arduino
*
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2020 STMicroelectronics</center></h2>
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*   1. Redistributions of source code must retain the above copyright notice,
*      this list of conditions and the following disclaimer.
*   2. Redistributions in binary form must reproduce the above copyright notice,
*      this list of conditions and the following disclaimer in the documentation
*      and/or other materials provided with the distribution.
*   3. Neither the name of STMicroelectronics nor the names of its contributors
*      may be used to endorse or promote products derived from this software
*      without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
*/

#ifndef _STM32_LOW_POWER_H_
#define _STM32_LOW_POWER_H_

#include <Arduino.h>

#include "low_power.h"

// Check if PWR HAL enable in variants/board_name/stm32yzxx_hal_conf.h
#ifndef HAL_PWR_MODULE_ENABLED
  #error "PWR configuration is missing. Check flag HAL_PWR_MODULE_ENABLED in variants/board_name/stm32yzxx_hal_conf.h"
#endif

#include "STM32RTC.h"

enum LP_Mode : uint8_t {
  IDLE_MODE,
  SLEEP_MODE,
  DEEP_SLEEP_MODE,
  SHUTDOWN_MODE
};

typedef void (*voidFuncPtrVoid)(void) ;

class STM32LowPower {
  public:
    STM32LowPower();

    void begin(void);

    void idle(uint32_t ms = 0);
    void idle(int ms)
    {
      idle((uint32_t)ms);
    }

    void sleep(uint32_t ms = 0);
    void sleep(int ms)
    {
      sleep((uint32_t)ms);
    }

    void deepSleep(uint32_t ms = 0);
    void deepSleep(int ms)
    {
      deepSleep((uint32_t)ms);
    }

    void shutdown(uint32_t ms = 0);
    void shutdown(int ms)
    {
      shutdown((uint32_t)ms);
    }

    void attachInterruptWakeup(uint32_t pin, voidFuncPtrVoid callback, uint32_t mode, LP_Mode LowPowerMode = SHUTDOWN_MODE);

    void enableWakeupFrom(HardwareSerial *serial, voidFuncPtrVoid callback);
    void enableWakeupFrom(STM32RTC *rtc, voidFuncPtr callback, void *data = NULL);

  private:
    bool _configured;     // Low Power mode initialization status
    serial_t *_serial;    // Serial for wakeup from deep sleep
    bool _rtc_wakeup;     // Is RTC wakeup?
    void programRtcWakeUp(uint32_t ms, LP_Mode lp_mode);
    void setAlarmTime(uint32_t ms, STM32RTC &rtc);

};

extern STM32LowPower LowPower;

#endif // _STM32_LOW_POWER_H_

使用特权

评论回复
7
天灵灵地灵灵| | 2024-4-19 17:27 | 只看该作者
/**
******************************************************************************
* @file    STM32LowPower.cpp
* @author  Frederic Pillon
* @brief   Provides a STM32 Low Power interface with Arduino
*
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2020 STMicroelectronics</center></h2>
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*   1. Redistributions of source code must retain the above copyright notice,
*      this list of conditions and the following disclaimer.
*   2. Redistributions in binary form must reproduce the above copyright notice,
*      this list of conditions and the following disclaimer in the documentation
*      and/or other materials provided with the distribution.
*   3. Neither the name of STMicroelectronics nor the names of its contributors
*      may be used to endorse or promote products derived from this software
*      without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
*/

#include "STM32LowPower.h"

STM32LowPower LowPower;


STM32LowPower::STM32LowPower()
{
  _configured = false;
  _serial = NULL;
  _rtc_wakeup = false;
}

/**
  * @brief  Initializes the low power mode
  * @param  None
  * @retval None
  */
void STM32LowPower::begin(void)
{
  LowPower_init();
  _configured = true;
}

/**
  * @brief  Enable the idle low power mode (STM32 sleep). Exit this mode on
  *         interrupt or in n milliseconds.
  * @param  ms: optional delay before leave the idle mode (default: 0).
  * @retval None
  */
void STM32LowPower::idle(uint32_t ms)
{
  if ((ms != 0) || _rtc_wakeup) {
    programRtcWakeUp(ms, IDLE_MODE);
  }
  LowPower_sleep(PWR_MAINREGULATOR_ON);
}

/**
  * @brief  Enable the sleep low power mode (STM32 sleep). Exit this mode on
  *         interrupt or in n milliseconds.
  * @param  ms: optional delay before leave the sleep mode (default: 0).
  * @retval None
  */
void STM32LowPower::sleep(uint32_t ms)
{
  if ((ms != 0) || _rtc_wakeup) {
    programRtcWakeUp(ms, SLEEP_MODE);
  }
#if defined(PWR_LOWPOWERREGULATOR_ON)
  LowPower_sleep(PWR_LOWPOWERREGULATOR_ON);
#else
  LowPower_sleep(PWR_MAINREGULATOR_ON);
#endif

}

/**
  * @brief  Enable the deepsleep low power mode (STM32 stop). Exit this mode on
  *         interrupt or in n milliseconds.
  * @param  ms: optional delay before leave the deepSleep mode (default: 0).
  * @retval None
  */
void STM32LowPower::deepSleep(uint32_t ms)
{
  if ((ms != 0) || _rtc_wakeup) {
    programRtcWakeUp(ms, DEEP_SLEEP_MODE);
  }
  LowPower_stop(_serial);
}

/**
  * @brief  Enable the shutdown low power mode (STM32 shutdown or standby mode).
  *          Exit this mode on interrupt or in n milliseconds.
  * @param  ms: optional delay before leave the shutdown mode (default: 0).
  * @retval None
  */
void STM32LowPower::shutdown(uint32_t ms)
{
  if ((ms != 0) || _rtc_wakeup) {
    programRtcWakeUp(ms, SHUTDOWN_MODE);
  }
  /* Get the rtc object to know if it is configured */
  STM32RTC &rtc = STM32RTC::getInstance();
  LowPower_shutdown(rtc.isConfigured());
}

/**
  * @brief  Enable GPIO pin in interrupt mode. If the pin is a wakeup pin, it is
  *         configured as wakeup source.
  * @param  pin:  pin number
  * @param  callback: pointer to callback function.
  * @param  mode: pin interrupt mode (HIGH, LOW, RISING, FALLING or CHANGE)
  * @param  LowPowerMode: Low power mode which will be used
  *         (IDLE_MODE, SLEEP_MODE, DEEP_SLEEP_MODE, SHUTDOWN_MODE)
  *         In case of SHUTDOWN_MODE only, Wakeup pin capability is activated
  * @retval None
  */
void STM32LowPower::attachInterruptWakeup(uint32_t pin, voidFuncPtrVoid callback, uint32_t mode, LP_Mode LowPowerMode)
{
  attachInterrupt(pin, callback, mode);

  if (LowPowerMode == SHUTDOWN_MODE) {
    // If Gpio is a Wake up pin activate it for shutdown (standby or shutdown stm32)
    LowPower_EnableWakeUpPin(pin, mode);
  }
}

/**
  * @brief  Enable a serial interface as a wakeup source.
  * @param  serial: pointer to a HardwareSerial
  * @param  callback: pointer to callback function called when leave the low power
  *                   mode.
  * @retval None
  */
void STM32LowPower::enableWakeupFrom(HardwareSerial *serial, voidFuncPtrVoid callback)
{
  if (serial != NULL) {
    _serial = &(serial->_serial);
    // Reconfigure serial for low power mode (using HSI as clock source)
    serial->configForLowPower();
    LowPower_EnableWakeUpUart(_serial, callback);
  }
}

/**
  * @brief  Attach a callback to a RTC alarm.
  * @param  rtc: pointer to a STM32RTC. Can be NULL as RTC is a Singleton.
  * @param  callback: pointer to callback function called when leave the low power
  *                   mode.
  * @param  data: optional pointer to callback data parameters (default NULL).
  * @retval None
  */
void STM32LowPower::enableWakeupFrom(STM32RTC *rtc, voidFuncPtr callback, void *data)
{
  if (rtc == NULL) {
    rtc = &(STM32RTC::getInstance());
  }
  _rtc_wakeup = true;
  rtc->attachInterrupt(callback, data);
}

/**
  * @brief  Configure the RTC alarm
  * @param  ms: time of the alarm in milliseconds.
  * @param  lp_mode: low power mode targeted.
  * @retval None
  */
void STM32LowPower::programRtcWakeUp(uint32_t ms, LP_Mode lp_mode)
{
  STM32RTC &rtc = STM32RTC::getInstance();
  STM32RTC::Source_Clock clkSrc = rtc.getClockSource();

  switch (lp_mode) {
    case IDLE_MODE:
    case SLEEP_MODE:
      break;
    // LSI or LSE must be selected as clock source to wakeup the device.
    case DEEP_SLEEP_MODE:
      clkSrc = (clkSrc == STM32RTC::HSE_CLOCK) ? STM32RTC::LSI_CLOCK : clkSrc;
      break;
    default:
    case SHUTDOWN_MODE:
#if defined(PWR_CR1_LPMS)
      // For shutdown mode LSE have to be used
      clkSrc = STM32RTC::LSE_CLOCK;
#else
      // LSE or LSI
      clkSrc = (clkSrc == STM32RTC::HSE_CLOCK) ? STM32RTC::LSI_CLOCK : clkSrc;
#endif
      break;
  }
  rtc.configForLowPower(clkSrc);

  setAlarmTime(ms, rtc);
}

static bool isLeapYear(uint8_t year2k)
{
  int year = year2k + 2000;

  // if year not divisible by 4 - not a leap year
  // else if year divisible by 4 and not by 100 - a leap year
  // else if year divisible by 400 - a leap year
  return (year % 4 != 0) ? false : (year % 100 != 0) ? true : year % 400 == 0;
}

void STM32LowPower::setAlarmTime(uint32_t ms, STM32RTC &rtc)
{
  if (ms != 0) {
    uint16_t subSecondsToAdd = ms % 1000;

    ms = ms / 1000;
    uint8_t daysToAdd = ms / 86400;
    uint8_t hoursToAdd = (ms - daysToAdd * 86400) / 3600;
    uint8_t minutesToAdd = (ms - daysToAdd * 86400 - hoursToAdd * 3600) / 60;
    uint8_t secondsToAdd = (ms - daysToAdd * 86400 - hoursToAdd * 3600 - minutesToAdd * 60);

    uint8_t hrCurrent, minCurrent, secCurrent;
    uint32_t subSecondsCurrent;
    STM32RTC::AM_PM period;
    rtc.getTime(&hrCurrent, &minCurrent, &secCurrent, &subSecondsCurrent, &period);

    uint8_t weekDay, currentDay, currentMonth, currentYear;
    rtc.getDate(&weekDay, &currentDay, &currentMonth, &currentYear);

    uint32_t ss = subSecondsCurrent + subSecondsToAdd;
    if (ss >= 1000) {
      ss -= 1000;
      secondsToAdd++;
    }

    if (secondsToAdd >= 60) {
      secondsToAdd = 0;
      minutesToAdd++;
    }
    uint8_t s = secCurrent + secondsToAdd;
    if (s >= 60) {
      s -= 60;
      minutesToAdd++;
    }

    if (minutesToAdd >= 60) {
      minutesToAdd -= 60;
      hoursToAdd++;
    }
    uint8_t m = minCurrent + minutesToAdd;
    if (m >= 60) {
      m -= 60;
      hoursToAdd++;
    }

    if (hoursToAdd >= 24) {
      hoursToAdd -= 24;
      daysToAdd++;
    }
    uint8_t h = hrCurrent + hoursToAdd;
    if (rtc._format == STM32RTC::Hour_Format::HOUR_12) {
      if (h >= 24) {
        h -= 24;
        daysToAdd++;
      } else if (h >= 12) {
        if (period == STM32RTC::AM_PM::AM) {
          period = STM32RTC::AM_PM::PM;
        } else {
          period = STM32RTC::AM_PM::AM;
          daysToAdd++;
        }

        if (h > 12) {
          h -= 12;
        }
      }
    } else if (h >= 24) {
      h -= 24;
      daysToAdd++;
    }

    // numbers of days in each month (february is calculated based on leap year)
    static uint8_t daysInMonths[] = {31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    uint8_t endDay;
    if (currentMonth == 2) {
      endDay = isLeapYear(currentYear) ? 29 : 28;
    } else {
      endDay = daysInMonths[currentMonth - 1];
    }

    uint8_t d = currentDay + daysToAdd;
    if (d > endDay) {
      d -= endDay;
    }

    // month-year overflow isn't handled because its not supported by RTC's alarm

    rtc.setAlarmTime(h, m, s, ss, period);
    rtc.setAlarmDay(d);
    rtc.enableAlarm(STM32RTC::Alarm_Match::MATCH_DHHMMSS);
  }
}

使用特权

评论回复
8
天灵灵地灵灵| | 2024-4-19 17:27 | 只看该作者
/**
  ******************************************************************************
  * @file    LowPower.c
  * @author  Frederic Pillon
  * @brief   Provides a Low Power interface
  *
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2020-2021, STMicroelectronics
  * All rights reserved.
  *
  * This software component is licensed by ST under BSD 3-Clause license,
  * the "License"; You may not use this file except in compliance with the
  * License. You may obtain a copy of the License at:
  *                        opensource.org/licenses/BSD-3-Clause
  *
  ******************************************************************************
  */

#include "Arduino.h"
#include "low_power.h"
#include "stm32yyxx_ll_pwr.h"

#if defined(HAL_PWR_MODULE_ENABLED) && !defined(HAL_PWR_MODULE_ONLY)

#if defined(HAL_UART_MODULE_ENABLED) && !defined(HAL_UART_MODULE_ONLY) \
  && (defined(UART_IT_WUF) || defined(LPUART1_BASE))
  #define UART_WKUP_SUPPORT
#endif

#ifdef __cplusplus
extern "C" {
#endif

#if defined(UART_WKUP_SUPPORT)
/* Save UART handler for callback */
static UART_HandleTypeDef *WakeUpUart = NULL;
#endif
/* Save callback pointer */
static void (*WakeUpUartCb)(void) = NULL;

#if defined(PWR_FLAG_WUF)
#define PWR_FLAG_WU PWR_FLAG_WUF
#elif defined(PWR_WAKEUP_ALL_FLAG)
#define PWR_FLAG_WU PWR_WAKEUP_ALL_FLAG
#endif
#if defined(PWR_FLAG_SBF)
#define PWR_FLAG_SB PWR_FLAG_SBF
#endif

/**
  * @brief  Initialize low power mode
  * @param  None
  * @retval None
  */
void LowPower_init()
{
#if defined(__HAL_RCC_PWR_CLK_ENABLE)
  /* Enable Power Clock */
  __HAL_RCC_PWR_CLK_ENABLE();
#endif

#if defined(PWR_CR_DBP) || defined(PWR_CR1_DBP) || defined(PWR_DBPR_DBP)
  /* Allow access to Backup domain */
  HAL_PWR_EnableBkUpAccess();
#endif

#ifdef __HAL_RCC_WAKEUPSTOP_CLK_CONFIG
  /* Ensure that HSI is wake-up system clock */
  __HAL_RCC_WAKEUPSTOP_CLK_CONFIG(RCC_STOP_WAKEUPCLOCK_HSI);
#endif
  /* Check if the system was resumed from StandBy mode */
  if (__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET) {
    /* Clear Standby flag */
    __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
  }

  /* Clear all related wakeup flags */
  __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
}

/**
  * @brief  Configure a pin as wakeup source if compatible.
  * @param  pin: pin to configure
  * @param  mode: pin mode (edge or state). The configuration have to be compatible.
  * @retval None
  */
void LowPower_EnableWakeUpPin(uint32_t pin, uint32_t mode)
{
#if !defined(PWR_WAKEUP_PIN1_HIGH)
  UNUSED(mode);
#endif
  uint32_t wkup_pin = 0;
  PinName p = digitalPinToPinName(pin);
  if (p != NC) {
#ifdef PWR_WAKEUP_PIN1
    if ((p == SYS_WKUP1)
#ifdef PWR_WAKEUP_PIN1_1
        || (p == SYS_WKUP1_1)
#endif
#ifdef PWR_WAKEUP_PIN1_2
        || (p == SYS_WKUP1_2)
#endif
       ) {
      wkup_pin = PWR_WAKEUP_PIN1;
#ifdef PWR_WAKEUP_PIN1_HIGH
      if (mode != RISING) {
        wkup_pin = PWR_WAKEUP_PIN1_LOW;
      }
#endif
    }
#endif /* PWR_WAKEUP_PIN1 */
#ifdef PWR_WAKEUP_PIN2
    if ((p == SYS_WKUP2)
#ifdef PWR_WAKEUP_PIN2_1
        || (p == SYS_WKUP2_1)
#endif
#ifdef PWR_WAKEUP_PIN2_2
        || (p == SYS_WKUP2_2)
#endif
       ) {
      wkup_pin = PWR_WAKEUP_PIN2;
#ifdef PWR_WAKEUP_PIN2_HIGH
      if (mode != RISING) {
        wkup_pin = PWR_WAKEUP_PIN2_LOW;
      }
#endif
    }
#endif /* PWR_WAKEUP_PIN2 */
#ifdef PWR_WAKEUP_PIN3
    if ((p == SYS_WKUP3)
#ifdef PWR_WAKEUP_PIN3_1
        || (p == SYS_WKUP3_1)
#endif
#ifdef PWR_WAKEUP_PIN3_2
        || (p == SYS_WKUP3_2)
#endif
       ) {
      wkup_pin = PWR_WAKEUP_PIN3;
#ifdef PWR_WAKEUP_PIN3_HIGH
      if (mode != RISING) {
        wkup_pin = PWR_WAKEUP_PIN3_LOW;
      }
#endif
    }
#endif /* PWR_WAKEUP_PIN3 */
#ifdef PWR_WAKEUP_PIN4
    if ((p == SYS_WKUP4)
#ifdef PWR_WAKEUP_PIN4_1
        || (p == SYS_WKUP4_1)
#endif
#ifdef PWR_WAKEUP_PIN4_2
        || (p == SYS_WKUP4_2)
#endif
       ) {
      wkup_pin = PWR_WAKEUP_PIN4;
#ifdef PWR_WAKEUP_PIN4_HIGH
      if (mode != RISING) {
        wkup_pin = PWR_WAKEUP_PIN4_LOW;
      }
#endif
    }
#endif /* PWR_WAKEUP_PIN4 */
#ifdef PWR_WAKEUP_PIN5
    if ((p == SYS_WKUP5)
#ifdef PWR_WAKEUP_PIN5_1
        || (p == SYS_WKUP5_1)
#endif
#ifdef PWR_WAKEUP_PIN5_2
        || (p == SYS_WKUP5_2)
#endif
       ) {
      wkup_pin = PWR_WAKEUP_PIN5;
#ifdef PWR_WAKEUP_PIN5_HIGH
      if (mode != RISING) {
        wkup_pin = PWR_WAKEUP_PIN5_LOW;
      }
#endif
    }
#endif /* PWR_WAKEUP_PIN5 */
#ifdef PWR_WAKEUP_PIN6
    if ((p == SYS_WKUP6)
#ifdef PWR_WAKEUP_PIN6_1
        || (p == SYS_WKUP6_1)
#endif
#ifdef PWR_WAKEUP_PIN6_2
        || (p == SYS_WKUP6_2)
#endif
       ) {
      wkup_pin = PWR_WAKEUP_PIN6;
#ifdef PWR_WAKEUP_PIN6_HIGH
      if (mode != RISING) {
        wkup_pin = PWR_WAKEUP_PIN6_LOW;
      }
#endif
    }
#endif /* PWR_WAKEUP_PIN6 */
#ifdef PWR_WAKEUP_PIN7
    if ((p == SYS_WKUP7)
#ifdef PWR_WAKEUP_PIN7_1
        || (p == SYS_WKUP7_1)
#endif
#ifdef PWR_WAKEUP_PIN7_2
        || (p == SYS_WKUP7_2)
#endif
       ) {
      wkup_pin = PWR_WAKEUP_PIN7;
    }
#endif /* PWR_WAKEUP_PIN7 */
#ifdef PWR_WAKEUP_PIN8
    if ((p == SYS_WKUP8)
#ifdef PWR_WAKEUP_PIN8_1
        || (p == SYS_WKUP8_1)
#endif
#ifdef PWR_WAKEUP_PIN8_2
        || (p == SYS_WKUP8_2)
#endif
       ) {
      wkup_pin = PWR_WAKEUP_PIN8;
    }
#endif /* PWR_WAKEUP_PIN8 */
    if (IS_PWR_WAKEUP_PIN(wkup_pin)) {
      HAL_PWR_EnableWakeUpPin(wkup_pin);
    }
  }
}

#if defined(PWR_CSR_REGLPF)
/**
  * @brief  For STM32L0 and STM32L1, running in LowPower Sleep requires
  *         to slow down frequency to MSI range1.
  * @retval None
  */
void SystemClock_Decrease(void)
{
  RCC_OscInitTypeDef RCC_OscInitStruct = {};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {};

  /** Configure the main internal regulator output voltage
  */
  __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);

  /** Initializes the RCC Oscillators according to the specified parameters
  * in the RCC_OscInitTypeDef structure.
  */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
  RCC_OscInitStruct.MSIState = RCC_MSI_ON;
  RCC_OscInitStruct.MSICalibrationValue = 0;
  RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_1;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
    Error_Handler();
  }

  /** Initializes the CPU, AHB and APB buses clocks
  */
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
                                | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK) {
    Error_Handler();
  }
}

#elif defined(STM32L4xx) || defined(STM32L5xx) || defined(STM32WBxx) || defined(STM32WLxx)
/**
  * @brief  For STM32L4, STM32L5, STM32WB and STM32WL
  *         running in LowPower Sleep requires to slow down frequency to 2MHz max.
  * @retval None
  */
void SystemClock_Decrease(void)
{
  RCC_OscInitTypeDef RCC_OscInitStruct = {};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {};

  /** Configure the main internal regulator output voltage
  */

#if (defined(STM32WBxx) && defined(PWR_CR1_VOS)) || !defined(STM32WBxx)
#if defined(STM32L4xx) || defined(STM32WBxx)
  if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK)
#elif defined(STM32L5xx) || defined(STM32WLxx)
  if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE2) != HAL_OK)
#endif
  {
    Error_Handler();
  }
#endif

  /** Initializes the RCC Oscillators according to the specified parameters
  * in the RCC_OscInitTypeDef structure.
  */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
  RCC_OscInitStruct.MSIState = RCC_MSI_ON;
  RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;
  RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_5;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
    Error_Handler();
  }

  /** Initializes the CPU and buses clocks
  */
#if defined(STM32WBxx)
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK4 | RCC_CLOCKTYPE_HCLK2
                                | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
                                | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
  RCC_ClkInitStruct.AHBCLK2Divider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.AHBCLK4Divider = RCC_SYSCLK_DIV1;
#elif defined(STM32WLxx)
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK3 | RCC_CLOCKTYPE_HCLK
                                | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1
                                | RCC_CLOCKTYPE_PCLK2;
  RCC_ClkInitStruct.AHBCLK3Divider = RCC_SYSCLK_DIV1;
#elif defined(STM32L4xx)
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
                                | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
#endif
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK) {
    Error_Handler();
  }
}

#elif defined(STM32G0xx) || defined(STM32G4xx)
/**
  * @brief  For STM32G0 and STM32G4
  *         running in LowPower Sleep requires to slow down frequency to 2MHz max.
  * @retval None
  */
void SystemClock_Decrease(void)
{
  RCC_OscInitTypeDef RCC_OscInitStruct = {};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {};

  /** Configure the main internal regulator output voltage
  */
  HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1);

  /** Initializes the RCC Oscillators according to the specified parameters
  * in the RCC_OscInitTypeDef structure.
  */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
#if defined(STM32G0xx)
  RCC_OscInitStruct.HSIDiv = RCC_HSI_DIV1;
#endif
  RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
    Error_Handler();
  }

  /** Initializes the CPU, AHB and APB buses clocks
  */
#if defined(STM32G4xx)
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
                                | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
#elif defined(STM32G0xx)
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
                                | RCC_CLOCKTYPE_PCLK1;
#endif
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV8;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;

  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK) {
    Error_Handler();
  }
}
#endif

/**
  * @brief  Enable the sleep mode.
  * @param  None
  * @retval None
  */
void LowPower_sleep(uint32_t regulator)
{

#if defined(PWR_LOWPOWERREGULATOR_ON) && \
    (defined(PWR_CSR_REGLPF) || defined(PWR_SR2_REGLPF))
  // When LowPower regulator sleep mode is used, it is necessary to decrease CPU Frequency
  if (regulator == PWR_LOWPOWERREGULATOR_ON) {
    SystemClock_Decrease();
  }
#endif

  /*
   * Suspend Tick increment to prevent wakeup by Systick interrupt.
   * Otherwise the Systick interrupt will wake up the device within
   * 1ms (HAL time base)
   */
  HAL_SuspendTick();

  /* Enter Sleep Mode , wake up is done once User push-button is pressed */
  HAL_PWR_EnterSLEEPMode(regulator, PWR_SLEEPENTRY_WFI);

#if defined(PWR_LOWPOWERREGULATOR_ON) && \
    (defined(PWR_CSR_REGLPF) || defined(PWR_SR2_REGLPF))
  // In case of LowPower Regulator used for sleep, restore Main regulator on exit
  if (regulator == PWR_LOWPOWERREGULATOR_ON) {
#if defined(__HAL_RCC_PWR_CLK_ENABLE)
    __HAL_RCC_PWR_CLK_ENABLE();
#endif
    HAL_PWREx_DisableLowPowerRunMode();

    // Restore systemClock which has been decreased by SystemClock_Decrease()
    SystemClock_Config();
  }
#endif

  /* Resume Tick interrupt if disabled prior to SLEEP mode entry */
  HAL_ResumeTick();

  if (WakeUpUartCb != NULL) {
    WakeUpUartCb();
  }
}

/**
  * @brief  Enable the stop mode.
  * @param  obj : pointer to serial_t structure
  * @retval None
  */
void LowPower_stop(serial_t *obj)
{
  __disable_irq();

#if defined(UART_WKUP_SUPPORT)
  if (WakeUpUart != NULL) {
    HAL_UARTEx_EnableStopMode(WakeUpUart);
  }
#endif

#if defined(PWR_CR_ULP)
  /* Enable Ultra low power mode */
  HAL_PWREx_EnableUltraLowPower();
#endif
#if defined(PWR_CR1_ULPMEN) || defined(PWR_CR3_ULPMEN)
  /* Enable Ultra low power mode */
  HAL_PWREx_EnableUltraLowPowerMode();
#endif
#if defined(PWR_CR_FWU)
  /* Enable the fast wake up from Ultra low power mode */
  HAL_PWREx_EnableFastWakeUp();
#endif
#ifdef __HAL_RCC_WAKEUPSTOP_CLK_CONFIG
  /* Select MSI or HSI as system clock source after Wake Up from Stop mode */
#ifdef RCC_STOP_WAKEUPCLOCK_MSI
  __HAL_RCC_WAKEUPSTOP_CLK_CONFIG(RCC_STOP_WAKEUPCLOCK_MSI);
#else
  __HAL_RCC_WAKEUPSTOP_CLK_CONFIG(RCC_STOP_WAKEUPCLOCK_HSI);
#endif
#endif
#if defined(STM32WBxx)
  /* Set low-power mode of CPU2 */
  /* Note: Typically, action performed by CPU2 on a dual core application.
           Since this example is single core, perform it by CPU1. */
  /* Note: On STM32WB, both CPU1 and CPU2 must be in low-power mode
           to set the entire System in low-power mode, corresponding to
           the deepest low-power mode possible.
           For example, CPU1 in Stop2 mode and CPU2 in Shutdown mode
           will make system enter in Stop2 mode. */
#if defined(LL_PWR_MODE_STOP2)
  LL_C2_PWR_SetPowerMode(LL_PWR_MODE_STOP2);
#else
  LL_C2_PWR_SetPowerMode(LL_PWR_MODE_SHUTDOWN);
#endif
#endif
  /* Enter Stop mode */
#if defined(UART_WKUP_SUPPORT) && (defined(PWR_CPUCR_RETDS_CD) \
|| defined(PWR_CR1_LPMS_STOP2) || defined(PWR_LOWPOWERMODE_STOP2) \
|| defined(LL_PWR_STOP2_MODE))
  if ((WakeUpUart == NULL)
      || (WakeUpUart->Instance == (USART_TypeDef *)LPUART1_BASE)
#ifdef LPUART2_BASE
      || (WakeUpUart->Instance == (USART_TypeDef *)LPUART2_BASE)
#endif
     ) {
#if defined(PWR_CR1_RRSTP)
    // STM32L4+ must keep SRAM3 content when entering STOP2 lowpower mode
    HAL_PWREx_EnableSRAM3ContentRetention();
#endif /* PWR_CR1_RRSTP */
    // STM32L4xx supports STOP2 mode which halves consumption
    HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
  } else
#endif
  {
#if defined(PWR_LOWPOWERREGULATOR_ON)
    HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
#else
    HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_STOPENTRY_WFI);
#endif
  }

  /* Exit Stop mode reset clocks */
  SystemClock_ConfigFromStop();
#if defined(UART_WKUP_SUPPORT)
  if (WakeUpUart != NULL) {
    /* In case of WakeUp from UART, reset its clock source to HSI */
    uart_config_lowpower(obj);
    HAL_UARTEx_DisableStopMode(WakeUpUart);
  }
#else
  UNUSED(obj);
#endif
  __enable_irq();

  HAL_Delay(10);

  if (WakeUpUartCb != NULL) {
    WakeUpUartCb();
  }
}

/**
  * @brief  Enable the standby mode. The board reset when leaves this mode.
  * @param  None
  * @retval None
  */
void LowPower_standby()
{
  __disable_irq();

  /* Clear wakeup flags */
#if defined(PWR_FLAG_WU)
  __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
#elif defined(PWR_CPUCR_CSSF)
  __HAL_PWR_CLEAR_FLAG(PWR_CPUCR_CSSF);
#elif defined(PWR_MPUCR_CSSF)
  __HAL_PWR_CLEAR_FLAG(PWR_MPUCR_CSSF);
#endif

#if defined(PWR_CR_ULP)
  /* Enable Ultra low power mode */
  HAL_PWREx_EnableUltraLowPower();
#endif
#if defined(PWR_CR_FWU)
  /* Enable the fast wake up from Ultra low power mode */
  HAL_PWREx_EnableFastWakeUp();
#endif
#if defined(STM32WBxx)
  /* Set low-power mode of CPU2 */
  /* Note: Typically, action performed by CPU2 on a dual core application.
           Since this example is single core, perform it by CPU1. */
  /* Note: On STM32WB, both CPU1 and CPU2 must be in low-power mode
           to set the entire System in low-power mode, corresponding to
           the deepest low-power mode possible.
           For example, CPU1 in Stop2 mode and CPU2 in Shutdown mode
           will make system enter in Stop2 mode. */
  LL_C2_PWR_SetPowerMode(LL_PWR_MODE_STANDBY);
#endif
  HAL_PWR_EnterSTANDBYMode();
}

/**
  * @brief  Enable the shutdown mode.The board reset when leaves this mode.
  *         If shutdown mode not available, use standby mode instead.
  * @param  boolean true if RTC is configured, in that case LSE is required
  * @retval None
  */
void LowPower_shutdown(bool isRTC)
{
  __disable_irq();

  /* Clear wakeup flags */
#if defined(PWR_FLAG_WU)
  __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
#elif defined(PWR_CPUCR_CSSF)
  __HAL_PWR_CLEAR_FLAG(PWR_CPUCR_CSSF);
#elif defined(PWR_MPUCR_CSSF)
  __HAL_PWR_CLEAR_FLAG(PWR_MPUCR_CSSF);
#endif
#if defined(STM32WBxx)
  /* Set low-power mode of CPU2 */
  /* Note: Typically, action performed by CPU2 on a dual core application.
           Since this example is single core, perform it by CPU1. */
  /* Note: On STM32WB, both CPU1 and CPU2 must be in low-power mode
           to set the entire System in low-power mode, corresponding to
           the deepest low-power mode possible.
           For example, CPU1 in Stop2 mode and CPU2 in Shutdown mode
           will make system enter in Stop2 mode. */
  LL_C2_PWR_SetPowerMode(LL_PWR_MODE_SHUTDOWN);
#endif
#if defined(LL_PWR_SHUTDOWN_MODE) || defined(LL_PWR_MODE_SHUTDOWN)
  /* LSE must be on to use shutdown mode within RTC else fallback to standby */
  if ((!isRTC) || (__HAL_RCC_GET_FLAG(RCC_FLAG_LSERDY) == SET)) {
    HAL_PWREx_EnterSHUTDOWNMode();
  } else
#else
  UNUSED(isRTC);
#endif
  {
    LowPower_standby();
  }
}

/**
  * @brief  Configure the UART as a wakeup source. A callback can be called when
  *         the chip leaves the low power mode. See board datasheet to check
  *         with which low power mode the UART is compatible.
  * Warning This function will change UART clock source to HSI
  * @param  serial: pointer to serial
  * @param  FuncPtr: pointer to callback
  * @retval None
  */
void LowPower_EnableWakeUpUart(serial_t *serial, void (*FuncPtr)(void))
{
#if defined(UART_WKUP_SUPPORT)
#ifdef IS_UART_WAKEUP_SELECTION
  UART_WakeUpTypeDef WakeUpSelection;
  if (serial == NULL) {
    return;
  }
  /* Save Uart handler and Serial object */
  WakeUpUart = &(serial->handle);

  /* make sure that no UART transfer is on-going */
  while (__HAL_UART_GET_FLAG(WakeUpUart, USART_ISR_BUSY) == SET);
  /* make sure that UART is ready to receive
   * (test carried out again later in HAL_UARTEx_StopModeWakeUpSourceConfig) */
  while (__HAL_UART_GET_FLAG(WakeUpUart, USART_ISR_REACK) == RESET);

  /* set the wake-up event:
   * specify wake-up on RXNE flag
   */
  WakeUpSelection.WakeUpEvent = UART_WAKEUP_ON_READDATA_NONEMPTY;
  HAL_UARTEx_StopModeWakeUpSourceConfig(WakeUpUart, WakeUpSelection);
#endif
#if defined(UART_IT_WUF)
  /* Enable the UART Wake UP from STOPx mode Interrupt */
  __HAL_UART_ENABLE_IT(WakeUpUart, UART_IT_WUF);
#endif
#else
  UNUSED(serial);
#endif
  /* Save callback */
  WakeUpUartCb = FuncPtr;
}

/**
  * @brief  Configures system clock and system IP clocks after wake-up from STOP
  * [url=home.php?mod=space&uid=536309]@NOTE[/url]   Weaked function which can be redefined by user at the sketch level.
  *         By default, call 'SystemClock_Config()'.
  * @param  None
  * @retval None
  */
WEAK void SystemClock_ConfigFromStop(void)
{
  configIPClock();
  SystemClock_Config();
}

#ifdef __cplusplus
}
#endif

#endif /* HAL_PWR_MODULE_ENABLED  && !HAL_PWR_MODULE_ONLY */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

使用特权

评论回复
9
天灵灵地灵灵| | 2024-4-19 17:27 | 只看该作者
/**
  ******************************************************************************
  * @file    LowPower.h
  * @author  Frederic Pillon
  * @brief   Header for Low Power module
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; COPYRIGHT(c) 2020 STMicroelectronics</center></h2>
  *
  * Redistribution and use in source and binary forms, with or without modification,
  * are permitted provided that the following conditions are met:
  *   1. Redistributions of source code must retain the above copyright notice,
  *      this list of conditions and the following disclaimer.
  *   2. Redistributions in binary form must reproduce the above copyright notice,
  *      this list of conditions and the following disclaimer in the documentation
  *      and/or other materials provided with the distribution.
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
  *      may be used to endorse or promote products derived from this software
  *      without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  ******************************************************************************
  */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __LOW_POWER_H
#define __LOW_POWER_H

/* Includes ------------------------------------------------------------------*/
#include "stm32_def.h"
#include "uart.h"

#if defined(HAL_PWR_MODULE_ENABLED) && !defined(HAL_PWR_MODULE_ONLY)

#ifdef __cplusplus
extern "C" {
#endif

/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */

void LowPower_init();
void LowPower_EnableWakeUpPin(uint32_t pin, uint32_t mode);
void LowPower_EnableWakeUpUart(serial_t *serial, void (*FuncPtr)(void));
void LowPower_sleep(uint32_t regulator);
void LowPower_stop(serial_t *obj);
void LowPower_standby();
void LowPower_shutdown(bool isRTC);
/* Weaked function */
void SystemClock_ConfigFromStop(void);
#ifdef __cplusplus
}
#endif

#endif /* HAL_PWR_MODULE_ENABLED  && !HAL_PWR_MODULE_ONLY */

#endif /* __LOW_POWER_H */

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

184

主题

3014

帖子

7

粉丝