Chris Dick
/
nRF2401A_Hello_World
Hello world example for the nRF2401A Library
Diff: main.cpp
- Revision:
- 7:202814542566
- Parent:
- 6:f43bf63489bb
--- a/main.cpp Sat Oct 26 21:57:37 2013 +0000 +++ b/main.cpp Sun Mar 09 11:58:07 2014 +0000 @@ -2,7 +2,7 @@ #include "nRF2401A.h" /* comment these out depending on the job of the mbed. If your only using one mbed leave both uncommented. */ -//#define TX +#define TX #define RX /* If using the FRDM-KL25Z uncomment this line */ @@ -23,7 +23,7 @@ #ifdef FRDMKL25Z nRF2401A rf2(PTD0, PTD5, PTA13, PTC12, PTC13); #else -nRF2401A rf2(p10, p11, p12, p13, p14); +nRF2401A rf2(p21, p22, p23, p24, p25); #endif bool rx_recieved = false; @@ -39,29 +39,22 @@ pc.printf("Hello nRF2401A\n\r"); #ifdef TX - /* initialise the nRF2401A with payload size, address, CRC, bit rate and channel */ - rf1.setDataPayloadLength(4 << 3) - .setAddress(0x0, 0x0, 0xa6, 0xa6, 0xa6, 3 << 3) - .setCRCMode(nRF2401A::NO_CRC) - .setDataRate(nRF2401A::BIT_RATE_250KBITS) - .setChannel(0x02); - + /* initialise the nRF2401A with payload size and address */ + rf1.setAddress(0x0, 0x0, 0xa6, 0xa6, 0xa6, 3 << 3); + rf1.printControlPacket(pc); rf1.flushControlPacket(); /* initialise variables to use for tranmission */ nRF2401A::address_t rf2_addr = {0x0, 0x0, 0x53, 0x53, 0x53}; + uint8_t msg[] = {0x01, 0x01, 0x01, 0x01}; uint32_t *msg32 = (uint32_t *) msg; #endif #ifdef RX - /* initialise the nRF2401A with payload size, address, CRC, bit rate and channel */ - rf2.setDataPayloadLength(4 << 3) - .setAddress(0x0, 0x0, 0x53, 0x53, 0x53, 3 << 3) - .setCRCMode(nRF2401A::NO_CRC) - .setDataRate(nRF2401A::BIT_RATE_250KBITS) - .setChannel(0x02); + /* initialise the nRF2401A with payload size and address */ + rf2.setAddress(0x0, 0x0, 0x53, 0x53, 0x53, 3 << 3); rf2.printControlPacket(pc); rf2.flushControlPacket(); @@ -94,7 +87,7 @@ /* send a single byte from the read buffer to the serial port */ uint8_t rx_msg = 0; - rf2.readMsg_byte(&rx_msg, 0 ); + rx_msg = rf2.readMsg_byte( 0 ); pc.printf("\n\r%d\n\r", rx_msg); /* read the read buffer , then send to the serial port */