//Set up nRF24L01 as a transmitter, does not actually send the data,
//(need to call tx_data_nRF24L01() for that)
uint8_t config_tx_nRF24L01(void)
{
    cbi(L01_PORT, L01_CE); //Go into standby mode
	
	send_command(0x20, 0x7C); //16 bit CRC enabled, be a transmitter

	send_command(0x21, 0x00); //Disable auto acknowledge on all pipes

	send_command(0x24, 0x00); //Disable auto-retransmit

	send_command(0x23, 0x03); //Set address width to 5bytes (default, not really needed)

	send_command(0x26, 0x07); //Air data rate 1Mbit, 0dBm, Setup LNA

	send_command(0x25, 0x02); //RF Channel 2 (default, not really needed)
	
	
	data_array[0] = 0xE7;
	data_array[1] = 0xE7;
	data_array[2] = 0xE7;
	data_array[3] = 0xE7;
	data_array[4] = 0xE7;
	tx_send_payload(0x30, 5); //Set TX address
	
	send_command(0x20, 0x7A); //Power up, be a transmitter

	return(send_byte(0xFF));
}
//This sends out the data stored in the data_array
//data_array must be setup before calling this function
void tx_data_nRF24L01(void)
{
	send_command(0x27, 0x7E); //Clear any interrupts
	
	send_command(0x20, 0x7A); //Power up and be a transmitter

	send_byte(0xE1); //Clear TX Fifo
	
	tx_send_payload(0xA0, 4); //Clock in 4 byte payload of data_array

    sbi(L01_PORT, L01_CE); //Pulse CE to start transmission
    delay_ms(1);
    cbi(L01_PORT, L01_CE);
}
Exemple #3
0
//////////////////////
// tx_send_packet: transmit a data packet
//
//	length: length of raw packet including header
//	pkt:	pointer to packet
//
void tx_send_pkt(pkt_t *pkt, uint8_t length) {

	log_packet('T', pkt, length);

	led_on();
	set_tx_packet_length(length);
	tx_send_payload(0x80 + REG_FIFO, length, (uint8_t *)pkt); 	// Clock out payload

	// Set TXON bit to start the tx cycle
	tx_start();
	led_off(); led_on();	// toggle to note time to here
	tx_packet_count++;

	// wait for the packet transmission to complete
	// per p.81 TXON is "Automatically cleared in FIFO mode once the packet is sent"
	// we spin for about 10ms here...
	while (!rf_interrupt()) {;}
	rf_read_status();

	// TODO: consider a better place to restore
	// this one wastes time going back into rx mode during long prints
	set_rx_mode();
	led_off();
}