Commit 8f17e63a authored by maniacbug's avatar maniacbug

Add getDataRate, add DISABLED to data rate enum

parent 48336102
...@@ -911,16 +911,22 @@ rf24_datarate_e RF24::getDataRate( void ) ...@@ -911,16 +911,22 @@ rf24_datarate_e RF24::getDataRate( void )
void RF24::setCRCLength(rf24_crclength_e length) void RF24::setCRCLength(rf24_crclength_e length)
{ {
uint8_t config = read_register(CONFIG) & ~_BV(CRCO) ; uint8_t config = read_register(CONFIG) & ~( _BV(CRCO) | _BV(EN_CRC)) ;
// Always make sure CRC hardware validation is actually on switch (length)
config |= _BV(EN_CRC) ;
// Now config 8 or 16 bit CRCs - only 16bit need be turned on
// 8b is the default.
if( length == RF24_CRC_16 )
{ {
config |= _BV( CRCO ) ; case RF24_CRC_DISABLED:
break;
case RF24_CRC_8:
config |= _BV(EN_CRC);
break;
case RF24_CRC_16:
default:
config |= _BV(EN_CRC);
config |= _BV( CRCO );
break;
} }
write_register( CONFIG, config ) ; write_register( CONFIG, config ) ;
...@@ -928,6 +934,24 @@ void RF24::setCRCLength(rf24_crclength_e length) ...@@ -928,6 +934,24 @@ void RF24::setCRCLength(rf24_crclength_e length)
/****************************************************************************/ /****************************************************************************/
rf24_crclength_e RF24::getCRCLength(void)
{
rf24_crclength_e result = RF24_CRC_DISABLED;
uint8_t config = read_register(CONFIG) & ( _BV(CRCO) | _BV(EN_CRC)) ;
if ( config & _BV(EN_CRC ) )
{
if ( config & _BV(CRCO) )
result = RF24_CRC_16;
else
result = RF24_CRC_8;
}
return result;
}
/****************************************************************************/
void RF24::disableCRC( void ) void RF24::disableCRC( void )
{ {
uint8_t disable = read_register(CONFIG) & ~_BV(EN_CRC) ; uint8_t disable = read_register(CONFIG) & ~_BV(EN_CRC) ;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
typedef enum { RF24_PA_MIN = 0,RF24_PA_LOW, RF24_PA_HIGH, RF24_PA_MAX, RF24_PA_ERROR } rf24_pa_dbm_e ; typedef enum { RF24_PA_MIN = 0,RF24_PA_LOW, RF24_PA_HIGH, RF24_PA_MAX, RF24_PA_ERROR } rf24_pa_dbm_e ;
typedef enum { RF24_1MBPS = 0, RF24_2MBPS, RF24_250KBPS } rf24_datarate_e; typedef enum { RF24_1MBPS = 0, RF24_2MBPS, RF24_250KBPS } rf24_datarate_e;
typedef enum { RF24_CRC_8 = 0, RF24_CRC_16 } rf24_crclength_e; typedef enum { RF24_CRC_DISABLED = 0, RF24_CRC_8, RF24_CRC_16 } rf24_crclength_e;
/** /**
* Driver for nRF24L01(+) 2.4GHz Wireless Transceiver * Driver for nRF24L01(+) 2.4GHz Wireless Transceiver
...@@ -481,6 +481,13 @@ public: ...@@ -481,6 +481,13 @@ public:
*/ */
void setCRCLength(rf24_crclength_e length); void setCRCLength(rf24_crclength_e length);
/**
* Get the CRC length
*
* @return RF24_DISABLED if disabled or RF24_CRC_8 for 8-bit or RF24_CRC_16 for 16-bit
*/
rf24_crclength_e getCRCLength(void);
/** /**
* Disable CRC validation * Disable CRC validation
* *
......
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