astyle -A1 -s2

This commit is contained in:
maniacbug 2011-07-31 09:47:41 -07:00
parent 602d96264a
commit 14c34ca2e4
2 changed files with 69 additions and 60 deletions

View File

@ -254,8 +254,8 @@ void RF24::print_address_register(prog_char* name, uint8_t reg, uint8_t qty)
/****************************************************************************/ /****************************************************************************/
RF24::RF24(uint8_t _cepin, uint8_t _cspin): RF24::RF24(uint8_t _cepin, uint8_t _cspin):
ce_pin(_cepin), csn_pin(_cspin), wide_band(true), p_variant(false), ce_pin(_cepin), csn_pin(_cspin), wide_band(true), p_variant(false),
payload_size(32), ack_payload_available(false) payload_size(32), ack_payload_available(false)
{ {
} }
@ -306,8 +306,8 @@ void RF24::printDetails(void)
read_register(CONFIG,buffer,1); read_register(CONFIG,buffer,1);
printf_P(PSTR("CONFIG = 0x%02x (CRC enable: %d; CRC16: %d)\n\r"), printf_P(PSTR("CONFIG = 0x%02x (CRC enable: %d; CRC16: %d)\n\r"),
*buffer,(*buffer)&_BV(EN_CRC)?1:0, *buffer,(*buffer)&_BV(EN_CRC)?1:0,
(*buffer)&_BV(CRCO)?1:0); (*buffer)&_BV(CRCO)?1:0);
#endif #endif
} }
@ -355,8 +355,9 @@ void RF24::begin(void)
// reset our data rate back to default value. This works // reset our data rate back to default value. This works
// because a non-P variant won't allow the data rate to // because a non-P variant won't allow the data rate to
// be set to 250Kbps. // be set to 250Kbps.
if( setDataRate( RF24_250KBPS ) ) { if( setDataRate( RF24_250KBPS ) )
p_variant = true ; {
p_variant = true ;
} }
setDataRate( RF24_2MBPS ) ; setDataRate( RF24_2MBPS ) ;
@ -715,8 +716,9 @@ bool RF24::isAckPayloadAvailable(void)
/****************************************************************************/ /****************************************************************************/
boolean RF24::isPVariant(void) { boolean RF24::isPVariant(void)
return p_variant ; {
return p_variant ;
} }
/******************************************************************/ /******************************************************************/
@ -736,10 +738,13 @@ void RF24::setAutoAck( uint8_t pipe, bool enable )
if ( pipe <= 6 ) if ( pipe <= 6 )
{ {
uint8_t en_aa = read_register( EN_AA ) ; uint8_t en_aa = read_register( EN_AA ) ;
if( enable ) { if( enable )
en_aa |= _BV(pipe) ; {
} else { en_aa |= _BV(pipe) ;
en_aa &= ~_BV(pipe) ; }
else
{
en_aa &= ~_BV(pipe) ;
} }
write_register( EN_AA, en_aa ) ; write_register( EN_AA, en_aa ) ;
} }
@ -769,24 +774,24 @@ void RF24::setPALevel(rf24_pa_dbm_e level)
switch( level ) switch( level )
{ {
case RF24_PA_MAX: case RF24_PA_MAX:
setup |= (_BV(RF_PWR_LOW) | _BV(RF_PWR_HIGH)) ; setup |= (_BV(RF_PWR_LOW) | _BV(RF_PWR_HIGH)) ;
break ; break ;
case RF24_PA_HIGH: case RF24_PA_HIGH:
setup |= _BV(RF_PWR_HIGH) ; setup |= _BV(RF_PWR_HIGH) ;
break ; break ;
case RF24_PA_LOW: case RF24_PA_LOW:
setup |= _BV(RF_PWR_LOW) ; setup |= _BV(RF_PWR_LOW) ;
break ; break ;
case RF24_PA_MIN: case RF24_PA_MIN:
break ; break ;
case RF24_PA_ERROR: case RF24_PA_ERROR:
// On error, go to maximum PA // On error, go to maximum PA
setup |= (_BV(RF_PWR_LOW) | _BV(RF_PWR_HIGH)) ; setup |= (_BV(RF_PWR_LOW) | _BV(RF_PWR_HIGH)) ;
break ; break ;
} }
write_register( RF_SETUP, setup ) ; write_register( RF_SETUP, setup ) ;
@ -802,20 +807,20 @@ rf24_pa_dbm_e RF24::getPALevel(void)
switch( power ) switch( power )
{ {
case (_BV(RF_PWR_LOW) | _BV(RF_PWR_HIGH)): case (_BV(RF_PWR_LOW) | _BV(RF_PWR_HIGH)):
result = RF24_PA_MAX ; result = RF24_PA_MAX ;
break ; break ;
case _BV(RF_PWR_HIGH): case _BV(RF_PWR_HIGH):
result = RF24_PA_HIGH ; result = RF24_PA_HIGH ;
break ; break ;
case _BV(RF_PWR_LOW): case _BV(RF_PWR_LOW):
result = RF24_PA_LOW ; result = RF24_PA_LOW ;
break ; break ;
default: default:
result = RF24_PA_MIN ; result = RF24_PA_MIN ;
break ; break ;
} }
return result ; return result ;
@ -856,8 +861,9 @@ boolean RF24::setDataRate(rf24_datarate_e speed)
// Verify our result // Verify our result
setup = read_register(RF_SETUP) ; setup = read_register(RF_SETUP) ;
if( setup == setup ) { if( setup == setup )
return true ; {
return true ;
} }
wide_band = false ; wide_band = false ;
@ -866,26 +872,28 @@ boolean RF24::setDataRate(rf24_datarate_e speed)
/******************************************************************/ /******************************************************************/
rf24_datarate_e RF24::getDataRate( void ) { rf24_datarate_e RF24::getDataRate( void )
{
rf24_datarate_e result ; rf24_datarate_e result ;
uint8_t setup = read_register(RF_SETUP) ; uint8_t setup = read_register(RF_SETUP) ;
// Order matters in our case below // Order matters in our case below
switch( setup & (_BV(RF_DR_LOW) | _BV(RF_DR_HIGH)) ) { switch( setup & (_BV(RF_DR_LOW) | _BV(RF_DR_HIGH)) )
{
case _BV(RF_DR_LOW): case _BV(RF_DR_LOW):
// '10' = 250KBPS // '10' = 250KBPS
result = RF24_250KBPS ; result = RF24_250KBPS ;
break ; break ;
case _BV(RF_DR_HIGH): case _BV(RF_DR_HIGH):
// '01' = 2MBPS // '01' = 2MBPS
result = RF24_2MBPS ; result = RF24_2MBPS ;
break ; break ;
default: default:
// '00' = 1MBPS // '00' = 1MBPS
result = RF24_1MBPS ; result = RF24_1MBPS ;
break ; break ;
} }
return result ; return result ;
@ -902,7 +910,8 @@ void RF24::setCRCLength(rf24_crclength_e length)
// Now config 8 or 16 bit CRCs - only 16bit need be turned on // Now config 8 or 16 bit CRCs - only 16bit need be turned on
// 8b is the default. // 8b is the default.
if( length == RF24_CRC_16 ) { if( length == RF24_CRC_16 )
{
config |= _BV( CRCO ) ; config |= _BV( CRCO ) ;
} }