/* reads the keypad and returns the bit number that was turned on in the shift
* register (from 0..7). If no bits were turned on, it returns 8 (aka NO_KEY)
*/
-extern inline u8 keypad_read_row(u8 row) {
- u8 i, j, num;
+extern inline u8 keypad_read_row(const u8 row) {
+ u8 i, num;
if (row)
bset((void*)&_io_ports[M6811_PORTD], PORTD_KEYPAD_ROW);
bclr_misc_output(A3800_DISPLAY_WRITE); /* disable the display clock */
- /* _io_ports[M6811_SPDR] = 0; */
- asm volatile (
- "ldab #0\n"
- "stab %0\n"
- : "=m" (_io_ports[M6811_SPDR])
- :
- : "b"
- );
+ _io_ports[M6811_SPDR] = 0x55; /* doesn't matter what we send. */
while(!(_io_ports[M6811_SPSR]&M6811_SPIF)); /* wait for completion */
/* SPDR read to clear SPIF flag is performed below: */
i = _io_ports[M6811_SPDR];
- /* print out the row & read in key in binary */
- char msg_buf[11] = "XKXXXXXXXX";
- msg_buf[0] = row?'1':'0';
- for (j = 1, num = 0; num < 8; j = j << 1, num++) {
- msg_buf[num+2] = (i & j)?'1':'0';
- }
- set_msg(msg_buf);
-
num = 0;
- while (((i & 0x01) == 0) && (num < 8)) {
- i = i >> 1;
+ while (((i & 0x80) == 0) && (num < 8)) {
+ i = i << 1;
num++;
}