Пример #1
0
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// void rf_power_up_param(bool rx_active_mode, unsigned char config)
//
// Description:
//  Powers up the device, but allows the user to pass in the value sent to the CONFIG register, as well as whether or not to go to
//   RX active mode (if RX is desired)
//
// Parameters:
//  bool rx_active_mode - true to take to RX active mode (if RX), false otherwise
//  unsigned char config - value to be written to the CONFIG register (the PWR_UP bit will obviously be cleared)
//
// Return value:
//  None
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void rf_power_up_param(bool rx_active_mode, unsigned char config)
{
	//Force the value of PWR_UP set in the passed in version of config, then write the value
	config |= RF_CONFIG_PWR_UP;
	rf_write_register(RF_CONFIG, &config, 1);

	delay_us(1); //Delay for power up

	//Operate CE based on whether RX standby/RX active/TX is requested
	if((config & RF_CONFIG_PRIM_RX) == 0)
	{
		rf_clear_ce(); //Clear CE for TX mode
	}
	else
	{
		//Set the CE pin if active RX mode is requested, and clear it otherwise
		if(rx_active_mode != false)
		{
			rf_set_ce();
		}
		else
		{
			rf_clear_ce();
		}
	}
}
Пример #2
0
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// void rf_set_as_rx(bool rx_active_mode)
//
// Description:
//  Sets the device as an RX, giving the user the option to go into active or standby mode
//
// Parameters:
//  bool rx_active_mode - true to take to RX active mode (if RX), false otherwise
//
// Return value:
//  None
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void rf_set_as_rx(bool rx_active_mode)
{
	unsigned char config;

	rf_read_register(RF_CONFIG, &config, 1); //Read the current CONFIG value

	//If the device is already configured as an RX, exit
	if((config & RF_CONFIG_PRIM_RX) != 0)
	{
		return;
	}

	//Set the PRIM_RX bit, then write the old value of CONFIG back to the device
	config |= RF_CONFIG_PRIM_RX;
	rf_write_register(RF_CONFIG, &config, 1);

	//Set the CE pin if active RX mode is requested, and clear it otherwise
	if(rx_active_mode != false)
	{
		rf_set_ce();
	}
	else
	{
		rf_clear_ce();
	}
}
Пример #3
0
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// void rf_transmit()
//
// Description:
//  Sets the CE pin to transmit a TX packet, then clears CE pin
//
// Parameters:
//  None
//
// Return value:
//  None
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void rf_transmit()
{
	//Set CE, hold for 10 microseconds, then clear CE to transmit only the current packet
	rf_set_ce();
	delay_us(100);
	rf_clear_ce();
}
Пример #4
0
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// void rf_set_as_tx()
//
// Description:
//  Sets the device as a TX
//
// Parameters:
//  None
//
// Return value:
//  None
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void rf_set_as_tx()
{
	uint8_t config;
	uint8_t ce_status = rf_get_ce();

	rf_read_register(RF_CONFIG, &config, 1); //Read the current CONFIG value

	//If the device is already configured as a TX, exit
	if((config & RF_CONFIG_PRIM_RX) == 0)
	{
		return;
	}

	rf_clear_ce(); //Clear the CE pin to enter TX mode

	//Clear the PRIM_RX bit, then write the old value of CONFIG back to the device
	config &= (~RF_CONFIG_PRIM_RX);
	rf_write_register(RF_CONFIG, &config, 1);

	//Set the CE pin if it was set coming into this function
	if(ce_status)
	{
		rf_set_ce();
	}
}