libxr
Embedded C++ framework for bare-metal, RTOS and Linux
Loading...
Searching...
No Matches
LibXR::HPMPowerManager Class Reference

HPM 电源管理实现 / HPM power manager implementation. More...

#include <hpm_power.hpp>

Inheritance diagram for LibXR::HPMPowerManager:
[legend]
Collaboration diagram for LibXR::HPMPowerManager:
[legend]

Public Member Functions

void Reset () override
 PPOR 软件复位整机 / Resets the whole device through the PPOR.
 
void Shutdown () override
 进入 power down 模式 / Enters the power down mode
 
void JumpToBootloader () override
 进入 ROM ISP / Enters the ROM ISP
 
- Public Member Functions inherited from LibXR::PowerManager
 PowerManager ()=default
 默认构造函数 / Default constructor
 
virtual ~PowerManager ()=default
 默认析构函数 / Default destructor
 
void RegisterCommand (RamFS &ramfs)
 在 RamFS 根目录注册 power 命令 / Registers the power command in the RamFS root
 
void CheckBootloaderPin (GPIO &pin, bool level)
 启动时按引脚电平进入启动加载器 / Pin-level bootloader entry at startup
 

Detailed Description

HPM 电源管理实现 / HPM power manager implementation.

Definition at line 12 of file hpm_power.hpp.

Constructor & Destructor Documentation

◆ HPMPowerManager()

HPMPowerManager::HPMPowerManager ( )
explicit

Definition at line 11 of file hpm_power.cpp.

11{}

Member Function Documentation

◆ JumpToBootloader()

void HPMPowerManager::JumpToBootloader ( )
overridevirtual

进入 ROM ISP / Enters the ROM ISP

关中断后调用 ROM API 进入 ISP,外设由 ROM 自动探测;正常不返回,返回时复位整机。 Disables the interrupts and calls the ROM API to enter the ISP, with the peripheral auto-detected by the ROM; the call does not return normally, and a return resets the device.

Reimplemented from LibXR::PowerManager.

Definition at line 63 of file hpm_power.cpp.

64{
65 disable_global_irq(CSR_MSTATUS_MIE_MASK);
66 api_boot_arg_t arg;
67 arg.index = 0;
68 arg.peripheral = API_BOOT_PERIPH_AUTO;
69 arg.src = API_BOOT_SRC_ISP;
70 arg.tag = API_BOOT_TAG;
71 rom_enter_bootloader(&arg);
72 Reset();
73}
void Reset() override
PPOR 软件复位整机 / Resets the whole device through the PPOR.
Definition hpm_power.cpp:20

◆ Reset()

void HPMPowerManager::Reset ( )
overridevirtual

PPOR 软件复位整机 / Resets the whole device through the PPOR.

做法与 SDK 的 DFU 触发例程一致:使能软件复位源后按 24 个计数(约 1 微秒)触发复位。 The same sequence as the DFU trigger sample of the SDK: enable the software reset source, then issue the reset after 24 counters (about one microsecond).

Implements LibXR::PowerManager.

Definition at line 20 of file hpm_power.cpp.

21{
22 ppor_reset_mask_set_source_enable(HPM_PPOR, ppor_reset_software);
23 ppor_sw_reset(HPM_PPOR, 24);
24 while (true)
25 {
26 }
27}

◆ Shutdown()

void HPMPowerManager::Shutdown ( )
overridevirtual

进入 power down 模式 / Enters the power down mode

有 PDGO 的 SoC(HPM5300 系列等)按 SDK 电源模式例程的做法设置关断计数后等待断电, 由 RESETN 或 WAKEUP 引脚唤醒;没有 PDGO 的 SoC 退化为关中断后执行 WFI 等待。 SoCs with a PDGO (the HPM5300 series among others) set the turn-off counter as the power mode sample of the SDK does and wait for the power down, woken up by the RESETN or WAKEUP pin; SoCs without a PDGO fall back to disabling interrupts and executing WFI.

Implements LibXR::PowerManager.

Definition at line 39 of file hpm_power.cpp.

40{
41#ifdef HPM_PDGO_BASE
42 pdgo_set_turnoff_counter(HPM_PDGO, 0x100);
43 while (true)
44 {
45 }
46#else
47 disable_global_irq(CSR_MSTATUS_MIE_MASK);
48 while (true)
49 {
50 __asm volatile("wfi");
51 }
52#endif
53}

The documentation for this class was generated from the following files: