/**************************************************************************************************
 * @fn          macBackoffTimerCancelTrigger
 *
 * @brief       Cancels the trigger for the backoff counter - obselete for CC253x and CC26xx.
 *              For CC253x and CC26xx, the timer trigger should never be late, therefore, no
 *              need to cancel.
 *
 * @param       none
 *
 * @return      none
 **************************************************************************************************
 */
MAC_INTERNAL_API void macBackoffTimerCancelTrigger(void)
{
  MAC_RADIO_BACKOFF_COMPARE_CLEAR_INTERRUPT();

#if defined USE_ICALL || defined OSAL_PORT2TIRTOS
  /* backoffTimerTrigger must be set to a value
   * to properly use rollover value for the next wakeup time.
   */
  {
    halIntState_t intState;
    HAL_ENTER_CRITICAL_SECTION(intState);
    /* This code assumes that backoff timer callback does not cause
     * a problem when the callback is made at the rollover even if
     * no timer is associated with it. At the time the following
     * code is written, mac_timer.c can live with such a callback.
     * Setting backoff comparator value one greater than rollver value
     * might be conceived here to lift the above constraint,
     * but it would have to ensure that rollover value is never
     * the highest counter value, which is a more dangerous assumption.
     */
    backoffTimerTrigger = macBackoffTimerRollover;

    /* Note that MAC_RADIO_BACKOFF_COMPARE_CLEAR_INTERRUPT() is not implemented
     * correctly and hence backoff timer trigger interrupt can still occur.
     * Instead of fixing MAC_RADIO_BACKOFF_COMPARE_CLEAR_INTERRUPT() macro,
     * comparator is set again, to simplify interrupt handling.
     */
    MAC_RADIO_BACKOFF_SET_COMPARE(backoffTimerTrigger);

    MAC_BACKOFF_TIMER_UPDATE_WAKEUP();
    HAL_EXIT_CRITICAL_SECTION(intState);
  }
#endif /* defined USE_ICALL || defined OSAL_PORT2TIRTOS */

}
예제 #2
0
/**************************************************************************************************
 * @fn          macBackoffTimerInit
 *
 * @brief       Intializes backoff timer.
 *
 * @param       none
 *
 * @return      none
 **************************************************************************************************
 */
void macBackoffTimerInit(void)
{
  compareState = COMPARE_STATE_ROLLOVER;
  MAC_RADIO_BACKOFF_SET_COUNT(0);
  macBackoffTimerSetRollover(MAC_BACKOFF_TIMER_DEFAULT_ROLLOVER);
  MAC_RADIO_BACKOFF_COMPARE_CLEAR_INTERRUPT();
  MAC_RADIO_BACKOFF_COMPARE_ENABLE_INTERRUPT();
}
예제 #3
0
/**************************************************************************************************
 * @fn          macBackoffTimerInit
 *
 * @brief       Intializes backoff timer.
 *
 * @param       none
 *
 * @return      none
 **************************************************************************************************
 */
MAC_INTERNAL_API void macBackoffTimerInit(void)
{
  MAC_RADIO_BACKOFF_SET_COUNT(0);
  macBackoffTimerSetRollover(MAC_BACKOFF_TIMER_DEFAULT_NONBEACON_ROLLOVER);
  MAC_RADIO_BACKOFF_PERIOD_CLEAR_INTERRUPT();
  MAC_RADIO_BACKOFF_PERIOD_ENABLE_INTERRUPT();
  MAC_RADIO_BACKOFF_COMPARE_CLEAR_INTERRUPT();
  MAC_RADIO_BACKOFF_COMPARE_ENABLE_INTERRUPT();
}
예제 #4
0
/**************************************************************************************************
 * @fn          macBackoffTimerSetTrigger
 *
 * @brief       Sets the trigger count for the backoff counter.  A callback is exectuted when
 *              the backoff count reaches the trigger
 *
 * @param       triggerBackoff - backoff count for new trigger
 *
 * @return      none
 **************************************************************************************************
 */
MAC_INTERNAL_API void macBackoffTimerSetTrigger(uint32 triggerBackoff)
{
  halIntState_t  s;

  MAC_ASSERT(triggerBackoff < backoffTimerRollover); /* trigger backoff must be less than rollover backoff */

  HAL_ENTER_CRITICAL_SECTION(s);
  backoffTimerTrigger = triggerBackoff;
  MAC_RADIO_BACKOFF_SET_COMPARE(triggerBackoff);
  if (triggerBackoff == MAC_RADIO_BACKOFF_COUNT())
  {
    /* Clear the interrupt and fire it manually */
    MAC_RADIO_BACKOFF_COMPARE_CLEAR_INTERRUPT();
    HAL_EXIT_CRITICAL_SECTION(s);
    macBackoffTimerTriggerCallback();
  }
  else
  {
    HAL_EXIT_CRITICAL_SECTION(s);
  }
}