Skip to content

Commit

Permalink
nRF24#401 There is an issue about the "toggle_feature()" after mcu reset
Browse files Browse the repository at this point in the history
  • Loading branch information
wmarkow committed Aug 16, 2018
1 parent a871827 commit 6c77c3c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
23 changes: 12 additions & 11 deletions RF24.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,7 @@ bool RF24::begin(void)
//setCRCLength( RF24_CRC_16 ) ;

// Disable dynamic payloads, to match dynamic_payloads_enabled setting - Reset value is 0
toggle_features();
write_register(FEATURE,0 );
activate_and_disable_features();
write_register(DYNPD,0);
dynamic_payloads_enabled = false;

Expand Down Expand Up @@ -1240,12 +1239,18 @@ void RF24::closeReadingPipe( uint8_t pipe )

/****************************************************************************/

void RF24::toggle_features(void)
void RF24::activate_and_disable_features(void)
{
beginTransaction();
_SPI.transfer( ACTIVATE );
_SPI.transfer( 0x73 );
endTransaction();
write_register(FEATURE, 0x01);
if(read_register(FEATURE) == 0)
{
beginTransaction();
_SPI.transfer( ACTIVATE );
_SPI.transfer( 0x73 );
endTransaction();
}

write_register(FEATURE, 0x00);
}

/****************************************************************************/
Expand All @@ -1254,7 +1259,6 @@ void RF24::enableDynamicPayloads(void)
{
// Enable dynamic payload throughout the system

//toggle_features();
write_register(FEATURE,read_register(FEATURE) | _BV(EN_DPL) );


Expand All @@ -1274,7 +1278,6 @@ void RF24::disableDynamicPayloads(void)
{
// Disables dynamic payload throughout the system. Also disables Ack Payloads

//toggle_features();
write_register(FEATURE, 0);


Expand All @@ -1297,7 +1300,6 @@ void RF24::enableAckPayload(void)
// enable ack payload and dynamic payload features
//

//toggle_features();
write_register(FEATURE,read_register(FEATURE) | _BV(EN_ACK_PAY) | _BV(EN_DPL) );

IF_SERIAL_DEBUG(printf("FEATURE=%i\r\n",read_register(FEATURE)));
Expand All @@ -1316,7 +1318,6 @@ void RF24::enableDynamicAck(void){
//
// enable dynamic ack features
//
//toggle_features();
write_register(FEATURE,read_register(FEATURE) | _BV(EN_DYN_ACK) );

IF_SERIAL_DEBUG(printf("FEATURE=%i\r\n",read_register(FEATURE)));
Expand Down
4 changes: 2 additions & 2 deletions RF24.h
Original file line number Diff line number Diff line change
Expand Up @@ -1139,12 +1139,12 @@ s *
void print_address_register(const char* name, uint8_t reg, uint8_t qty = 1);
#endif
/**
* Turn on or off the special features of the chip
* Activate and disable the special features of the chip
*
* The chip has certain 'features' which are only available when the 'features'
* are enabled. See the datasheet for details.
*/
void toggle_features(void);
void activate_and_disable_features(void);

/**
* Built in spi transfer function to simplify repeating code repeating code
Expand Down

1 comment on commit 6c77c3c

@WindyYam
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code basically will work though I don't have boards to test now

Please sign in to comment.