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

C++ pal_timer_start函数代码示例

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

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



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


示例16: tal_reset

/**
 * @brief Resets TAL state machine and sets the default PIB values if requested
 *
 * @param set_default_pib Defines whether PIB values need to be set
 *                        to its default values
 *
 * @return MAC_SUCCESS  if the transceiver state is changed to TRX_OFF
 *         FAILURE otherwise
 */
retval_t tal_reset(bool set_default_pib)
{
    /*
     * Do the reset stuff.
     * Set the default PIBs depending on the given parameter set_default_pib.
     * Do NOT generate random seed again.
     */
    if (internal_tal_reset(set_default_pib) != MAC_SUCCESS)
    {
        return FAILURE;
    }

#if (NUMBER_OF_TAL_TIMERS > 0)
    /* Clear all running TAL timers. */
    {
        uint8_t timer_id;

        ENTER_CRITICAL_REGION();

        for (timer_id = TAL_FIRST_TIMER_ID; timer_id <= TAL_LAST_TIMER_ID;
                timer_id++)
        {
            pal_timer_stop(timer_id);
        }

        LEAVE_CRITICAL_REGION();
    }
#endif

    /* Clear TAL Incoming Frame queue and free used buffers. */
    while (tal_incoming_frame_queue.size > 0)
    {
        buffer_t *frame = qmm_queue_remove(&tal_incoming_frame_queue, NULL);
        if (NULL != frame)
        {
            bmm_buffer_free(frame);
        }
    }

#ifdef ENABLE_TFA
    tfa_reset(set_default_pib);
#endif

    /*
     * Configure interrupt handling.  Clear all pending interrupts.
     * Handlers have been installed in tal_init(), and are never
     * uninstalled.
     */
    pal_trx_irq_flag_clr_rx_end();
    pal_trx_irq_flag_clr_tx_end();
#if (defined BEACON_SUPPORT) || (defined ENABLE_TSTAMP)
    pal_trx_irq_flag_clr_tstamp();
#endif /* (defined BEACON_SUPPORT) || (defined ENABLE_TSTAMP) */
    pal_trx_irq_flag_clr_awake();

    /*
     * To make sure that the CSMA seed is properly set within the transceiver,
     * put the trx to sleep briefly and wake it up again.
     */
    tal_trx_sleep(SLEEP_MODE_1);

    tal_trx_wakeup();

#ifdef ENABLE_FTN_PLL_CALIBRATION
    {
        /* Handle PLL calibration and filter tuning. */
        retval_t timer_status;

        /* Calibration timer has already been stopped within this function. */

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

#ifdef STB_ON_SAL
    stb_restart();
#endif

    return MAC_SUCCESS;
}
开发者ID:nandojve,项目名称:embedded,代码行数:99,代码来源:tal_init.c


示例17: mlme_rx_enable_request


//.........这里部分代码省略.........
         * According to 7.1.10.1.3:
         * On a beacon-enabled PAN, the MLME first determines whether
         * (RxOnTime + RxOnDuration) is less than the beacon interval, defined
         * by macBeaconOrder. If it is not less, the MLME issues the
         * MLME-RX-ENABLE.confirm primitive with a status of MAC_INVALID_PARAMETER.
         */

        rx_off_time_symbols = rxe->RxOnTime + rxe->RxOnDuration;

        if (rx_off_time_symbols >= curr_beacon_int_time_symbols)
        {
            /* Send the confirm immediately. */
            gen_rx_enable_conf((buffer_t *)m, (uint8_t)MAC_INVALID_PARAMETER);
            return;
        }

        pal_get_current_time(&now_time_symbols);
        now_time_symbols = TAL_CONVERT_US_TO_SYMBOLS(now_time_symbols);

        symbols_since_beacon  = tal_sub_time_symbols(now_time_symbols, tal_pib.BeaconTxTime);

        /*
         * Actually, MLME-RX-ENABLE.request in a beacon enabled PAN does
         * only make sense if the MAC is currently tracking beacons, so
         * that macBeaconTxTime is up to date. If it appears that
         * the last known macBeaconTxTime does not relate to the
         * current superframe, reject the request.
         */
        if (symbols_since_beacon > curr_beacon_int_time_symbols)
        {
            /* Send the confirm immediately. */
            gen_rx_enable_conf((buffer_t *)m, (uint8_t)MAC_INVALID_PARAMETER);
            return;
        }

        rx_on_time_symbols = tal_add_time_symbols(tal_pib.BeaconTxTime, rxe->RxOnTime);

        /* Check whether RxOnTime can still be handled in current CAP. */
        pal_get_current_time(&now_time_symbols);
        now_time_symbols = TAL_CONVERT_US_TO_SYMBOLS(now_time_symbols);

        if (tal_add_time_symbols(rx_on_time_symbols, TAL_CONVERT_US_TO_SYMBOLS(MIN_TIMEOUT))
            < now_time_symbols)
        {
            /* RxOnTime not possible within this CAP, see whether deferred
             * handling is allowed or not.. */
            if (!(rxe->DeferPermit))
            {
                gen_rx_enable_conf((buffer_t *)m, (uint8_t)MAC_PAST_TIME);
                return;
            }
            else
            {
                /*
                 * The MAC defers until the next superframe and attempts to enable
                 * the receiver in that superframe.
                 */
                rx_on_time_symbols = tal_add_time_symbols(rx_on_time_symbols,
                                                          curr_beacon_int_time_symbols);
            }
        }

        /*
         * Since the Rx-Enable timer could already be running,
         * it is stopped first, before it will be started (again).
         */
        pal_timer_stop(T_Rx_Enable);

        do
        {
            /*
             * Start a timer to turn Rx ON at the time "rxe->RxOnTime" from the start
             * of the next superframe.
             * Return value to be checked, because Rx on time could be too short
             * or in the past already.
             */
            timer_status =
                pal_timer_start(T_Rx_Enable,
                                TAL_CONVERT_SYMBOLS_TO_US(rx_on_time_symbols),
                                TIMEOUT_ABSOLUTE,
                                (FUNC_PTR())mac_t_rx_on_cb,
                                (void *)m);

            if (MAC_SUCCESS != timer_status)
            {
                rx_on_time_symbols = tal_add_time_symbols(rx_on_time_symbols,
                                                          curr_beacon_int_time_symbols);
            }
        }
        while (MAC_SUCCESS != timer_status);

        /* Remember the time to turn off the receiver. */
        rx_off_time_symbols = tal_add_time_symbols(rx_on_time_symbols, rxe->RxOnDuration);

        /* The remaining stuff will be done once the Rx On Timer expires. */
    }
#else   /* No BEACON_SUPPORT */
    handle_rx_on(rxe->RxOnDuration, m);
#endif  /* BEACON_SUPPORT / No BEACON_SUPPORT */
} /* mlme_rx_enable_request() */
开发者ID:subpos,项目名称:atmel_ranging_toolbox_zigbit,代码行数:101,代码来源:mac_rx_enable.c


示例18: scan_set_complete

/**
 * @brief Continue scanning after setting of PIB attributes
 *
 * This functions continues scanning once the corresponding PIB
 * attribute change has been completed depending on the status.
 *
 * @param set_status Status of the Request to change the PIB attribute
 */
void scan_set_complete(retval_t set_status)
{
	switch (mac_scan_state) {
#if (MAC_SCAN_ED_REQUEST_CONFIRM == 1)
	case MAC_SCAN_ED:
	{
		if (MAC_SUCCESS == set_status) {
			MAKE_MAC_BUSY();
			tal_ed_start(scan_duration);
		} else {
			/* Channel not supported, continue. */
			scan_curr_channel++;
		}
	}
	break;
#endif /* (MAC_SCAN_ED_REQUEST_CONFIRM == 1) */

#if (MAC_SCAN_ACTIVE_REQUEST_CONFIRM == 1)
	case MAC_SCAN_ACTIVE:
		if (MAC_SUCCESS == set_status) {
			/*
			 * The TAL switches ON the transmitter while sending a
			 * beacon request, hence the MAC can call
			 * send_scan_cmd() to send
			 * the beacon directly
			 */

			/* Send an beacon request command */
			if (!send_scan_cmd(true)) {
				uint8_t timer_id = T_Scan_Duration;

				/*
				 * Beacon request could not be transmitted
				 * since there is no buffer available stop
				 * scanning
				 * we call the function usually called by the
				 * scan
				 * duration timer to pretend scanning has
				 * finished
				 */
				mac_t_scan_duration_cb((uint8_t *)&timer_id);
			}
		} else {
			/* Channel not supported, continue. */
			scan_curr_channel++;
		}
		break;
#endif /* (MAC_SCAN_ACTIVE_REQUEST_CONFIRM == 1) */

#if (MAC_SCAN_PASSIVE_REQUEST_CONFIRM == 1)
	case MAC_SCAN_PASSIVE:
	{
		if (MAC_SUCCESS == set_status) {
			uint8_t status = tal_rx_enable(PHY_RX_ON);

			if (PHY_RX_ON == status) {
				retval_t timer_status;
				uint32_t tmr
					= MAC_CALCULATE_SYMBOL_TIME_SCANDURATION(
						scan_duration);

				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(MLME_SCAN_TYPE_PASSIVE,
						(buffer_t *)mac_conf_buf_ptr);
			}
		} else {
			/* Channel not supported, continue. */
//.........这里部分代码省略.........
开发者ID:InSoonPark,项目名称:asf,代码行数:101,代码来源:mac_scan.c


示例19: mac_process_beacon_frame


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


/* Handling of ancounced broadcast traffic by the parent. */
#ifdef BEACON_SUPPORT
    if (MAC_SCAN_IDLE == mac_scan_state)
    {
        /*
         * In case this is a beaconing network, and this node is not scanning,
         * and the FCF indicates pending data thus indicating broadcast data at
         * parent, the node needs to be awake until the received broadcast
         * data has been received.
         */
        if (mac_parse_data.fcf & FCF_FRAME_PENDING)
        {
            mac_bc_data_indicated = true;

            /*
             * Start timer since the broadcast frame is expected within
             * macMaxFrameTotalWaitTime symbols.
             */
            if (MAC_POLL_IDLE == mac_poll_state)
            {
                /*
                 * If the poll state is not idle, there is already an
                 * indirect transaction ongoing.
                 * Since the T_Poll_Wait_Time is going to be re-used,
                 * this timer can only be started, if we are not in
                 * a polling state other than idle.
                 */
                uint32_t response_timer = mac_pib.mac_MaxFrameTotalWaitTime;
                response_timer = TAL_CONVERT_SYMBOLS_TO_US(response_timer);

                if (MAC_SUCCESS != pal_timer_start(T_Poll_Wait_Time,
                                                   response_timer,
                                                   TIMEOUT_RELATIVE,
                                                   (FUNC_PTR)mac_t_wait_for_bc_time_cb,
                                                   NULL))
                {
                    mac_t_wait_for_bc_time_cb(NULL);
                }
            }
            else
            {
                /*
                 * Any indirect poll operation is ongoing, so the timer will
                 * not be started, i.e. nothing to be done here.
                 * Once this ongoing indirect transaction has finished, this
                 * node will go back to sleep anyway.
                 */
            }
        }
        else
        {
            mac_bc_data_indicated = false;
        }

    }   /* (MAC_SCAN_IDLE == mac_scan_state) */
#endif /* BEACON_SUPPORT */


/* Handling of presented indirect traffic by the parent for this node. */
#if ((MAC_INDIRECT_DATA_BASIC == 1) && (MAC_SYNC_REQUEST == 1))
    if (MAC_SCAN_IDLE == mac_scan_state)
    {
        /*
开发者ID:bswe,项目名称:6.1,代码行数:67,代码来源:mac_process_beacon_frame.c


示例20: tal_reset

/*
 * \brief Resets TAL state machine and sets the default PIB values if requested
 *
 * \param set_default_pib Defines whether PIB values need to be set
 *                        to its default values
 *
 * \return MAC_SUCCESS  if the transceiver state is changed to TRX_OFF
 *         FAILURE otherwise
 */
retval_t tal_reset(bool set_default_pib)
{
	/*
	 * Do the reset stuff.
	 * Set the default PIBs depending on the given parameter
	 * set_default_pib.
	 * Do NOT generate random seed again.
	 */
	if (internal_tal_reset(set_default_pib) != MAC_SUCCESS) {
		return FAILURE;
	}

	ENTER_CRITICAL_REGION();
	tal_timers_stop();
	LEAVE_CRITICAL_REGION();

	/* Clear TAL Incoming Frame queue and free used buffers. */
	while (tal_incoming_frame_queue.size > 0) {
		buffer_t *frame = qmm_queue_remove(&tal_incoming_frame_queue,
				NULL);
		if (NULL != frame) {
			bmm_buffer_free(frame);
		}
	}

#ifdef ENABLE_TFA
	tfa_reset(set_default_pib);
#endif

	/*
	 * Configure interrupt handling.
	 * Install a handler for the transceiver interrupt.
	 */
	trx_irq_init((FUNC_PTR)trx_irq_handler_cb);

	/* The pending transceiver interrupts on the microcontroller are
	 * cleared. */
	pal_trx_irq_flag_clr();
	pal_trx_irq_en(); /* Enable transceiver main interrupt. */

#ifdef ENABLE_FTN_PLL_CALIBRATION
	{
		/* Handle PLL calibration and filter tuning. */
		retval_t timer_status;

		/* Calibration timer has already been stopped within this
		 * function. */

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

	return MAC_SUCCESS;
}
开发者ID:ThucVD2704,项目名称:femto-usb-blink-example,代码行数:72,代码来源:tal_init.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ pal_trx_bit_write函数代码示例发布时间:2022-05-30
下一篇:
C++ pal_timer_delay函数代码示例发布时间: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