1 2 3 4 5 6 7 8 9 10 11
12 /*!
13 * ======== Button ========
14 * Simple momentary button switch manager
15 */
16 @ModuleStartup
17 module Button
18 {
19
20 metaonly readonly config Ptr PORT0 = 0x11;
21
22 metaonly readonly config Ptr PORT1 = 0x21;
23 metaonly readonly config Ptr PORT2 = 0x29;
24
25 metaonly readonly config Ptr PORT0_IE = 0x15;
26 metaonly readonly config Ptr PORT0_IFG = 0x13;
27 metaonly readonly config Ptr PORT0_OUT = 0x11;
28 metaonly readonly config Ptr PORT0_REN = 0x11;
29
30 metaonly readonly config Ptr PORT1_IE = 0x25;
31 metaonly readonly config Ptr PORT1_IFG = 0x23;
32 metaonly readonly config Ptr PORT1_OUT = 0x21;
33 metaonly readonly config Ptr PORT1_REN = 0x27;
34
35 metaonly readonly config Ptr PORT2_IE = 0x2D;
36 metaonly readonly config Ptr PORT2_IFG = 0x2B;
37 metaonly readonly config Ptr PORT2_OUT = 0x29;
38 metaonly readonly config Ptr PORT2_REN = 0x2F;
39
40 metaonly readonly config Ptr PORTA_IE_L = 0x21A;
41 metaonly readonly config Ptr PORTA_IFG_L = 0x21C;
42 metaonly readonly config Ptr PORTA_OUT_L = 0x202;
43 metaonly readonly config Ptr PORTA_REN_L = 0x206;
44
45 metaonly readonly config Ptr PORTA_IE_H = 0x21B;
46 metaonly readonly config Ptr PORTA_IFG_H = 0x21D;
47 metaonly readonly config Ptr PORTA_OUT_H = 0x203;
48 metaonly readonly config Ptr PORTA_REN_H = 0x207;
49
50 /*!
51 * ======== PORT ========
52 * Address of 8-bit output port to use
53 */
54 config Ptr PORT = PORT1;
55
56 /*!
57 * ======== PORT_IE ========
58 * Address of Interrupt Enable register
59 */
60 config Ptr PORT_IE = PORT1_IE;
61
62 /*!
63 * ======== PORT_OUT ========
64 * Address of output configuration register
65 */
66 config Ptr PORT_OUT = PORT1_OUT;
67
68 /*!
69 * ======== PORT_REN ========
70 * Address of pullup/down resister enable configuration register
71 */
72 config Ptr PORT_REN = PORT1_REN;
73
74 /*!
75 * ======== PORT_IFG ========
76 * Address of Interrupt Flag register
77 */
78 config Ptr PORT_IFG = PORT1_IFG;
79
80 /*!
81 * ======== SWITCH1 ========
82 * Port mask for switch #1
83 */
84 config Bits8 SWITCH1 = 0x1;
85
86 /*!
87 * ======== SWITCH2 ========
88 * Port mask for switch #2
89 */
90 config Bits8 SWITCH2 = 0x2;
91
92 /*!
93 * ======== enable ========
94 * Enable the specified buttons
95 */
96 @DirectCall
97 Void enable(Bits8 mask);
98
99 /*!
100 * ======== disable ========
101 * Disable the specified buttons
102 */
103 @DirectCall
104 Void disable(Bits8 mask);
105
106 /*!
107 * ======== read ========
108 * Atomically read and clear the specified buttons
109 *
110 * This function returns the state of the buttons and clears
111 * their state. Only the state of the buttons specified by
112 * `mask` are affected.
113 */
114 @DirectCall
115 Bits8 read(Bits8 mask);
116 }