Docsity

Changing Typematic Rate-System Programming-Lecture Notes, Study notes of System Programming

Toggle sidebar
bg1
Lecture # 22
Using the described information we can design a protocol for correctly writing on the
keyboard device as described below.
Keyboard writing Protocol
•Wait till input buffer is full
•Write on buffer
•Wait till output buffer is full
•Check the acknowledgement byte
•Repeat the process if it was previously
unsuccessful.
Keyboard is a typically an input device but some data can also be send to the keyboard
device. This data is used as some control information by the keyboard. One such
information is the typematic rate. This type matic rate can be conveyed to the keyboard as
described by the slide below.
Command for writing Typematic rate
0xF3
Means Typematic rate will be sent in the
next byte.
docsity.com
pf3
pf4
pf5

Partial preview of the text

Download Changing Typematic Rate-System Programming-Lecture Notes and more Study notes System Programming in PDF only on Docsity!

Lecture # 22

Using the described information we can design a protocol for correctly writing on the

keyboard device as described below.

Keyboard writing Protocol

  • Wait till input buffer is full
  • Write on buffer
  • Wait till output buffer is full
  • Check the acknowledgement byte
  • Repeat the process if it was previously

unsuccessful.

Keyboard is a typically an input device but some data can also be send to the keyboard

device. This data is used as some control information by the keyboard. One such

information is the typematic rate. This type matic rate can be conveyed to the keyboard as

described by the slide below.

Command for writing Typematic rate

Means Typematic rate will be sent in the

next byte.

Other such control information is the LED status. Every keyboard has three LEDs for

representing the status of Num Lock, Caps Lock and the Scroll Lock. If the device driver

needs to change the status then the LED status byte should be written on the keyboard as

described below. But before writing this byte the keyboard should be told that the control

byte is to be written. This is done by sending the code 0XED before sending the status

byte using the above described protocol.

Keyboard LEDs

Scroll Lock

LED Status byte

Num Lock Caps Lock

LED Control byte = 0xED

Changing Typematic Rate

#include <dos.h> #include <conio.h> char st [80]; int SendKbdRate(unsigned char data , int maxtry) { unsigned char ch; do{ do{ ch=inport(0x64); }while (ch&0x02); outport(0x60,data); do{ ch = inport(0x64); }while (ch&0x01);

Now this function is used to change the typematic rate. Firstly 0XF3 is written to indicate

that the typematic rate is to be changed then the typematic rate is set to 0x7F and a strng

can be type to experience the new typematic rate. Again this rate is set to 0. This program

will not work if you have booted the system in windows. First boot the system in DOS

and then run this program.

Changing LEDs Status

#include <bios.h> #include <dos.h> char st [80]; unsigned char far *kbd = (unsigned char far *) 0x00400017; int SendKbdRate(unsigned char data , int maxtry) { unsigned char ch; do{ do{ ch=inport(0x64); }while (ch&0x02); outport(0x60,data);

do{ ch = inport(0x64); }while (ch&0x01); ch=inport(0x60); if (ch==0xfa) { puts("success\n"); break; } maxtry = maxtry - 1; } while (maxtry != 0); if (maxtry==0) return 1; else return 0; }

void main () { //clrscr(); SendKbdRate(0xed,3); SendKbdRate(0x7,3); puts("Enter a string "); gets(st); kbd=(kbd )|0x70; puts("Enter a string "); gets(st); }

Again the same function is being used in this program to turn on the keyboard LEDs.

Firstly 0xED is sent to indicate the operation and then 7 is written to turn on all the

LEDs. But tuning on the LEDs like this will not change the keyboard status indicated by

the byte at 40:17H. If the status for the device driver usage is to changes as well then the

corresponding at 40:17H can be set by ORing it with 0x70. This program will not work if

you have booted the system in windows. First boot the system in DOS and then run this

program.

DMA Controller

I/O Proce ssor

DMA

Main Memory