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.

CC2538按键长按短按

Other Parts Discussed in Thread: CC2538, CC2630, CC2530

你好,CC2538基于3.0HA的协议栈,实现按键的长按短按识别,
代码如下,可是实际上得不到想要的效果,
按键的中断和查询方式在哪里设置?
static void zclSampleDoorLockController_HandleKeys( byte shift, byte keys )
{
    (void)shift; // Intentionally unreferenced parameter
    if( keys & HAL_KEY_SW_1 )
      {
      keyPressTime = osal_getClock();
      }
    else
      {
      if ( keyPressTime )
        {
         keyPressTime = ( osal_getClock() - keyPressTime );
        if ( keyPressTime < 3 )//小于3秒,短按
          {
          NLME_PermitJoiningRequest(30);//允许加入
          }
        else //大于3秒,长按
          {
          //恢复出厂设置
          zgWriteStartupOptions( ZG_STARTUP_SET, (ZCD_STARTOPT_DEFAULT_NETWORK_STATE | ZCD_STARTOPT_DEFAULT_CONFIG_STATE) );
          SystemResetSoft();
          }
          keyPressTime = 0;
        }
      }
}