Skip to content

Instantly share code, notes, and snippets.

@JHeld07
Created December 16, 2015 20:12
Show Gist options
  • Save JHeld07/794dcfaa120abe4749a5 to your computer and use it in GitHub Desktop.
Save JHeld07/794dcfaa120abe4749a5 to your computer and use it in GitHub Desktop.
// Hardware Connections
#define R1 0xE
#define R2 0xD
#define R3 0xB
#define R4 0x7
#define C1 0x3
#define C2 0x5
#define C3 0x6
struct KeyPadCon{
int COLS:3;
int UNUSED:1;
int ROWS:4;
};
struct KeyPadCon *KEYPAD=0xF81; // Port B
// Delarations
char KeyPress(void);
// Definitions
char KeyPress(void){
char press='@';
KEYPAD->COLS=C1;
switch(KEYPAD->ROWS){
case R1:
press='1';
break;
case R2:
press='4';
break;
case R3:
press='7';
break;
case R4:
press='*';
break;
default:
}
KEYPAD->COLS=C2;
switch(KEYPAD->ROWS){
case R1:
press='2';
break;
case R2:
press='5';
break;
case R3:
press='8';
break;
case R4:
press='0';
break;
default:
}
KEYPAD->COLS=C3;
switch(KEYPAD->ROWS){
case R1:
press='3';
break;
case R2:
press='6';
break;
case R3:
press='9';
break;
case R4:
press='#';
break;
default:
}
return(press);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment