LPC2103,设置管脚模式的宏定义,如下:
#define P00(MODE) PINSEL0 &= (~(0x00000003 << 0)); PINSEL0 |= (MODE << 0)
#define P01(MODE) PINSEL0 &= (~(0x00000003 << 2)); PINSEL0 |= (MODE << 2)
#define P02(MODE) PINSEL0 &= (~(0x00000003 << 4)); PINSEL0 |= (MODE << 4)
#define P03(MODE) PINSEL0 &= (~(0x00000003 << 6)); PINSEL0 |= (MODE << 6)
#define P04(MODE) PINSEL0 &= (~(0x00000003 << 8)); PINSEL0 |= (MODE << 8)
#define P05(MODE) PINSEL0 &= (~(0x00000003 << 10));PINSEL0 |= (MODE << 10)
#define P06(MODE) PINSEL0 &= (~(0x00000003 << 12));PINSEL0 |= (MODE << 12)
#define P07(MODE) PINSEL0 &= (~(0x00000003 << 14));PINSEL0 |= (MODE << 14)
#define P08(MODE) PINSEL0 &= (~(0x00000003 << 16));PINSEL0 |= (MODE << 16)
#define P09(MODE) PINSEL0 &= (~(0x00000003 << 18));PINSEL0 |= (MODE << 18)
#define P010(MODE) PINSEL0 &= (~(0x00000003 << 20));PINSEL0 |= (MODE << 20)
#define P011(MODE) PINSEL0 &= (~(0x00000003 << 22));PINSEL0 |= (MODE << 22)
#define P012(MODE) PINSEL0 &= (~(0x00000003 << 24));PINSEL0 |= (MODE << 24)
#define P013(MODE) PINSEL0 &= (~(0x00000003 << 26));PINSEL0 |= (MODE << 26)
#define P014(MODE) PINSEL0 &= (~(0x00000003 << 28));PINSEL0 |= (MODE << 28)
#define P015(MODE) PINSEL0 &= (~(0x00000003 << 30));PINSEL0 |= (MODE << 30)
当使用P015(X)的时候,编译时就出现警告:
warning: #61-D: integer operation result is out of range
而用函数进行移位操作,还是左移30位,就没有警告。。。
求大虾解释!! |