//LPC900单片机IO模式设置宏定义 //eg:将P0_7设置成推挽输出模式:SetIOMode_P07_TW();
#ifndef SETIOMODE_H_H #define SETIOMODE_H_H
//********************* 双向模式 ************************************ #define SetIOMode_P00_SX() P0M1 &= 0xfe;P0M2 &= 0xfe #define SetIOMode_P01_SX() P0M1 &= 0xfd;P0M2 &= 0xfd #define SetIOMode_P02_SX() P0M1 &= 0xfb;P0M2 &= 0xfb #define SetIOMode_P03_SX() P0M1 &= 0xf7;P0M2 &= 0xf7 #define SetIOMode_P04_SX() P0M1 &= 0xef;P0M2 &= 0xef #define SetIOMode_P05_SX() P0M1 &= 0xdf;P0M2 &= 0xdf #define SetIOMode_P06_SX() P0M1 &= 0xbf;P0M2 &= 0xbf #define SetIOMode_P07_SX() P0M1 &= 0x7f;P0M2 &= 0x7f
#define SetIOMode_P10_SX() P1M1 &= 0xfe;P1M2 &= 0xfe #define SetIOMode_P11_SX() P1M1 &= 0xfd;P1M2 &= 0xfd #define SetIOMode_P12_SX() P1M1 &= 0xfb;P1M2 &= 0xfb #define SetIOMode_P13_SX() P1M1 &= 0xf7;P1M2 &= 0xf7 #define SetIOMode_P14_SX() P1M1 &= 0xef;P1M2 &= 0xef #define SetIOMode_P15_SX() P1M1 &= 0xdf;P1M2 &= 0xdf #define SetIOMode_P16_SX() P1M1 &= 0xbf;P1M2 &= 0xbf #define SetIOMode_P17_SX() P1M1 &= 0x7f;P1M2 &= 0x7f
#define SetIOMode_P20_SX() P2M1 &= 0xfe;P2M2 &= 0xfe #define SetIOMode_P21_SX() P2M1 &= 0xfd;P2M2 &= 0xfd #define SetIOMode_P22_SX() P2M1 &= 0xfb;P2M2 &= 0xfb #define SetIOMode_P23_SX() P2M1 &= 0xf7;P2M2 &= 0xf7 #define SetIOMode_P24_SX() P2M1 &= 0xef;P2M2 &= 0xef #define SetIOMode_P25_SX() P2M1 &= 0xdf;P2M2 &= 0xdf #define SetIOMode_P26_SX() P2M1 &= 0xbf;P2M2 &= 0xbf #define SetIOMode_P27_SX() P2M1 &= 0x7f;P2M2 &= 0x7f
#define SetIOMode_P30_SX() P3M1 &= 0xfe;P3M2 &= 0xfe #define SetIOMode_P31_SX() P3M1 &= 0xfd;P3M2 &= 0xfd #define SetIOMode_P32_SX() P3M1 &= 0xfb;P3M2 &= 0xfb #define SetIOMode_P33_SX() P3M1 &= 0xf7;P3M2 &= 0xf7 #define SetIOMode_P34_SX() P3M1 &= 0xef;P3M2 &= 0xef #define SetIOMode_P35_SX() P3M1 &= 0xdf;P3M2 &= 0xdf #define SetIOMode_P36_SX() P3M1 &= 0xbf;P3M2 &= 0xbf #define SetIOMode_P37_SX() P3M1 &= 0x7f;P3M2 &= 0x7f //*****************************************************************
//******************** 推挽模式 *********************************** #define SetIOMode_P00_TW() P0M1 &= 0xfe;P0M2 |= 0x01 #define SetIOMode_P01_TW() P0M1 &= 0xfd;P0M2 |= 0x02 #define SetIOMode_P02_TW() P0M1 &= 0xfb;P0M2 |= 0x04 #define SetIOMode_P03_TW() P0M1 &= 0xf7;P0M2 |= 0x08 #define SetIOMode_P04_TW() P0M1 &= 0xef;P0M2 |= 0x10 #define SetIOMode_P05_TW() P0M1 &= 0xdf;P0M2 |= 0x20 #define SetIOMode_P06_TW() P0M1 &= 0xbf;P0M2 |= 0x40 #define SetIOMode_P07_TW() P0M1 &= 0x7f;P0M2 |= 0x80
#define SetIOMode_P10_TW() P1M1 &= 0xfe;P1M2 |= 0x01 #define SetIOMode_P11_TW() P1M1 &= 0xfd;P1M2 |= 0x02 #define SetIOMode_P12_TW() P1M1 &= 0xfb;P1M2 |= 0x04 #define SetIOMode_P13_TW() P1M1 &= 0xf7;P1M2 |= 0x08 #define SetIOMode_P14_TW() P1M1 &= 0xef;P1M2 |= 0x10 #define SetIOMode_P15_TW() P1M1 &= 0xdf;P1M2 |= 0x20 #define SetIOMode_P16_TW() P1M1 &= 0xbf;P1M2 |= 0x40 #define SetIOMode_P17_TW() P1M1 &= 0x7f;P1M2 |= 0x80
#define SetIOMode_P20_TW() P2M1 &= 0xfe;P2M2 |= 0x01 #define SetIOMode_P21_TW() P2M1 &= 0xfd;P2M2 |= 0x02 #define SetIOMode_P22_TW() P2M1 &= 0xfb;P2M2 |= 0x04 #define SetIOMode_P23_TW() P2M1 &= 0xf7;P2M2 |= 0x08 #define SetIOMode_P24_TW() P2M1 &= 0xef;P2M2 |= 0x10 #define SetIOMode_P25_TW() P2M1 &= 0xdf;P2M2 |= 0x20 #define SetIOMode_P26_TW() P2M1 &= 0xbf;P2M2 |= 0x40 #define SetIOMode_P27_TW() P2M1 &= 0x7f;P2M2 |= 0x80
#define SetIOMode_P30_TW() P3M1 &= 0xfe;P3M2 |= 0x01 #define SetIOMode_P31_TW() P3M1 &= 0xfd;P3M2 |= 0x02 #define SetIOMode_P32_TW() P3M1 &= 0xfb;P3M2 |= 0x04 #define SetIOMode_P33_TW() P3M1 &= 0xf7;P3M2 |= 0x08 #define SetIOMode_P34_TW() P3M1 &= 0xef;P3M2 |= 0x10 #define SetIOMode_P35_TW() P3M1 &= 0xdf;P3M2 |= 0x20 #define SetIOMode_P36_TW() P3M1 &= 0xbf;P3M2 |= 0x40 #define SetIOMode_P37_TW() P3M1 &= 0x7f;P3M2 |= 0x80 //****************************************************************
//******************* 输入模式 *********************************** #define SetIOMode_P00_SR() P0M1 |= 0x01;P0M2 &= 0xfe #define SetIOMode_P01_SR() P0M1 |= 0x02;P0M2 &= 0xfd #define SetIOMode_P02_SR() P0M1 |= 0x04;P0M2 &= 0xfb #define SetIOMode_P03_SR() P0M1 |= 0x08;P0M2 &= 0xf7 #define SetIOMode_P04_SR() P0M1 |= 0x10;P0M2 &= 0xef #define SetIOMode_P05_SR() P0M1 |= 0x20;P0M2 &= 0xdf #define SetIOMode_P06_SR() P0M1 |= 0x40;P0M2 &= 0xbf #define SetIOMode_P07_SR() P0M1 |= 0x80;P0M2 &= 0x7f
#define SetIOMode_P10_SR() P1M1 |= 0x01;P1M2 &= 0xfe #define SetIOMode_P11_SR() P1M1 |= 0x02;P1M2 &= 0xfd #define SetIOMode_P12_SR() P1M1 |= 0x04;P1M2 &= 0xfb #define SetIOMode_P13_SR() P1M1 |= 0x08;P1M2 &= 0xf7 #define SetIOMode_P14_SR() P1M1 |= 0x10;P1M2 &= 0xef #define SetIOMode_P15_SR() P1M1 |= 0x20;P1M2 &= 0xdf #define SetIOMode_P16_SR() P1M1 |= 0x40;P1M2 &= 0xbf #define SetIOMode_P17_SR() P1M1 |= 0x80;P1M2 &= 0x7f
#define SetIOMode_P20_SR() P2M1 |= 0x01;P2M2 &= 0xfe #define SetIOMode_P21_SR() P2M1 |= 0x02;P2M2 &= 0xfd #define SetIOMode_P22_SR() P2M1 |= 0x04;P2M2 &= 0xfb #define SetIOMode_P23_SR() P2M1 |= 0x08;P2M2 &= 0xf7 #define SetIOMode_P24_SR() P2M1 |= 0x10;P2M2 &= 0xef #define SetIOMode_P25_SR() P2M1 |= 0x20;P2M2 &= 0xdf #define SetIOMode_P26_SR() P2M1 |= 0x40;P2M2 &= 0xbf #define SetIOMode_P27_SR() P2M1 |= 0x80;P2M2 &= 0x7f
#define SetIOMode_P30_SR() P3M1 |= 0x01;P3M2 &= 0xfe #define SetIOMode_P31_SR() P3M1 |= 0x02;P3M2 &= 0xfd #define SetIOMode_P32_SR() P3M1 |= 0x04;P3M2 &= 0xfb #define SetIOMode_P33_SR() P3M1 |= 0x08;P3M2 &= 0xf7 #define SetIOMode_P34_SR() P3M1 |= 0x10;P3M2 &= 0xef #define SetIOMode_P35_SR() P3M1 |= 0x20;P3M2 &= 0xdf #define SetIOMode_P36_SR() P3M1 |= 0x40;P3M2 &= 0xbf #define SetIOMode_P37_SR() P3M1 |= 0x80;P3M2 &= 0x7f //*************************************************************
//*********************** 开漏模式 **************************** #define SetIOMode_P00_KL() P0M1 |= 0x01;P0M2 |= 0x01 #define SetIOMode_P01_KL() P0M1 |= 0x02;P0M2 |= 0x02 #define SetIOMode_P02_KL() P0M1 |= 0x04;P0M2 |= 0x04 #define SetIOMode_P03_KL() P0M1 |= 0x08;P0M2 |= 0x08 #define SetIOMode_P04_KL() P0M1 |= 0x10;P0M2 |= 0x10 #define SetIOMode_P05_KL() P0M1 |= 0x20;P0M2 |= 0x20 #define SetIOMode_P06_KL() P0M1 |= 0x40;P0M2 |= 0x40 #define SetIOMode_P07_KL() P0M1 |= 0x80;P0M2 |= 0x80
#define SetIOMode_P10_KL() P1M1 |= 0x01;P1M2 |= 0x01 #define SetIOMode_P11_KL() P1M1 |= 0x02;P1M2 |= 0x02 #define SetIOMode_P12_KL() P1M1 |= 0x04;P1M2 |= 0x04 #define SetIOMode_P13_KL() P1M1 |= 0x08;P1M2 |= 0x08 #define SetIOMode_P14_KL() P1M1 |= 0x10;P1M2 |= 0x10 #define SetIOMode_P15_KL() P1M1 |= 0x20;P1M2 |= 0x20 #define SetIOMode_P16_KL() P1M1 |= 0x40;P1M2 |= 0x40 #define SetIOMode_P17_KL() P1M1 |= 0x80;P1M2 |= 0x80
#define SetIOMode_P20_KL() P2M1 |= 0x01;P2M2 |= 0x01 #define SetIOMode_P21_KL() P2M1 |= 0x02;P2M2 |= 0x02 #define SetIOMode_P22_KL() P2M1 |= 0x04;P2M2 |= 0x04 #define SetIOMode_P23_KL() P2M1 |= 0x08;P2M2 |= 0x08 #define SetIOMode_P24_KL() P2M1 |= 0x10;P2M2 |= 0x10 #define SetIOMode_P25_KL() P2M1 |= 0x20;P2M2 |= 0x20 #define SetIOMode_P26_KL() P2M1 |= 0x40;P2M2 |= 0x40 #define SetIOMode_P27_KL() P2M1 |= 0x80;P2M2 |= 0x80
#define SetIOMode_P30_KL() P3M1 |= 0x01;P3M2 |= 0x01 #define SetIOMode_P31_KL() P3M1 |= 0x02;P3M2 |= 0x02 #define SetIOMode_P32_KL() P3M1 |= 0x04;P3M2 |= 0x04 #define SetIOMode_P33_KL() P3M1 |= 0x08;P3M2 |= 0x08 #define SetIOMode_P34_KL() P3M1 |= 0x10;P3M2 |= 0x10 #define SetIOMode_P35_KL() P3M1 |= 0x20;P3M2 |= 0x20 #define SetIOMode_P36_KL() P3M1 |= 0x40;P3M2 |= 0x40 #define SetIOMode_P37_KL() P3M1 |= 0x80;P3M2 |= 0x80 //************************************************************
#endif
|