当前位置: 首页>>代码示例>>C++>>正文


C++ HAL_ENTER_CRITICAL_SECTION函数代码示例

本文整理汇总了C++中HAL_ENTER_CRITICAL_SECTION函数的典型用法代码示例。如果您正苦于以下问题:C++ HAL_ENTER_CRITICAL_SECTION函数的具体用法?C++ HAL_ENTER_CRITICAL_SECTION怎么用?C++ HAL_ENTER_CRITICAL_SECTION使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了HAL_ENTER_CRITICAL_SECTION函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: osal_start_system

/*********************************************************************
 * @fn      osal_start_system
 *
 * @brief
 *
 *   This function is the main loop function of the task system.  It
 *   will look through all task events and call the task_event_processor()
 *   function for the task with the event.  If there are no events (for
 *   all tasks), this function puts the processor into Sleep.
 *   This Function doesn't return.
 *
 * @param   void
 *
 * @return  none
 */
void osal_start_system( void )
{
  uint16 events;
  uint16 retEvents;

  while(1)
  {
    TaskActive = osalNextActiveTask();
    if ( TaskActive )
    {
      HAL_ENTER_CRITICAL_SECTION();
      events = TaskActive->events;
      // Clear the Events for this task
      TaskActive->events = 0;
      HAL_EXIT_CRITICAL_SECTION();

      if ( events != 0 )
      {
        // Call the task to process the event(s)
        if ( TaskActive->pfnEventProcessor )
        {
          retEvents = (TaskActive->pfnEventProcessor)( TaskActive->taskID, events );

          // Add back unprocessed events to the current task
          HAL_ENTER_CRITICAL_SECTION();
          TaskActive->events |= retEvents;
          HAL_EXIT_CRITICAL_SECTION();
        }
      }
    }
  }
}
开发者ID:mcuwty,项目名称:osal_transplant,代码行数:47,代码来源:osal.c

示例2: macBackoffTimerCount

/**************************************************************************************************
 * @fn          macBackoffTimerCount
 *
 * @brief       Returns the current backoff count.
 *
 * @param       none
 *
 * @return      current backoff count
 **************************************************************************************************
 */
uint32 macBackoffTimerCount(void)
{
  halIntState_t  s;
  uint32 backoffCount;

  HAL_ENTER_CRITICAL_SECTION(s);
  backoffCount = MAC_RADIO_BACKOFF_COUNT();
  HAL_EXIT_CRITICAL_SECTION(s);
  
#ifdef MAC_RADIO_FEATURE_HARDWARE_OVERFLOW_NO_ROLLOVER
  /*
   *  Extra processing is required if the radio has a special hardware overflow
   *  count feature.  Unfortunately this feature does not provide for setting a
   *  rollover value.  This must be done manually.
   *
   *  This means there is a small window in time when reading the hardware count
   *  will be inaccurate.  It's possible it could be one more than the allowable
   *  count.  This happens if the count has just incremented beyond the maximum
   *  and is queried before the ISR has a chance to run and reset the backoff
   *  count back to zero.  (Pure software implementation of backoff count does
   *  not have this problem.)
   *
   *  To solve this, before returning a value for the backoff count, the value
   *  must be tested to see if it is beyond the maximum value.  If so, a rollover
   *  interrupt that will set backoff count to zero is imminent.  In that case,
   *  the correct backoff count of zero is returned.
   */
  if (backoffCount >= backoffTimerRollover)
  {
    return(0);
  }
#endif
  
  return(backoffCount);
}
开发者ID:gxp,项目名称:node,代码行数:45,代码来源:mac_backoff_timer.c

示例3: macBackoffTimerCancelTrigger

/**************************************************************************************************
 * @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 */

}
开发者ID:peifengzhou,项目名称:CC2630_HA_Demo,代码行数:47,代码来源:mac_backoff_timer.c

示例4: macBackoffTimerPeriodIsr

/**************************************************************************************************
 * @fn          macBackoffTimerPeriodIsr
 *
 * @brief       Interrupt service routine that fires when the backoff count rolls over on
 *              overflow period.
 *
 * @param       none
 *
 * @return      none
 **************************************************************************************************
 */
MAC_INTERNAL_API void macBackoffTimerPeriodIsr(void)
{
  halIntState_t s;
  uint32 macRatCount           =  MAC_RAT_COUNT;
  uint32 backoffRolloverRat    =  macBackoffTimerRollover * MAC_BACKOFF_TO_RAT_RATIO;
  uint32 ratCompensation       = (macRatCount - macPrevPeriodRatCount) % MAC_BACKOFF_TO_RAT_RATIO;
      
  MAC_ASSERT( macBackoffTimerRollover <= MAC_BACKOFF_MAXIMUM_ROLLOVER );

  if (macRatCount < backoffRolloverRat)
  {
    /* RAT wraparound has occurred. This would occur once in a blue moon (1073.74 seconds).
     */
    DBG_PRINTL1(DBGSYS, "!!! RAT wraparound !!! RAT = %u", macRatCount);
  }

  DBG_PRINTL2(DBGSYS, "macRatChanA Period ISR, Rollover Period = %u, RAT Compensation = %u", macBackoffTimerRollover, ratCompensation);
  
  /* Convert count to RAT count and set MAC Channel A Compare. The modulus calculation will 
   * compensate the math or interrupt latency error and prevent it from being accumulated.
   * Note that MAC_BACKOFF_TO_RAT_RATIO is used as part of compensation. This means the 
   * maximum error that can be compensated is 320us. If the interrupt latency is greater 
   * than 320us, more elaborated compensation scheme must be used for Beacon mode. 
   * Non-beacon mode does not require absolute timing. Longer interrupt latency can be 
   * tolerated.
   */
  macPrevPeriodRatCount = macRatCount - ratCompensation;
  macSetupRATChanCompare( macRatChanA, backoffRolloverRat + macPrevPeriodRatCount );
  macBackoffTimerRolloverCallback();
  HAL_ENTER_CRITICAL_SECTION(s);
  MAC_BACKOFF_TIMER_UPDATE_WAKEUP();
  HAL_EXIT_CRITICAL_SECTION(s);
}
开发者ID:peifengzhou,项目名称:CC2630_HA_Demo,代码行数:44,代码来源:mac_backoff_timer.c

示例5: halUartPollRx

/***********************************************************************************
* @fn           halUartPollRx
*
* @brief        Poll for data from USB.
*
* @param        none
*
* @return       none
*/
void halUartPollRx(void)
{
  uint8 cnt;
  uint8 ep = USBFW_GET_SELECTED_ENDPOINT();
  USBFW_SELECT_ENDPOINT(4);

  /* If the OUT endpoint has received a complete packet. */
  if (USBFW_OUT_ENDPOINT_DISARMED())
  {
    halIntState_t intState;

    HAL_ENTER_CRITICAL_SECTION(intState);
    /* Get length of USB packet, this operation must not be interrupted. */
    cnt = USBFW_GET_OUT_ENDPOINT_COUNT_LOW();
    cnt += USBFW_GET_OUT_ENDPOINT_COUNT_HIGH() >> 8;
    HAL_EXIT_CRITICAL_SECTION(intState);

    while (cnt--)
    {
      halUartRxQ[halUartRxT++] = HWREG(USB_F4);
    }
    USBFW_ARM_OUT_ENDPOINT();

    /* If the USB has transferred in more Rx bytes, reset the Rx idle timer. */

    /* Re-sync the shadow on any 1st byte(s) received. */
    if (rxTick == 0)
    {
      rxShdw = ST0;
    }
    rxTick = HAL_UART_USB_IDLE;
  }
  else if (rxTick)
开发者ID:sdhczw,项目名称:ACGatewayDemo,代码行数:42,代码来源:_hal_uart_usb.c

示例6: osal_run_task

/*********************************************************************
 * @fn      osal_run_task
 *
 * @brief
 *
 *   This function is the main loop function of the task system.  It
 *   will look through all task events and call the task_event_processor()
 *   function for the task with the event.  If there are no events (for
 *   all tasks), this function puts the processor into Sleep.
 *   This Function doesn't return.
 *
 * @param   void
 *
 * @return  none
 */
static void osal_run_task(uint8 idx)
{
    uint16 events;
    halIntState_t intState;

    HAL_ENTER_CRITICAL_SECTION(intState);
    events = tasksEvents[idx];
    tasksEvents[idx] = 0;  // Clear the Events for this task.
    HAL_EXIT_CRITICAL_SECTION(intState);

    events = (tasksArr[idx])( idx, events );

    HAL_ENTER_CRITICAL_SECTION(intState);
    tasksEvents[idx] |= events;  // Add back unprocessed events to the current task.
    HAL_EXIT_CRITICAL_SECTION(intState);
}
开发者ID:kangschampagne,项目名称:ZigBee,代码行数:31,代码来源:OSAL_ZNP.c

示例7: HalFlashRead

/**************************************************************************************************
 * @fn          HalFlashRead
 *
 * @brief       This function reads 'cnt' bytes from the internal flash.
 *
 * input parameters
 *
 * @param       pg - A valid flash page number.
 * @param       offset - A valid offset into the page.
 * @param       buf - A valid buffer space at least as big as the 'cnt' parameter.
 * @param       cnt - A valid number of bytes to read.
 *
 * output parameters
 *
 * None.
 *
 * @return      None.
 **************************************************************************************************
 */
void HalFlashRead(uint8 pg, uint16 offset, uint8 *buf, uint16 cnt)
{
  // Calculate the offset into the containing flash bank as it gets mapped into XDATA.
  uint8 *pData = (uint8 *)(offset + HAL_FLASH_PAGE_MAP) +
                 ((pg % HAL_FLASH_PAGE_PER_BANK) * HAL_FLASH_PAGE_SIZE);
  uint8 memctr = MEMCTR;  // Save to restore.

#if (!defined HAL_OAD_BOOT_CODE) && (!defined HAL_OTA_BOOT_CODE)
  halIntState_t is;
#endif

  pg /= HAL_FLASH_PAGE_PER_BANK;  // Calculate the flash bank from the flash page.

#if (!defined HAL_OAD_BOOT_CODE) && (!defined HAL_OTA_BOOT_CODE)
  HAL_ENTER_CRITICAL_SECTION(is);
#endif

  // Calculate and map the containing flash bank into XDATA.
  MEMCTR = (MEMCTR & 0xF8) | pg;

  while (cnt--)
  {
    *buf++ = *pData++;
  }

  MEMCTR = memctr;

#if (!defined HAL_OAD_BOOT_CODE) && (!defined HAL_OTA_BOOT_CODE)
  HAL_EXIT_CRITICAL_SECTION(is);
#endif
}
开发者ID:Mecabot,项目名称:BLE-CC254x-1.4.0,代码行数:50,代码来源:hal_flash.c

示例8: macBackoffTimerCompareIsr

/**************************************************************************************************
 * @fn          macBackoffTimerCompareIsr
 *
 * @brief       Interrupt service routine that fires when the backoff count is equal
 *              to the trigger count.
 *
 * @param       none
 *
 * @return      none
 **************************************************************************************************
 */
void macBackoffTimerCompareIsr(void)
{
  uint8 oldState;
  halIntState_t  s;

  HAL_ENTER_CRITICAL_SECTION(s);
  oldState = compareState;

  /* if compare is a rollover, set count to zero */
  if (oldState & COMPARE_STATE_ROLLOVER_BV)
  {
    MAC_RADIO_BACKOFF_SET_COUNT(0);
    macBackoffTimerRolloverCallback();
  }

  /* if compare is a trigger, reset for rollover and run the trigger callback */
  if (oldState & COMPARE_STATE_TRIGGER_BV)
  {
    compareState = COMPARE_STATE_ROLLOVER;
    MAC_RADIO_BACKOFF_SET_COMPARE(backoffTimerRollover);
    HAL_EXIT_CRITICAL_SECTION(s);
    macBackoffTimerTriggerCallback();
  }
  else if (oldState == COMPARE_STATE_ROLLOVER_AND_ARM_TRIGGER)
  {
    compareState = COMPARE_STATE_TRIGGER;
    MAC_RADIO_BACKOFF_SET_COMPARE(backoffTimerTrigger);
    HAL_EXIT_CRITICAL_SECTION(s);
  }
  else
  {
    HAL_EXIT_CRITICAL_SECTION(s);
  }
}
开发者ID:gxp,项目名称:node,代码行数:45,代码来源:mac_backoff_timer.c

示例9: HalSPIRead

/*********************************************************************
 * @fn      HalSPIRead
 *
 * @brief   Read from the external NV storage via SPI.
 *
 * @param   addr - Offset into the external NV.
 * @param   pBuf - Pointer to the buffer in which to copy the bytes read from external NV.
 * @param   len - Number of bytes to read from external NV.
 *
 * @return  None.
 *********************************************************************/
static void HalSPIRead(uint32 addr, uint8 *pBuf, uint16 len)
{
#if !HAL_OAD_BOOT_CODE
  uint8 shdw = P1DIR;
  halIntState_t his;
  HAL_ENTER_CRITICAL_SECTION(his);
  P1DIR |= BV(3);
#endif

  XNV_SPI_BEGIN();
  do {
    xnvSPIWrite(XNV_STAT_CMD);
  } while (XNV_SPI_RX() & XNV_STAT_WIP);
  XNV_SPI_END();
  asm("NOP"); asm("NOP");

  XNV_SPI_BEGIN();
  xnvSPIWrite(XNV_READ_CMD);
  xnvSPIWrite(addr >> 16);
  xnvSPIWrite(addr >> 8);
  xnvSPIWrite(addr);
  xnvSPIWrite(0);

  while (len--)
  {
    xnvSPIWrite(0);
    *pBuf++ = XNV_SPI_RX();
  }
  XNV_SPI_END();

#if !HAL_OAD_BOOT_CODE
  P1DIR = shdw;
  HAL_EXIT_CRITICAL_SECTION(his);
#endif
}
开发者ID:12019,项目名称:hellowsn,代码行数:46,代码来源:hal_oad.c

示例10: macRxOff

/**************************************************************************************************
 * @fn          macRxOff
 *
 * @brief       Turn off the receiver if it's not already off.
 *
 * @param       none
 *
 * @return      none
 **************************************************************************************************
 */
MAC_INTERNAL_API void macRxOff(void)
{
  halIntState_t  s;

  DBG_PRINT1(DBGSYS, "macRxOff(): macRxOnFlag = 0x%X", macRxOnFlag);
  HAL_ENTER_CRITICAL_SECTION(s);
  if (macRxOnFlag)
  {
    macRxOnFlag = 0;
    DBG_PRINT0(DBGSYS, "MAC_RADIO_RXTX_OFF()");
    MAC_RADIO_RXTX_OFF();

    /* Wait till RX is completely off before issuing another RX related
     * command which may fail if issued beforehand. */
    macCheckCommnadDone(&macRxEdScan.rxCmd.rfOpCmd);
    
    /* Wait till all FG commands are done */
    macCheckCommnadDone(&macCsmaCaCmd.rfOpCmd);
    macCheckCommnadDone(&macTxCmd.rfOpCmd); 
    macCheckCommnadDone(&macRxAckCmd.rfOpCmd);
       
    MAC_DEBUG_TURN_OFF_RX_LED();
    
    /* just in case a receive was about to start, flush the receive FIFO */
    MAC_RADIO_FLUSH_RX_FIFO();

    /* clear any receive interrupt that happened to squeak through */
    MAC_RADIO_CLEAR_RX_THRESHOLD_INTERRUPT_FLAG();

  }
  HAL_EXIT_CRITICAL_SECTION(s);
}
开发者ID:peifengzhou,项目名称:CC2630_HA_Demo,代码行数:42,代码来源:mac_rx_onoff.c

示例11: macRadioUpdateTxPower

/**************************************************************************************************
 * @fn          macRadioUpdateTxPower
 *
 * @brief       Update the radio's transmit power if a new power level has been requested
 *
 * @param       reqTxPower - file scope variable that holds the last request power level
 *              macPhyTxPower - global variable that holds radio's set power level
 *
 * @return      none
 **************************************************************************************************
 */
MAC_INTERNAL_API void macRadioUpdateTxPower(void)
{
  halIntState_t  s;

  /*
   *  If the requested power setting is different from the actual radio setting,
   *  attempt to udpate to the new power setting.
   */
  HAL_ENTER_CRITICAL_SECTION(s);
  if (reqTxPower != macPhyTxPower)
  {
    /*
     *  Radio power cannot be updated when the radio is physically transmitting.
     *  If there is a possibility radio is transmitting, do not change the power
     *  setting.  This function will be called again after the current transmit
     *  completes.
     */
    if (!macRxOutgoingAckFlag && !MAC_TX_IS_PHYSICALLY_ACTIVE())
    {
      /*
       *  Set new power level;  update the shadow value and write
       *  the new value to the radio hardware.
       */
      macPhyTxPower = reqTxPower;
      MAC_RADIO_SET_TX_POWER(macPhyTxPower);
    }
  }
  HAL_EXIT_CRITICAL_SECTION(s);
}
开发者ID:Daan1992,项目名称:WSN-Lab,代码行数:40,代码来源:mac_radio.c

示例12: macRadioUpdateChannel

/**************************************************************************************************
 * @fn          macRadioUpdateChannel
 *
 * @brief       Update the radio channel if a new channel has been requested.
 *
 * @param       none
 *
 * @return      none
 **************************************************************************************************
 */
MAC_INTERNAL_API void macRadioUpdateChannel(void)
{
  halIntState_t  s;

  MAC_ASSERT(!macTxActive); /* cannot change channel during a transmit */

  /* if the channel has changed, set the radio to the new channel */
  HAL_ENTER_CRITICAL_SECTION(s);
  if (reqChannel != macPhyChannel)
  {
    macPhyChannel = reqChannel;
    HAL_EXIT_CRITICAL_SECTION(s);

    /* changing the channel stops any receive in progress */
    macRxOff();
    MAC_RADIO_SET_CHANNEL(macPhyChannel);

    /* If the channel is updated in the middle of receiving a frame, we must
     * clean up the Rx logic.
     */
    macRxHaltCleanup();

    macRxOnRequest();
  }
  else
  {
    HAL_EXIT_CRITICAL_SECTION(s);
  }
}
开发者ID:Daan1992,项目名称:WSN-Lab,代码行数:39,代码来源:mac_radio.c

示例13: MAC_MlmeSetActivePib

/**************************************************************************************************
 * @fn          MAC_MlmeSetActivePib
 *
 * @brief       This function initializes the PIB.
 *
 * input parameters
 *
 * @param       None.
 *
 * output parameters
 *
 * None.
 *
 * @return      None.
 **************************************************************************************************
 */
void MAC_MlmeSetActivePib( void* pPib )
{
    halIntState_t intState;
    HAL_ENTER_CRITICAL_SECTION(intState);
    pMacPib = (macPib_t *)pPib;
    HAL_EXIT_CRITICAL_SECTION(intState);
}
开发者ID:paoloach,项目名称:zpowermeter,代码行数:23,代码来源:mac_pib.c

示例14: macMcuPrecisionCount

/**************************************************************************************************
 * @fn          macMcuPrecisionCount
 *
 * @brief       This function is used by higher layer to read a free running counter driven by
 *              MAC timer.
 *
 * @param       none
 *
 * @return      overflowCount
 **************************************************************************************************
 */
uint32 macMcuPrecisionCount(void)
{
  uint32         overflowCount = 0;
  halIntState_t  s;

  HAL_ENTER_CRITICAL_SECTION(s);

  /* This T2 access macro allows accessing both T2MOVFx and T2Mx */
  MAC_MCU_T2_ACCESS_OVF_COUNT_VALUE();

  /* Latch the entire T2MOVFx first by reading T2M0.
   * T2M0 is discarded.
   */
  T2M0;
  ((uint8 *)&overflowCount)[UINT32_NDX0] = T2MOVF0;
  ((uint8 *)&overflowCount)[UINT32_NDX1] = T2MOVF1;
  ((uint8 *)&overflowCount)[UINT32_NDX2] = T2MOVF2;

  /* the overflowCount needs to account for the accumulated overflow count in Beacon mode.
   */
  overflowCount += accumulatedOverflowCount;
  HAL_EXIT_CRITICAL_SECTION(s);

  return(overflowCount);
}
开发者ID:zeroWin,项目名称:BP_CC2530,代码行数:36,代码来源:mac_mcu.c

示例15: osal_pwrmgr_powerconserve

/*********************************************************************
 * @fn      osal_pwrmgr_powerconserve
 *
 * @brief   This function is called from the main OSAL loop when there are
 *          no events scheduled and shouldn't be called from anywhere else.
 *
 * @param   none.
 *
 * @return  none.
 */
void osal_pwrmgr_powerconserve( void )
{
  uint32        next;
  halIntState_t intState;

  // Should we even look into power conservation
#ifdef USER_DEFINED  
  if ( pwrmgr_attribute.pwrmgr_device != PWRMGR_ALWAYS_ON && !E009_upoff && isPair )
#else
  if ( pwrmgr_attribute.pwrmgr_device != PWRMGR_ALWAYS_ON )
#endif
  {
    // Are all tasks in agreement to conserve
    if ( pwrmgr_attribute.pwrmgr_task_state == 0 )
    {
      // Hold off interrupts.
      HAL_ENTER_CRITICAL_SECTION( intState );

      // Get next time-out
      next = osal_next_timeout();

      // Re-enable interrupts.
      HAL_EXIT_CRITICAL_SECTION( intState );

      // Put the processor into sleep mode
      OSAL_SET_CPU_INTO_SLEEP( next );
    }
  }
}
开发者ID:tanxjian,项目名称:BLE-CC254x-1.3.2,代码行数:39,代码来源:OSAL_PwrMgr.c


注:本文中的HAL_ENTER_CRITICAL_SECTION函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。