LPC寄存器位操作总结--(参考网上例程)

/****************************************************************/

1 #define __IO_REG32_BIT(NAME, ADDRESS, ATTRIBUTE, BIT_STRUCT)\
2                         volatile __no_init ATTRIBUTE union \
3                          {                                 \
4                            unsigned long NAME;             \
5                            BIT_STRUCT NAME ## _bit;      \
6                          } @ ADDRESS

 

/****************************************************************/

 

 

/****************************************************************/

__IO_REG32_BIT(IO1PIN,          0xE0028010,__READ_WRITE,__gpio1_bits);

 

/****************************************************************/

 

 

/****************************************************************/

 1 /* GPIO 0 Registers */
 2 typedef struct {
 3 __REG32 P0_0   : 1;
 4 __REG32 P0_1   : 1;
 5 __REG32 P0_2   : 1;
 6 __REG32 P0_3   : 1;
 7 __REG32 P0_4   : 1;
 8 __REG32 P0_5   : 1;
 9 __REG32 P0_6   : 1;
10 __REG32 P0_7   : 1;
11 __REG32 P0_8   : 1;
12 __REG32 P0_9   : 1;
13 __REG32 P0_10  : 1;
14 __REG32 P0_11  : 1;
15 __REG32 P0_12  : 1;
16 __REG32 P0_13  : 1;
17 __REG32 P0_14  : 1;
18 __REG32 P0_15  : 1;
19 __REG32 P0_16  : 1;
20 __REG32 P0_17  : 1;
21 __REG32 P0_18  : 1;
22 __REG32 P0_19  : 1;
23 __REG32 P0_20  : 1;
24 __REG32 P0_21  : 1;
25 __REG32 P0_22  : 1;
26 __REG32 P0_23  : 1;
27 __REG32 P0_24  : 1;
28 __REG32 P0_25  : 1;
29 __REG32 P0_26  : 1;
30 __REG32 P0_27  : 1;
31 __REG32 P0_28  : 1;
32 __REG32 P0_29  : 1;
33 __REG32 P0_30  : 1;
34 __REG32 P0_31  : 1;
35 } __gpio0_bits;

 

/****************************************************************/

 

1 在程序中,可以直接引用位操作
2   IO0PIN_bit.P0_1= 1;
3   IO0PIN_bit.P0_25 = 1;

 

 

posted @ 2013-10-14 16:07  Iamchritian  阅读(1024)  评论(0编辑  收藏  举报