/************************************************************************************************** * @fn MRFI_SetRxAddrFilter * * @brief Set the address used for filtering received packets. * * @param pAddr - pointer to address to use for filtering * * @return zero : successfully set filter address * non-zero : illegal address ************************************************************************************************** */ uint8_t MRFI_SetRxAddrFilter(uint8_t * pAddr) { /* * If first byte of filter address match fir byte of broadcast address, * there is a conflict with hardware filtering. */ if (pAddr[0] == mrfiBroadcastAddr[0]) { /* unable to set filter address */ return( 1 ); } /* * Set the hardware address register. The hardware address filtering only recognizes * a single byte but this does provide at least some automatic hardware filtering. */ MRFI_WRITE_REGISTER( ADDR, pAddr[0] ); /* save a copy of the filter address */ { uint8_t i; for (i=0; i<MRFI_ADDR_SIZE; i++) { mrfiRxFilterAddr[i] = pAddr[i]; } } /* successfully set filter address */ return( 0 ); }
/************************************************************************************************** * @fn MRFI_DisableRxAddrFilter * * @brief Disable received packet filtering. * * @param pAddr - pointer to address to test for filtering * * @return none ************************************************************************************************** */ void MRFI_DisableRxAddrFilter(void) { /* clear flag that indicates filtering is enabled */ mrfiRxFilterEnabled = 0; /* disable hardware filtering on the radio */ MRFI_WRITE_REGISTER( PKTCTRL1, PKTCTRL1_ADDR_FILTER_OFF ); }
/************************************************************************************************** * @fn MRFI_EnableRxAddrFilter * * @brief Enable received packet filtering. * * @param none * * @return none ************************************************************************************************** */ void MRFI_EnableRxAddrFilter(void) { MRFI_ASSERT(mrfiRxFilterAddr[0] != mrfiBroadcastAddr[0]); /* filter address must be set before enabling filter */ /* set flag to indicate filtering is enabled */ mrfiRxFilterEnabled = 1; /* enable hardware filtering on the radio */ MRFI_WRITE_REGISTER( PKTCTRL1, PKTCTRL1_ADDR_FILTER_ON ); }
/************************************************************************************************** * @fn MRFI_SetLogicalChannel * * @brief Set logical channel. * * @param chan - logical channel number * * @return none ************************************************************************************************** */ void MRFI_SetLogicalChannel(uint8_t chan) { /* logical channel is not valid? */ MRFI_ASSERT( chan < MRFI_NUM_LOGICAL_CHANS ); /* make sure radio is off before changing channels */ Mrfi_RxModeOff(); MRFI_WRITE_REGISTER( CHANNR, mrfiLogicalChanTable[chan] ); /* turn radio back on if it was on before channel change */ if(mrfiRadioState == MRFI_RADIO_STATE_RX) { Mrfi_RxModeOn(); } }
/************************************************************************************************** * @fn MRFI_SetRFPwr * * @brief Set RF Output power level. * * @param idx - index into power table. * * @return none ************************************************************************************************** */ void MRFI_SetRFPwr(uint8_t idx) { /* is power level specified valid? */ MRFI_ASSERT( idx < MRFI_NUM_POWER_SETTINGS ); /* make sure radio is off before changing power levels */ Mrfi_RxModeOff(); MRFI_WRITE_REGISTER( PA_TABLE0, mrfiRFPowerTable[idx] ); /* turn radio back on if it was on before power level change */ if(mrfiRadioState == MRFI_RADIO_STATE_RX) { Mrfi_RxModeOn(); } }