Chris Dick
/
nRF2401A_Hello_World
Hello world example for the nRF2401A Library
Revision 2:440c95f796ac, committed 2013-10-04
- Comitter:
- TheChrisyd
- Date:
- Fri Oct 04 19:56:17 2013 +0000
- Parent:
- 1:fc964ee17649
- Child:
- 3:34ae527e9d41
- Commit message:
- commit to share with Erik Olieman
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Oct 04 16:28:15 2013 +0000 +++ b/main.cpp Fri Oct 04 19:56:17 2013 +0000 @@ -6,6 +6,7 @@ #define RX DigitalOut myled(LED1); +DigitalOut debug(LED2); #ifdef TX nRF2401A rf1(p10, p11, p12, p13, p14); #endif @@ -14,7 +15,16 @@ #endif Serial pc(USBTX, USBRX); - +#ifdef RX +bool rx_recieved = false; +nRF2401A_rx_handler_t nRF2401A_rx () +{ + //rf2.printDataPacket(pc); + debug = !debug; + rx_recieved = true; + return; +} +#endif int main() { wait(0.005); @@ -27,7 +37,7 @@ .setDataRate(nRF2401A::BIT_RATE_250KBITS) .setChannel(0x02); - rf1.printControlPacket(pc); + // rf1.printControlPacket(pc); #endif #ifdef RX @@ -37,8 +47,9 @@ .setDataRate(nRF2401A::BIT_RATE_250KBITS) .setChannel(0x02); - rf2.printControlPacket(pc); + // rf2.printControlPacket(pc); + rf2.attachRXHandler(nRF2401A_rx(), 0); #endif #ifdef TX rf1.flushControlPacket(); @@ -59,9 +70,13 @@ #endif myled = 1; wait(0.25); -#ifdef RX - rf2.printDataPacket(pc); -#endif +#ifdef RX + if (rx_recieved) + { + rf2.printDataPacket(pc); + rx_recieved = false; + } +#endif myled = 0; wait(0.25); }