u16 HardWare_ProcessEvent( u8 task_id, u16 events )
{

    if ( events & HAL_LED_BLINK_EVENT )
    {
        #if (defined (BLINK_LEDS)) && (HAL_LED == TRUE)

        HalLedUpdate();

        #endif /* BLINK_LEDS && HAL_LED */

        return events ^ HAL_LED_BLINK_EVENT;
    }

    if (events & HAL_KEY_EVENT)
    {
        #if (defined HAL_KEY) && (HAL_KEY == TRUE)

        //TODO when key was pressed
        HalKeyPoll();

        #endif

        return events ^ HAL_KEY_EVENT;
    }

    return 0 ;
}
Exemplo n.º 2
0
/**************************************************************************************************
 * @fn      Hal_ProcessEvent
 *
 * @brief   Hal Process Event
 *
 * @param   task_id - Hal TaskId
 *          events - events
 *
 * @return  None
 **************************************************************************************************/
uint16 Hal_ProcessEvent( uint8 task_id, uint16 events )
{
  uint8 *msgPtr;
  
  (void)task_id;  // Intentionally unreferenced parameter

  if ( events & SYS_EVENT_MSG )
  {
    msgPtr = osal_msg_receive(Hal_TaskID);

    while (msgPtr)
    {
      /* Do something here - for now, just deallocate the msg and move on */

      /* De-allocate */
      osal_msg_deallocate( msgPtr );
      /* Next */
      msgPtr = osal_msg_receive( Hal_TaskID );
    }
    return events ^ SYS_EVENT_MSG;
  }

  if ( events & HAL_LED_BLINK_EVENT )
  {
#if (defined (BLINK_LEDS)) && (HAL_LED == TRUE)
    HalLedUpdate();
#endif /* BLINK_LEDS && HAL_LED */
    return events ^ HAL_LED_BLINK_EVENT;
  }

  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);
    }
#endif // HAL_KEY

    return events ^ HAL_KEY_EVENT;
  }

#ifdef POWER_SAVING
  if ( events & HAL_SLEEP_TIMER_EVENT )
  {
    halRestoreSleepLevel();
    return events ^ HAL_SLEEP_TIMER_EVENT;
  }
#endif

  /* Nothing interested, discard the message */
  return 0;

}
Exemplo n.º 3
0
/**************************************************************************************************
 * @fn      Hal_ProcessEvent
 *
 * @brief   Hal Process Event
 *
 * @param   task_id - Hal TaskId
 *          events - events
 *
 * @return  None
 **************************************************************************************************/
uint16 Hal_ProcessEvent( uint8 task_id, uint16 events )
{
    uint8 *msgPtr;

    (void)task_id;  // Intentionally unreferenced parameter

    if ( events & SYS_EVENT_MSG )
    {
        msgPtr = osal_msg_receive(Hal_TaskID);

        while (msgPtr)
        {
            /* Do something here - for now, just deallocate the msg and move on */

            /* De-allocate */
            osal_msg_deallocate( msgPtr );
            /* Next */
            msgPtr = osal_msg_receive( Hal_TaskID );
        }
        return events ^ SYS_EVENT_MSG;
    }

    if ( events & HAL_LED_BLINK_EVENT )
    {
#if (defined (BLINK_LEDS)) && (HAL_LED == TRUE)
        HalLedUpdate();
#endif /* BLINK_LEDS && HAL_LED */
        return events ^ HAL_LED_BLINK_EVENT;
    }

    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);
        }
#endif // HAL_KEY

        return events ^ HAL_KEY_EVENT;
    }

#if (defined HAL_MOTION) && (HAL_MOTION == TRUE) && (!defined NO_POINTING_LIB)
    if (events & HAL_MOTION_EVENT)
    {
        uint16 eventHandled = HalMotionHandleOSEvent( events );
        return events ^ eventHandled;
    }

#if (defined HAL_I2C) && (HAL_I2C == TRUE)
    if (events & HAL_GYRO_REGISTER_ACCESS_READY_EVENT)
    {
        HalGyroHandleGyroRegisterAccessReadyEvent();
        return events ^ HAL_GYRO_REGISTER_ACCESS_READY_EVENT;
    }
#endif // #if (defined HAL_I2C) && (HAL_I2C == TRUE)
#endif // #if (defined HAL_MOTION) && (HAL_MOTION == TRUE)

#if (defined HAL_BUZZER) && (HAL_BUZZER == TRUE)
    if (events & HAL_BUZZER_EVENT)
    {
        HalBuzzerStop();
        return events ^ HAL_BUZZER_EVENT;
    }
#endif

    /* Nothing interested, discard the message */
    return 0;

}
Exemplo n.º 4
0
/**************************************************************************************************
 * @fn      Hal_ProcessEvent
 *
 * @brief   Hal Process Event
 *
 * @param   task_id - Hal TaskId
 *          events - events
 *
 * @return  None
 **************************************************************************************************/
uint16 Hal_ProcessEvent( uint8 task_id, uint16 events )
{
    uint8 *msgPtr;

    (void)task_id;  // Intentionally unreferenced parameter

    if ( events & SYS_EVENT_MSG )
    {
        msgPtr = osal_msg_receive(Hal_TaskID);

        while (msgPtr)
        {
            /* Do something here - for now, just deallocate the msg and move on */

            /* De-allocate */
            osal_msg_deallocate( msgPtr );
            /* Next */
            msgPtr = osal_msg_receive( Hal_TaskID );
        }
        return events ^ SYS_EVENT_MSG;
    }

#if (defined HAL_BUZZER) && (HAL_BUZZER == TRUE)
    if (events & HAL_BUZZER_EVENT)
    {
        HalBuzzerStop();
        return events ^ HAL_BUZZER_EVENT;
    }
#endif

#ifdef CC2591_COMPRESSION_WORKAROUND
    if ( events & PERIOD_RSSI_RESET_EVT )
    {
        macRxResetRssi();
        return (events ^ PERIOD_RSSI_RESET_EVT);
    }
#endif

    if ( events & HAL_LED_BLINK_EVENT )
    {
#if (defined (BLINK_LEDS)) && (HAL_LED == TRUE)
        HalLedUpdate();
#endif /* BLINK_LEDS && HAL_LED */
        return events ^ HAL_LED_BLINK_EVENT;
    }

    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);
        }
#endif
        return events ^ HAL_KEY_EVENT;
    }

#if defined POWER_SAVING
    if ( events & HAL_SLEEP_TIMER_EVENT )
    {
        halRestoreSleepLevel();
        return events ^ HAL_SLEEP_TIMER_EVENT;
    }

    if ( events & HAL_PWRMGR_HOLD_EVENT )
    {
        (void)osal_pwrmgr_task_state(Hal_TaskID, PWRMGR_HOLD);

        (void)osal_stop_timerEx(Hal_TaskID, HAL_PWRMGR_CONSERVE_EVENT);
        (void)osal_clear_event(Hal_TaskID, HAL_PWRMGR_CONSERVE_EVENT);

        return (events & ~(HAL_PWRMGR_HOLD_EVENT | HAL_PWRMGR_CONSERVE_EVENT));
    }

    if ( events & HAL_PWRMGR_CONSERVE_EVENT )
    {
        (void)osal_pwrmgr_task_state(Hal_TaskID, PWRMGR_CONSERVE);
        return events ^ HAL_PWRMGR_CONSERVE_EVENT;
    }
#endif

    return 0;
}