RGB LED cube 5x5x5  1.0
Martin Stejskal, Schmidt Dominik
 All Files Functions Variables Macros Groups Pages
bit_operations.h
Go to the documentation of this file.
1 
14 // Trick for multiply include this file
15 #ifndef _bit_operations_library_
16 #define _bit_operations_library_
17 
18 /*-----------------------------------------*
19  | Includes |
20  *-----------------------------------------*/
21 #include <avr/io.h>
22 
23 /*-----------------------------------------*
24  | Macros |
25  *-----------------------------------------*/
43 #define set_bit_simple(var,bit_num) var = (var) | (1<<bit_num)
44 
62 #define set_bit(var,bit_num) set_bit_simple(var, bit_num)
63 
81 #define clr_bit_simple(var,bit_num) var = (var) & (~(1<<bit_num))
82 
83 
101 #define clr_bit(var,bit_num) var = (var) & (~(1<<bit_num))
102 
103 
104 
121 #define io_set_dir_out_simple(X,pin) DDR##X = DDR##X | (1<< pin)
122 
138 #define io_set_dir_out(X,pin) io_set_dir_out_simple(X,pin)
139 
140 
159 #define io_set_dir_in_simple(X,pin) DDR##X = DDR##X & (~(1 << pin));\
160  PIN##X = PIN##X & (~(1 << pin))
161 
180 #define io_set_dir_in(X,pin) io_set_dir_in_simple(X,pin)
181 
182 
200 #define io_set_1_simple(X,pin) PORT##X = PORT##X | (1 << pin )
201 
202 
220 #define io_set_1(X,pin) io_set_1_simple(X,pin)
221 
236 // Same as "io_set_1" macro
237 #define io_set_H(X,pin) io_set_1(X,pin)
238 
239 
257 #define io_set_0_simple(X,pin) PORT##X = PORT##X & (~(1 << pin))
258 
259 
277 #define io_set_0(X,pin) io_set_0_simple(X,pin)
278 
293 #define io_set_L(X,pin) io_set_0(X,pin)
294 
295 
314 #define io_read_simple(X,pin) ( PIN##X & (1 << pin) )>>pin
315 
316 
335 #define io_read(X,pin) io_read_simple(X,pin)
336 
337 
338 
359 #define io_read_fast_simple(X,pin) PIN##X & (1 << pin)
360 
361 
362 
383 #define io_read_fast(X,pin) io_read_fast_simple(X,pin)
384 
385 /*-----------------------------------------*
386  | Function prototypes |
387  *-----------------------------------------*/
388 
389 
390 /*-----------------------------------------*
391  | Definitions |
392  *-----------------------------------------*/
406 #define dir_out 1
407 #define dir_in 0
408 
415 #endif