自己学习总结,学会总结分享
分类: 嵌入式
2016-03-26 22:30:11
4 #define vi *( volatile unsigned int * )
5
6 #define SET_ZERO( addr, bit ) ( (vi addr) &= ( ~ ( 1 << (bit) ) ) )
7 #define SET_ONE( addr, bit ) ( (vi addr) |= ( 1 << ( bit ) ) )
8
9 #define SET_BIT( addr, bit, val ) ( (vi addr) = (( vi addr)&=(~(1<<(bit))) ) | ( (val)<<(bit) ) )
10
11 #define SET_2BIT( addr, bit, val ) ( (vi addr) = (( vi addr)&(~(3<<(bit))) ) | ( (val)<<(bit) ) )
12
13 #define SET_NBIT( addr, bit, len, val ) \
14 ( (vi addr) = ((( vi addr)&(~(( ((1<<(len))-1) )<<(bit)))) | ( (val)<<(bit) ) ))
15
16 #define GET_BIT( addr, bit ) ( (( vi addr ) & ( 1 << (bit) )) > 0 )
17
18 #define GET_VAL( addr, val ) ( (val) = vi addr )
19 #define SET_VAL( addr, val ) ( (vi addr) = (val) )
20 #define OR_VAL( addr, val ) ( (vi addr) |= (val) )