• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ HAL_EXIT_CRITICAL_SECTION函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: 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;

  HAL_ENTER_CRITICAL_SECTION(s);
  if (macRxOnFlag)
  {
    macRxOnFlag = 0;
    MAC_RADIO_RXTX_OFF();
    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:KimiRaikking,项目名称:z-stack,代码行数:30,代码来源:mac_rx_onoff.c


示例2: macBackoffTimerCapture

/**************************************************************************************************
 * @fn          macBackoffTimerCapture
 *
 * @brief       Returns the most recently captured backoff count
 *
 * @param       none
 *
 * @return      last backoff count that was captured
 **************************************************************************************************
 */
uint32 macBackoffTimerCapture(void)
{
  halIntState_t  s;
  uint32 backoffCapture;

  HAL_ENTER_CRITICAL_SECTION(s);
  backoffCapture = MAC_RADIO_BACKOFF_CAPTURE();
  HAL_EXIT_CRITICAL_SECTION(s);

#ifdef MAC_RADIO_FEATURE_HARDWARE_OVERFLOW_NO_ROLLOVER
  /*
   *  See other instance of this #ifdef for detailed comments.
   *  Those comments apply to the backoff capture value too.
   */
  if (backoffCapture >= backoffTimerRollover)
  {
    return(0);
  }
#endif
  
  return(backoffCapture);
}
开发者ID:gxp,项目名称:node,代码行数:32,代码来源:mac_backoff_timer.c


示例3: 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
 	if ( pwrmgr_attribute.pwrmgr_device != PWRMGR_ALWAYS_ON ) {
    	// 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:paoloach,项目名称:zpowermeter,代码行数:32,代码来源:OSAL_PwrMgr.c


示例4: macMcuOverflowSetCount

/**************************************************************************************************
 * @fn          macMcuOverflowSetCount
 *
 * @brief       Sets the value of the hardware overflow counter.
 *
 * @param       count - new overflow count value
 *
 * @return      none
 **************************************************************************************************
 */
MAC_INTERNAL_API void macMcuOverflowSetCount(uint32 count)
{
  halIntState_t  s;

  MAC_ASSERT(! (count >> 24) );   /* illegal count value */

  /* save the current overflow count */
  accumulatedOverflowCount += macMcuOverflowCount();

  /* deduct the initial count */
  accumulatedOverflowCount -= count;

  HAL_ENTER_CRITICAL_SECTION(s);
  MAC_MCU_T2_ACCESS_OVF_COUNT_VALUE();

  /* for efficiency, the 32-bit value is decoded using endian abstracted indexing */
  /* T2OF2 must be written last */
  T2MOVF0 = (uint32)((uint8 *)&count)[UINT32_NDX0];
  T2MOVF1 = (uint32)((uint8 *)&count)[UINT32_NDX1];
  T2MOVF2 = (uint32)((uint8 *)&count)[UINT32_NDX2];
  HAL_EXIT_CRITICAL_SECTION(s);
}
开发者ID:chessami92,项目名称:ceen4360-cc2538-code,代码行数:32,代码来源:mac_mcu.c


示例5: macMcuOverflowCount

/**************************************************************************************************
 * @fn          macMcuOverflowCount
 *
 * @brief       Returns the value of the overflow counter which is a special hardware feature.
 *              The overflow count actually is 24 bits of information.
 *
 * @param       none
 *
 * @return      value of overflow counter
 **************************************************************************************************
 */
MAC_INTERNAL_API uint32 macMcuOverflowCount(void)
{
  uint32         overflowCount;
  halIntState_t  s;

  /* for efficiency, the 32-bit value is encoded using endian abstracted indexing */

  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;
  ((uint8 *)&overflowCount)[UINT32_NDX0] = T2MOVF0;
  ((uint8 *)&overflowCount)[UINT32_NDX1] = T2MOVF1;
  ((uint8 *)&overflowCount)[UINT32_NDX2] = T2MOVF2;
  ((uint8 *)&overflowCount)[UINT32_NDX3] = 0;
  HAL_EXIT_CRITICAL_SECTION(s);

  return (overflowCount);
}
开发者ID:chessami92,项目名称:ceen4360-cc2538-code,代码行数:33,代码来源:mac_mcu.c


示例6: osal_timer_num_active

/*********************************************************************
 * @fn      osal_timer_num_active
 *
 * @brief
 *
 *   This function counts the number of active timers.
 *
 * @return  u8 - number of timers
 */
u8 osal_timer_num_active( void )
{
  halIntState_t intState;
  u8 num_timers = 0;
  osalTimerRec_t *srchTimer;

  HAL_ENTER_CRITICAL_SECTION( intState );  // Hold off interrupts.

  // Head of the timer list
  srchTimer = timerHead;

  // Count timers in the list
  while ( srchTimer != NULL )
  {
    num_timers++;
    srchTimer = srchTimer->next;
  }

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

  return num_timers;
}
开发者ID:Aline1029,项目名称:NPLink-Mote-STM32-SDK,代码行数:31,代码来源:osal_time.c


示例7: RFHAL_NextDataEntryDone

/*******************************************************************************
 * @fn          RFHAL_NextDataEntryDone API
 *
 * @brief       This function is used to mark the next System data entry on a
 *              data entry queue as Pending so that the radio can once again
 *              use it. It should be called after the user has processed the
 *              data entry.
 *
 * input parameters
 *
 * @param       dataEntryQueue_t - Pointer to data entry queue.
 *
 * output parameters
 *
 * @param       None.
 *
 * @return      None.
 */
void RFHAL_NextDataEntryDone( dataEntryQ_t *pDataEntryQ )
{
  halIntState_t  cs;
  dataQ_t       *pDataQueue;

#ifdef DEBUG
  RFHAL_ASSERT( pDataEntryQ != NULL );
#endif // DEBUG

  // point to data queue
  pDataQueue = (dataQ_t *)pDataEntryQ;

  if ( pDataQueue->pNextDataEntry != NULL )
  {
    HAL_ENTER_CRITICAL_SECTION(cs);

    // mark the next System data entry as Pending
    pDataQueue->pNextDataEntry->status = DATASTAT_PENDING;

    // advance to the next data entry in the data entry queue
    pDataQueue->pNextDataEntry = pDataQueue->pNextDataEntry->pNextEntry;

    HAL_EXIT_CRITICAL_SECTION(cs);

    // return pointer to next entry, or NULL if there isn't one
    // Note: For a ring buffer, there is always another.
    return; //( pDataQueue->pNextDataEntry );
  }
  else // we are at the end of a linked list
  {
    // ALT: Could set pNextDataEntry to first entry, but could be problematic
    //       if the radio data queue commands are being used to add/remove
    //       data entries.
  }

  // return next data entry to may be processed by System software
  return;
}
开发者ID:PolymorphicLabs,项目名称:PML-Firmware,代码行数:56,代码来源:rfHal.c


示例8: macRadioSetChannel

/**************************************************************************************************
 * @fn          macRadioSetChannel
 *
 * @brief       Set radio channel.
 *
 * @param       channel - channel number, valid range is 11 through 26. Allow
 *              channels 27 and 28 for some Japanese customers.
 *
 * @return      none
 **************************************************************************************************
 */
MAC_INTERNAL_API void macRadioSetChannel(uint8 channel)
{
  halIntState_t  s;

  MAC_ASSERT((channel >= 11) && (channel <= 28));  /* illegal channel */

  /* critical section to make sure transmit does not start while updating channel */
  HAL_ENTER_CRITICAL_SECTION(s);

  /* set requested channel */
  reqChannel = channel;

  /*
   *  If transmit is not active, update the radio hardware immediately.  If transmit is active,
   *  the channel will be updated at the end of the current transmit.
   */
  if (!macTxActive)
  {
    macRadioUpdateChannel();
  }

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


示例9: macMcuOverflowSetPeriod

/**************************************************************************************************
 * @fn          macMcuOverflowSetPeriod
 *
 * @brief       Set overflow count period value.  An interrupt is triggered when the overflow
 *              count equals this period value.
 *
 * @param       count - overflow count compare value
 *
 * @return      none
 **************************************************************************************************
 */
MAC_INTERNAL_API void macMcuOverflowSetPeriod(uint32 count)
{
  halIntState_t  s;
  uint8 enableCompareInt = 0;

  MAC_ASSERT( !(count >> 24) );   /* illegal count value */

  HAL_ENTER_CRITICAL_SECTION(s);

  /*  Disable overflow compare interrupts. */
  if (T2IRQM & TIMER2_OVF_PERM)
  {
    enableCompareInt = 1;
    T2IRQM &= ~TIMER2_OVF_PERM;
  }

  MAC_MCU_T2_ACCESS_OVF_PERIOD_VALUE();

  /* for efficiency, the 32-bit value is decoded using endian abstracted indexing */
  T2MOVF0 = ((uint8 *)&count)[UINT32_NDX0];
  T2MOVF1 = ((uint8 *)&count)[UINT32_NDX1];
  T2MOVF2 = ((uint8 *)&count)[UINT32_NDX2];

  /*
   *  Now that new compare value is stored, clear the interrupt flag.  This is important just
   *  in case a false match was generated as the multi-byte compare value was written.
   */
  T2IRQF &= ~TIMER2_OVF_PERF;

  /* re-enable overflow compare interrupts if they were previously enabled */
  if (enableCompareInt)
  {
    T2IRQM |= TIMER2_OVF_PERM;
  }

  HAL_EXIT_CRITICAL_SECTION(s);
}
开发者ID:chessami92,项目名称:ceen4360-cc2538-code,代码行数:48,代码来源:mac_mcu.c


示例10: macBackoffTimerICallPwrNotify

/**************************************************************************************************
 * @fn          macBackoffTimerICallPwrNotify
 *
 * @brief       power state transition notify callback function
 *
 * @param       pwrTrans  power transition
 * @param       data      custom data - not used
 *
 * @return      none
 **************************************************************************************************
 */
static void macBackoffTimerICallPwrNotify(ICall_PwrTransition pwrTrans,
                                          ICall_PwrNotifyData *data)
{
  if (pwrTrans == ICALL_PWR_AWAKE_FROM_STANDBY)
  {
    /* Wakeup must be handled from the thread context.
     * Signal the event to the OSAL thread. */
    halIntState_t is;

    HAL_ENTER_CRITICAL_SECTION(is);
    macBackoffTimerEvents |= MAC_BACKOFF_TIMER_EVENT_POWER_WAKEUP;
    HAL_EXIT_CRITICAL_SECTION(is);
    ICall_signal(osal_semaphore);
  }
  else if (pwrTrans == ICALL_PWR_ENTER_STANDBY)
  {
    /* Stop RAT timer */
    macRATValue = macStopRAT();

    /* Park CM0 */
    MAC_RADIO_POWER_DOWN();

    /* The following calls are necessary to prevent a race condition in 
     * pg2_leakage_workaround that causes CM3 to constantly firing up CPE1
     * interrupts during power up until CM3 crashes.
     */
    ICall_disableInt( INT_RF_CPE0 );
    ICall_disableInt( INT_RF_CPE1 );
    ICall_disableInt( INT_RF_HW );
    ICall_disableInt( INT_RF_CMD_ACK );
  }
  else if (pwrTrans == ICALL_PWR_ENTER_SHUTDOWN)
  {
    /* Park CM0 */
    MAC_RADIO_POWER_DOWN();
  }
}
开发者ID:peifengzhou,项目名称:CC2630_HA_Demo,代码行数:48,代码来源:mac_backoff_timer.c


示例11: HalKeyPoll

/**************************************************************************************************
 * @fn          HalKeyPoll
 *
 * @brief       This function is called by Hal_ProcessEvent() on a HAL_KEY_EVENT.
 *
 * input parameters
 *
 * None.
 *
 * output parameters
 *
 * None.
 *
 * @return      None.
 **************************************************************************************************
 */
void HalKeyPoll(void)
{
  uint8 newKeys;

  if (Hal_KeyIntEnable)
  {
    halIntState_t intState;
    HAL_ENTER_CRITICAL_SECTION(intState);
    newKeys = isrKeys;
    isrKeys = 0;
    HAL_EXIT_CRITICAL_SECTION(intState);
  }
  else
  {
    uint8 keys = HalKeyRead();
    newKeys = (halKeys ^ keys) & keys;
    halKeys = keys;
  }

  if (newKeys && pHalKeyProcessFunction)
  {
    (pHalKeyProcessFunction)(newKeys, HAL_KEY_STATE_NORMAL);
  }
}
开发者ID:JensenSung,项目名称:shred444,代码行数:40,代码来源:hal_key.c


示例12: HalSPIRead

/******************************************************************************
 * @fn      HalSPIRead
 *
 * @brief   Read from the external NV storage via SPI.
 *
 * @param   addr - Offset into the external NV.
 * @param   pBuf - Pointer to buffer 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_OTA_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_OTA_BOOT_CODE
  P1DIR = shdw;
  HAL_EXIT_CRITICAL_SECTION(his);
#endif
}
开发者ID:binwulang,项目名称:zstack-agriculture,代码行数:47,代码来源:hal_ota.c


示例13: stack_main

/**
 * Main entry function for the stack image
 */
int stack_main( void *arg )
{
  /* User reconfiguration of BLE Controller and Host variables */
  setBleUserConfig( (bleUserCfg_t *)arg );
  
  /* Establish OSAL for a stack service that requires accompanying
   * messaging service */
  if (ICall_enrollService(ICALL_SERVICE_CLASS_BLE_MSG,
                          (ICall_ServiceFunc) osal_service_entry,
                          &osal_entity, &osal_semaphore) !=
      ICALL_ERRNO_SUCCESS)
  {
    /* abort */
    ICall_abort();
  }

  halIntState_t state;
  HAL_ENTER_CRITICAL_SECTION(state);
  
  // Turn off interrupts
  //osal_int_disable( INTS_ALL );

  // Initialize NV System
  osal_snv_init( );

  // Initialize the operating system
  osal_init_system();

  // Allow interrupts
  //osal_int_enable( INTS_ALL );
  HAL_EXIT_CRITICAL_SECTION(state);

  osal_start_system(); // No Return from here

  return 0;  // Shouldn't get here.
}
开发者ID:ClarePhang,项目名称:ALL_SmartBatterySwitch_CC2640,代码行数:39,代码来源:OSAL_ICallBle.c


示例14: halUartPollRx

/***********************************************************************************
* @fn           halUartPollRx
*
* @brief        Poll for data from USB.
*
* @param        none
*
* @return       none
*/
static 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++] = USBF4;
    }
    USBFW_ARM_OUT_ENDPOINT();

#if !defined HAL_SB_BOOT_CODE
    // 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;
#endif
  }
#if !defined HAL_SB_BOOT_CODE
  else if (rxTick)
开发者ID:paoloach,项目名称:zpowermeter,代码行数:45,代码来源:_hal_uart_usb.c


示例15: macRadioSetTxPower

void macRadioSetTxPower(uint8 txPower)
{
  halIntState_t  s;

  /* if the selected dBm is out of range, use the closest available */
  if (txPower > MAC_RADIO_TX_POWER_MAX_MINUS_DBM)
  {
    txPower = MAC_RADIO_TX_POWER_MAX_MINUS_DBM;
  }

  /*
   *  Set the global variable reqTxPower.  This variable is referenced
   *  by the function macRadioUpdateTxPower() to write the radio register.
   *
   *  A lookup table is used to translate the power level to the register
   *  value.
   */
  HAL_ENTER_CRITICAL_SECTION(s);
  reqTxPower = macRadioDefsTxPowerTable[txPower];
  HAL_EXIT_CRITICAL_SECTION(s);

  /* update the radio power setting */
  macRadioUpdateTxPower();
}
开发者ID:kricnam,项目名称:blackboxreader,代码行数:24,代码来源:mac_radio.c


示例16: RFHAL_FreeNextTxDataEntry

/*******************************************************************************
 * @fn          RFHAL_FreeNextTxDataEntry API
 *
 * @brief       This function is used to free the next TX data entry based on
 *              the internal data entry queue pointer. This routine should be
 *              used after the radio FW indicates a TX Entry Done interrupt.
 *              Once freed, the internal data entry queue is updated to the
 *              next entry.
 *
 *              Note: It is assumed the data entry queue is really based on a
 *                    data queue.
 *
 * input parameters
 *
 * @param       pDataEntryQ - Pointer to data entry queue.
 *
 * output parameters
 *
 * @param       None.
 *
 * @return      None.
 */
void RFHAL_FreeNextTxDataEntry( dataEntryQ_t *pDataEntryQ )
{
  halIntState_t cs;
  dataEntry_t   *pNextEntry;

  HAL_ENTER_CRITICAL_SECTION(cs);

  // get next data entry to free (i.e. head of internal queue)
  pNextEntry = ((dataQ_t *)pDataEntryQ)->pNextDataEntry;

  // update the internal next data entry pointer based on pCurEntry
  // Note: If this was the last data entry on the queue, then pCurEntry would
  //       be NULL, and so would pNextDataEntry. If this was not the last data
  //       entry on the queue, then pNextDataEntry should point to the current
  //       entry. So pNextEntry in either case.
  ((dataQ_t *)pDataEntryQ)->pNextDataEntry = pNextEntry->pNextEntry;

  // free the TX data entry given by the internal next data entry
  osal_bm_free( (void *)pNextEntry );

  HAL_EXIT_CRITICAL_SECTION(cs);

  return;
}
开发者ID:PolymorphicLabs,项目名称:PML-Firmware,代码行数:46,代码来源:rfHal.c


示例17: rxStartIsr


//.........这里部分代码省略.........

    /* read FCS from FIFO (threshold set so bytes are guaranteed to be there) */
    MAC_RADIO_READ_RX_FIFO(fcsBuf, MAC_FCS_FIELD_LEN);

    /*
     *  This critical section ensures that the ACK timeout won't be triggered in the
     *  middle of receiving the ACK frame.
     */
    HAL_ENTER_CRITICAL_SECTION(s);

    /* see if transmit is listening for an ACK */
    if (macTxActive == MAC_TX_ACTIVE_LISTEN_FOR_ACK)
    {
      MAC_ASSERT(pMacDataTx != NULL); /* transmit buffer must be present */

      /* record link quality metrics for the receive ACK */
      {
        int8 rssiDbm;
        uint8 corr;

        rssiDbm = PROPRIETARY_FCS_RSSI(fcsBuf) + MAC_RADIO_RSSI_OFFSET;
        MAC_RADIO_RSSI_LNA_OFFSET(rssiDbm);
        corr = PROPRIETARY_FCS_CORRELATION_VALUE(fcsBuf);

        pMacDataTx->internal.mpduLinkQuality = macRadioComputeLQI(rssiDbm, corr);
        pMacDataTx->internal.correlation = corr;
        pMacDataTx->internal.rssi= rssiDbm;
      }

      /*
       *  It's okay if the ACK timeout is triggered here. The callbacks for ACK received
       *  or ACK not received will check "macTxActive" flag before taking any actions.
       */
      HAL_EXIT_CRITICAL_SECTION(s);

      /*
       *  An ACK was received so transmit logic needs to know.  If the FCS failed,
       *  the transmit logic still needs to know.  In that case, treat the frame
       *  as a non-ACK to complete the active transmit.
       */
      if (PROPRIETARY_FCS_CRC_OK(fcsBuf))
      {
        /* call transmit logic to indicate ACK was received */
        macTxAckReceivedCallback(MAC_SEQ_NUMBER(&rxBuf[1]), MAC_FRAME_PENDING(&rxBuf[1]));
      }
      else
      {
        macTxAckNotReceivedCallback();
      }
    }
    else
    {
      HAL_EXIT_CRITICAL_SECTION(s);
    }

    /* receive is done, exit from here */
    rxDone();
    return;
  }
  else if (macTxActive == MAC_TX_ACTIVE_LISTEN_FOR_ACK)
  {
    macTxAckNotReceivedCallback();
  }

  /*-------------------------------------------------------------------------------
   *  Apply filtering.
开发者ID:comword,项目名称:SmartIR-8051,代码行数:67,代码来源:mac_rx.c


示例18: MAC_MlmeSetReq

/**************************************************************************************************
 * @fn          MAC_MlmeSetReq
 *
 * @brief       This direct execute function sets an attribute value
 *              in the MAC PIB.
 *
 * input parameters
 *
 * @param       pibAttribute - The attribute identifier.
 * @param       pValue - pointer to the attribute value.
 *
 * output parameters
 *
 * None.
 *
 * @return      The status of the request, as follows:
 *              MAC_SUCCESS Operation successful.
 *              MAC_UNSUPPORTED_ATTRIBUTE Attribute not found.
 *
 **************************************************************************************************
 */
uint8 MAC_MlmeSetReq(uint8 pibAttribute, void *pValue)
{
  uint8         i;
  halIntState_t intState;

  if (pibAttribute == MAC_BEACON_PAYLOAD)
  {
    macPib.pBeaconPayload = pValue;
    return MAC_SUCCESS;
  }

  /* look up attribute in PIB table */
  if ((i = macPibIndex(pibAttribute)) == MAC_PIB_INVALID)
  {
    return MAC_UNSUPPORTED_ATTRIBUTE;
  }

  /* do range check; no range check if min and max are zero */
  if ((macPibTbl[i].min != 0) || (macPibTbl[i].max != 0))
  {
    /* if min == max, this is a read-only attribute */
    if (macPibTbl[i].min == macPibTbl[i].max)
    {
      return MAC_READ_ONLY;
    }

    /* check for special cases */
    if (pibAttribute == MAC_MAX_FRAME_TOTAL_WAIT_TIME)
    {
      if ((*((uint16 *) pValue) < MAC_MAX_FRAME_RESPONSE_MIN) ||
          (*((uint16 *) pValue) > MAC_MAX_FRAME_RESPONSE_MAX))
      {
        return MAC_INVALID_PARAMETER;
      }
    }

    /* range check for general case */
    if ((*((uint8 *) pValue) < macPibTbl[i].min) || (*((uint8 *) pValue) > macPibTbl[i].max))
    {
      return MAC_INVALID_PARAMETER;
    }

  }

  /* set value in PIB */
  HAL_ENTER_CRITICAL_SECTION(intState);
  osal_memcpy((uint8 *) &macPib + macPibTbl[i].offset, pValue, macPibTbl[i].len);
  HAL_EXIT_CRITICAL_SECTION(intState);

  /* handle special cases */
  switch (pibAttribute)
  {
    case MAC_PAN_ID:
      /* set pan id in radio */
      macRadioSetPanID(macPib.panId);
      break;

    case MAC_SHORT_ADDRESS:
      /* set short address in radio */
      macRadioSetShortAddr(macPib.shortAddress);
      break;

    case MAC_RX_ON_WHEN_IDLE:
      /* turn rx on or off */
      if (macPib.rxOnWhenIdle)
      {
        macRxEnable(MAC_RX_WHEN_IDLE);
      }
      else
      {
        macRxDisable(MAC_RX_WHEN_IDLE);
      }
      break;

    case MAC_LOGICAL_CHANNEL:
      macRadioSetChannel(macPib.logicalChannel);
      break;

    case MAC_EXTENDED_ADDRESS:
//.........这里部分代码省略.........
开发者ID:jphome,项目名称:zigbee_2.5.1,代码行数:101,代码来源:mac_pib.c


示例19: macTxFrame


//.........这里部分代码省略.........
    txComplete(MAC_TX_ABORTED);

    /* exit from transmit logic */
    return;
  }

  /* save transmit type */
  macTxType = txType;

  /*-------------------------------------------------------------------------------
   *  Prepare for transmit.
   */
  if (macTxType == MAC_TX_TYPE_SLOTTED)
  {
    MAC_RADIO_TX_PREP_SLOTTED();
  }

#ifdef FEATURE_GREEN_POWER
  else if (macTxType == MAC_TX_TYPE_GREEN_POWER)
  {
    txGreenPowerPrep();
  }
#endif /* #ifdef FEATURE_GREEN_POWER */

  else
  {
    MAC_ASSERT((macTxType == MAC_TX_TYPE_SLOTTED_CSMA) || (macTxType == MAC_TX_TYPE_UNSLOTTED_CSMA));

    nb = 0;
    macTxBe = (pMacDataTx->internal.txOptions & MAC_TXOPTION_ALT_BE) ? pMacPib->altBe : pMacPib->minBe;

    if ((macTxType == MAC_TX_TYPE_SLOTTED_CSMA) && (pMacPib->battLifeExt))
    {
      macTxBe = MIN(2, macTxBe);
    }

    txCsmaPrep();
  }

  /*-------------------------------------------------------------------------------
   *  Load transmit FIFO unless this is a retransmit.  No need to write
   *  the FIFO again in that case.
   */
  if (!txRetransmitFlag)
  {
    uint8 * p;
    uint8   lenMhrMsdu;

    MAC_ASSERT(pMacDataTx != NULL); /* must have data to transmit */

    /* save needed parameters */
    txAckReq = MAC_ACK_REQUEST(pMacDataTx->msdu.p);
    txSeqn   = MAC_SEQ_NUMBER(pMacDataTx->msdu.p);

    /* set length of frame (note: use of term msdu is a misnomer, here it's actually mhr + msdu) */
    lenMhrMsdu = pMacDataTx->msdu.len;

    /* calling code guarantees an unused prepended byte  */
    p = pMacDataTx->msdu.p - PREPENDED_BYTE_LEN;

    /* first byte of buffer is length of MPDU */
    *p = lenMhrMsdu + MFR_LEN;

    /*
     *  Flush the TX FIFO.  This is necessary in case the previous transmit was never
     *  actually sent (e.g. CSMA failed without strobing TXON).  If bytes are written to
     *  the FIFO but not transmitted, they remain in the FIFO to be transmitted whenever
     *  a strobe of TXON does happen.
     */
    MAC_RADIO_FLUSH_TX_FIFO();

    /* write bytes to FIFO, prepended byte is included, MFR is not (it's generated by hardware) */
    MAC_RADIO_WRITE_TX_FIFO(p, PREPENDED_BYTE_LEN + lenMhrMsdu);
  }

  /*-------------------------------------------------------------------------------
   *  If not receiving, start the transmit.  If receive is active
   *  queue up the transmit.
   *
   *  Critical sections around the state change prevents any sort of race condition
   *  with  macTxStartQueuedFrame().  This guarantees function txGo() will only be
   *  called once.
   */
  {
    halIntState_t  s;

    HAL_ENTER_CRITICAL_SECTION(s);
    if (!macRxActive && !macRxOutgoingAckFlag)
    {
      macTxActive = MAC_TX_ACTIVE_GO;
      HAL_EXIT_CRITICAL_SECTION(s);
      txGo();
    }
    else
    {
      macTxActive = MAC_TX_ACTIVE_QUEUED;
      HAL_EXIT_CRITICAL_SECTION(s);
    }
  }
}
开发者ID:LILCMU,项目名称:WRATIOT,代码行数:101,代码来源:mac_tx.c


示例20: MAC_MlmeSetReq

/**************************************************************************************************
 * @fn          MAC_MlmeSetReq
 *
 * @brief       This direct execute function sets an attribute value
 *              in the MAC PIB.
 *
 * input parameters
 *
 * @param       pibAttribute - The attribute identifier.
 * @param       pValue - pointer to the attribute value.
 *
 * output parameters
 *
 * None.
 *
 * @return      The status of the request, as follows:
 *              MAC_SUCCESS Operation successful.
 *              MAC_UNSUPPORTED_ATTRIBUTE Attribute not found.
 *
 **************************************************************************************************
 */
uint8 MAC_MlmeSetReq(uint8 pibAttribute, void *pValue)
{
    uint8         i;
    halIntState_t intState;

    if (pibAttribute == MAC_BEACON_PAYLOAD)
    {
        pMacPib->pBeaconPayload = pValue;
        return MAC_SUCCESS;
    }

    /* look up attribute in PIB table */
    if ((i = MAP_macPibIndex(pibAttribute)) == MAC_PIB_INVALID)
    {
        return MAC_UNSUPPORTED_ATTRIBUTE;
    }

    /* do range check; no range check if min and max are zero */
    if ((macPibTbl[i].min != 0) || (macPibTbl[i].max != 0))
    {
        /* if min == max, this is a read-only attribute */
        if (macPibTbl[i].min == macPibTbl[i].max)
        {
            return MAC_READ_ONLY;
        }

        /* check for special cases */
        if (pibAttribute == MAC_MAX_FRAME_TOTAL_WAIT_TIME)
        {
            if ((*((uint16 *) pValue) < MAC_MAX_FRAME_RESPONSE_MIN) ||
                    (*((uint16 *) pValue) > MAC_MAX_FRAME_RESPONSE_MAX))
            {
                return MAC_INVALID_PARAMETER;
            }
        }

        /* range check for general case */
        if ((*((uint8 *) pValue) < macPibTbl[i].min) || (*((uint8 *) pValue) > macPibTbl[i].max))
        {
            return MAC_INVALID_PARAMETER;
        }

    }

    /* set value in PIB */
    HAL_ENTER_CRITICAL_SECTION(intState);
    osal_memcpy((uint8 *) pMacPib + macPibTbl[i].offset, pValue, macPibTbl[i].len);
    HAL_EXIT_CRITICAL_SECTION(intState);

    /* handle special cases */
    switch (pibAttribute)
    {
    case MAC_PAN_ID:
        /* set pan id in radio */
        macRadioSetPanID(pMacPib->panId);
        break;

    case MAC_SHORT_ADDRESS:
        /* set short address in radio */
        macRadioSetShortAddr(pMacPib->shortAddress);
        break;

    case MAC_RX_ON_WHEN_IDLE:
        /* turn rx on or off */
        if (pMacPib->rxOnWhenIdle)
        {
            macRxEnable(MAC_RX_WHEN_IDLE);
        }
        else
        {
            macRxDisable(MAC_RX_WHEN_IDLE);
        }
        break;

    case MAC_LOGICAL_CHANNEL:
        macRadioSetChannel(pMacPib->logicalChannel);
        break;

    case MAC_EXTENDED_ADDRESS:
//.........这里部分代码省略.........
开发者ID:paoloach,项目名称:zpowermeter,代码行数:101,代码来源:mac_pib.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ HAL_FLASHEx_Erase函数代码示例发布时间:2022-05-30
下一篇:
C++ HAL_ERROR1函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap