//Handyboard NRF24L01 Interface //Rand Voorhies #define nordic_ce 7 #define nordic_csn 6 #define spi_sck 5 #define spi_mosi 4 #define spi_miso 7 #define irq 8 void up_tone() { tone(440., .1); tone(660., .1); tone(880., .1); tone(1320., .1); } void down_tone() { tone(880., .1); tone(660., .1); tone(440., .1); tone(220., .1); } void spi_xmit(int c[], int c_size, int csn) { int i,j; clear_digital_out(csn); for(j=0;j=10uS set_digital_out(nordic_ce); sleep(.1); clear_digital_out(nordic_ce); //Write to the CONFIG register: //Put the device back into RX-mode send_buffer[0] = 0x20; send_buffer[1] = 0x0B; spi_xmit(send_buffer,2,nordic_csn); set_digital_out(nordic_ce); } int nordic_get_rx_buffer(int message[], int size) { int buffer[33]; int i; buffer[0] = 0x61; clear_digital_out(nordic_ce); spi_xmit(buffer, size+1, nordic_csn); set_digital_out(nordic_ce); for(i=0;i 5) { down_tone(); printf("\nError - Bad Pipe # (%d)!\n", pipe); while(1); } if(size < 0 || size > 32) { down_tone(); printf("\nError - Bad Msg Size(%d)!\n", size); while(1); } send_buffer[0] = 0x31 + pipe; send_buffer[1] = size; spi_xmit(send_buffer,2,nordic_csn); }