Commit 72602783 authored by maniacbug's avatar maniacbug

Merge branch 'master' of github.com:maniacbug/RF24

parents 066d79f2 ef02ce6e
...@@ -266,14 +266,16 @@ void RF24::setChannel(uint8_t channel) ...@@ -266,14 +266,16 @@ void RF24::setChannel(uint8_t channel)
// TODO: This method could take advantage of the 'wide_band' calculation // TODO: This method could take advantage of the 'wide_band' calculation
// done in setChannel() to require certain channel spacing. // done in setChannel() to require certain channel spacing.
write_register(RF_CH,min(channel,127)); const uint8_t max_channel = 127;
write_register(RF_CH,min(channel,max_channel));
} }
/****************************************************************************/ /****************************************************************************/
void RF24::setPayloadSize(uint8_t size) void RF24::setPayloadSize(uint8_t size)
{ {
payload_size = min(size,32); const uint8_t max_payload_size = 32;
payload_size = min(size,max_payload_size);
} }
/****************************************************************************/ /****************************************************************************/
...@@ -593,7 +595,9 @@ void RF24::openWritingPipe(uint64_t value) ...@@ -593,7 +595,9 @@ void RF24::openWritingPipe(uint64_t value)
write_register(RX_ADDR_P0, reinterpret_cast<uint8_t*>(&value), 5); write_register(RX_ADDR_P0, reinterpret_cast<uint8_t*>(&value), 5);
write_register(TX_ADDR, reinterpret_cast<uint8_t*>(&value), 5); write_register(TX_ADDR, reinterpret_cast<uint8_t*>(&value), 5);
write_register(RX_PW_P0,min(payload_size,32));
const uint8_t max_payload_size = 32;
write_register(RX_PW_P0,min(payload_size,max_payload_size));
} }
/****************************************************************************/ /****************************************************************************/
...@@ -707,7 +711,8 @@ void RF24::writeAckPayload(uint8_t pipe, const void* buf, uint8_t len) ...@@ -707,7 +711,8 @@ void RF24::writeAckPayload(uint8_t pipe, const void* buf, uint8_t len)
csn(LOW); csn(LOW);
SPI.transfer( W_ACK_PAYLOAD | ( pipe & B111 ) ); SPI.transfer( W_ACK_PAYLOAD | ( pipe & B111 ) );
uint8_t data_len = min(len,32); const uint8_t max_payload_size = 32;
uint8_t data_len = min(len,max_payload_size);
while ( data_len-- ) while ( data_len-- )
SPI.transfer(*current++); SPI.transfer(*current++);
......
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