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