Mbed OS 文档翻译 之 参考(API(平台(DeepSleepLock)))

DeepSleepLock

DeepSleepLock 类提供用于禁用睡眠的 RAII 对象。换句话说,创建 DeepSleepLock 对象会调用其构造函数,该构造函数会增加深度睡眠防护锁定。当对象超出范围时,DeepSleepLock 对象会在其析构函数中自动释放深度睡眠防护锁。另一种看待它的方法是当 DeepSleepLock 对象存在时,它会阻止深度睡眠。

       注意: 不在深度睡眠模式下工作的驱动程序会自动阻止深度睡眠模式,因此 DeepSleepLock 不需要保护它们。

DeepSleepLock 类参考

mbed::DeepSleepLock 类参考

公共成员函数
void lock ()
void unlock ()

示例

此示例显示了如何锁定深度睡眠以减少中断延迟,但代价是功耗增加。

main.cpp                                                                                                                                       导入到 Mbed IDE

#include "mbed.h"

InterruptIn button(BUTTON1);
DigitalOut led(LED1);

void toggle()
{
    led = !led;
}

int main()
{
    button.rise(&toggle);
    button.fall(&toggle);

    // Lock deep sleep to decrease interrupt latency
    // at the expense of high power consumption
    DeepSleepLock lock;

    while(1) {
        // Wait and let interrupts take care of the rest
        wait(1.0);
    }
}
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值