summaryrefslogtreecommitdiffstats
path: root/src/target/firmware/include/keypad.h
blob: e2e6519fe79d0735c1c110c97c0e4d4d9fa6075c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef _KEYPAD_H
#define _KEYPAD_H

enum buttons {
	BTN_0		= 0x00002000,
	BTN_1		= 0x00008000,
	BTN_2		= 0x00000400,
	BTN_3		= 0x00000020,
	BTN_4		= 0x00010000,
	BTN_5		= 0x00000800,
	BTN_6		= 0x00000040,
	BTN_7		= 0x00020000,
	BTN_8		= 0x00001000,
	BTN_9		= 0x00000080,
	BTN_STAR	= 0x00040000,
	BTN_HASH	= 0x00000100,
	BTN_MENU	= 0x00004000,
	BTN_LEFT_SB	= 0x00080000,
	BTN_RIGHT_SB	= 0x00000200,
	BTN_UP		= 0x00000002,
	BTN_DOWN	= 0x00000004,
	BTN_LEFT	= 0x00000008,
	BTN_RIGHT	= 0x00000010,
	BTN_OK		= 0x00000001,
	BTN_POWER	= 0x01000000,
};

enum key_codes {
	KEY_0	= 0,
	KEY_1,
	KEY_2,
	KEY_3,
	KEY_4,
	KEY_5,
	KEY_6,
	KEY_7,
	KEY_8,
	KEY_9,
	KEY_STAR,	//*
	KEY_HASH,	//#
	KEY_MENU,	//center of directional keys
	KEY_LEFT_SB,	//softbutton
	KEY_RIGHT_SB,	//softbutton
	KEY_UP,
	KEY_DOWN,
	KEY_LEFT,
	KEY_RIGHT,
	KEY_OK,		//green off-hook
	KEY_POWER,	//red on-hook
	KEY_INV = 0xFF
};

enum key_states {
	PRESSED,
	RELEASED,
};

void keypad_init(uint8_t interrupts);

void keypad_poll();

typedef void (*key_handler_t)(enum key_codes code, enum key_states state);

void keypad_set_handler(key_handler_t handler);

#endif /* KEYPAD_H */