Path: utzoo!mnetor!uunet!mcvax!ukc!stl!stc!root44!pjh From: pjh@root.co.uk (Paul Haffenden) Newsgroups: comp.os.minix Subject: Re: How do you turn on the AT's LEDs? Message-ID: <537@root44.co.uk> Date: 2 Feb 88 11:12:17 GMT References: <1832@botter.cs.vu.nl> Reply-To: pjh@root44.UUCP (Paul Haffenden) Organization: UniSoft Ltd, London, England Lines: 68 I have had a big struggle with getting the leds lights on my AT based machine. Here is the code I use. I'm running V.3 on a 386 so it may not be exactly what you want. My biggest problem is knowing when to send the command to the keyboard. I check the input buffer full bit but the keyboard will lock up if I don't have the delays in. Here it is: Keystate is a global int that indicates the state of the control keys like shift and control. The bottom three bits are used to specify the led status, so by just anding them I can load it directly into the keyboard. #define KB 0x60 #define KBSTATUS 0x64 #define LEDWRITE 0xed #define INPUTFULL 2 /* the led defines */ #define CAPSLOCK 0x04 #define NUMSET 0x02 #define SCROLLSET 0x01 /* * set up the keyboard leds. */ loadled() { int led; int x1,x2,x3; int s; int n1,n2,n3; s = spl7(); led = keystate & 0x7; x1 = 0xffff; do { tenmicrosec(); } while(((n1=inb(KBSTATUS)) & INPUTFULL) && --x1); tenmicrosec(); tenmicrosec(); tenmicrosec(); outb(KB,LEDWRITE); x2 = 0xffff; do { tenmicrosec(); } while(((n2=inb(KBSTATUS)) & INPUTFULL) && --x2); tenmicrosec(); tenmicrosec(); tenmicrosec(); outb(KB,led); tenmicrosec(); x3 = 0xffff; while(((n3=inb(KBSTATUS)) & INPUTFULL) && --x3) ; /*printf("n1 x1 0x%x 0x%x n2 x2 0x%x 0x%x n3 x3 0x%x 0x%x\n",n1,x1,n2,x2,n3,x3);*/ splx(s); } If someone knows the correct way to do it without the finger in the air delays please post it. Paul.