]> git.piffa.net Git - sketchbook_andrea/blob - libraries/AVR-Programming-Library/macros.h
7987b22e554727f2bbe65b4bc41d9eaf7d3bc1af
[sketchbook_andrea] / libraries / AVR-Programming-Library / macros.h
1
2 /* Standard Macros */
3 /* You can totally get by without these, but why? */
4
5 /* Make sure we've already got io / sfr / pindefs loaded */
6 #ifndef   _AVR_IO_H_
7 #include  <avr/io.h>
8 #endif
9
10 /* Reminder: the following useful bit-twiddling macros are
11    always included in avr/sfr_defs.h, which is called from
12    avr/io.h 
13
14  bit_is_set(sfr, bit)
15  bit_is_clear(sfr, bit)
16  loop_until_bit_is_set(sfr, bit)
17  loop_until_bit_is_clear(sfr, bit)
18
19 */
20
21 /* Define up the full complement of bit-twiddling macros */
22 #define BV(bit)               (1 << bit)
23 #define set_bit(sfr, bit)     (_SFR_BYTE(sfr) |= BV(bit))  // old sbi()
24 #define clear_bit(sfr, bit)   (_SFR_BYTE(sfr) &= ~BV(bit)) // old cbi()
25 #define toggle_bit(sfr, bit)  (_SFR_BYTE(sfr) ^= BV(bit))  
26