MCPcopy Create free account
hub / github.com/CE-Programming/CEmu / keypad_scan_event

Function keypad_scan_event

core/keypad.c:132–157  ·  view source on GitHub ↗

Scan next row of keypad, if scanning is enabled */

Source from the content-addressed store, hash-verified

130
131/* Scan next row of keypad, if scanning is enabled */
132static void keypad_scan_event(enum sched_item_id id) {
133 uint8_t row = keypad.row++;
134 if (row < keypad_row_limit()) {
135 /* scan each data row */
136 uint16_t data = keypad_query_keymap(row) & keypad_data_mask();
137
138 /* if mode 3 or 2, generate data change interrupt */
139 if (keypad.data[row] != data) {
140 keypad.status |= 2;
141 keypad.data[row] = data;
142 }
143 }
144 if (keypad.row < keypad.rows) { /* scan the next row */
145 sched_repeat(id, keypad.rowWait);
146 } else { /* finished scanning the keypad */
147 keypad.status |= 1;
148 if (keypad.mode & 1) { /* are we in mode 1 or 3 */
149 keypad.row = 0;
150 sched_repeat(id, 2 + keypad.scanWait + keypad.rowWait);
151 } else {
152 /* If in single scan mode, go to idle mode */
153 keypad.mode = 0;
154 }
155 }
156 keypad_intrpt_check();
157}
158
159static void keypad_write(const uint16_t pio, const uint8_t byte, bool poke) {
160 uint16_t index = (pio >> 2) & 0x7F;

Callers

nothing calls this directly

Calls 5

keypad_row_limitFunction · 0.85
keypad_query_keymapFunction · 0.85
keypad_data_maskFunction · 0.85
sched_repeatFunction · 0.85
keypad_intrpt_checkFunction · 0.85

Tested by

no test coverage detected