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

Function keypad_write

core/keypad.c:159–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

157}
158
159static void keypad_write(const uint16_t pio, const uint8_t byte, bool poke) {
160 uint16_t index = (pio >> 2) & 0x7F;
161 uint8_t bit_offset = (pio & 3) << 3;
162
163 switch (index) {
164 case 0x00:
165 write8(keypad.control, bit_offset, byte);
166 if (keypad.mode & 2) {
167 keypad.row = 0;
168 sched_set(SCHED_KEYPAD, keypad.rowWait);
169 } else {
170 sched_clear(SCHED_KEYPAD);
171 keypad_any_check();
172 }
173 break;
174 case 0x01:
175 write8(keypad.size, bit_offset, byte);
176 break;
177 case 0x02:
178 write8(keypad.status, bit_offset, keypad.status >> bit_offset & ~byte);
179 keypad_any_check();
180 keypad_intrpt_check();
181 break;
182 case 0x03:
183 write8(keypad.enable, bit_offset, byte & 7);
184 keypad_intrpt_check();
185 break;
186 case 0x04: case 0x05: case 0x06: case 0x07:
187 case 0x08: case 0x09: case 0x0A: case 0x0B:
188 if (poke) {
189 write8(keypad.data[(pio - 0x10) >> 1 & 15], pio << 3 & 8, byte);
190 write8(keypad_atomics.keyMap[pio >> 1 & 15], pio << 3 & 8, byte);
191 }
192 break;
193 case 0x10:
194 write8(keypad.gpioEnable, bit_offset, byte);
195 break;
196 case 0x11: /* GPIO status is always 0, no 1 bits to reset */
197 default:
198 break; /* Escape write sequence if unimplemented */
199 }
200}
201
202static void keypad_init_events(void) {
203 sched_init_event(SCHED_KEYPAD, CLOCK_6M, keypad_scan_event);

Callers

nothing calls this directly

Calls 4

sched_setFunction · 0.85
sched_clearFunction · 0.85
keypad_any_checkFunction · 0.85
keypad_intrpt_checkFunction · 0.85

Tested by

no test coverage detected