完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
使用的开发板为正点原子的 STM32F429IGTx 阿波罗开发板,内核版本为 4.0.4,PM组件版本为 2.0。
在测试时测试过程如下,下载程序后查看当前处于运行模式,然后请求 DeepSleep 也就是停止模式,然后释放掉 None Mode,此时板子就唤醒不了了,按理说在停止模式下可以使用外部中断(外部按键)进行唤醒,但是按下按键没有响应。在裸机代码中使用按键可以唤醒 stop 模式。 | / - RT - Thread Operating System / | 4.0.4 build May 30 2022 14:08:12 2006 - 2021 Copyright by rt-thread team [I/drv.rtc] RTC hasn't been configured, please use msh >date Sat Jan 1 00:06:25 2000 msh >list_device device type ref count -------- -------------------- ---------- rtc RTC 0 pm PM Pseudo Device 0 uart1 Character Device 2 pin Miscellaneous Device 0 msh > msh >pm_dump | Power Management Mode | Counter | Timer | +-----------------------+---------+-------+ | None Mode | 1 | 0 | | Idle Mode | 0 | 0 | | LightSleep Mode | 0 | 0 | | DeepSleep Mode | 0 | 1 | | Standby Mode | 0 | 0 | | Shutdown Mode | 0 | 0 | +-----------------------+---------+-------+ pm current sleep mode: None Mode pm current run mode: Normal Speed | module | busy | start time | timeout | +--------+------+------------+-----------+ | 0001 | 0 | 0x00000000 | 0x00000000 | +--------+------+------------+-----------+ msh > msh >pm_request 3 msh > msh >pm_dump | Power Management Mode | Counter | Timer | +-----------------------+---------+-------+ | None Mode | 1 | 0 | | Idle Mode | 0 | 0 | | LightSleep Mode | 0 | 0 | | DeepSleep Mode | 1 | 1 | | Standby Mode | 0 | 0 | | Shutdown Mode | 0 | 0 | +-----------------------+---------+-------+ pm current sleep mode: None Mode pm current run mode: Normal Speed | module | busy | start time | timeout | +--------+------+------------+-----------+ | 0001 | 0 | 0x00000000 | 0x00000000 | +--------+------+------------+-----------+ msh > msh >pm_release 0 msh >on ▒▒M main.c 的代码如下: #include #include "rtdevice.h" #include "drv_common.h" #include "led.h" #include "key.h" #define DBG_TAG "main" #define DBG_LVL DBG_LOG #include void pm_notify_callback(rt_uint8_t event, rt_uint8_t mode, void *data) { if(event == RT_PM_ENTER_SLEEP) { //if(mode == PM_SLEEP_MODE_DEEP) { led0_on(); rt_kprintf("onn"); } } else if (event == RT_PM_EXIT_SLEEP) { //if(mode == PM_SLEEP_MODE_DEEP) { led0_off(); rt_kprintf("offn"); } } } int main(void) { led_init(); key_irq_init(); rt_pm_notify_set(pm_notify_callback, 0); while (1) { led1_on(); rt_thread_mdelay(500); led1_off(); rt_thread_mdelay(500); } return RT_EOK; } 按键的初始化代码如下,在没有休眠时,按下 KEY0 或者 KEY1 可以进入回调函数打印 "key irqn" #include #include "rtdevice.h" #include "drv_common.h" #include "key.h" |
|
相关推荐
1个回答
|
|
不要在 msh 里用命令请求休眠。 单独写个测试命令,起个线程去请求休眠模式可能就好了。
命令是运行在 tshell 线程中的,你现在可能已经唤醒了,但是 shell 线程没退出来,不能把串口的数据拿回来,就卡在里面了。 static void wakeup_callback(void* p) { rt_event_send(wakeup_event, WAKEUP_EVENT_BUTTON); } void wakeup_sample(void) { /* init */ rt_uint32_t pin = rt_pin_get(USER_INPUT); rt_kprintf("n pin number : 0x%04X n", pin); rt_err_t err = rt_pin_attach_irq(pin, PIN_IRQ_MODE_RISING, wakeup_callback, RT_NULL); if (RT_EOK != err) { rt_kprintf("n attach irq failed. n"); } err = rt_pin_irq_enable(pin, PIN_IRQ_ENABLE); if (RT_EOK != err) { rt_kprintf("n enable irq failed. n"); } } static void wakeup_init(void) { wakeup_event = rt_event_create("wakup", RT_IPC_FLAG_FIFO); RT_ASSERT(wakeup_event != RT_NULL); wakeup_sample(); } static void pm_mode_init(void) { rt_pm_release_all(RT_PM_DEFAULT_SLEEP_MODE); rt_pm_request(PM_SLEEP_MODE_NONE); } void pm_test_entry(void* para) { /* 唤醒回调函数初始化 */ wakeup_init(); /* 电源管理初始化 */ pm_mode_init(); while (1) { /* 等待唤醒事件 */ if (rt_event_recv(wakeup_event, WAKEUP_EVENT_BUTTON, RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR, RT_WAITING_FOREVER, RT_NULL) == RT_EOK) { led_app(); } } } int pm_test(void) { rt_thread_t tid = rt_thread_create( "pmtest",pm_test_entry,RT_NULL,512,10,10); if(tid) rt_thread_startup(tid); return 0; } MSH_CMD_EXPORT(pm_test, pm_test); #endif |
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
1056 浏览 0 评论
AI模型部署边缘设备的奇妙之旅:如何在边缘端部署OpenCV
3545 浏览 0 评论
tms320280021 adc采样波形,为什么adc采样频率上来波形就不好了?
1482 浏览 0 评论
2181 浏览 0 评论
1663 浏览 0 评论
75382 浏览 21 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-29 03:20 , Processed in 0.623257 second(s), Total 71, Slave 55 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号