Michiel Van Endert
/
nRF24L01P_Project
Project wireless
Fork of nRF24L01P_Project by
Diff: main.cpp
- Revision:
- 2:178e089b3ce9
- Parent:
- 1:5be2682710c6
- Child:
- 3:1f92895432d2
--- a/main.cpp Wed Jan 19 23:53:19 2011 +0000 +++ b/main.cpp Thu May 07 16:39:31 2015 +0000 @@ -13,20 +13,26 @@ // The nRF24L01+ supports transfers from 1 to 32 bytes, but Sparkfun's // "Nordic Serial Interface Board" (http://www.sparkfun.com/products/9019) // only handles 4 byte transfers in the ATMega code. -#define TRANSFER_SIZE 4 +#define TRANSFER_SIZE 32 char txData[TRANSFER_SIZE], rxData[TRANSFER_SIZE]; int txDataCnt = 0; int rxDataCnt = 0; my_nrf24l01p.powerUp(); + + //Set Device + my_nrf24l01p.setTxAddress(0xE7E7E7E7E7,5); + //my_nrf24l01p.setRxAddress(0xE7E7E7E7E7,5); + my_nrf24l01p.setRfFrequency(2450); + my_nrf24l01p.setRfOutputPower(0); // Display the (default) setup of the nRF24L01+ chip pc.printf( "nRF24L01+ Frequency : %d MHz\r\n", my_nrf24l01p.getRfFrequency() ); pc.printf( "nRF24L01+ Output power : %d dBm\r\n", my_nrf24l01p.getRfOutputPower() ); pc.printf( "nRF24L01+ Data Rate : %d kbps\r\n", my_nrf24l01p.getAirDataRate() ); pc.printf( "nRF24L01+ TX Address : 0x%010llX\r\n", my_nrf24l01p.getTxAddress() ); - pc.printf( "nRF24L01+ RX Address : 0x%010llX\r\n", my_nrf24l01p.getRxAddress() ); + pc.printf( "nRF24L01+ RX Address : 0x%010llX\r\n", my_nrf24l01p.getRxAddress(0) ); pc.printf( "Type keys to test transfers:\r\n (transfers are grouped into %d characters)\r\n", TRANSFER_SIZE ); @@ -42,10 +48,13 @@ // ...add it to the transmit buffer txData[txDataCnt++] = pc.getc(); + + //pc.printf("lengte txData: %d \n\r", sizeof(txData)); + //pc.printf("txData count: %d \n\r", txDataCnt); // If the transmit buffer is full - if ( txDataCnt >= sizeof( txData ) ) { - + if ( txDataCnt >= sizeof(txData) ) { + //pc.printf("eerste if \n\r"); // Send the transmitbuffer via the nRF24L01+ my_nrf24l01p.write( NRF24L01P_PIPE_P0, txData, txDataCnt ); @@ -57,8 +66,8 @@ } // If we've received anything in the nRF24L01+... - if ( my_nrf24l01p.readable() ) { - + if ( my_nrf24l01p.readable(NRF24L01P_PIPE_P0) ) { + //pc.printf("tweede if \n\r"); // ...read the data into the receive buffer rxDataCnt = my_nrf24l01p.read( NRF24L01P_PIPE_P0, rxData, sizeof( rxData ) );