小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

協(xié)議棧按鍵流程(轉(zhuǎn))

 韋小楓 2012-11-30

我使用的協(xié)議棧版本及例子信息:
ZigBee2006\Texas Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Samples\SampleApp

記錄下個(gè)人對(duì)按鍵流程的理解協(xié)議棧按鍵流程 - 小峰 - happy~

在hal_key.c中有一段說(shuō)明:
/*********************************************************************
 NOTE: If polling is used, the hal_driver task schedules the KeyRead()
       to occur every 100ms.  This should be long enough to naturally
       debounce(去抖動(dòng)) the keys.  The KeyRead() function remembers the key
       state of the previous poll and will only return a non-zero
       value if the key state changes.

 NOTE: If interrupts are used, the KeyRead() function is scheduled
       25ms after the interrupt occurs by the ISR.  This delay is used
       for key debouncing.  The ISR disables any further Key interrupt
       until KeyRead() is executed.  KeyRead() will re-enable Key
       interrupts after executing.  Unlike polling, when interrupts
       are enabled, the previous key state is not remembered.  This
       means that KeyRead() will return the current state of the keys
       (not a change in state of the keys).

 NOTE: If interrupts are used, the KeyRead() fucntion is scheduled by
       the ISR.  Therefore, the joystick movements will only be detected
       during a pushbutton interrupt caused by S1 or the center joystick
       pushbutton.

 NOTE: When a switch like S1 is pushed, the S1 signal goes from a normally
       high state to a low state.  This transition is typically clean.  The
       duration of the low state is around 200ms.  When the signal returns
       to the high state, there is a high likelihood of signal bounce, which
       causes a unwanted interrupts.  Normally, we would set the interrupt
       edge to falling edge to generate an interrupt when S1 is pushed, but
       because of the signal bounce, it is better to set the edge to rising
       edge to generate an interrupt when S1 is released.  The debounce logic
       can then filter out the signal bounce.  The result is that we typically
       get only 1 interrupt per button push.  This mechanism is not totally
       foolproof because occasionally, signal bound occurs during the falling
       edge as well.  A similar mechanism is used to handle the joystick
       pushbutton on the DB.  For the EB, we do not have independent control
       of the interrupt edge for the S1 and center joystick pushbutton.  As
       a result, only one or the other pushbuttons work reasonably well with
       interrupts.  The default is the make the S1 switch on the EB work more
       reliably.

*********************************************************************/

對(duì)本協(xié)議中,對(duì)按鍵有兩種處理方式
1、中斷法:有按鍵按下,則進(jìn)入中斷,開(kāi)啟一軟定時(shí)器25ms后,讀取鍵值進(jìn)行相應(yīng)處理
2、查詢法:開(kāi)啟一軟定時(shí)器,系統(tǒng)每隔100ms進(jìn)行輪詢,如有按鍵按下讀取鍵值進(jìn)行相應(yīng)處理
                   (軟定時(shí)器即軟件定時(shí)器,參見(jiàn)“系統(tǒng)時(shí)鐘定時(shí)器”說(shuō)明)                  

首先看下協(xié)議棧對(duì)KEY的初始化,在InitBoard()函數(shù)中:

     /* Initialize Key stuff */
    OnboardKeyIntEnable = HAL_KEY_INTERRUPT_DISABLE;
    HalKeyConfig( OnboardKeyIntEnable, OnBoard_KeyCallback);

從而知道協(xié)議棧默認(rèn)的按鍵處理機(jī)制是查詢法.就先來(lái)看下查詢法的流程:

 

1、查詢法(或者輪詢法)
首先看下HalKeyConfig()
這個(gè)函數(shù)用于把按鍵/開(kāi)關(guān)/操縱桿服務(wù)配置為輪詢或中斷驅(qū)動(dòng)。它還為服務(wù)配置一個(gè)回調(diào)函數(shù)。如果不使用中斷,輪詢?cè)?00ms后自動(dòng)開(kāi)始。按鍵/開(kāi)關(guān)/操縱桿將每100ms被輪詢一次。如果使用中斷,就使用一個(gè)ISR來(lái)處理這種情況.在中斷發(fā)生后,有一個(gè)25ms的延時(shí)以消除回跳.
/***************************************************************************
void HalKeyConfig (bool interruptEnable, halKeyCBack_t cback)
{
   ……………………

  if (Hal_KeyIntEnable)
  {

     ………… (清除中斷標(biāo)志,設(shè)置上升沿下降沿觸發(fā)外部中斷等)

    /* Do this only after the hal_key is configured - to work with sleep stuff */
    if (HalKeyConfigured == TRUE)
    {
      osal_stop_timerEx( Hal_TaskID, HAL_KEY_EVENT);   /* Cancel polling if active */
   /*如果采用中斷方式則不用定時(shí)器來(lái)查詢事件,關(guān)閉以前為這個(gè)事件開(kāi)啟的系統(tǒng)時(shí)鐘*/
    }
  }
  else    /* Interrupts NOT enabled */
  {

    ………… (清除中斷標(biāo)志等)
    osal_start_timerEx (Hal_TaskID, HAL_KEY_EVENT, HAL_KEY_POLLING_VALUE); /* Kick off polling */
  }

}
/***************************************************************************

可以看到查詢法中,開(kāi)啟了一個(gè)系統(tǒng)軟定時(shí)器,任務(wù)是HAL層任務(wù),事件是HAL_KEY_POLLING_VALUE,系統(tǒng)要定時(shí)輪詢按鍵事件得到按鍵值再作相應(yīng)處理。輪詢時(shí)間為#define HAL_KEY_POLLING_VALUE   100,即100ms.跟前面的英文說(shuō)明一致。當(dāng)這個(gè)軟定時(shí)器溢出時(shí),便設(shè)置事件發(fā)生標(biāo)志調(diào)用HAL層任務(wù)事件處理函數(shù),然后從系統(tǒng)時(shí)鐘鏈表中刪除這個(gè)軟定時(shí)器設(shè)置(后面會(huì)看到當(dāng)處理完按鍵事件后又會(huì)重新啟動(dòng)這個(gè)軟定時(shí)器).
下面就來(lái)看下它所調(diào)用的HAL層任務(wù)事件處理函數(shù):

/***************************************************************************
uint16 Hal_ProcessEvent( uint8 task_id, uint16 events )
{
  uint8 *msgPtr;

 ………… (其它事件處理)

  if (events & HAL_KEY_EVENT)
  {

#if (defined HAL_KEY) && (HAL_KEY == TRUE)
    /* Check for keys */
    HalKeyPoll();

    /* if interrupt disabled, do next polling */
    if (!Hal_KeyIntEnable)
    {
      osal_start_timerEx( Hal_TaskID, HAL_KEY_EVENT, 100);  //因?yàn)樵?HalKeyInit()時(shí),如果采用
    }                        //非中斷方式,已經(jīng)初始化設(shè)置過(guò)一個(gè)按鍵事件軟定時(shí)器,當(dāng)這個(gè)軟定時(shí)器
                             //溢出時(shí),便設(shè)置事件發(fā)生標(biāo)志調(diào)用事件處理函數(shù),然后從系統(tǒng)軟定時(shí)器鏈表
                             //中刪除這個(gè)定時(shí)器設(shè)置,因此這里調(diào)用HalKeyPoll()處理完后續(xù)工作后
                             //如果還是采用非中斷方式,則要重新開(kāi)啟一個(gè)軟定時(shí)器!
#endif  // HAL_KEY       

    return events ^ HAL_KEY_EVENT;
  }

 …………  (其它事件處理)

}
/***************************************************************************

可以看到HAL層任務(wù)事件處理函數(shù)中對(duì)按鍵事件HAL_KEY_EVENT調(diào)用HalKeyPoll()進(jìn)行下一步處理,在HalKeyPoll()處理完后跳出來(lái),立馬開(kāi)啟一個(gè)新的定時(shí)器,跟前面采用查詢法(非中斷:!Hal_KeyIntEnable)時(shí)開(kāi)啟的定時(shí)器一樣,準(zhǔn)備100ms后的下一次查詢!
下面看下
HalKeyPoll()

/***************************************************************************
void HalKeyPoll (void)
{
 …………
(調(diào)用HalAdcRead(),檢測(cè)模擬電壓值最終得出鍵值keys)

  /* Exit if polling and no keys have changed */
  if (!Hal_KeyIntEnable)
  {
    if (keys == halKeySavedKeys)
    {
      return;
    }
    halKeySavedKeys = keys;     /* Store the current keys for comparation next time */
  }

  /* Invoke Callback if new keys were depressed */
  if (keys && (pHalKeyProcessFunction))
  {
    (pHalKeyProcessFunction) (keys, HAL_KEY_STATE_NORMAL);
  }

#endif

}
/***************************************************************************

可以看到這里通過(guò)一系列處理讀取鍵值,最后調(diào)用按鍵的回調(diào)函數(shù) (pHalKeyProcessFunction) (keys, HAL_KEY_STATE_NORMAL);這之前有個(gè)存儲(chǔ)鍵值為下一次比較做準(zhǔn)備,這里是查詢法與中斷法之間鍵值讀取的區(qū)別點(diǎn),查詢法需要存儲(chǔ)鍵值,而中斷法則直接讀取當(dāng)前鍵值就好,具體我不鉆了?;氐交卣{(diào)函數(shù),在InitBoard()里調(diào)用HalKeyConfig( OnboardKeyIntEnable, OnBoard_KeyCallback),即把回調(diào)函數(shù)初始化為OnBoard_KeyCallback(),下面來(lái)看下這個(gè)函數(shù)

/***************************************************************************
void OnBoard_KeyCallback ( uint8 keys, uint8 state )
{
  uint8 shift;

  // shift key (S1) is used to generate key interrupt
  // applications should not use S1 when key interrupt is enabled

  shift = (OnboardKeyIntEnable == HAL_KEY_INTERRUPT_ENABLE) ? false : ((keys & HAL_KEY_SW_6) ? true : false);

  if ( OnBoard_SendKeys( keys, shift ) != ZSuccess )
  {
 …………  (如果不成功進(jìn)行的一些處理)
  }
}
/***************************************************************************

可以看到得到一個(gè)參數(shù)shift,然后調(diào)用了OnBoard_SendKeys( keys, shift ),來(lái)看下這個(gè)函數(shù)

/***************************************************************************
byte OnBoard_SendKeys( byte keys, byte state )
{
  keyChange_t *msgPtr;

  if ( registeredKeysTaskID != NO_TASK_ID )  //按鍵事件被注冊(cè)在sampleAPP應(yīng)用registeredKeysTaskID=SampleApp_TaskID
  {
    // Send the address to the task
    msgPtr = (keyChange_t *)osal_msg_allocate( sizeof(keyChange_t) );
    if ( msgPtr )
    {
      msgPtr->hdr.event = KEY_CHANGE;
      msgPtr->state = state;
      msgPtr->keys = keys;

      osal_msg_send( registeredKeysTaskID, (uint8 *)msgPtr );//
    }
    return ( ZSuccess );
  }
  else
    return ( ZFailure );
}
/***************************************************************************

可以看到首先涉及到一個(gè)參數(shù)registeredKeysTaskID,在OnBoard.c中它被定義為:
static byte registeredKeysTaskID = NO_TASK_ID;
如果是這樣的話,那按鍵事件處理到這里就返回一個(gè)ZFailure,沒(méi)有任何反應(yīng)了,但在SampleApp這個(gè)例子中是按SW1:發(fā)送閃爍消息到組1,按SW2:進(jìn)/退組…這是為何?這里涉及到一個(gè)函數(shù)RegisterForKeys( byte task_id ),來(lái)看下:

/***************************************************************************
 * Keyboard Register function
 *
 * The keyboard handler is setup to send all keyboard changes to
 * one task (if a task is registered).
 *
 * If a task registers, it will get all the keys. You can change this
 * to register for individual keys.

 ************************************
byte RegisterForKeys( byte task_id )  //task_id=SampleApp_TaskID
{
  // Allow only the first task
  if ( registeredKeysTaskID == NO_TASK_ID )
  {
    registeredKeysTaskID = task_id;
    return ( true );
  }
  else
    return ( false );
}
/***************************************************************************
可以看到一個(gè)應(yīng)用任務(wù)要得到按鍵值,那必須首先進(jìn)行注冊(cè),這樣一旦有按鍵發(fā)生,這個(gè)任務(wù)才能得到鍵值進(jìn)行相應(yīng)的處理,而協(xié)議棧中唯一一個(gè)用戶應(yīng)用任務(wù)SampleApp就對(duì)其進(jìn)行了注冊(cè),具體在SampleApp_Init()函數(shù)中有這么一句:

// Register for all key events - This app will handle all key events
RegisterForKeys( SampleApp_TaskID );

即可由這個(gè)任務(wù)SampleApp來(lái)處理按鍵事件。通過(guò)函數(shù)參數(shù)傳遞易知最后registeredKeysTaskID=SampleApp_TaskID,然后再回到OnBoard_SendKeys()這個(gè)函數(shù)中,此時(shí)registeredKeysTaskID != NO_TASK_ID,所以調(diào)用 osal_msg_send( registeredKeysTaskID, (uint8 *)msgPtr ),而這個(gè)函數(shù)里又調(diào)用osal_set_event(destination_task, SYS_EVENT_MSG)來(lái)觸發(fā)事件發(fā)生標(biāo)志,系統(tǒng)調(diào)用相應(yīng)任務(wù)事件處理函數(shù),任務(wù)ID為SampleApp_TaskID,即 SampleApp_ProcessEvent(),通過(guò)參數(shù)SYS_EVENT_MSGOnBoard_SendKeys()里的msgPtr->hdr.event = KEY_CHANGE可知任務(wù)事件處理函數(shù)SampleApp_ProcessEvent()最終調(diào)用SampleApp_HandleKeys(),SampleApp_HandleKeys()里面對(duì)按鍵進(jìn)行了處理,包括按SW1:發(fā)送閃爍消息到組1,按SW2:進(jìn)/退組。
   
至此,協(xié)議棧的按鍵查詢法流程結(jié)束,一次下來(lái)兩次觸發(fā)系統(tǒng)事件(第一次通過(guò)osal_start_timerEx()啟動(dòng)一個(gè)軟定時(shí)器觸發(fā),第二次通過(guò)osal_msg_send()發(fā)送系統(tǒng)消息觸發(fā);這倆的確是重點(diǎn)函數(shù)),分別調(diào)用相應(yīng)任務(wù)事件處理函數(shù),第一次是HAL層的Hal_ProcessEvent()來(lái)查詢按鍵得到鍵值,一系列處理,第二次是APP層的SampleApp_ProcessEvent()把傳送過(guò)來(lái)的按鍵事件進(jìn)行最終處理.查詢法函數(shù)調(diào)用流程如下:

HalKeyConfig()配置一定時(shí)器為輪詢按鍵作準(zhǔn)備——時(shí)間一到觸發(fā)系統(tǒng)任務(wù)事件調(diào)用Hal_ProcessEvent()—— 調(diào)用HalKeyPoll()得到按鍵值——調(diào)用OnBoard_KeyCallback()進(jìn)一步處理——調(diào)用OnBoard_SendKeys()構(gòu)造消息包,準(zhǔn)備觸發(fā)應(yīng)用按鍵事件【注意這個(gè)應(yīng)用之前必須通過(guò)RegisterForKeys()注冊(cè)接收按鍵事件的任務(wù)ID】——調(diào)用osal_msg_send()向系統(tǒng)發(fā)送消息——調(diào)用osal_set_event()設(shè)置事件發(fā)生標(biāo)志——調(diào)用SampleApp_ProcessEvent()處理事件——最終調(diào)用SampleApp_HandleKeys()處理具體按鍵事件

 

2、中斷法
按鍵引起的中斷應(yīng)屬于外部中斷.在HalKeyConfig()中有這樣一段描述:
       Work around for CC2430DB when interrupt is enabled and SW5 (center joystick)
       is used. This SW5 uses P2 which also has debug lines connected to it. This
       causes contant interruption on P2INT_VECTOR. Disable the usage of P2 interrupt
       will stop this problem.

操縱桿SW5(上,下,左,右,中)可以觸發(fā)P2口外部中斷,協(xié)議默認(rèn)中斷向量為P2INT_VECTOR.函數(shù)HalKeyConfig()對(duì)其配置如下:

/***************************************************************************
void HalKeyConfig (bool interruptEnable, halKeyCBack_t cback)
{
#if (HAL_KEY == TRUE)
  /* Enable/Disable Interrupt or */
  Hal_KeyIntEnable = interruptEnable;

  /* Register the callback fucntion */
  pHalKeyProcessFunction = cback;

  /* Determine if interrupt is enable or not */
  if (Hal_KeyIntEnable)
  {

    /*
       Work around for CC2430DB when interrupt is enabled and SW5 (center joystick)
       is used. This SW5 uses P2 which also has debug lines connected to it. This
       causes contant interruption on P2INT_VECTOR. Disable the usage of P2 interrupt
       will stop this problem.
    */

    #if defined (HAL_BOARD_CC2430DB)
      #undef HAL_KEY_SW_5_ENABLE                      /* Dis-allow SW5 when key interrupt is enable */
    #endif

#if defined (HAL_KEY_SW_5_ENABLE)
    PICTL &= ~(HAL_KEY_SW_5_EDGEBIT);                 /* Set rising or falling edge */
  #if (HAL_KEY_SW_5_EDGE == HAL_KEY_FALLING_EDGE)
    PICTL |= HAL_KEY_SW_5_EDGEBIT;
  #endif
    HAL_KEY_SW_5_ICTL |= HAL_KEY_SW_5_ICTLBIT;        /* Set interrupt enable bit */
    HAL_KEY_SW_5_IEN |= HAL_KEY_SW_5_IENBIT;
    HAL_KEY_SW_5_PXIFG = ~(HAL_KEY_SW_5_BIT);        /* Clear any pending interrupts */
#endif

#if defined (HAL_KEY_SW_6_ENABLE)
    PICTL &= ~(HAL_KEY_SW_6_EDGEBIT);                 /* Set rising or falling edge */
  #if (HAL_KEY_SW_6_EDGE == HAL_KEY_FALLING_EDGE)
    PICTL |= HAL_KEY_SW_6_EDGEBIT;
  #endif
    HAL_KEY_SW_6_ICTL |= HAL_KEY_SW_6_ICTLBIT;        /* Set interrupt enable bit */
    HAL_KEY_SW_6_IEN |= HAL_KEY_SW_6_IENBIT;
    HAL_KEY_SW_6_PXIFG = ~(HAL_KEY_SW_6_BIT);        /* Clear any pending interrupts */
#endif                                                
  //(清除推遲的中斷)清除中斷標(biāo)志位

    /* Do this only after the hal_key is configured - to work with sleep stuff */
    if (HalKeyConfigured == TRUE)
    {
      osal_stop_timerEx( Hal_TaskID, HAL_KEY_EVENT);  /* Cancel polling if active */
    }
  }
  else    /* Interrupts NOT enabled */
  {

    ………… (查詢法,見(jiàn)上)
  }
}
/***************************************************************************

可以看到具體設(shè)置了是上升沿還是下降沿來(lái)觸發(fā)中斷,并清除中斷標(biāo)志。
當(dāng)按鍵/操作桿觸發(fā)中斷后,進(jìn)入中斷向量為P2INT_VECTOR的中斷函數(shù)如下:

/***************************************************************************
HAL_ISR_FUNCTION( halKeyPort2Isr, P2INT_VECTOR )
{
  if( CHVER <= REV_D )
  {
    P2IF = 0;
  }

  halProcessKeyInterrupt();

  if( CHVER >= REV_E )
  {
    P2IF = 0;
    CLEAR_SLEEP_MODE();
  }
}
/***************************************************************************

進(jìn)入中斷函數(shù)后首先清除中斷標(biāo)志么?前后兩個(gè)if語(yǔ)句還不清楚何用,先不鉆了……反正進(jìn)入處理按鍵中斷函數(shù)halProcessKeyInterrupt()

/***************************************************************************
void halProcessKeyInterrupt (void)
{

#if (HAL_KEY == TRUE)

  bool    valid=FALSE;

#if defined (HAL_KEY_SW_6_ENABLE)
  if (HAL_KEY_SW_6_PXIFG & HAL_KEY_SW_6_BIT)      /* Interrupt Flag has been set */
  {
    HAL_KEY_SW_6_PXIFG = ~(HAL_KEY_SW_6_BIT);    /* Clear Interrupt Flag */
    valid = TRUE;
  }
#endif

#if defined (HAL_KEY_SW_5_ENABLE)
  if (HAL_KEY_SW_5_PXIFG & HAL_KEY_SW_5_BIT)      /* Interrupt Flag has been set */
  {
    HAL_KEY_SW_5_PXIFG = ~(HAL_KEY_SW_5_BIT);    /* Clear Interrupt Flag */
    valid = TRUE;
  }
#endif

  if (valid)
  {
    osal_start_timerEx (Hal_TaskID, HAL_KEY_EVENT, HAL_KEY_DEBOUNCE_VALUE);
  }
#endif   /* HAL_KEY */
}
/***************************************************************************
可以看到這里倒是真的清除中斷標(biāo)志,最后啟動(dòng)一個(gè)軟定時(shí)器,相應(yīng)事件為HAL_KEY_EVENT,時(shí)間為HAL_KEY_DEBOUNCE_VALUE,且#define HAL_KEY_DEBOUNCE_VALUE  25,即25ms,這與開(kāi)頭的英文說(shuō)明一致,在中斷發(fā)生后,需等待25ms再讀鍵值,以消除按鍵的回跳。對(duì)于osal_start_timerEx()這個(gè)函數(shù)我想應(yīng)該很熟悉了,觸發(fā)任務(wù)事件,即當(dāng)25ms到了以后,觸發(fā)HAL層任務(wù)HAL_KEY_EVENT事件,調(diào)用HAL層任務(wù)事件處理函數(shù)Hal_ProcessEvent(),然后就回到了與查詢法一樣的線路上(具體參照上面的查詢法流程),調(diào)用HalKeyPoll()讀取鍵值,再調(diào)用按鍵的回調(diào)函數(shù)即OnBoard_KeyCallback(),再調(diào)用OnBoard_SendKeys(),再調(diào)用 osal_msg_send() ……觸發(fā)sampleApp事件,并調(diào)用SampleApp_ProcessEvent()對(duì)按鍵事件進(jìn)入最終處理。

至此,協(xié)議棧的按鍵中斷法流程結(jié)束,與查詢法一樣,一次下來(lái)兩次觸發(fā)系統(tǒng)事件(第一次通過(guò)osal_start_timerEx()啟動(dòng)一個(gè)軟定時(shí)器觸發(fā),第二次通過(guò)osal_msg_send()發(fā)送系統(tǒng)消息觸發(fā)),分別調(diào)用相應(yīng)任務(wù)事件處理函數(shù),第一次是HAL層的Hal_ProcessEvent()來(lái)查詢按鍵得到鍵值,一系列處理,第二次是APP層的SampleApp_ProcessEvent()把傳送過(guò)來(lái)的按鍵事件進(jìn)行最終處理.中斷法函數(shù)調(diào)用流程如下:

HalKeyConfig()進(jìn)行按鍵中斷配置——按鍵引起中斷進(jìn)入中斷函數(shù)HAL_ISR_FUNCTION()——調(diào)用halProcessKeyInterrupt()對(duì)按鍵中斷進(jìn)行下一步處理:清除中斷標(biāo)志,啟動(dòng)一定時(shí)器——時(shí)間一到觸發(fā)系統(tǒng)任務(wù)事件調(diào)用Hal_ProcessEvent()—— 調(diào)用HalKeyPoll()得到按鍵值——調(diào)用OnBoard_KeyCallback()進(jìn)一步處理——調(diào)用OnBoard_SendKeys()構(gòu)造消息包,準(zhǔn)備觸發(fā)應(yīng)用按鍵事件【注意這個(gè)應(yīng)用之前必須通過(guò)RegisterForKeys()注冊(cè)接收按鍵事件的任務(wù)ID】——調(diào)用osal_msg_send()向系統(tǒng)發(fā)送消息——調(diào)用osal_set_event()設(shè)置事件發(fā)生標(biāo)志——調(diào)用SampleApp_ProcessEvent()處理事件——最終調(diào)用SampleApp_HandleKeys()處理具體按鍵事件


3、從上面對(duì)按鍵查詢法和中斷法的總結(jié),可以看到中斷法就比查詢法大致多出兩步:進(jìn)入中斷函數(shù)HAL_ISR_FUNCTION()與調(diào)用調(diào)用halProcessKeyInterrupt(),后面都是開(kāi)始開(kāi)啟一軟定時(shí)器觸發(fā)相同事件HAL_KEY_EVENT,然后……………………。

   雖然我現(xiàn)在沒(méi)有實(shí)驗(yàn)平臺(tái),無(wú)法做相關(guān)實(shí)驗(yàn),但個(gè)人在想,如果現(xiàn)在自己在協(xié)議棧中添加了一應(yīng)用(事實(shí)上具體添加任務(wù)我還好多不清楚),應(yīng)用中需要用到按鍵,如果硬件配置按協(xié)議棧默認(rèn)來(lái)配置,那基本只要完成這兩件事情:
(1)、在自己的應(yīng)用中注冊(cè)按鍵:RegisterForKeys(MyAPP_TaskID),這樣用戶應(yīng)用就得接收到所有按鍵事件
(2)、在自己的應(yīng)用任務(wù)事件處理函數(shù)中配置具體處理函數(shù):比如SampleApp中按SW1,發(fā)送閃爍信息給組1,按     SW2,進(jìn)/退組1.

一下子發(fā)好幾篇小結(jié),自已都暈乎乎的…協(xié)議棧按鍵流程 - 小峰 - happy~……協(xié)議棧按鍵流程 - 小峰 - happy~……

 

說(shuō)明:
本文作者所記錄,以上基本為個(gè)人見(jiàn)解,錯(cuò)誤之處還請(qǐng)高手指點(diǎn),本人隨時(shí)更新,轉(zhuǎn)載請(qǐng)注明出處,謝謝!

 最近更新:2010.6.01

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多