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


C++ pal_timer_start函数代码示例

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


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

示例1: start_backoff

/**
 * \brief Starts the timer for the backoff period and enables receiver.
 */
static void start_backoff(void)
{
	/* Start backoff timer to trigger CCA */
	uint8_t backoff_8;
	backoff_8  = (uint8_t)rand() & ((1 << BE) - 1);
	if (backoff_8 > 0) {
		uint16_t backoff_16;
		uint32_t backoff_duration_us;
		backoff_16 = backoff_8 * aUnitBackoffPeriod;
		backoff_duration_us = TAL_CONVERT_SYMBOLS_TO_US(backoff_16);
		pal_timer_start(TAL_T_BOFF, backoff_duration_us,
				TIMEOUT_RELATIVE,
				(FUNC_PTR)cca_start, NULL);
		tal_state = TAL_BACKOFF;

#ifdef RX_WHILE_BACKOFF
		/* Switch receiver on during backoff */
		if (NULL == tal_rx_buffer) {
			set_trx_state(CMD_PLL_ON);
			tal_rx_on_required = true;
		} else {
			set_trx_state(CMD_RX_AACK_ON); /* receive while backoff
			                                **/
		}

#else
		set_trx_state(CMD_PLL_ON);
#endif
	} else {
		/* Start CCA immediately - no backoff */
		cca_start(NULL);
	}
}
开发者ID:InSoonPark,项目名称:asf,代码行数:36,代码来源:tal_tx.c

示例2: bc_data_cb_vanet

void bc_data_cb_vanet(frame_info_t *transmit_frame)
{
	uint8_t index;
	index  = nwkFindPassiveAck(transmit_frame->NwkFrameHeader->srcAddr, transmit_frame->NwkFrameHeader->sequenceNumber);
	if (index != 0xFF)
	{
#if 0
		if (gNwkPassiveAckTable.table[index].end == false)
		{

			NwkState = NWK_MODULE_NONE;
			pal_timer_start(gNwkPassiveAckTable.table[index].timerID,
							((uint32_t)	(NWK_BROADCAST_DELIVERY_TIME-(gNwkPassiveAckTable.table[index].reTryTimes+1)*NWK_PASSIVE_ACK_TIMEOUT)),
							TIMEOUT_RELATIVE,
							(FUNC_PTR)bc_data_cb_vanet,
							transmit_frame);
			gNwkPassiveAckTable.table[index].end = true;
			return;
		}
#endif
		gNwkPassiveAckTable.table[index].end = false;
		gNwkPassiveAckTable.table[index].reTryTimes = 0;
		nwkFreePassiveAck(transmit_frame->NwkFrameHeader->srcAddr, transmit_frame->NwkFrameHeader->sequenceNumber);
		if (transmit_frame != NULL)
			bmm_buffer_free(transmit_frame->buffer_header);
		//NwkState = NWK_MODULE_NONE;//if为1时原本是释掉的
		mac_sleep_trans();
	}
}
开发者ID:gexueyuan,项目名称:cct,代码行数:29,代码来源:nwk_broadcast.c

示例3: nlme_set_confirm

/**
 * @brief Notify the application of the status of its request to to change the
 *        value of a NIB attribute.
 *
 * @param Status              nwk status
 * @param NIBAttribute        NIBAttribute
 * @param NIBAttributeIndex   NIBAttributeIndex
 */
void nlme_set_confirm(nwk_enum_t Status, nib_attribute_t NIBAttribute, uint8_t NIBAttributeIndex)
{
  if (Status != NWK_SUCCESS)
    {
        return;
    }

    if (NIBAttribute == nwkBaseChannel)
    {
        pal_timer_start(T_LED_TIMER,
                        PAIR_WAIT_PERIOD,
                        TIMEOUT_RELATIVE,
                        (FUNC_PTR)led_handling,
                        NULL);
        pal_led(LED_NWK_SETUP, LED_ON);

        dev_type_t RecDevTypeList[DEVICE_TYPE_LIST_SIZE];
        profile_id_t RecProfileIdList[PROFILE_ID_LIST_SIZE];

        RecDevTypeList[0]   = SUPPORTED_DEV_TYPE_0;
        RecProfileIdList[0] = SUPPORTED_PROFILE_ID_0;

        pbp_rec_pair_request(APP_CAPABILITIES, RecDevTypeList, RecProfileIdList);
        return;
    }

  
    /* Keep compiler happy */
    UNUSED(NIBAttributeIndex);
}
开发者ID:AndreyMostovov,项目名称:asf,代码行数:38,代码来源:main.c

示例4: mac_t_rx_off_cb

/*
 * @brief Set the transceiver state to PHY_TRX_OFF
 *
 * This actually turns the radio receiver off - i.e. this is the end
 * of the PHY_RX_ON period.
 *
 * @param callback_parameter Callback parameter
 */
static void mac_t_rx_off_cb(void *callback_parameter)
{
    uint8_t status;

    /*
     * Rx is disabled.
     * This will make sure that the radio will be put to sleep in function
     * mac_sleep_trans().
     */
    mac_rx_enabled = false;

    /*
     * In case macRxOnWhenIdle is not set, the radio is put to PHY_TRX_OFF
     * state, until the return status does not match the desired radio state,
     * i.e. PHY_TRX_OFF
     */
    if (!mac_pib.mac_RxOnWhenIdle)
    {
        /*
         * In case the radio is awake, we need to switch RX off.
         */
        if (RADIO_AWAKE == mac_radio_sleep_state)
        {
            status = tal_rx_enable(PHY_TRX_OFF);

            if (status != PHY_TRX_OFF)
            {
                /*
                 * The TAL is still busy and cannot set the TRX to OFF.
                 * In order to get progress this requires another
                 * round of the TAL task being processed.
                 * Therefore the MAC task needs to stopp here and pass
                 * controll back to the TAL.
                 * This is reached by starting the Rx-Enable timer again
                 * for a very short time with the same callback returning
                 * here very soon.
                 */
                pal_timer_start(T_Rx_Enable,
                                MIN_TIMEOUT,
                                TIMEOUT_RELATIVE,
                                (FUNC_PTR())mac_t_rx_off_cb,
                                NULL);

                /*
                 * Return now, since the TAL is still busy, so radio cannot go
                 * to sleep for now.
                 */
                return;
            }
            else
            {
                /* Set radio to sleep if allowed */
                mac_sleep_trans();
            }
        }
    }

    callback_parameter = callback_parameter;  /* Keep compiler happy. */
}
开发者ID:subpos,项目名称:atmel_ranging_toolbox_zigbit,代码行数:67,代码来源:mac_rx_enable.c

示例5: mac_start_missed_beacon_timer

/*
 * @brief helper function to start missed beacon timer
 */
void mac_start_missed_beacon_timer(void)
{
    uint32_t sync_loss_time;
    uint8_t timer_status;

    /* Stop the missed beacon timer. */
    pal_timer_stop(T_Missed_Beacon);

#if (DEBUG > 0)
    if (pal_is_timer_running(T_Missed_Beacon))
    {
        ASSERT("Missed BCN tmr running" == 0);
    }
#endif

    /* Calculate the time allowed for missed beacons. */
    if (tal_pib.BeaconOrder < NON_BEACON_NWK)
    {
        /*
         * This the regualar case where we already have a Beacon Order.
         * In this case the Sync Loss time is a function of the actual
         * Beacon Order.
         */
        sync_loss_time = TAL_GET_BEACON_INTERVAL_TIME(tal_pib.BeaconOrder);
    }
    else
    {
        /*
         * This the "pathological" case where we don NOT have a Beacon Order.
         * This happens regularly in case of synchronization before association
         * if the Beacon Order was not set be the network layer or application.
         *
         * In this case the Sync Loss time is based on the highest possible
         * Beacon Order, which is 15 - 1, since 15 means no Beacon network.
         */
        sync_loss_time = TAL_GET_BEACON_INTERVAL_TIME(NON_BEACON_NWK - 1);
    }

    sync_loss_time *= aMaxLostBeacons;

    sync_loss_time = TAL_CONVERT_SYMBOLS_TO_US(sync_loss_time);

    timer_status = pal_timer_start(T_Missed_Beacon,
                                   sync_loss_time,
                                   TIMEOUT_RELATIVE,
                                   (FUNC_PTR)mac_t_missed_beacons_cb,
                                   NULL);

    if (MAC_SUCCESS != timer_status)
    {
#if (DEBUG > 0)
        ASSERT(MAC_SUCCESS == timer_status);
#endif
        /* Sync timer could not be started hence report sync-loss */
        mac_sync_loss(MAC_BEACON_LOSS);
    }
}
开发者ID:nandojve,项目名称:embedded,代码行数:60,代码来源:mac_sync.c

示例6: handle_rx_on

/*
 * @brief Internal function to handle immediate RX_ON
 *
 * This function immediately enables the receiver with the given
 * RxOnDuration time in symbols from now.
 *
 * @param rx_on_duration_symbols Duration in symbols that the reciever is
 *                               switched on.
 */
static void handle_rx_on(uint32_t rx_on_duration_symbols, uint8_t *m)
{
    retval_t timer_status;
    uint8_t rx_enable_status = mac_rx_enable();

    /*
     * TODO: Once it is possible to restart a timer even if it is
     * already running, this could be improved by simply calling
     * function pal_timer_start() without this previous check using
     * function pal_is_timer_running().
     */
    if (pal_is_timer_running(T_Rx_Enable))
    {
        /*
         * Rx-Enable timer is already running, so we need to stopp it first
         * before it will be started.
         */
        pal_timer_stop(T_Rx_Enable);
    }

    /*
     * Start timer for the Rx On duration of the radio being on
     * in order to switch it off later again.
     */
    timer_status =
        pal_timer_start(T_Rx_Enable,
                        TAL_CONVERT_SYMBOLS_TO_US(rx_on_duration_symbols),
                        TIMEOUT_RELATIVE,
                        (FUNC_PTR())mac_t_rx_off_cb,
                        NULL);

    ASSERT(MAC_SUCCESS == timer_status);

    /*
     * Send the confirm immediately depending on the status of
     * the timer start and the Rx Status
     */
    if (MAC_SUCCESS != timer_status)
    {
        gen_rx_enable_conf((buffer_t *)m, (uint8_t)MAC_INVALID_PARAMETER);
        /* Do house-keeeping and turn radio off. */
        mac_t_rx_off_cb(NULL);
    }
    else if (PHY_RX_ON != rx_enable_status)
    {
        gen_rx_enable_conf((buffer_t *)m, (uint8_t)MAC_TX_ACTIVE);
    }
    else
    {
        gen_rx_enable_conf((buffer_t *)m, (uint8_t)MAC_SUCCESS);
    }

    return;
}
开发者ID:subpos,项目名称:atmel_ranging_toolbox_zigbit,代码行数:63,代码来源:mac_rx_enable.c

示例7: tal_trx_wakeup

/**
 * @brief Wakes up the transceiver from sleep
 *
 * This function awakes the transceiver from sleep state.
 *
 * @return   TAL_TRX_AWAKE - The transceiver is already awake
 *           MAC_SUCCESS - The transceiver is woken up from sleep
 *           FAILURE - The transceiver did not wake-up from sleep
 */
retval_t tal_trx_wakeup(void)
{
    tal_trx_status_t trx_status;

    if (tal_trx_status != TRX_SLEEP)
    {
        return TAL_TRX_AWAKE;
    }

#ifdef ENABLE_FTN_PLL_CALIBRATION
    {
        retval_t timer_status;

        /*
         * Calibration timer has been stopped when going to sleep,
         * so it needs to be restarted.
         * All other state changes except via sleep that are ensuring
         * implicit filter tuning and pll calibration are ignored.
         * Therefore the calibration timer needs to be restarted for
         * to those cases.
         * This is handled in file tal.c.
         */

        /* Start periodic calibration timer.*/
        timer_status = pal_timer_start(TAL_CALIBRATION,
                                       TAL_CALIBRATION_TIMEOUT_US,
                                       TIMEOUT_RELATIVE,
                                       (FUNC_PTR)calibration_timer_handler_cb,
                                       NULL);

        if (timer_status != MAC_SUCCESS)
        {
            ASSERT("PLL calibration timer start problem" == 0);
        }
    }
#endif  /* ENABLE_FTN_PLL_CALIBRATION */

    trx_status = set_trx_state(CMD_TRX_OFF);

    if (trx_status == TRX_OFF)
    {
        pal_timer_source_select(TMR_CLK_SRC_DURING_TRX_AWAKE);
        return MAC_SUCCESS;
    }
    else
    {
        return FAILURE;
    }
}
开发者ID:nandojve,项目名称:embedded,代码行数:58,代码来源:tal_pwr_mgmt.c

示例8: start_timer

/**
 * @brief starts a timer
 */
static void start_timer()
{
    uint8_t status = pal_timer_start(    TIMER_DATA_FWD,
            (uint32_t)1000*TIMER_INTERVAL,
            TIMEOUT_RELATIVE,
            (void*)data_fwd_cb,
            NULL);

#if(ALERT_ON_ERROR==true)
    if(status != MAC_SUCCESS)
    {
        pal_alert();
    }
#endif
}
开发者ID:mknapik,项目名称:avr-MAC,代码行数:18,代码来源:main.c

示例9: bc_delay_cb

void bc_delay_cb(frame_info_t *transmit_frame)
{
	retval_t status;

	status = tal_tx_frame(nwkBroadDelay[minBroadDelayIndex].transmit_frame, CSMA_UNSLOTTED, true);
	broadDelayBitmap &= ~(1<<minBroadDelayIndex);
	nwkBroadDelay[minBroadDelayIndex].transmit_frame = NULL;
	nwkBroadDelay[minBroadDelayIndex].delayCount = 0xFFFFFFFF;
	broadDelayCount--;

	if (MAC_SUCCESS == status)
	{
		MAKE_MAC_BUSY();
	}
	else
	{
       // NwkState = NwkState;
        //bmm_buffer_free(nwkBroadDelay[minBroadDelayIndex].transmit_frame->buffer_header);//TODO 要多考虑,如果后面还有数据,需要再启动
        mac_sleep_trans();
	}



	if (broadDelayCount > 0)
	{
		//bubble_sort_broad();

		do
		{
			status = pal_timer_start(APP_TIMER_UART_TIMEOUT,
					nwkBroadDelay[++minBroadDelayIndex].delayCount,
					TIMEOUT_ABSOLUTE, (FUNC_PTR) bc_delay_cb,
					NULL);
			if (MAC_SUCCESS != status)
			{
				broadDelayBitmap &= ~(1<<minBroadDelayIndex);
				nwkBroadDelay[minBroadDelayIndex].transmit_frame = NULL;
				nwkBroadDelay[minBroadDelayIndex].delayCount = 0xFFFFFFFF;
				broadDelayCount--;
			}
		} while (MAC_SUCCESS != status && nwkBroadDelay[minBroadDelayIndex+1].transmit_frame != NULL);
	}
    
    if (broadDelayCount == 0)
      minBroadDelayIndex = 0;
}
开发者ID:gexueyuan,项目名称:cct,代码行数:46,代码来源:nwk_broadcast.c

示例10: mac_scan_send_complete

/**
 * @brief Continue scanning after the completion of frame transmission.
 *
 * This functions continues the corresponding scaning depending on status
 * from the transmission of a beacon request or orphan notification frame.
 *
 * @param status Status of transmission
 */
void mac_scan_send_complete(retval_t status)
{
	retval_t timer_status;

	mac_pib.mac_DSN++;

	if (MAC_SUCCESS == status) {
		uint32_t tmr = 0;

		if (MAC_SCAN_ACTIVE == mac_scan_state) {
			tmr = MAC_CALCULATE_SYMBOL_TIME_SCANDURATION(
					scan_duration);
		} else {
			/*
			 * Since this function is only called in active or
			 * orphan scan state,
			 * this case is handling the orphan scan state.
			 */
			tmr = mac_pib.mac_ResponseWaitTime;
		}

		timer_status = pal_timer_start(T_Scan_Duration,
				TAL_CONVERT_SYMBOLS_TO_US(tmr),
				TIMEOUT_RELATIVE,
				(FUNC_PTR)mac_t_scan_duration_cb,
				NULL);
#if (_DEBUG_ > 0)
		Assert(MAC_SUCCESS == timer_status);
#endif
		if (MAC_SUCCESS != timer_status) {
			uint8_t timer_id = T_Scan_Duration;

			/*
			 * Scan duration timer could not be started, so we call
			 * the timer callback function directly. This will
			 * basically
			 * shorten scanning without having really scanned.
			 */
			mac_t_scan_duration_cb((void *)&timer_id);
		}
	} else {
		/* Did not work, continue. */
		scan_curr_channel++;
		scan_proceed(scan_type, (buffer_t *)mac_conf_buf_ptr);
	}
}
开发者ID:InSoonPark,项目名称:asf,代码行数:54,代码来源:mac_scan.c

示例11: calibration_timer_handler_cb

/*
 * \brief PLL calibration and filter tuning timer callback
 *
 * \param parameter Unused callback parameter
 */
void calibration_timer_handler_cb(void *parameter)
{
	retval_t timer_status;

	handle_ftn_pll_calibration();

	/* Restart periodic calibration timer again.*/
	timer_status = pal_timer_start(TAL_CALIBRATION,
			TAL_CALIBRATION_TIMEOUT_US,
			TIMEOUT_RELATIVE,
			(FUNC_PTR)calibration_timer_handler_cb,
			NULL);

	if (timer_status != MAC_SUCCESS) {
		Assert("PLL calibration timer start problem" == 0);
	}

	parameter = parameter; /* Keep compiler happy. */
}
开发者ID:AndreyMostovov,项目名称:asf,代码行数:24,代码来源:tal.c

示例12: start_beacon_loss_timer

/**
 * \brief Starts the beacon loss timer
 */
static void start_beacon_loss_timer(void)
{
	uint32_t timer_duration_us;
#if (_DEBUG_ > 0)
	retval_t timer_status;
#endif

	/* debug pin to switch on: define ENABLE_DEBUG_PINS, pal_config.h */
	PIN_BEACON_LOSS_TIMER_START();

	timer_duration_us
		= TAL_CONVERT_SYMBOLS_TO_US(TAL_GET_BEACON_INTERVAL_TIME(tal_pib
			.BeaconOrder));
	timer_duration_us *= aMaxLostBeacons;
	timer_duration_us += CSMA_BEACON_LOSS_GUARD_TIME_US;

#if (_DEBUG_ > 0)
	timer_status =
#endif
	pal_timer_start(TAL_CSMA_BEACON_LOSS_TIMER,
			timer_duration_us,
			TIMEOUT_RELATIVE,
			(FUNC_PTR)beacon_loss_timer_cb,
			NULL);

#if (_DEBUG_ > 0)
	if (timer_status != MAC_SUCCESS) {
		if (timer_status == PAL_TMR_INVALID_TIMEOUT) {
			Assert(
					"beacon loss timer start failed: PAL_TMR_INVALID_TIMEOUT" ==
					0);
		} else if (timer_status == PAL_TMR_ALREADY_RUNNING) {
			Assert(
					"beacon loss timer start failed: PAL_TMR_ALREADY_RUNNING" ==
					0);
		} else {
			Assert("beacon loss timer start failed: ?" == 0);
		}
	}

#endif
}
开发者ID:InSoonPark,项目名称:asf,代码行数:45,代码来源:tal_slotted_csma.c

示例13: led_handling

/**
 * @brief LED handling including timer control .
 */
static void led_handling(void *callback_parameter)
{
    switch (node_status)
    {
        case PUSH_BUTTON_PAIRING:
        case ALL_IN_ONE_START:
            pal_timer_start(T_LED_TIMER,
                            PAIR_WAIT_PERIOD,
                            TIMEOUT_RELATIVE,
                            (FUNC_PTR)led_handling,
                            NULL);
            pal_led(LED_NWK_SETUP, LED_TOGGLE);
            break;

        default:
            pal_timer_stop(T_LED_TIMER);
            pal_led(LED_DATA, LED_OFF);
            pal_led(LED_NWK_SETUP, LED_OFF);
            break;
    }

    /* Keep compiler happy */
    UNUSED(callback_parameter);
}
开发者ID:AndreyMostovov,项目名称:asf,代码行数:27,代码来源:main.c

示例14: start_backoff

/**
 * @brief Starts the timer for the backoff period and enables receiver.
 *
 * @param trx_id Transceiver identifier
 */
static void start_backoff(trx_id_t trx_id)
{
	/* Start backoff timer to trigger CCA */
	uint8_t backoff_8;
	backoff_8  = (uint8_t)(rand() & (((uint16_t)1 << BE[trx_id]) - 1));
	if (backoff_8 > 0) {
		uint8_t timer_id;
		uint16_t backoff_16;
		uint32_t backoff_duration_us;
		backoff_16 = backoff_8 * aUnitBackoffPeriod;
		backoff_duration_us
			= (uint32_t)tal_pib[trx_id].SymbolDuration_us *
				(uint32_t)backoff_16;
#ifdef REDUCED_BACKOFF_DURATION
		backoff_duration_us = REDUCED_BACKOFF_DURATION;
#endif
		if (trx_id == RF09) {
			timer_id = TAL_T_0;
		} else {
			timer_id = TAL_T_1;
		}

		retval_t status
			= pal_timer_start(timer_id, backoff_duration_us,
				TIMEOUT_RELATIVE,
				(FUNC_PTR)cca_start,
				(void *)&timer_cb_parameter[trx_id]);
		if (status != MAC_SUCCESS) {
			tx_done_handling(trx_id, status);
			return;
		}

		tx_state[trx_id] = TX_BACKOFF;

#ifdef RX_WHILE_BACKOFF
		/* Keep receiver on during backoff */
		if ((trx_default_state[trx_id] == RF_RX) &&
				(tal_pib[trx_id].NumRxFramesDuringBackoff <
				tal_pib[trx_id].MaxNumRxFramesDuringBackoff)) {
			if (trx_state[trx_id] != RF_RX) {
				if (trx_state[trx_id] == RF_TRXOFF) {
					switch_to_txprep(trx_id);
				}

				switch_to_rx(trx_id);
			}
		} else
#endif
		{
#ifdef USE_TXPREP_DURING_BACKOFF
			/* Switch to TXPREP during backoff */

			if (trx_state[trx_id] != RF_TXPREP) {
				switch_to_txprep(trx_id);
			}

#else
			/* Switch to TRXOFF during backoff */
			if (trx_state[trx_id] != RF_TRXOFF) {
				uint16_t reg_offset = RF_BASE_ADDR_OFFSET *
						trx_id;
				trx_reg_write(reg_offset + RG_RF09_CMD,
						RF_TRXOFF);
				trx_state[trx_id] = RF_TRXOFF;
			}

#endif
		}
	} else { /* no backoff required */
		/* Start CCA immediately - no backoff */
		cca_start((void *)&timer_cb_parameter[trx_id]);
	}
}
开发者ID:thegeek82000,项目名称:asf,代码行数:78,代码来源:tal_auto_csma.c

示例15: csma_backoff_calculation


//.........这里部分代码省略.........
			                                    * be reduced */

			/* Add some guard time to wakeup the transceiver. */
			transaction_duration_sym
				= (transaction_duration_periods *
					aUnitBackoffPeriod) +
					TAL_CONVERT_US_TO_SYMBOLS(
					SLEEP_TO_TRX_OFF_TYP_US +
					CCA_GUARD_DURATION_US);

			time_after_transaction_sym
				= tal_add_time_symbols(TAL_CONVERT_US_TO_SYMBOLS(
					next_backoff_boundary_us),
					transaction_duration_sym);

			/* Check if the entire transaction fits into the current
			 * CAP. */
			if (time_after_transaction_sym < current_CAP_end_sym) {
				retval_t timer_status;
				uint32_t callback_start_time;

				/* Calculate the time needed to backoff. */
				cca_starttime_us
					= pal_add_time_us(
						next_backoff_boundary_us,
						TAL_CONVERT_SYMBOLS_TO_US(
						remaining_backoff_periods *
						aUnitBackoffPeriod));

				/*
				 * Ensure that wakeup time is available before
				 * CCA.
				 * The required duration depends on the current
				 * trx status.
				 * Assume here the worst case: trx is in SLEEP.
				 */

				/*
				 * \TODO depending on the duration that we need
				 * to backoff,
				 * set trx to SLEEP, TRX_OFF or PLL_ON
				 * meanwhile.
				 */
				while (pal_sub_time_us(cca_starttime_us,
						TAL_CONVERT_SYMBOLS_TO_US(
						now_time_sym)) <
						(SLEEP_TO_TRX_OFF_TYP_US +
						CCA_GUARD_DURATION_US)) {
					cca_starttime_us
						= pal_add_time_us(
							cca_starttime_us,
							TAL_CONVERT_SYMBOLS_TO_US(
							aUnitBackoffPeriod));
				}

				/*
				 * Start the CCA timer.
				 * Add some time to locate the next backoff
				 * boundary
				 * once CCA timer fires.
				 */
				callback_start_time
					= pal_sub_time_us(cca_starttime_us,
						(SLEEP_TO_TRX_OFF_TYP_US +
						CCA_PREPARATION_DURATION_US));

				timer_status = pal_timer_start(TAL_CSMA_CCA,
						callback_start_time,
						TIMEOUT_ABSOLUTE,
						(FUNC_PTR)cca_timer_handler_cb,
						NULL);

				if (timer_status == MAC_SUCCESS) {
					tal_csma_state
						= BACKOFF_WAITING_FOR_CCA_TIMER;
				} else if (timer_status ==
						PAL_TMR_INVALID_TIMEOUT) {
					/* Start the CCA immediately. */
					cca_timer_handler_cb(NULL);
				} else {
					tal_csma_state = CSMA_ACCESS_FAILURE;
					Assert("CCA timer start problem" == 0);
				}

				/* debug pin to switch on: define
				 * ENABLE_DEBUG_PINS, pal_config.h */
				PIN_BACKOFF_START();
			} else {
				/* Restart again after next beacon. */
				NB = 0;
				remaining_backoff_periods
					= (uint8_t)(rand() &
						((1 << BE) - 1));
				tal_csma_state = BACKOFF_WAITING_FOR_BEACON;

				start_beacon_loss_timer();
			}
		}
	}
}
开发者ID:InSoonPark,项目名称:asf,代码行数:101,代码来源:tal_slotted_csma.c


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