Esempio n. 1
0
/**
 * @brief Converts a phyTransmitPower value to a register value
 *
 * @param phyTransmitPower_value phyTransmitPower value
 *
 * @return register value
 */
static uint8_t convert_phyTransmitPower_to_reg_value(uint8_t phyTransmitPower_value)
{
    int8_t dbm_value;
    uint8_t reg_value = 0x00;

    dbm_value = CONV_phyTransmitPower_TO_DBM(phyTransmitPower_value);

    /* Select the corresponding tx_pwr_table */
#ifdef HIGH_DATA_RATE_SUPPORT
    if ((tal_pib_CurrentPage == 5) || (tal_pib_CurrentPage == 18) || (tal_pib_CurrentPage == 19))
#else
    if (tal_pib_CurrentPage == 5)
#endif
    {
        reg_value = PGM_READ_BYTE(&tx_pwr_table_China[MAX_TX_PWR - dbm_value]);
    }
    else
    {
        if (tal_pib_CurrentChannel == 0)
        {
            reg_value = PGM_READ_BYTE(&tx_pwr_table_EU[MAX_TX_PWR - dbm_value]);
        }
        else    // channels 1-10
        {
            reg_value = PGM_READ_BYTE(&tx_pwr_table_NA[MAX_TX_PWR - dbm_value]);
        }
    }

    return reg_value;
}
Esempio n. 2
0
/**
 * @brief Converts a phyTransmitPower value to a register value
 *
 * @param phyTransmitPower_value phyTransmitPower value
 *
 * @return register value
 */
static uint8_t convert_phyTransmitPower_to_reg_value(uint8_t phyTransmitPower_value)
{
    int8_t dbm_value;
    uint8_t i;
    int8_t trx_tx_level;

    dbm_value = CONV_phyTransmitPower_TO_DBM(phyTransmitPower_value);

    /* Compare to the register value to identify the value that matches. */
    for (i = 0; i < sizeof(tx_pwr_table); i++)
    {
        trx_tx_level = (int8_t)PGM_READ_BYTE(&tx_pwr_table[i]);
        if (trx_tx_level <= dbm_value)
        {
            if (trx_tx_level < dbm_value)
            {
                return (i - 1);
            }
            return i;
        }
    }

    /* This code should never be reached. */
    return 0;
}
Esempio n. 3
0
/**
 * \brief Set the default Power Values For Respective Pages and Channels
 */
static void set_default_tx_pwr(void)
{
	int8_t dbm_value;

	dbm_value = CONV_phyTransmitPower_TO_DBM(tal_pib.TransmitPower);

	if ((tal_pib.CurrentPage == 5) ||
			(tal_pib.CurrentPage == 18) ||
			(tal_pib.CurrentPage == 19)) {
		if ((tal_pib.CurrentChannel == 0) ||
				(tal_pib.CurrentChannel == 3)) {
			if (dbm_value > DEFAULT_TX_PWR_CHINA_CH_0_3) {
				dbm_value = DEFAULT_TX_PWR_CHINA_CH_0_3;
			}
		} else {
			if ((tal_pib.CurrentPage == 5) ||
					(tal_pib.CurrentPage == 18)) {
				if (dbm_value >
						DEFAULT_TX_PWR_OQPSK_RC_250_500)
				{
					dbm_value
						=
							DEFAULT_TX_PWR_OQPSK_RC_250_500;
				}
			}
		}
	} else if (tal_pib.CurrentPage == 0) {
		if (tal_pib.CurrentChannel == 0) {
			if (dbm_value > DEFAULT_TX_PWR_BPSK_20) {
				dbm_value = DEFAULT_TX_PWR_BPSK_20;
			}
		}
	} else {
		if (tal_pib.CurrentChannel == 0) {
			if (dbm_value >
					DEFAULT_TX_PWR_OQPSK_SIN_RC_100_200_400)
			{
				dbm_value
					=
						DEFAULT_TX_PWR_OQPSK_SIN_RC_100_200_400;
			}
		}
	}

	tal_pib.TransmitPower = TX_PWR_TOLERANCE | CONV_DBM_TO_phyTransmitPower(
			dbm_value);

	/*Handle other Channel and page combinations here*/
	limit_tx_pwr();

	trx_reg_write(RG_PHY_TX_PWR,
			convert_phyTransmitPower_to_reg_value(tal_pib.
			TransmitPower));
}
Esempio n. 4
0
/*
 * \brief handle the tx power settings in case of External PA enabled,
 * and the channel changes from or to 26.This is to meet the FCC compliance
 *
 * \param Current channel and Previous channel
 */
void limit_tx_power_in_ch26(uint8_t curr_chnl, uint8_t prev_chnl)
{
	pib_value_t pib_value;

	/* If the cuurent channel set to 26*/
	if (curr_chnl == CHANNEL_26) {
		/* Get last previous non 26 channel tx power  */
		if (prev_chnl != CHANNEL_26) {
			tal_pib_get(phyTransmitPower, &prev_non_26chn_tx_power);
		}

		/* If the Tx power is more than 13dBm, i.e. TX_PWR < 0x0d */
		if (trx_bit_read(SR_TX_PWR) <= MAX_TX_PWR_REG_VAL_CH26) {
			pib_value.pib_value_8bit = DEFAULT_TX_POWER_CH26;
			tal_pib_set(phyTransmitPower, &pib_value);
			curr_trx_config_params.tx_power_reg = trx_bit_read(
					SR_TX_PWR);
			curr_trx_config_params.tx_power_dbm
				= CONV_phyTransmitPower_TO_DBM(
					pib_value.pib_value_8bit);
		}
	} else {
		/* if the channel changed from 26 to other  */
		if (prev_chnl == CHANNEL_26) {
			/* Set back the tx power to default value i.e. 20dBm,
			 *TX_PWR 0x09 */
			pib_value.pib_value_8bit = prev_non_26chn_tx_power;
			tal_pib_set(phyTransmitPower, &pib_value);
			curr_trx_config_params.tx_power_reg = trx_bit_read(
					SR_TX_PWR);
			curr_trx_config_params.tx_power_dbm
				= CONV_phyTransmitPower_TO_DBM(
					pib_value.pib_value_8bit);
		}
	}
}
Esempio n. 5
0
/**
 * \brief Limit the phyTransmitPower to the trx limits
 *
 * \param phyTransmitPower phyTransmitPower value
 *
 */
static void limit_tx_pwr(void)
{
	int8_t dbm_value;

	dbm_value = CONV_phyTransmitPower_TO_DBM(tal_pib.TransmitPower);

	/* Limit to the transceiver's absolute maximum/minimum. */
	if (dbm_value <= MIN_TX_PWR) {
		dbm_value = MIN_TX_PWR;
	} else if (dbm_value > MAX_TX_PWR) {
		dbm_value = MAX_TX_PWR;
	}

	tal_pib.TransmitPower = TX_PWR_TOLERANCE | CONV_DBM_TO_phyTransmitPower(
			dbm_value);
}
Esempio n. 6
0
/**
 * @brief Limit the phyTransmitPower to the trx limits
 *
 * @param phyTransmitPower phyTransmitPower value
 *
 * @return limited tal_pib_TransmitPower
 */
static uint8_t limit_tx_pwr(uint8_t tal_pib_TransmitPower)
{
    uint8_t ret_val = tal_pib_TransmitPower;
    int8_t dbm_value;

    dbm_value = CONV_phyTransmitPower_TO_DBM(tal_pib_TransmitPower);
    if (dbm_value > (int8_t)PGM_READ_BYTE(&tx_pwr_table[0]))
    {
        dbm_value = (int8_t)PGM_READ_BYTE(&tx_pwr_table[0]);
        ret_val = CONV_DBM_TO_phyTransmitPower(dbm_value);

    }
    else if (dbm_value < (int8_t)PGM_READ_BYTE(&tx_pwr_table[sizeof(tx_pwr_table)-1]))
    {
        dbm_value = (int8_t)PGM_READ_BYTE(&tx_pwr_table[sizeof(tx_pwr_table)-1]);
        ret_val = CONV_DBM_TO_phyTransmitPower(dbm_value);
    }

    return (ret_val | TX_PWR_TOLERANCE);
}
Esempio n. 7
0
/**
 * \brief Converts a phyTransmitPower value to a register value
 *
 * \param phyTransmitPower_value phyTransmitPower value
 *
 * \return register value
 */
static uint8_t convert_phyTransmitPower_to_reg_value(
		uint8_t phyTransmitPower_value)
{
	int8_t dbm_value;
	uint8_t reg_value = 0x00;

	dbm_value = CONV_phyTransmitPower_TO_DBM(phyTransmitPower_value);

	/* Select the corresponding tx_pwr_table, also valid for high data rates
	**/
#ifdef HIGH_DATA_RATE_SUPPORT
	if ((tal_pib.CurrentPage == 5) || (tal_pib.CurrentPage == 18) ||
			(tal_pib.CurrentPage == 19))
#else
	if (tal_pib.CurrentPage == 5)
#endif
	{
		reg_value
			= PGM_READ_BYTE(
				&tx_pwr_table_China[MAX_TX_PWR - dbm_value]);
	} else { /* concerns channel pages={0, 2, 16, 17}*/
		if (tal_pib.CurrentChannel == 0) {
			reg_value
				= PGM_READ_BYTE(
					&tx_pwr_table_EU[MAX_TX_PWR -
					dbm_value]);
		} else { /* channels 1-10 */
			reg_value
				= PGM_READ_BYTE(
					&tx_pwr_table_NA[MAX_TX_PWR -
					dbm_value]);
		}
	}

	return reg_value;
}
Esempio n. 8
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) */
	}
}
Esempio n. 9
0
/**
 * @brief Limit the phyTransmitPower to the trx limits
 *
 * @param phyTransmitPower phyTransmitPower value
 *
 */
static void limit_tx_pwr(void)
{
    int8_t dbm_value;

    dbm_value = CONV_phyTransmitPower_TO_DBM(tal_pib_TransmitPower);

    /* Limit to the transceiver's absolute maximum/minimum. */
    if (dbm_value <= MIN_TX_PWR)
    {
        dbm_value = MIN_TX_PWR;
    }
    else
    {
        /* Upper Tx power limits depend on the currently used channel and channel page */
        switch (tal_pib_CurrentPage)
        {
            case 0: /* BPSK */
                if (tal_pib_CurrentChannel == 0)
                {
                    if (dbm_value > MAX_TX_PWR_BPSK_20)
                    {
                        dbm_value = MAX_TX_PWR_BPSK_20;
                    }
                }
                else    /* channels 1-10 */
                {
                    if (dbm_value > MAX_TX_PWR)
                    {
                        dbm_value = MAX_TX_PWR;
                    }
                }
                break;
            case 2: /* O-QPSK */
                if (tal_pib_CurrentChannel == 0)
                {
                    if (dbm_value > MAX_TX_PWR_OQPSK_100)
                    {
                        dbm_value = MAX_TX_PWR_OQPSK_100;
                    }
                }
                else    /* channels 1-10 */
                {
                    if (dbm_value > MAX_TX_PWR)
                    {
                        dbm_value = MAX_TX_PWR;
                    }
                }
                break;
            case 5: /* China, O-QPSK */
#ifdef HIGH_DATA_RATE_SUPPORT
            case 18: /* Chinese O-QPSK 500 */
            case 19: /* Chinese O-QPSK 1000 */
#endif
                if (dbm_value > MAX_TX_PWR_CHINA)
                {
                    dbm_value = MAX_TX_PWR_CHINA;
                }
                break;
#ifdef HIGH_DATA_RATE_SUPPORT
            case 16: /* O-QPSK 200, 500 */
                if (tal_pib_CurrentChannel == 0)
                {
                    if (dbm_value > MAX_TX_PWR_OQPSK_200)
                    {
                        dbm_value = MAX_TX_PWR_OQPSK_200;
                    }
                }
                else    /* channels 1-10 */
                {
                    if (dbm_value > MAX_TX_PWR_OQPSK_500)
                    {
                        dbm_value = MAX_TX_PWR_OQPSK_500;
                    }
                }
                break;
            case 17: /* O-QPSK 400, 1000 */
                if (tal_pib_CurrentChannel == 0)
                {
                    if (dbm_value > MAX_TX_PWR_OQPSK_400)
                    {
                        dbm_value = MAX_TX_PWR_OQPSK_400;
                    }
                }
                else    /* channels 1-10 */
                {
                    if (dbm_value > MAX_TX_PWR_OQPSK_1000)
                    {
                        dbm_value = MAX_TX_PWR_OQPSK_1000;
                    }
                }
                break;
#endif  /* #ifdef HIGH_DATA_RATE_SUPPORT */
        }
    }

    tal_pib_TransmitPower = TX_PWR_TOLERANCE | CONV_DBM_TO_phyTransmitPower(dbm_value);
}