在Z-STACK中怎样设置功率

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/12 16:41:38

在Z-STACK中怎样设置功率
在Z-STACK中怎样设置功率

在Z-STACK中怎样设置功率
/
*/
#ifndef HAL_MAC_USE_REGISTER_POWER_VALUES
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
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();
}
#else
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
void macRadioSetTxPower(uint8 txPower)
{
halIntState_t s;
/* same as above but with no lookup table, use raw register value */
HAL_ENTER_CRITICAL_SECTION(s);
reqTxPower = txPower;
HAL_EXIT_CRITICAL_SECTION(s);
/* update the radio power setting */
macRadioUpdateTxPower();
}
#endif