This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CC2340R5:POWER_SHUTDOWN API 失败

Guru**** 2526700 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1561490/cc2340r5-power_shutdown-api-is-failing

器件型号:CC2340R5


工具/软件:

您好论坛、
我正在处理涉及多个 GPIO 的项目、它们的中断进一步涉及同一个 GPIO 用作从 SHUTDOWN 状态唤醒的触发器。 该应用涉及测量按钮按压间隔及其组合。
通常(预期)的情况如下:
button_press --> wake-up--> process_timings--> take_accessed_action--> shutdown

一切都适用于单按钮按下操作、即在执行操作后进入关断模式。 但是、当发生多次按钮按下时、“Power_Shutdown"API 出现“ 出现故障、器件保持开启状态。

失败时、返回值为 0xFFFF。
请让我来解释为什么会失败?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Vaibhav:

    根据 之前的经验 、我可以验证当某些关断 GPIO 处于活动或挂起状态时、电源 TI 驱动器是否可以阻止关断模式。  这是为了防止在关断期间出现意外的 I/O 状态并从关断模式恢复。  下面是 simplelink_lowpower_f3_SDK_9_11_00_18\source\ti\drivers\power\PowerCC23X0.c 提供的 Power_shutdown :

    /*
     *  ======== Power_shutdown ========
     */
    int_fast16_t Power_shutdown(uint_fast16_t shutdownState, uint_fast32_t shutdownTime)
    {
        int_fast16_t notifyStatus;
        uintptr_t hwiKey;
        uint8_t i;
        bool ioPending = false;
    
        hwiKey = HwiP_disable();
    
        /* Check if there is a constraint to prohibit shutdown */
        if ((Power_getConstraintMask() & (1U << PowerLPF3_DISALLOW_SHUTDOWN)) != 0U)
        {
            HwiP_restore(hwiKey);
            return Power_ECHANGE_NOT_ALLOWED;
        }
    
        /* Check whether we were transitioning to another power state */
        if (powerState != Power_ACTIVE)
        {
            HwiP_restore(hwiKey);
            return Power_EBUSY;
        }
    
        /* Set new transition state to entering shutdown */
        powerState = Power_ENTERING_SHUTDOWN;
    
        /* Signal all clients registered for pre-shutdown notification */
        notifyStatus = PowerCC23X0_notify(PowerLPF3_ENTERING_SHUTDOWN);
    
        for (i = GPIO_pinLowerBound; i <= GPIO_pinUpperBound; i++)
        {
            /* Read WUCFGSD field once and check both values.
             * Use IOC3 since CC2340R2 does not have IOC0, IOC1, or IOC2.
             */
            uint32_t ioShutdownConfig = HWREG(IOC_ADDR(i)) & IOC_IOC3_WUCFGSD_M;
    
            if (((ioShutdownConfig == IOC_IOC3_WUCFGSD_WAKE_HIGH) || (ioShutdownConfig == IOC_IOC3_WUCFGSD_WAKE_LOW)) &&
                (GPIOGetEventDio(i) != 0U))
            {
                ioPending = true;
            }
        }
    
        /* If no IO event is pending on a shutdown wakeup IO, go to shutdown */
        if (ioPending == false && notifyStatus == Power_SOK)
        {
            HWREG(PMCTL_BASE + PMCTL_O_SHTDWN) = PMCTL_SHTDWN_KEY_VALID;
        }
    
        /* If shutdown succeeded, should never get here */
    
        powerState = Power_ACTIVE;
    
        HwiP_restore(hwiKey);
    
        /* If we get here, failed to shutdown, return error code */
        return Power_EFAIL;
    }

    我建议为所有 GPIO 提供服务并确保它们在进入 SHUTDOWN 模式之前处于非活动状态。  您可以使用定期计时器持续检查并尝试在程序已开始时进入 SHUTDOWN 模式。

    此致、
    Ryan

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    谢谢 Ryan、

    您的解决方案有效。

    此致

    Vaibhav