NRF receiver
Dependencies: TSI mbed nRF24L01P
Revision 0:4eda749091bd, committed 2013-05-27
- Comitter:
- vmihalcut
- Date:
- Mon May 27 06:06:52 2013 +0000
- Commit message:
- NRF24L01 receiver;
Changed in this revision
diff -r 000000000000 -r 4eda749091bd TSI.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TSI.lib Mon May 27 06:06:52 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/TSI/#1a60ef257879
diff -r 000000000000 -r 4eda749091bd main_send.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main_send.cpp Mon May 27 06:06:52 2013 +0000 @@ -0,0 +1,225 @@ +#include "mbed.h" +#include "nRF24L01P.h" +#include "TSISensor.h" + +Serial pc(USBTX, USBRX); // tx, rx + +nRF24L01P my_nrf24l01p(PTD2, // MOSI + PTD3, // MISO + PTD1, // SCK + PTA13, // CSN + PTD5, // CE + PTD0); // IRQ +#define TRANSFER_SIZE 4 + +DigitalOut led(LED_GREEN); + +TSISensor tsi; + +int main() +{ + + pc.baud(115200); + pc.format(); + + char txData[TRANSFER_SIZE]; + int txDataCnt = 4; + + my_nrf24l01p.powerUp(); + + 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( "Type keys to test transfers:\r\n (transfers are grouped into %d characters)\r\n", TRANSFER_SIZE ); + + my_nrf24l01p.setTransferSize( TRANSFER_SIZE ); + + my_nrf24l01p.enable(); + + while (1) { + + while(tsi.readPercentage() < 0.5); + txData[0] = 's'; + txData[1] = 't'; + txData[2] = 'a'; + txData[3] = '\0'; + my_nrf24l01p.write( NRF24L01P_PIPE_P0, txData, txDataCnt ); + pc.printf("txData: %s \n\r", txData); + + wait(1); + + while(tsi.readPercentage() < 0.5); + txData[0] = 'S'; + txData[1] = 'T'; + txData[2] = 'A'; + txData[3] = '\0'; + my_nrf24l01p.write( NRF24L01P_PIPE_P0, txData, txDataCnt ); + pc.printf("txData: %s \n\r", txData); + + wait(1); + } +} + +/* +///////////////////////////////////////////////////////////////////////////////////// +Serial pc(USBTX, USBRX); // tx, rx + +nRF24L01P my_nrf24l01p(PTD2, // MOSI + PTD3, // MISO + PTD1, // SCK + PTA13, // CSN + PTD5, // CE + PTD0); // IRQ +#define TRANSFER_SIZE 4 + +DigitalOut led(LED_GREEN); + +int main() { + + pc.baud(9600); + pc.format(); + + char txData[TRANSFER_SIZE]; + txData[0] = 's'; + txData[1] = 't'; + txData[2] = 'a'; + txData[3] = '\0'; + int txDataCnt = 4; + + my_nrf24l01p.powerUp(); + + 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( "Type keys to test transfers:\r\n (transfers are grouped into %d characters)\r\n", TRANSFER_SIZE ); + + my_nrf24l01p.setTransferSize( TRANSFER_SIZE ); + + my_nrf24l01p.enable(); + + while (1) + { + led = 1 - led; + wait(2.0); + + my_nrf24l01p.write( NRF24L01P_PIPE_P0, txData, txDataCnt ); + + pc.printf("txData: %s \n\r", txData); + } +} + + +///////////////////////////////////////////////////////////////////////////////////// +Serial pc(USBTX, USBRX); // tx, rx + +nRF24L01P my_nrf24l01p(PTD2, // MOSI + PTD3, // MISO + PTD1, // SCK + PTA13, // CSN + PTD5, // CE + PTD0); // IRQ +#define TRANSFER_SIZE 4 + +TSISensor tsi; + +DigitalOut led(LED_GREEN); + +int main() { + + pc.baud(9600); + pc.format(); + + char txData[TRANSFER_SIZE]; + txData[0] = 's'; + txData[1] = 't'; + txData[2] = 'a'; + txData[3] = '\0'; + int txDataCnt = 4; + + my_nrf24l01p.powerUp(); + + 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( "Type keys to test transfers:\r\n (transfers are grouped into %d characters)\r\n", TRANSFER_SIZE ); + + my_nrf24l01p.setTransferSize( TRANSFER_SIZE ); + + my_nrf24l01p.enable(); + + while(1) + { + my_nrf24l01p.write( NRF24L01P_PIPE_P0, txData, txDataCnt ); + //wait(0.5); + //pc.printf("txData: %s \n\r", txData); + //led = 1 - led; + } +} + +///////////////////////////////////////////////////////////////////////////////////// +Serial pc(USBTX, USBRX); // tx, rx + +nRF24L01P my_nrf24l01p(p5, p6, p7, p8, p9); +#define TRANSFER_SIZE 32 + + +//DigitalOut led(LED_GREEN); + +int main() { + + pc.baud(115200); + pc.format(); + + char txData[TRANSFER_SIZE]; + txData[0] = 's'; + txData[1] = 't'; + txData[2] = 'a'; + txData[3] = '\0'; + int txDataCnt = 4; + + my_nrf24l01p.powerUp(); + my_nrf24l01p.setAirDataRate(NRF24L01P_DATARATE_1_MBPS); + 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( "Type keys to test transfers:\r\n (transfers are grouped into %d characters)\r\n", TRANSFER_SIZE ); + + my_nrf24l01p.setTransferSize( TRANSFER_SIZE ); + + my_nrf24l01p.enable(); + + while (1) + { + + //while(tsi.readPercentage() < 0.5); + txData[0] = 's'; + txData[1] = 't'; + txData[2] = 'a'; + txData[3] = '\0'; + my_nrf24l01p.write( NRF24L01P_PIPE_P0, txData, txDataCnt ); + pc.printf("txData: %s \n\r", txData); + + wait(1); + //while(tsi.readPercentage() < 0.5); + txData[0] = 'S'; + txData[1] = 'T'; + txData[2] = 'A'; + txData[3] = '\0'; + my_nrf24l01p.write( NRF24L01P_PIPE_P0, txData, txDataCnt ); + pc.printf("txData: %s \n\r", txData); + + wait(1); + } +}*/ \ No newline at end of file
diff -r 000000000000 -r 4eda749091bd mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon May 27 06:06:52 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/7e6c9f46b3bd \ No newline at end of file
diff -r 000000000000 -r 4eda749091bd nRF24L01P.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nRF24L01P.lib Mon May 27 06:06:52 2013 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/pabloamr/code/nRF24L01P/#8d55f1f49a33