Esempio n. 1
0
void init_state_init(void *arg)
{
	sw_timer_init();

	/* Set the node information base */
	config_node_ib();

	/* Initialize the TAL layer */
	if (tal_init() != MAC_SUCCESS) {
		/* something went wrong during initialization */
		app_alert();
	}

	app_timers_init();

	/* Initilaize sio rx state */
	init_sio();

	/* select the configurtion mode */
	configuration_mode_selection();

#if (TAL_TYPE == AT86RF233) && (ANTENNA_DIVERSITY == 1)
	/* In order to demonstrate RPC the antenna diversity is disabled. */
	tal_ant_div_config(ANT_DIVERSITY_DISABLE, ANT_CTRL_1); /* Enable A1/X2 */
#endif

	/* Keep compiler happy */
	arg = arg;
}
Esempio n. 2
0
/**
 * \brief Recover all user settings before Start of CW transmission
 */
void recover_all_settings(void)
{
	int8_t tx_pwr_dbm;
	uint8_t temp_var;
	pib_value_t pib_value;

#if (ANTENNA_DIVERSITY == 1)
	if (ANT_DIV_DISABLE == ant_div_before_ct) {
		tal_ant_div_config(ANT_DIVERSITY_DISABLE, ant_sel_before_ct);
	}

#endif

#if (TAL_TYPE == AT86RF233)
	/* Set the ISM frequency back   */
	if (CC_BAND_0 != cc_band_ct) {
		tal_set_frequency_regs(cc_band_ct, cc_number_ct);
	}

#endif /* End of #if(TAL_TYPE == AT86RF233) */

	/*RPC settings are reseted during tal_reset,hence reconfiguring based
	 *on old config*/
#if ((TAL_TYPE == ATMEGARFR2)||(TAL_TYPE == AT86RF233))
	if (true == curr_trx_config_params.rpc_enable) {
		/* RPC feature configuration. */
		tal_rpc_mode_config(ENABLE_ALL_RPC_MODES); 
		                                            
	} else {
		tal_rpc_mode_config(DISABLE_ALL_RPC_MODES);
	}

#endif

#if (TAL_TYPE != AT86RF230B)
	/* set the desensitization settings back */
	if (true == curr_trx_config_params.rx_desensitize) {
		tal_set_rx_sensitivity_level(RX_DESENSITIZE_LEVEL);
	}

#endif

#if ((TAL_TYPE != AT86RF212) && (TAL_TYPE != AT86RF212B))
	if (last_tx_power_format_set == 0) {
		uint8_t tx_pwr_reg = curr_trx_config_params.tx_power_reg;
		tal_set_tx_pwr(REGISTER_VALUE, tx_pwr_reg);
	} else
#endif
	{
		tx_pwr_dbm = curr_trx_config_params.tx_power_dbm;
		temp_var = CONV_DBM_TO_phyTransmitPower(tx_pwr_dbm);
		pib_value.pib_value_8bit = temp_var;
		tal_pib_set(phyTransmitPower, &pib_value);
	}
}
Esempio n. 3
0
void start_cw_transmission(uint8_t tx_mode,uint16_t tmr_val)
{
	
/* If the test is initiated on the receptor node, First send the 
 * Start confirmation back to the host.
 * Once this is done the test could be started.
 * The cw_ack_sent flag is used for this purpose
 */
if(node_info.main_state == PER_TEST_RECEPTOR && !cw_ack_sent)
{
     /* timer value should not exceed 3600 seconds */
	if((tx_mode !=CW_MODE && tx_mode != PRBS_MODE) || (3600 < tmr_val)) 
	{
		usr_cont_wave_tx_confirm(INVALID_ARGUMENT, 0x01, tx_mode);
		return;
	}
	else
	{
	   /* Send Set confirmation with status SUCCESS and start CW trx on 
	    * successful transmission of the Confirmation message*/
	   usr_cont_wave_tx_confirm(MAC_SUCCESS, START_CWT, tx_mode); 
	   remote_cw_start = true;
	   cw_start_mode = tx_mode;
	   cw_tmr_val = tmr_val;
	   return;
	}
	
	
}

else if(node_info.main_state == PER_TEST_INITIATOR || (node_info.main_state == SINGLE_NODE_TESTS) || ((node_info.main_state == PER_TEST_RECEPTOR) && cw_ack_sent))
{
	/* Save all user settings before continuous tx */
	save_all_settings();

	/* Added to ensure CW transmission happen in every attempt */
	tal_reset(false);

#if (ANTENNA_DIVERSITY == 1)
	if (ANT_DIV_DISABLE == ant_div_before_ct) {
		tal_ant_div_config(ANT_DIVERSITY_DISABLE, ant_sel_before_ct);
	}

#endif

if((node_info.main_state == PER_TEST_RECEPTOR) && 1 <= tmr_val )
{
	sw_timer_start(CW_TX_TIMER,
	(uint32_t)tmr_val * 1E6,
	SW_TIMEOUT_RELATIVE,
	(FUNC_PTR)stop_cw_transmission,
	(void *)&tx_mode);

	
}

	switch (tx_mode) {
	case CW_MODE: /* CW mode*/
	{
		/* In CW_MODE the parameter random_content is obsolete. */
		tfa_continuous_tx_start(CW_MODE, false);
	}
	break;

	case PRBS_MODE: /* PRBS mode*/
	{
		/* Start PRBS_MODE mode using random content. */
		tfa_continuous_tx_start(PRBS_MODE, true);
	}
	break;

	default:
	{
		usr_cont_wave_tx_confirm(INVALID_ARGUMENT, 0x01, tx_mode);
		return;
	}
	}

	op_mode = CONTINUOUS_TX_MODE;
	if(node_info.main_state == PER_TEST_RECEPTOR )
	{
		cw_ack_sent=false;
	}
	else
	{
	
	/* Send Set confirmation with status SUCCESS */
	usr_cont_wave_tx_confirm(MAC_SUCCESS, START_CWT, tx_mode);
	}
}
}
Esempio n. 4
0
/**
 * \brief Function to set trx configure parameters
 *
 */
void config_per_test_parameters(void)
{
	uint8_t temp;
	pib_value_t pib_value;

	/* Set the default values */
	curr_trx_config_params.ack_request
		= default_trx_config_params.ack_request = true;
	curr_trx_config_params.csma_enabled
		= default_trx_config_params.csma_enabled = true;
	curr_trx_config_params.retry_enabled
		= default_trx_config_params.retry_enabled = false;

#if (ANTENNA_DIVERSITY == 1)
#if (TAL_TYPE == AT86RF233)
	/* Disable antenna diversity by default. */
	curr_trx_config_params.antenna_diversity
		= default_trx_config_params.antenna_diversity = false;
	curr_trx_config_params.antenna_selected
		= default_trx_config_params.antenna_selected
				= ANT_CTRL_1;

	/* This is required for set default config request command to set the
	 * config parameters to their defaults */
	/* Disable antenna diversity by default */
	/* Enable A1/X2 */
	tal_ant_div_config(ANT_DIVERSITY_DISABLE, ANT_CTRL_1); /* Enable A1/X2
	                                                       **/

#else
	curr_trx_config_params.antenna_diversity
		= default_trx_config_params.antenna_diversity = true;
	curr_trx_config_params.antenna_selected
		= default_trx_config_params.antenna_selected
				= ANT_CTRL_0;

	/* Enable Antenna Diversity*/
	tal_ant_div_config(ANT_DIVERSITY_ENABLE, ANTENNA_DEFAULT);
#endif /* end of (TAL_TYPE == AT86RF233) */
#endif

#if (TAL_TYPE != AT86RF230B)
	/* Disable desensitization by default */
	curr_trx_config_params.rx_desensitize
		= default_trx_config_params.rx_desensitize = false;
	/* Disable Rx desensitization */

	tal_set_rx_sensitivity_level(NO_RX_DESENSITIZE_LEVEL);
#endif /* End of #if(TAL_TYPE != AT86RF230B)*/

#if ((TAL_TYPE == AT86RF233) || (TAL_TYPE == ATMEGARFR2))
	curr_trx_config_params.rpc_enable
		= default_trx_config_params.rpc_enable = false;

	/* Enable RPC feature by default */
	tal_rpc_mode_config(DISABLE_ALL_RPC_MODES);
	/* Reset RX_SAFE Mode in TRX_CTRL_2 */
	tal_trx_reg_write(RG_TRX_CTRL_2, ENABLE_RX_SAFE_MODE);
#endif
	if (peer_found == true) {
		curr_trx_config_params.trx_state
			= default_trx_config_params.trx_state
					= RX_AACK_ON;
	} else {
		curr_trx_config_params.trx_state
			= default_trx_config_params.trx_state = TRX_OFF;
	}

	curr_trx_config_params.number_test_frames
		= default_trx_config_params.number_test_frames
				= DEFAULT_NO_OF_TEST_FRAMES;
	curr_trx_config_params.phy_frame_length
		= default_trx_config_params.phy_frame_length
				= DEFAULT_FRAME_LENGTH;

	/* As channel & channel page are already configured during
	 * the application initialization so get it
	 */
	curr_trx_config_params.channel = default_trx_config_params.channel
				= DEFAULT_CHANNEL;
	pib_value.pib_value_8bit = (uint8_t)default_trx_config_params.channel;
	tal_pib_set(phyCurrentChannel,
			&pib_value);

	/* Make the ISM frequency as null as IEEE channel is set in default case
	**/
#if (TAL_TYPE == AT86RF233)
	curr_trx_config_params.ism_frequency
		= default_trx_config_params.ism_frequency = 0.0;
#endif

	curr_trx_config_params.channel_page
		= default_trx_config_params.channel_page
				= TAL_CURRENT_PAGE_DEFAULT;
	pib_value.pib_value_8bit = default_trx_config_params.channel_page;
	tal_pib_set(phyCurrentPage, &pib_value);

	/* As tx power is already configure by TAL in tal_pib.c get it for
	 * application*/
	temp = TAL_TRANSMIT_POWER_DEFAULT;
	pib_value.pib_value_8bit = temp;
	tal_pib_set(phyTransmitPower, &pib_value);

	curr_trx_config_params.tx_power_dbm
		= default_trx_config_params.tx_power_dbm
				= CONV_phyTransmitPower_TO_DBM(
			TAL_TRANSMIT_POWER_DEFAULT);
#if ((TAL_TYPE != AT86RF212) && (TAL_TYPE != AT86RF212B))
	tal_get_curr_trx_config(TX_PWR, &(curr_trx_config_params.tx_power_reg));
	tal_get_curr_trx_config(TX_PWR,
			&(default_trx_config_params.tx_power_reg));
#endif

	/* The following fields has no meaning if there is no peer */
	if (true == peer_found) {
#ifdef CRC_SETTING_ON_REMOTE_NODE
		curr_trx_config_params.crc_settings_on_peer
			= default_trx_config_params.crc_settings_on_peer
					= false;
#endif

		/* Set the config parameters on peer node */
#if (ANTENNA_DIVERSITY == 1)
#if (TAL_TYPE == AT86RF233)
		curr_trx_config_params.antenna_diversity_on_peer
			= default_trx_config_params.
				antenna_diversity_on_peer = false;
		curr_trx_config_params.antenna_selected_on_peer
			= default_trx_config_params.
				antenna_selected_on_peer = ANT_CTRL_1;

#else
		curr_trx_config_params.antenna_diversity_on_peer
			= default_trx_config_params.
				antenna_diversity_on_peer = true;
		curr_trx_config_params.antenna_selected_on_peer
			= default_trx_config_params.
				antenna_selected_on_peer = ANT_CTRL_0;
#endif /* End of #if(TAL_TYPE == AT86RF233) */
#endif /* End of #if (ANTENNA_DIVERSITY == 1) */
	}
}