示例#1
0
// Sends a data package to the default address. Be sure to send the correct
// amount of bytes as configured as payload on the receiver.
void nrf24_send(uint8_t* value) 
{    
    /* Go to Standby-I first */
    nrf24_ce_digitalWrite(LOW);
     
    /* Set to transmitter mode , Power up if needed */
    nrf24_powerUpTx();

    /* Do we really need to flush TX fifo each time ? */
    #if 1
        /* Pull down chip select */
        nrf24_csn_digitalWrite(LOW);           

        /* Write cmd to flush transmit FIFO */
        spi_transfer(FLUSH_TX);     

        /* Pull up chip select */
        nrf24_csn_digitalWrite(HIGH);                    
    #endif 

    /* Pull down chip select */
    nrf24_csn_digitalWrite(LOW);

    /* Write cmd to write payload */
    spi_transfer(W_TX_PAYLOAD);

    /* Write payload */
    nrf24_transmitSync(value,payload_len);   

    /* Pull up chip select */
    nrf24_csn_digitalWrite(HIGH);

    /* Start the transmission */
    nrf24_ce_digitalWrite(HIGH);    
}
示例#2
0
void nrf24_test_sender()
{
	int temp;
	data_array[0] = 0x00;
	data_array[1] = 0xAA;
	data_array[2] = 0x55;
	data_array[3] = 0x00;
	nrf24_ce_digitalWrite(LOW);
	/* Set to transmitter mode , Power up if needed */
	nrf24_powerUpTx();
	/* Do we really need to flush TX fifo each time ? */
#if 1
	/* Pull down chip select */
	nrf24_csn_digitalWrite(LOW);

	/* Write cmd to flush transmit FIFO */
	spi_transfer(FLUSH_TX);

	/* Pull up chip select */
	nrf24_csn_digitalWrite(HIGH);
#endif

	/* Pull down chip select */
	nrf24_csn_digitalWrite(LOW);

	/* Write cmd to write payload */
	spi_transfer(W_TX_PAYLOAD);

	/* Write payload */
	nrf24_transmitSync(data_array, 30);

	/* Pull up chip select */
	nrf24_csn_digitalWrite(HIGH);

	/* Start the transmission */
	nrf24_ce_digitalWrite(HIGH);
	/* Wait for transmission to end */

}
示例#3
0
void nrf24_send(const void *value, unsigned short payload_len)
{    

	//This is supposed to be modularisd and call prepare and transmit but for now we just do
	//everythung here
	/* Go to Standby-I first */
	int i=0;
	length_arr=payload_len;
	//payload_len=23;
	//nrf24_test_sender();
	//return;
	for(i=0;i<127;i++)
			{
				data[i]=0;
			}

		for(i=0;i<payload_len;i++)
		{
			data[i]=((uint8_t *)value)[i];
		}










    nrf24_ce_digitalWrite(LOW);
     
    /* Set to transmitter mode , Power up if needed */

    nrf24_powerUpTx();

    /* Do we really need to flush TX fifo each time ? */


    #if 1
        /* Pull down chip select */

        nrf24_csn_digitalWrite(LOW);

        /* Write cmd to flush transmit FIFO */
        spi_transfer(FLUSH_TX);

        /* Pull up chip select */
        nrf24_csn_digitalWrite(HIGH);




    #endif 

    /* Pull down chip select */
    nrf24_csn_digitalWrite(LOW);


    /* Write cmd to write payload */
    spi_transfer(W_TX_PAYLOAD);

    /* Write payload */
    nrf24_transmitSync(value,payload_len);


    /* Pull up chip select */
    nrf24_csn_digitalWrite(HIGH);

    /* Start the transmission */
    nrf24_ce_digitalWrite(HIGH);
   //while(true);
   //while(1);
    //while(1);
    while(nrf24_isSending());
    //nrf24_powerUpRx();



}