Programming with the Keyboard January 11, 1994 $Source: /u/cyliax/Projects/030/Doc/Prog/kbd.ms,v $ The keyboard is a standard IBM-AT compatible keyboard which is connected to the system via the MFP USART and parallel port. The parallel port is only used to send data to the keyboard (to control the LEDs or set the repeat rate) or to inhibit the keyboard from sending data. The keyboard uses a serial data stream to send codes. This data stream is clocked from the keyboard via the keyboard clk signal. The USART in the MFP is programmed to use a divide by 1 clk to clock in the data. The keyboard generates scan codes and other control information. Each time a key is pressed, the scan code for the location of the key is send. When the key is released, a special key-up code is send, followed by the scan code for the key that was released. The processor can also send control information to the keyboard using the same serial protocol. On our system, the data has to be serialized over the keyboard data bit on the parallel port. Each time a bit is loaded, the clk line has to be toggled. Some of the codes that can be send to the keyboard. Code Description 8 ________________________________________________________ ff reset ed xx set LED's xx -> 01 - scroll, 02 - num, 04 - caps xx xx set keyboard repeat rate Each time a command is send to the keyboard, the key- board will send a reply to indicate if the command was understood or needs to be resend. Code Description 8 _____________________________________ aa reset done fa command receive fe resend fe keyboard is flooded (overrun) f0 xx keyup, followed by scan code Sample code to display scan codes using monitor outchar service. January 11, 1994 - 2 - mfprsr equ $7f200015 * usart status register mfpdat equ $7f200017 * usart data register rcvful equ $80 * buffer full * start: btst.b #7,mfprsr beq start move.b mfpdat,d0 bsr hex2 move.l #$d,d0 bsr outchar move.l #$a,d0 bsr outchar bra start * hex2: move.b d0,d1 lsr.b #4,d0 bsr hex move.b d1,d0 bsr hex rts hex: and.l #$f,d0 move.l #hstr,a0 move.b (a0,d0),d0 bsr outchar rts * hstr: dc.b '0123456789abcdef' * outchar: trap #15 dc.w 1 rts January 11, 1994