1065 views|4 replies

91

Posts

0

Resources
The OP
 

Read "RT-Thread Device Driver Development Guide" --- Part 5 [Copy link]

 
This post was last edited by xiaolinen on 2023-9-28 15:28

Read "RT-Thread Device Driver Development Guide" --- PM device driver learning

Part 1: Understanding PM Components

The PM component adopts a layered design concept, separating the architecture and chip-related parts, and extracting the common parts as the core, which not only ensures the uniformity of the interface called by the application layer, but also realizes the flexibility of the underlying driver adaptation. The framework structure diagram is as follows:

My humble opinion:

1) PM component is a management framework. We should use it according to the actual situation. It is not a restriction that requires using PM component when using rt-thread.

2) Since it is a framework, we need to adapt it, modify and verify it according to the business requirements of the application layer, so as to achieve optimal power consumption .

3) The PM component framework is not only applicable to rt-thred, but can also be ported to other rtos.

Part 2: Using PM Components

In the ENV tool, turn on the PM component, as shown in the figure:

File location:

Part III: Some codes and experimental phenomena
Code:
/*
功能:深度睡眠
*/
void pm_bsp_enter_deepsleep(struct rt_pm *pm)
{

	HAL_SysTickDisable();
	if (pm->run_mode == PM_RUN_MODE_LOW_SPEED)
    {
        /* Enter LP SLEEP Mode, Enable low-power regulator */
         pmu_to_deepsleepmode(PMU_LDO_LOWPOWER,PMU_LOWDRIVER_ENABLE,WFI_CMD);
    }
    else
    {
        /* Enter SLEEP Mode, Main regulator is ON */
        pmu_to_deepsleepmode(PMU_LDO_LOWPOWER,PMU_LOWDRIVER_ENABLE,WFI_CMD);
    }
		HAL_SysTickEnable();
		
}

/*
功能:深度睡眠1
*/
void pm_bsp_enter_deepsleep_1(struct rt_pm *pm)
{
    
	HAL_SysTick_IRQ_Disable();
	if (pm->run_mode == PM_RUN_MODE_LOW_SPEED)
    {
        /* Enter LP SLEEP Mode, Enable low-power regulator */
         pmu_to_deepsleepmode_1(PMU_LDO_LOWPOWER,PMU_LOWDRIVER_ENABLE,WFI_CMD);
    }
    else
    {
        /* Enter SLEEP Mode, Main regulator is ON */
        pmu_to_deepsleepmode_1(PMU_LDO_LOWPOWER,PMU_LOWDRIVER_ENABLE,WFI_CMD);
    }
		HAL_SysTick_IRQ_Enable();
    
}

/*
功能:深度睡眠2
*/
void pm_bsp_enter_deepsleep_2(struct rt_pm *pm)
{
	rt_base_t level;
	//level = rt_hw_interrupt_disable();
	HAL_SysTick_IRQ_Disable();
    if (pm->run_mode == PM_RUN_MODE_LOW_SPEED)
    {
        /* Enter LP SLEEP Mode, Enable low-power regulator */
         pmu_to_deepsleepmode_2(PMU_LDO_LOWPOWER,PMU_LOWDRIVER_ENABLE,WFI_CMD);
    }
    else
    {
        /* Enter SLEEP Mode, Main regulator is ON */
        pmu_to_deepsleepmode_2(PMU_LDO_LOWPOWER,PMU_LOWDRIVER_ENABLE,WFI_CMD);
    }
				//system_lowpower_set(SCB_LPM_DEEPSLEEP);
		HAL_SysTick_IRQ_Enable();
		// rt_hw_interrupt_enable(level);

}

/*
功能:待机模式
*/
void pm_bsp_enter_standby(struct rt_pm *pm)
{
    pmu_to_standbymode(WFI_CMD);
}

Realization phenomenon:

Normal operation of the equipment: 165mA;

Device sleep state (external sensor power-off operation): 27uA;

Summarize:

Adjusting the power consumption of equipment is a technical job and a physical job. You will inevitably encounter various problems when adjusting the power consumption. If you can sit still and work hard, there will be fewer and fewer problems. Remember not to lose your mind for a while and then lose your mind again. It is useless to lose your mind for many times. After all, the work is yours and you need to finish it!!! Now, with the PM framework, we cannot say that our problems are completely solved, but at least it points out some solutions for us. I personally think that the essence of rt-thread is not only its system, but more of its components. These components provide convenience and show us a programming idea. RT-Thread is a beautiful product that deserves our in-depth study and full application.

Latest reply

This component should only be available in the standard version of RTThread, right?   Details Published on 2023-9-30 09:21
 

6748

Posts

2

Resources
2
 

I haven't paid much attention to this PM power management component. Will it enter sleep mode when the MCU is not working?

Comments

Yes, put the MCU to sleep if it needs it  Details Published on 2023-9-28 17:22
 
 
 

91

Posts

0

Resources
3
 
wangerxian posted on 2023-9-28 17:07 I haven't paid much attention to this PM power management component. Will it enter sleep mode when the MCU is not working?

Yes, put the MCU to sleep if the MCU needs it

Comments

This component should only be available in the standard version of RTThread, right?  Details Published on 2023-9-30 09:21
 
 
 

6748

Posts

2

Resources
4
 
xiaolinen posted on 2023-9-28 17:22 Yes, put the MCU to sleep if the MCU needs it

This component should only be available in the standard version of RTThread, right?

Comments

Yes  Details Published on 2023-10-1 22:43
 
 
 

91

Posts

0

Resources
5
 
wangerxian posted on 2023-9-30 09:21 This component should only be available in the standard version of RTThread, right?

Yes

 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list