View Single Post
Old 06-08-2009, 11:28 AM   #1632 (permalink)
JayC
EcoModding Lurker
 
Join Date: Jul 2008
Location: Memphis, TN
Posts: 58

2010 Prius - '10 Toyota Prius IV
Last 3: 51.4 mpg (US)
Thanks: 0
Thanked 1 Time in 1 Post
I'm not sure either. The refactored code does not have any of the items people were posting about? Are you guys looking at the latest code? It's using the _BV(bit) macro to create bit masks. It's a lot more readable.

To set a bit you use:
PORTB |= _BV(PB1); // PORTB = PORTB | (00000010)

To clear a bit you use:
PORTB &= ~_BV(PB1); // PORTB = PORTB & (11111101)

Finally, you can set multiple bits at once:
PORTB |= | _BV(PB7) | _BV(PB1) | _BV(PB0); // PORTB = PORTB | (10000000) | 0000010) | (00000001)

FWIW,
Jay

Last edited by JayC; 06-08-2009 at 11:56 AM..
  Reply With Quote