/* ======================================================================== Routine Description: Write RF register through MAC with specified bit mask Arguments: pAd - pointer to the adapter structure regID - RF register ID Value - only write the part of (Value & BitMask) to RF register BitMask - bit wise mask Return Value: Note: ======================================================================== */ VOID RTMP_WriteRF(RTMP_ADAPTER *pAd, UCHAR RegID, UCHAR Value, UCHAR BitMask) { UCHAR RfReg = 0; RTMP_ReadRF(pAd, RegID, NULL, &RfReg, BitMask); RfReg |= ((Value) & BitMask); RT30xxWriteRFRegister(pAd, RegID, RfReg); }
/* ======================================================================== Routine Description: Adjust frequency offset when do channel switching or frequency calabration. Arguments: pAd - Adapter pointer pRefFreqOffset in: referenced Frequency offset out: adjusted frequency offset Return Value: None ======================================================================== */ BOOLEAN RTMPAdjustFrequencyOffset( IN PRTMP_ADAPTER pAd, INOUT PUCHAR pRefFreqOffset) { BOOLEAN RetVal = TRUE; UCHAR RFValue = 0; UCHAR PreRFValue = 0; UCHAR FreqOffset = 0; UCHAR HighCurrentBit = 0; RTMP_ReadRF(pAd, RF_R17, &FreqOffset, &HighCurrentBit, 0x7F); PreRFValue = HighCurrentBit | FreqOffset; FreqOffset = min((*pRefFreqOffset & 0x7F), 0x5F); RFValue = HighCurrentBit | FreqOffset; if (PreRFValue != RFValue) { #ifdef RTMP_MAC_USB RetVal = AsicSendCommandToMcu(pAd, 0x74, 0xff, FreqOffset, PreRFValue, FALSE); #else RetVal = (RT30xxWriteRFRegister(pAd, RF_R17, RFValue) == STATUS_SUCCESS ? TRUE:FALSE); #endif /* !RTMP_MAC_USB */ } if (RetVal == FALSE) DBGPRINT(RT_DEBUG_TRACE, ("%s(): Error in tuning frequency offset !!\n", __FUNCTION__)); else *pRefFreqOffset = FreqOffset; return RetVal; }
/* ======================================================================== Routine Description: Adjust frequency offset when do channel switching or frequency calabration. Arguments: pAd - Adapter pointer pRefFreqOffset in: referenced Frequency offset out: adjusted frequency offset Return Value: None ======================================================================== */ BOOLEAN RTMPAdjustFrequencyOffset(RTMP_ADAPTER *pAd,UCHAR *pRefFreqOffset) { BOOLEAN RetVal = TRUE; UCHAR RFValue = 0; UCHAR PreRFValue = 0; UCHAR FreqOffset = 0; UCHAR HighCurrentBit = 0; RTMP_ReadRF(pAd, RF_R17, &FreqOffset, &HighCurrentBit, 0x7F); PreRFValue = HighCurrentBit | FreqOffset; FreqOffset = min((*pRefFreqOffset & 0x7F), 0x5F); RFValue = HighCurrentBit | FreqOffset; if (PreRFValue != RFValue) { RetVal = (RT30xxWriteRFRegister(pAd, RF_R17, RFValue) == STATUS_SUCCESS ? TRUE:FALSE); } if (RetVal == FALSE) DBGPRINT(RT_DEBUG_TRACE, ("%s(): Error in tuning frequency offset !!\n", __FUNCTION__)); else *pRefFreqOffset = FreqOffset; return RetVal; }
/* ======================================================================== Routine Description: Write RF register through MAC with specified bit mask Arguments: pAd - pointer to the adapter structure regID - RF register ID Value - only write the part of (Value & BitMask) to RF register BitMask - bit wise mask Return Value: Note: ======================================================================== */ VOID RTMP_WriteRF( IN PRTMP_ADAPTER pAd, IN UCHAR RegID, IN UCHAR Value, IN UCHAR BitMask) { UCHAR RfReg = 0; RTMP_ReadRF(pAd, RegID, NULL, &RfReg, BitMask); RfReg = (RfReg & ~BitMask) | ((Value) & BitMask); RT30xxWriteRFRegister(pAd, RegID, RfReg); }