Maniacbug's nRF24L01 arduino library ported to mbed. Functional with minor issues.
Fork of nRF24L01P_Maniacbug by
Revision 8:ea2d2e86df4f, committed 2015-01-01
- Comitter:
- kenno
- Date:
- Thu Jan 01 11:56:44 2015 +0000
- Parent:
- 7:8858f26d373f
- Commit message:
- Fix conflicted variable names with K64F board.
Changed in this revision
nRF24L01P_Maniacbug.cpp | Show annotated file Show diff for this revision Revisions of this file |
nRF24L01P_Maniacbug.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 8858f26d373f -r ea2d2e86df4f nRF24L01P_Maniacbug.cpp --- a/nRF24L01P_Maniacbug.cpp Fri Oct 03 04:39:21 2014 +0000 +++ b/nRF24L01P_Maniacbug.cpp Thu Jan 01 11:56:44 2015 +0000 @@ -40,12 +40,12 @@ { uint8_t status; - csn(LOW); + csn(RF_LOW); status = spi.write( R_REGISTER | ( REGISTER_MASK & reg ) ); while ( len-- ) *buf++ = spi.write(0xff); - csn(HIGH); + csn(RF_HIGH); return status; } @@ -54,11 +54,11 @@ uint8_t RF24::read_register(uint8_t reg) { - csn(LOW); + csn(RF_LOW); spi.write( R_REGISTER | ( REGISTER_MASK & reg ) ); uint8_t result = spi.write(0xff); - csn(HIGH); + csn(RF_HIGH); return result; } @@ -68,12 +68,12 @@ { uint8_t status; - csn(LOW); + csn(RF_LOW); status = spi.write( W_REGISTER | ( REGISTER_MASK & reg ) ); while ( len-- ) spi.write(*buf++); - csn(HIGH); + csn(RF_HIGH); return status; } @@ -86,10 +86,10 @@ // IF_SERIAL_DEBUG(printf(("write_register(%02x,%02x)\r\n"),reg,value)); - csn(LOW); + csn(RF_LOW); status = spi.write( W_REGISTER | ( REGISTER_MASK & reg ) ); spi.write(value); - csn(HIGH); + csn(RF_HIGH); return status; } @@ -107,13 +107,13 @@ //printf("[Writing %u bytes %u blanks]",data_len,blank_len); - csn(LOW); + csn(RF_LOW); status = spi.write( W_TX_PAYLOAD ); while ( data_len-- ) spi.write(*current++); while ( blank_len-- ) spi.write(0); - csn(HIGH); + csn(RF_HIGH); return status; } @@ -130,13 +130,13 @@ //printf("[Reading %u bytes %u blanks]",data_len,blank_len); - csn(LOW); + csn(RF_LOW); status = spi.write( R_RX_PAYLOAD ); while ( data_len-- ) *current++ = spi.write(0xff); while ( blank_len-- ) spi.write(0xff); - csn(HIGH); + csn(RF_HIGH); return status; } @@ -147,9 +147,9 @@ { uint8_t status; - csn(LOW); + csn(RF_LOW); status = spi.write( FLUSH_RX ); - csn(HIGH); + csn(RF_HIGH); return status; } @@ -160,9 +160,9 @@ { uint8_t status; - csn(LOW); + csn(RF_LOW); status = spi.write( FLUSH_TX ); - csn(HIGH); + csn(RF_HIGH); return status; } @@ -173,9 +173,9 @@ { uint8_t status; - csn(LOW); - status = spi.write( NOP ); - csn(HIGH); + csn(RF_LOW); + status = spi.write( RF_NOP ); + csn(RF_HIGH); return status; } @@ -343,8 +343,8 @@ //spi.begin(); mainTimer.start(); - ce(LOW); - csn(HIGH); + ce(RF_LOW); + csn(RF_HIGH); // Must allow the radio time to settle else configuration bits will not necessarily stick. // This is actually only required following power up but some settling time also appears to @@ -414,7 +414,7 @@ flush_tx(); // Go! - ce(HIGH); + ce(RF_HIGH); // wait for the radio to come up (130us actually only needed) // wait_msMicroseconds(130); @@ -425,7 +425,7 @@ void RF24::stopListening(void) { - ce(LOW); + ce(RF_LOW); flush_tx(); flush_rx(); } @@ -523,10 +523,10 @@ write_payload( buf, len ); // Allons! - ce(HIGH); + ce(RF_HIGH); // wait_msMicroseconds(15); wait_us(15); - ce(LOW); + ce(RF_LOW); } /****************************************************************************/ @@ -535,10 +535,10 @@ { uint8_t result = 0; - csn(LOW); + csn(RF_LOW); spi.write( R_RX_PL_WID ); result = spi.write(0xff); - csn(HIGH); + csn(RF_HIGH); return result; } @@ -669,10 +669,10 @@ void RF24::toggle_features(void) { - csn(LOW); + csn(RF_LOW); spi.write( ACTIVATE ); spi.write( 0x73 ); - csn(HIGH); + csn(RF_HIGH); } /****************************************************************************/ @@ -734,14 +734,14 @@ { const uint8_t* current = reinterpret_cast<const uint8_t*>(buf); - csn(LOW); + csn(RF_LOW); spi.write( W_ACK_PAYLOAD | ( pipe & 7 ) ); const uint8_t max_payload_size = 32; uint8_t data_len = min(len,max_payload_size); while ( data_len-- ) spi.write(*current++); - csn(HIGH); + csn(RF_HIGH); } /****************************************************************************/
diff -r 8858f26d373f -r ea2d2e86df4f nRF24L01P_Maniacbug.h --- a/nRF24L01P_Maniacbug.h Fri Oct 03 04:39:21 2014 +0000 +++ b/nRF24L01P_Maniacbug.h Thu Jan 01 11:56:44 2015 +0000 @@ -110,7 +110,7 @@ #define FLUSH_TX 0xE1 #define FLUSH_RX 0xE2 #define REUSE_TX_PL 0xE3 -#define NOP 0xFF +#define RF_NOP 0xFF /* Non-P omissions */ #define LNA_HCURR 0 @@ -124,8 +124,8 @@ #define RF_PWR_LOW 1 #define RF_PWR_HIGH 2 -#define HIGH 1 -#define LOW 0 +#define RF_HIGH 1 +#define RF_LOW 0 #define _BV(n) (1 << n) /*