文件名称:五线键盘 led显示
文件大小:6KB
文件格式:C
更新时间:2012-09-05 05:03:32
五线键盘 led显示 msp430
nt keyscan() { P2DIR = 0xff; RL1S; RL0S; SL2C; SL1C; SL0C; P2DIR = 0x00; if (RL0 == 0 || RL1 == 0) { delaynms(5); if (RL0 == 0) { key = 0; RL0S; return 0; } else if (RL1 == 0) { key = 8; RL1S; return 0; } } P2DIR |= BIT2 + BIT3 + BIT4; SL2C; SL1C; SL0S; P2DIR = 0x00; if (RL0 == 0 || RL1 == 0) { delaynms(5); if (RL0 == 0) { key = 1; RL0S; return 0; } else if (RL1 == 0) { key = 9; RL1S; return 0; } } P2DIR |= BIT2 + BIT3 + BIT4; SL2C; SL1S; SL0C; P2DIR = 0x00; if (RL0 == 0 || RL1 == 0) { delaynms(5); if (RL0 == 0) { key = 2; RL0S; return 0; } else if (RL1 == 0) { key = 10; RL1S; return 0; } } P2DIR |= BIT2 + BIT3 + BIT4; SL2C; SL1S; SL0S; P2DIR = 0x00; if (RL0 == 0 || RL1 == 0) { delaynms(5); if (RL0 == 0) { key = 3; RL0S; return 0; } else if (RL1 == 0) { key = 11; RL1S; return 0; } } P2DIR |= BIT2 + BIT3 + BIT4; SL2S; SL1C; SL0C; P2DIR = 0x00; if (RL0 == 0 || RL1 == 0) { delaynms(5); if (RL0 == 0) { key = 4; RL0S; return 0; } else if (RL1 == 0) { key = 12; RL1S; return 0; } } P2DIR |= BIT2 + BIT3 + BIT4; SL2S; SL1C; SL0S; P2DIR = 0x00; if (RL0 == 0 || RL1 == 0) { delaynms(5); if (RL0 == 0) { key = 5; RL0S; return 0; } else if (RL1 == 0) { key = 13; RL1S; return 0; } } P2DIR |= BIT2 + BIT3 + BIT4; SL2S; SL1S; SL0C; P2DIR = 0x00; if (RL0 == 0 || RL1 == 0) { delaynms(5); if (RL0 == 0) { key = 6; RL0S; return 0; } else if (RL1 == 0) { key = 14; RL1S; return 0; } } P2DIR |= BIT2 + BIT3 + BIT4; SL2S; SL1S; SL0S; P2DIR = 0x00; if (RL0 == 0 || RL1 == 0) { delaynms(5); if (RL0 == 0) { key = 7; RL0S; return 0; } else if (RL1 == 0) { key = 15; RL1S; return 0; } } return 1; }