/******************************************************************************* Function: void WF_TxPowerSetMax(int8_t maxTxPower) Summary: Sets the Tx max power on the MRF24WG0MA/B. Description: After initialization the MRF24WG0MA/B max Tx power is determined by a factory-set value. This function can set a different maximum Tx power levels. However, this function can never set a maximum Tx power greater than the factory-set value, which can be read via WF_TxPowerGetFactoryMax(). Precondition: MACInit must be called first. Parameters: maxTxPower - valid range (0 to 18 dBm) Returns: None. Remarks: No conversion of units needed, input to MRF24WG0MA/B is in dBm. *****************************************************************************/ void WF_TxPowerSetMax(int8_t maxTxPower) { int8_t factoryMaxPower; uint8_t msgData[2]; int16_t max = (int16_t)maxTxPower; WF_TxPowerGetFactoryMax(&factoryMaxPower); WF_ASSERT(maxTxPower <= factoryMaxPower); /* cannot set max tx power greater than factor-set max tx power */ msgData[0] = (int8_t)(max >> 8); /* msb of max power */ msgData[1] = (int8_t)(max & 0xff); /* lsb of max power */ SendSetParamMsg(PARAM_TX_POWER, msgData, sizeof(msgData)); }
/******************************************************************************* Function: void WF_TxPowerSetMax(INT8 maxTxPower) Summary: Sets the Tx max power on the MRF24WG0M. Description: After initialization the MRF24WG0M max Tx power is determined by a factory-set value. This function can set a different maximum Tx power levels. However, this function can never set a maximum Tx power greater than the factory-set value, which can be read via WF_TxPowerGetFactoryMax(). Precondition: MACInit must be called first. Parameters: maxTxPower - valid range (0 to 18 dBm) Returns: None. Remarks: No conversion of units needed, input to MRF24WG0M is in dBm. *****************************************************************************/ void WF_TxPowerSetMax(INT8 maxTxPower) { INT8 factoryMaxPower; UINT8 msgData[2]; INT16 max = (INT16)maxTxPower; WF_TxPowerGetFactoryMax(&factoryMaxPower); WF_ASSERT(maxTxPower <= factoryMaxPower); /* cannot set max tx power greater than factor-set max tx power */ msgData[0] = (INT8)(max >> 8); /* msb of max power */ msgData[1] = (INT8)(max & 0xff); /* lsb of max power */ SendSetParamMsg(PARAM_TX_POWER, msgData, sizeof(msgData)); }
/******************************************************************************* Function: void WF_TxPowerSetMinMax(int8_t minTxPower, int8_t maxTxPower) Summary: Sets the Tx min and max power on the MRF24WB0MA/B. Description: After initialization the MRF24WB0MA/B max Tx power is determined by a factory-set value. This function can set a different minimum and maximum Tx power levels. However, this function can never set a maximum Tx power greater than the factory-set value, which can be read via WF_TxPowerGetFactoryMax(). Precondition: MACInit must be called first. Parameters: minTxPower - Desired minTxPower (-10 to 10dB) maxTxPower - Desired maxTxPower (-10 to 10dB) Returns: None. Remarks: No conversion of units needed, input to MRF24WB0MA/B is in dB. *****************************************************************************/ void WF_TxPowerSetMinMax(int8_t minTxPower, int8_t maxTxPower) { int8_t factoryMaxPower; uint8_t msgData[4]; /* need to input to chip two signed 16-bit values, max power followed by min power */ int16_t max; int16_t min; max = (int16_t)maxTxPower; min = (int16_t)minTxPower; WF_ASSERT(minTxPower <= maxTxPower); WF_TxPowerGetFactoryMax(&factoryMaxPower); WF_ASSERT(maxTxPower <= factoryMaxPower); /* cannot set max tx power greater than factor-set max tx power */ msgData[0] = (int8_t)(max >> 8); /* msb of max power */ msgData[1] = (int8_t)(max & 0xff); /* lsb of max power */ msgData[2] = (int8_t)(min >> 8); /* msb of min power */ msgData[3] = (int8_t)(min & 0xff); /* lsb of min power */ SendSetParamMsg(PARAM_TX_POWER, msgData, sizeof(msgData)); }