STR使用参考

Version 0.1


1. 概述

STR即Suspend To Ram,是一种低功耗模式,RTOS支持xtal_gating、wfi等模式进入低功耗。


2. RTOS使用STR


2.1. API

头文件:hal_power_manag.h

void HalSTR_WakeupInit(enum strType mode, int gpio);

enum strType{
    uvc_mode,            //__USB_GADGET_STR__: 
    remote_wakeup_mode, //not support
    gpio_wfi_mode,        //Support HID connect (USBPLL不关)
    gpio_xtalgate_mode,   //only GPIO
    gpio_usb_wfi_mode,
    gpio_usb_mode,
}

2.2. 命令

pm_str_init [mode] [gpio index]

pm_str_init 0 0 : uvc (xtal_gating) //仅支持UVC suspend / resume event
pm_str_init 1 29: gpio(TTL 12)/ uvc remote wakeup (xtal_gating): not support //目前不支持
pm_str_init 2 29: gpio(TTL 12)(wfi) //GPIO为唤醒源. suspend当下为WFI mode
pm_str_init 3 29: gpio(TTL 12)(xtal_gating) //GPIO为唤醒源. suspend当下为xtal_gating
pm_str_init 4 29: gpio and usb (TTL 12)(wfi) //GPIO/USB皆为唤醒源, suspend当下为wfi mode
pm_str_init 5 29: gpio and usb(TTL12)(xtal_gating) //GPIO/USB皆为唤醒源, suspend当下为xtal_gating

pm_str : 进入STR

2.3. 使用时机

  • UVC应用

    • HalSTR_WakeupInit(uvc_mode, 0)

    • run_command("pm_str_init 0 0");

    • run_command("pm_str");

  • HID应用 (GPIO为唤醒源, 但睡眠时保持USB连接)

    • HalSTR_WakeupInit(gpio_wfi_mode, GPIO_index)

    • run_command("pm_str_init 2 29"); (PAD_TTL12当唤醒源)

    • run_command("pm_str");


3. WFI与XTAL_Gating差异


3.1. 性能差异

XTAL_GATING WFI
耗电量 较低 较高
唤醒种类 USB GPIO(index0~70) 中断皆可 常用为USB/ GPIO
唤醒条件 Active High 皆可
唤醒时间 无差异 无差异

3.2. 耗电量差异

Board SSC021A-S01A-S

config 35 pioneer3_64_nor_isw_uvc_str commit: 3a352b32
suspend Type xtal_Gating wfi
Voltage 5V 5V
preview 130mA 130mA
suspend 23.1mA
拔sensor 7.7mA
58.1mA
拔sensor 15.7mA
idle 74mA 74mA
config 33 pioneer3_64_nor_isw commit: 3a352b32
suspend Type xtal_Gating wfi
cmd str_init 3 29 str_init 2 29
Voltage 5V 5V
suspend 7.5mA 8.8mA
idle 74mA 74mA

4. 注意事项

  1. gpio按钮唤醒需要注意bounce

    WFI mode下使用按钮睡眠 < - >唤醒时需注意bounce, 可在唤醒源中断中加上Delay, 或是修改电路。

  2. WFI mode下使用其他中断:SetWakeupIrq(irq, GPIO);

    以下为注册gpio为唤醒源范例。IRQ也可替换成其他中断, gpio填0即可

    以下为注册gpio及USB为唤醒源的范例。Usb部分注册此INT_IRQ_OTG中断为唤醒源

  3. 在进入和退出STR做客制化操作

    头文件路径:drv_power_manag.h

    使用接口drv_power_manag_register_dev_handle对唤醒和睡眠时动作做实现。可参考ms_iic_rtk.cI2C_Probe函数的用法,注册一个对象,对pfResumeFuncpfSuspendFunc成员函数做相关实现。