Commit 64da0885 authored by TMRh20's avatar TMRh20

Add transaction code to remaining functions

- Remove most Due specific code
- Update remaining SPI code using transaction functions
parent f6e1f37b
...@@ -601,13 +601,6 @@ bool RF24::begin(void) ...@@ -601,13 +601,6 @@ bool RF24::begin(void)
// Initialize pins // Initialize pins
if (ce_pin != csn_pin) pinMode(ce_pin,OUTPUT); if (ce_pin != csn_pin) pinMode(ce_pin,OUTPUT);
#if defined (RF24_DUE)
_SPI.begin(csn_pin); // Using the extended SPI features of the DUE
_SPI.setClockDivider(csn_pin, 11); // Set the bus speed to just under 8mhz on Due
_SPI.setBitOrder(csn_pin,MSBFIRST); // Set the bit order and mode specific to this device
_SPI.setDataMode(csn_pin,SPI_MODE0);
ce(LOW);
#else
#if ! defined(LITTLEWIRE) #if ! defined(LITTLEWIRE)
if (ce_pin != csn_pin) if (ce_pin != csn_pin)
#endif #endif
...@@ -619,7 +612,6 @@ bool RF24::begin(void) ...@@ -619,7 +612,6 @@ bool RF24::begin(void)
#if defined (__ARDUINO_X86__) #if defined (__ARDUINO_X86__)
delay(100); delay(100);
#endif #endif
#endif
#endif //Linux #endif //Linux
// Must allow the radio time to settle else configuration bits will not necessarily stick. // Must allow the radio time to settle else configuration bits will not necessarily stick.
...@@ -1036,15 +1028,11 @@ uint8_t RF24::getDynamicPayloadSize(void) ...@@ -1036,15 +1028,11 @@ uint8_t RF24::getDynamicPayloadSize(void)
_SPI.transfernb( (char *) spi_txbuff, (char *) spi_rxbuff, 2); _SPI.transfernb( (char *) spi_txbuff, (char *) spi_rxbuff, 2);
result = spi_rxbuff[1]; result = spi_rxbuff[1];
csn(HIGH); csn(HIGH);
#elif defined (RF24_DUE)
_SPI.transfer(csn_pin, R_RX_PL_WID, SPI_CONTINUE );
result = _SPI.transfer(csn_pin,0xff);
#else #else
csn(LOW); beginTransaction();
_SPI.transfer( R_RX_PL_WID ); _SPI.transfer( R_RX_PL_WID );
result = _SPI.transfer(0xff); result = _SPI.transfer(0xff);
csn(HIGH); endTransaction();
#endif #endif
if(result > 32) { flush_rx(); delay(2); return 0; } if(result > 32) { flush_rx(); delay(2); return 0; }
...@@ -1226,15 +1214,13 @@ void RF24::toggle_features(void) ...@@ -1226,15 +1214,13 @@ void RF24::toggle_features(void)
_SPI.transfer( ACTIVATE ); _SPI.transfer( ACTIVATE );
_SPI.transfer( 0x73 ); _SPI.transfer( 0x73 );
csn(HIGH); csn(HIGH);
#elif defined (RF24_DUE)
_SPI.transfer(csn_pin, ACTIVATE, SPI_CONTINUE );
_SPI.transfer(csn_pin, 0x73 );
#else #else
csn(LOW); beginTransaction();
_SPI.transfer( ACTIVATE ); _SPI.transfer( ACTIVATE );
_SPI.transfer( 0x73 ); _SPI.transfer( 0x73 );
csn(HIGH); endTransaction();
#endif #endif
} }
/****************************************************************************/ /****************************************************************************/
...@@ -1312,23 +1298,16 @@ void RF24::writeAckPayload(uint8_t pipe, const void* buf, uint8_t len) ...@@ -1312,23 +1298,16 @@ void RF24::writeAckPayload(uint8_t pipe, const void* buf, uint8_t len)
_SPI.transfern( (char *) spi_txbuff, size); _SPI.transfern( (char *) spi_txbuff, size);
csn(HIGH); csn(HIGH);
#elif defined (RF24_DUE)
_SPI.transfer(csn_pin, W_ACK_PAYLOAD | ( pipe & 0b111 ), SPI_CONTINUE);
while ( data_len-- > 1 ){
_SPI.transfer(csn_pin,*current++, SPI_CONTINUE);
}
_SPI.transfer(csn_pin,*current++);
#else #else
csn(LOW); beginTransaction();
_SPI.transfer(W_ACK_PAYLOAD | ( pipe & 0b111 ) ); _SPI.transfer(W_ACK_PAYLOAD | ( pipe & 0b111 ) );
while ( data_len-- ) while ( data_len-- )
_SPI.transfer(*current++); _SPI.transfer(*current++);
endTransaction();
csn(HIGH);
#endif #endif
} }
/****************************************************************************/ /****************************************************************************/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment