Quantcast
Channel: 蓝牙论坛 - 最近的话题
Viewing all articles
Browse latest Browse all 7523

用osal_start_timerEx弄Led blink

$
0
0

不好意思 我是一枚菜鸟刚刚接触这些 我现在想弄Led blink可是我不太会用osal_start_timerEx()这个function.

现在我是这样做,我是用keyfobdemo.c那边改

void KeyFobApp_Init( uint8 task_id )
{
  keyfobapp_TaskID = task_id;  
   
       
  // Register for all key events - This app will handle all key events
   RegisterForKeys( keyfobapp_TaskID );
   
   osal_start_timerEx( keyfobapp_TaskID, LED_ON , STARTDELAY );
    
  // Setup a delayed profile startup
  // osal_start_timerEx( keyfobapp_TaskID, KFD_START_DEVICE_EVT, STARTDELAY );
 
}

uint16 KeyFobApp_ProcessEvent( uint8 task_id, uint16 events )
{
 
 if ( events & SYS_EVENT_MSG )
  {
    uint8 *pMsg;

    if ( (pMsg = osal_msg_receive( keyfobapp_TaskID )) != NULL )
    {
      keyfobapp_ProcessOSALMsg( (osal_event_hdr_t *)pMsg );

      // Release the OSAL message
      VOID osal_msg_deallocate( pMsg );
    }
    
    // return unprocessed events
    return (events ^ SYS_EVENT_MSG);
  }
       if ( events & LED_ON )
   {
      Led_Init( LED_RED_PORT, LED_RED_PIN );
      Led_On( LED_RED_PORT, LED_RED_PIN );  
   }
   
   if ( events & LED_OFF )
   {
     Led_Init( LED_RED_PORT, LED_RED_PIN );
     Led_Off( LED_RED_PORT, LED_RED_PIN );
   }

然后我在keyfobdemo.h那边的Key Fob Task Events加了这些东西

#define LED_ON                                                         0x0040
#define LED_OFF                                                       0x0080

可是我加了这些东西他还是不会运行 我知道uint8 osal_start_timerEx( uint8 taskID, uint16 event_id, uint32 timeout_value )是这样, taskID已经是不必改的 然后timeout_value我放了500ms, 只是我好奇这个event_id能自己给一个数字他吗就好像以上的define led那样? 如果我要让LED blink有啥办法??? 谢谢各位 如果不明白的话我会edit



Viewing all articles
Browse latest Browse all 7523

Trending Articles