+ bclr((void*)&_io_ports[M6811_PORTD], PORTD_KEYPAD_ROW);
+
+ spi_enable();
+
+ bset_misc_output(A3800_KEYPAD_STROBE);
+ bclr_misc_output(A3800_KEYPAD_STROBE);
+
+ bclr_misc_output(A3800_DISPLAY_WRITE); /* disable the display clock */
+
+ _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];
+
+ num = 0;
+ while (((i & 0x80) == 0) && (num < 8)) {
+ i = i << 1;
+ num++;
+ }
+
+ spi_disable();
+
+ return num;