工具/软件:
尊敬的团队:
我正在开发一款可以在长按后使用按钮打开/关闭电源的器件。 以前它可以正常工作、但最近我在它上添加了一个片上 OAD 功能。
之后、我发现只能在长按后关闭器件、但无法再次唤醒。
下面是长按一下按钮唤醒/关闭的主要逻辑,我将 Boot_init () 放在 SimplePeripheral_taskFxn 函数的开头:
void Boot_Init ()
{
PowerCC26X2_ResetReason resetReason = PowerCC26X2_getResetReason ();
if (resetReason == PowerCC26X2_RESET_SHUTDOWN_IO)
{
PowerCC26X2_releaseLatters();
BootCountDownCreate();
BootCountDownInit();
GPIO_setConfig (CONFIG_GPIO_MPB_CONST、GPIO_CFG_IN_PU);
uint8_t PRESS = GPIO_READ (CONFIG_GPIO_MPB_CONST);
BootServiceRoutine(印刷机);
BootCountEliminate();
GPIO_resetconfig (CONFIG_GPIO_MPB_CONST);
howToBoot = 0x00;
}
否则 if (resetReason == PowerCC26X2_RESET_TCK_NOISE)
{
howToBoot = 0x01;
}
否则 if (resetReason == PowerCC26X2_RESET_SYSTEM)
{
howToBoot = 0x02;
}
否则 if (resetReason == PowerCC26X2_RESET_WARM_RESET)/*快速引导*/
{
howToBoot = 0x03;
}
否则 if (resetReason == PowerCC26X2_RESET_CLK)
{
howToBoot = 0x04;
}
否则 if (resetReason == PowerCC26X2_RESET_VDDR)
{
howToBoot = 0x05;
}
否则 if (resetReason == PowerCC26X2_RESET_VDDS)
{
howToBoot = 0x06;
}
否则 if (resetReason == PowerCC26X2_RESET_PIN)
{
howToBoot = 0x07;
}
否则 if (resetReason == PowerCC26X2_RESET_POR)
{
howToBoot = 0x08;
}
}
void BootServiceRoutine (uint8_t isWakeUp)
{
uint8_t boot_finished = 0x00;
IF (isWakeUp = 0)
{
/*如果用户仍在按此按钮、倒计时器将立即启动*/
uint8_t stillPress = GPIO_READ (CONFIG_GPIO_MPB_CONST);
if (stillPress == 0x00)
{
/*开始向下计数的时间为 BOOTREADY_TIME x BOOTREADY_COUNT 秒*/
BootCountStart();
}
/*我们还没有启动! 尽管您正在按下按钮! 不要放下你的手!*/
while (boot_finished == 0x00)
{
/* STATUS = 0x01 -->释放按钮
* status = 0x00 -->按下按钮
*/
uint8_t status = GPIO_READ (CONFIG_GPIO_MPB_CONST);
我的天哪! 您已释放按钮! 让我再睡一觉!*/
IF (STATUS == 0x01)
{
/*倒计时器停止*/
BootCountStop();
/*再次进入关闭模式*/
SystemShutDownRoutine();
}
/*如果用户仍在按按钮直到时间增加、倒计时器将停止! 引导例程已完成! */
/*对于每 500 毫秒计时器溢出、bootCount 会增加 1。
*要有 1.5 秒的延迟, bootReady 是 3.
*要查看闪烁,请等待 bootReady 为 3 ,同时按下按钮!
**/
IF (bootReady >= BOOTREADY_COUNT)
{
/*已完成倒计数*/
BootCountStop();
/*祝贺您! 引导过程已完成! 走出圈子! 享受驾驶! */
BOOT_FINISED = 0x01;
}
}
}
否则 if (isWakeUp == 1)
{
while (boot_finished == 0x00)
{
/*再次进入关闭模式*/
SystemShutDownRoutine();
}
}
}
作废系统 ShutDownRoutine()
{
GPIO_resetconfig (CONFIG_GPIO_MPB_CONST);
/*如何唤醒我? */
GPIO_setConfig (CONFIG_GPIO_MPB_CONST、GPIO_CFG_INPUT_INTERNAL | GPIO_CFG_PULL_UP_INTERNAL | GPIO_CFG_SHUTDOWN_WAKE_LOW);
/*让我睡觉! 再见! */
POWER_SHUTDOWN (0、0);
while (1)
{
}
}
我想知道此问题是否与 bim_onchip 有关、因此我需要对 bim 工程实现我的按钮按压逻辑?
我正在使用 simplelink_cc13xx_cc26xx_sdk_7_40_00_77 和 CCS 12.8.1、您能帮我解决这个问题吗?
非常感谢。
Jermyn