CVS: examples/pc_keyboard hardware.h,1.1,1.2 lcd.c,1.2,1.3 lcd.h,1.1,1.2 main.c,1.3,1.4 makefile,1.5,1.6

Chris Liechti <[email protected]>
Newsgroups gmane.comp.hardware.texas-instruments.msp430.gcc.cvs
Message-ID <[email protected]>
Update of /cvsroot/mspgcc/examples/pc_keyboard
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2437/examples/pc_keyboard

Modified Files:
	hardware.h lcd.c lcd.h main.c makefile 
Log Message:
updated implementation

Index: hardware.h
===================================================================
RCS file: /cvsroot/mspgcc/examples/pc_keyboard/hardware.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -d -r1.1 -r1.2
--- hardware.h	8 Jul 2002 20:05:38 -0000	1.1
+++ hardware.h	26 Dec 2005 20:41:05 -0000	1.2
@@ -30,7 +30,8 @@
 #define LCDIN           P3IN
 //customize this if your MSP runs at different speed.
 #define LCDDELAY1MS     750                     // ~1ms @750kHz
-
+#define LCD_4LINETYPE
+#define LCD_EXTRA
 
 //Port Output Register 'P1OUT, P2OUT':
 #define P1OUT_INIT      0                       // Init Output data of port1

Index: lcd.c
===================================================================
RCS file: /cvsroot/mspgcc/examples/pc_keyboard/lcd.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -d -r1.2 -r1.3
--- lcd.c	10 Oct 2003 00:06:39 -0000	1.2
+++ lcd.c	26 Dec 2005 20:41:05 -0000	1.3
@@ -53,7 +53,7 @@
     LCDOUT  = 0;                //reset pins
     lcdDelay(LCDDELAY1MS*30);   //wait more than 30ms
     //send the reset sequece (3 times the same pattern)
-    LCDOUT  = LCD8BITS;         //set 8 bit interface
+    LCDOUT  = LCD_8BITS;        //set 8 bit interface
     LCDOUT |= LCD_E;            //toggle LCD_E, the enable pin
     LCDOUT &= ~LCD_E;           //back to inactive position
     lcdDelay(LCDDELAY1MS*5);    //wait a bit
@@ -64,7 +64,7 @@
     LCDOUT &= ~LCD_E;           //back to inactive position
     lcdDelay(LCDDELAY1MS*5);    //wait until instr is finished
 
-    LCDOUT  = LCD4BITS;         //now set up the 4 bit interface
+    LCDOUT  = LCD_4BITS;        //now set up the 4 bit interface
     LCDOUT |= LCD_E;            //toggle LCD_E, the enable pin
     LCDOUT &= ~LCD_E;           //back to inactive position
     lcdBusy();                  //wait until instr is finished
@@ -130,6 +130,27 @@
 }
 
 /**
+Read one character from the LCD
+*/
+unsigned char lcdGetchar(void)
+{
+    unsigned char c ;
+    LCDDIR = (char)~(LCD_D4|LCD_D5|LCD_D6|LCD_D7); //
+    LCDOUT = LCD_RW|LCD_RS;      //read out data
+    //read out the high nibble with the BF flag
+    LCDOUT |= LCD_E;        //toggle LCD_E, the enable pin
+    nop();
+    c = (LCDIN & 0xf0);
+    LCDOUT &= ~LCD_E;       //back to inactive position
+    //read out the low nibble, ignore it
+    LCDOUT |= LCD_E;        //toggle LCD_E, the enable pin
+    c |= (LCDIN & 0xf0) >> 4;
+    LCDOUT &= ~LCD_E;       //back to inactive position
+    LCDDIR = LCD_D4|LCD_D5|LCD_D6|LCD_D7|LCD_E|LCD_RW|LCD_RS;
+    return c;
+}
+
+/**
 Initialize the display with two lines, cursor hidden and clear
 display.
 
@@ -137,12 +158,37 @@
 this function to complete the display setup.
 */
 void lcdInit( void ) {
-    lcdInstr(LCD2LINES);        //set 2 lines display
-    lcdInstr(LCDCURSOROFF);     //hide cursor
-    lcdInstr(LCDCLEAR);         //clear display
+    #ifdef LCD_4LINETYPE
+        // select the extension register (set RE bit)
+        lcdInstr(LCD_FUNCTIONSET | LCD_RE_BIT);
+        // set the 4-line display mode
+        lcdInstr(LCD_EXT_FUNCTIONSET | LCD_4LINES);
+        // clear RE bit
+        lcdInstr(LCD_FUNCTIONSET);
+    #else
+        // set the 2-line display mode
+        lcdInstr(LCD_FUNCTIONSET | LCD_2LINES);
+    #endif
+    lcdInstr(LCD_CURSOROFF);     //hide cursor
+    lcdInstr(LCD_CLEAR);         //clear display
 }
 
 /**
+Unspecific delay function (busy wait type).
+this small assembler bit does not need any C init etc. so
+we can use the attribute "naked"
+*/
+__attribute__ ((naked)) void lcdDelay(unsigned int n) {
+    //first arg comes in register R15
+    //the loop uses 3 cycles per round
+    //the eight cycles come from the call overhead and ret
+    //
+    //delay_time = (1/MCLK)*(8+(3*n))
+    asm("lcdloop: dec %0\n  jnz lcdloop\n ret" :: "r" (n));
+}
+
+#ifdef LCD_EXTRA
+/**
 Write a string in CGRAM or DDRAM of display controller. It uses
 NULL terminated strings, whitch is usual in C code.
 
@@ -159,18 +205,6 @@
 }
 
 /**
-Unspecific delay function (busy wait type).
-*/
-void __attribute__ ((naked)) lcdDelay(unsigned int n) {
-    //first arg comes in register R15
-    //the loop uses 3 cycles per round
-    //the eight cycles come from the call overhad ond ret
-    //
-    //delay_time = (1/MCLK)*(8+(3*n))
-    asm("lcdloop: dec r15\n  jnz lcdloop\n ret");
-}
-
-/**
 Write font data in CGRAM. This function is intended to download the
 user definable characters to the display. These are 8 bytes per
 characte and our display has eight free programmable characters. This
@@ -221,9 +255,11 @@
 */
 void lcdDownloadFont(const void * fontdata, int size) {
     int i;
-    lcdInstr(LCDCGADRSET);
+    lcdInstr(LCD_CGRAM);
     for (i = 0; i<size; i++) {
         lcdPutc(((unsigned char *)fontdata)[i]);
     }
-    lcdInstr(LCDLINE1);         //just in case, set cursor to a visible pos
+    lcdInstr(LCD_DDRAM);         //just in case, set cursor to a visible pos
 }
+
+#endif //LCD_EXTRA

Index: lcd.h
===================================================================
RCS file: /cvsroot/mspgcc/examples/pc_keyboard/lcd.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -d -r1.1 -r1.2
--- lcd.h	8 Jul 2002 20:05:38 -0000	1.1
+++ lcd.h	26 Dec 2005 20:41:05 -0000	1.2
@@ -11,61 +11,89 @@
 <B>IMPORTANT:</B> <code>lcdDelay(LCDDELAY2)</code> must be called after
 this instruction because the display contoller needs some additional time.
 */
-#define LCDON         0x01 //0x00000001 //Switch on  display
-#define LCDOFF        0x08 //0x00001000 //Switch off display
+#define LCD_ON              0x01 //0x00000001 //Switch on  display
+#define LCD_OFF             0x08 //0x00001000 //Switch off display
 
 //#define LCDEMODE      0x06 //0x00000110
 //#define LCDFONT       0x21 //0x00100001
 
-/** Clear the display. As this function is exactly the same as "Switch on display",
-it needs the same precautions:
-IMPORTANT:> lcdDelay(LCDDELAY2) must be called after
-this instruction because the display contoller needs some additional time.
-*/
-#define LCDCLEAR      0x01 //0x00000001
+/** Clear the display. */
+#define LCD_CLEAR           0x01 //0x00000001
 
 /** Place cursor on a specific display line. The horizontal offset
 can be added: LCDLINEx + xoffset. As the line length is limited,
 the horizontal offset must not be greater 64
 */
-#define LCDLINE1      0x80 //0x10000000
-#define LCDLINE2      0xc0 //0x11000000
+#ifdef LCD_4LINETYPE
+    //~ #message "lcd.h: 4 Line LCD selected"
+    // 4 line display
+    #define LCD_LINE1       0x80                    ///< Address offset for 1st line in 4-line display mode
+    #define LCD_LINE2       0xa0                    ///< Address offset for 2nd line in 4-line display mode
+    #define LCD_LINE3       0xc0                    ///< Address offset for 3rd line in 4-line display mode
+    #define LCD_LINE4       0xe0                    ///< Address offset for 4th line in 4-line display mode
+    #define LCD_LINEWIDTH   0x20                    ///< Specify the line with in 4-line display mode
+#else   // LCD_4LINETYPE
+    //~ #message "lcd.h: 2 Line LCD selected"
+    // 2 line display
+    #define LCD_LINE1       0x80                    ///< Address offset for 1st line in 2-line display mode
+    #define LCD_LINE2       0xc0                    ///< Address offset for 2nd line in 2-line display mode
+    #define LCD_LINEWIDTH   0x40                    ///< Specify the line with in 2-line display mode
+#endif  // LCD_4LINETYPE
 
 /** Cursor modes.
 */
-#define LCDCURSORON   0x0f //0x00001111 //turn on cursor blinking
-#define LCDCURSOROFF  0x0c //0x00001100 //Disable cursor blinking. The cursor is hidden.
-
-/** Set address pointer in CGRAM. An offset can be added:
-<code>LCDCGADRSET + offset</code>. As the CGRAM is limited to 64 bytes, the
-offset must not exeed 64.
-*/
-#define LCDCGADRSET   0x40 //0b01000000
+#define LCD_CURSORON        0x0f //0x00001111 //turn on cursor blinking
+#define LCD_CURSOROFF       0x0c //0x00001100 //Disable cursor blinking. The cursor is hidden.
 
-/** Set address pointer in DDRAM. An offset can be added:
-<code>LCDDDADRSET + offset</code>. As the CGRAM is limited to 128 bytes, the
-offset must not exeed 128.
-For code redability and ease of use the <code>LCDLINEx</code> command should be
-sed!
-*/
-#define LCDDDADRSET   0x80 //0b10000000
 
 /** these are used for the LCD init and module internally
 */
-#define LCD2LINES     0x28 //0b00101000 //Set display mode to two lines.
 //Bitpatters for LCDOUT
-#define LCD8BITS      0x30 //0b00110000 //select 8 Bit interface
-#define LCD4BITS      0x20 //0b00100000 //select 4 Bit interface
+#define LCD_8BITS           0x30 //0b00110000 //select 8 Bit interface
+#define LCD_4BITS           0x20 //0b00100000 //select 4 Bit interface
 #define LCD_DATA_OFF  0x05 //0x00000101 //mask used to clear the data lines
 
+//some instructions
+#define LCD_FUNCTIONSET     0x20                    ///< LCD function set instruction
+#define LCD_2LINES          0x08                    ///< Bitmask for the \c LCD_FUNCTIONSET to set the 2-line display mode
+#define LCD_RE_BIT          0x04                    ///< Bitmask for the \c LCD_FUNCTIONSET to select the extension register (set RE bit)
+
+#define LCD_EXT_FUNCTIONSET 0x08                    ///< LCD extended function set instruction
+#define LCD_4LINES          0x01                    ///< Bitmask for the \c LCD_EXT_FUNCTIONSET to set the 4-line display mode
+
+#define LCD_DISP_CTRL       0x08                    ///< LCD ON/OFF control instruction
+#define LCD_DISP_ON         0x04                    ///< Bitmask for the \c LCD_DISP_CTRL to turn on the display (visible).
+
+#define LCD_ENTRYMODE       0x04                    ///< LCD entry mode set
+#define LCD_INC             0x02                    ///< Bitmask for the #LCD_ENTRYMODE to set the cursor moving direction
+
+#define LCD_CLEAR           0x01                    /**< Instruction to clear the display.
+                                                    @note This instructions use much more execution time then an other instruction.
+                                                    @warning The data book says not more then 1.53ms but in fact its 2ms.
+                                                    Call <code>lcdDelay(LCD_DELAY_2MS)</code> after using this instruction! */
+
+#define LCD_HOME            0x02                    /**< Instruction to set the cursor to the home position.
+                                                    @note This instructions use much more execution time then an other instruction.
+                                                    @warning The data book says not more then 1.53ms but in fact its 2ms.
+                                                    Call <code>lcdDelay(LCD_DELAY_2M)</code> after using this instruction! */
+
+#define LCD_CGRAM           0x40                    /**< Set the address pointer in CGRAM. An additionally offset can be added.
+                                                    @note The CGRAM is limited to 64 bytes. The offset can not exeed 64. */
+
+#define LCD_DDRAM           0x80                    /**< Set the address pointer in DDRAM. An additionally offset can be added.
+                                                    For direct access to the individual lines use the definitions like #LCD_LINE1.
+                                                    @note The DDRAM is limited to 128 bytes. The offset can not exeed 128. */
+
 //forward declarations
 void lcdOn( void );
 void lcdInstr( char cmd );
 void lcdPutc( char c );
 void lcdInit( void );
-void lcdPuts( char * str );
 void lcdDelay(unsigned int d);
+#ifdef LCD_EXTRA
+void lcdPuts( char * str );
 void lcdDownloadFont( const void * fontdata, int size);
+#endif //LCD_EXTRA
 
 #endif /*LCD_H*/
 

Index: main.c
===================================================================
RCS file: /cvsroot/mspgcc/examples/pc_keyboard/main.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -d -r1.3 -r1.4
--- main.c	10 Oct 2003 00:06:39 -0000	1.3
+++ main.c	26 Dec 2005 20:41:05 -0000	1.4
@@ -8,6 +8,11 @@
 #include <stdio.h>
 #include "lcd.h"
 
+int putchar(int c) {
+    lcdPutc(c);
+    return 1;
+}
+
 //the font file has no separate header file, it just provides
 //the font in this array:
 extern const char lcdfont[64];
@@ -21,6 +26,7 @@
 
 #define SHIFTED (1<<0)
 #define ALTERED (1<<1)
+#define CONTROLLED (1<<2)
 
 const keytranslation keymap[] = {
     {0x1c, 'a', 'A'},
@@ -88,11 +94,6 @@
     return 0;
 }
 
-//redirect stdio looking funcs to LCD
-#define printf(format, args...) uprintf(lcdPutc, format, args)
-#define puts            lcdPuts
-#define putc            lcdPutc
-
 //global vars to store the time
 int h, m, s;
 
@@ -127,36 +128,31 @@
 }
 
 
-#define CLK_HI  P2DIR &= ~CLK
-#define CLK_LO  P2DIR |= CLK
-#define DAT_HI  P2DIR &= ~DAT
-#define DAT_LO  P2DIR |= DAT
-#define WAIT_NEG_PULSE  while ((P2IN & CLK) != 0); while ((P2IN & CLK) == 0)
-#define WAIT_NEG  while ((P2IN & CLK) != 0)
-#define WAIT_POS  while ((P2IN & CLK) == 0)
-#define HIGHLOW   while ((P2IN & CLK) == 0); while ((P2IN & CLK) != 0)
-
 char rawqueue[8];      //store raw scancodes
 int  rawq_start;
 int  rawq_end;
 
 wakeup interrupt (PORT2_VECTOR) INT_P2(void) {
-    unsigned char key = 0;
-    int i;
-    WAIT_POS;             //wait until startbit is finished
-    for (i=0; i<8; i++) {
-        WAIT_NEG;
-        key >>= 1;
-        key |= (P2IN & DAT) ? 0x80 : 0;
-        WAIT_POS;
-    }
-    WAIT_NEG;               //wait for parity
-    //p = (P2IN & DAT) ? 0x80 : 0;
-    WAIT_POS;
-    WAIT_NEG;               //wait for stop bit
-    //WAIT_POS;
-    rawqueue[rawq_end] = key;
+    static unsigned char bit = 0;
+    static unsigned short code;
+    switch (bit++) {
+        case 0: //startbit
+            code = 0;
+            if (P2IN & DAT) bit = 0;
+            break;
+        case 1 ... 8:   //data
+            code >>= 1;
+            code |= (P2IN & DAT) ? 0x80 : 0;
+            break;
+        case 9: //parity
+            break;
+        case 10:
+            rawqueue[rawq_end] = code;
     if (++rawq_end >= sizeof(rawqueue)) rawq_end = 0;
+            bit = 0;
+            _BIC_SR_IRQ(LPM0_bits);
+            break;
+    }
     P2IFG &= ~(CLK|DAT);
 }
 
@@ -167,6 +163,10 @@
 
 #define RELEASE         0x8000
 #define SPECIALKEY      0x4000
+#define EXTENDED        0x2000
+#define X_CONTROLLED    0x0400
+#define X_ALTERED       0x0200
+#define X_SHIFTED       0x0100
 #define CAPS    (SPECIALKEY|0x58)
 #define F1      (SPECIALKEY|0x05)
 #define F2      (SPECIALKEY|0x06)
@@ -180,9 +180,14 @@
 #define F10     (SPECIALKEY|0x09)
 #define F11     (SPECIALKEY|0x78)
 #define F12     (SPECIALKEY|0x07)
+#define ARROW_UP        (SPECIALKEY|EXTENDED|0x75)
+#define ARROW_DOWN      (SPECIALKEY|EXTENDED|0x72)
+#define ARROW_LEFT      (SPECIALKEY|EXTENDED|0x6b)
+#define ARROW_RIGHT     (SPECIALKEY|EXTENDED|0x74)
 void processRawq(void) {
-    static int mode = 0;
-    static int nextrelease = 0;
+    static char mode = 0;
+    static char nextrelease = 0;
+    static char extended = 0;
     
     while (rawq_start != rawq_end) { //queue not empty
         unsigned char key;
@@ -198,6 +203,14 @@
             case 0xf0: //release key
                 nextrelease = 1;
                 break;
+            case 0x14: //control key
+                if (nextrelease) {
+                    mode &= ~CONTROLLED;
+                } else {
+                    mode |= CONTROLLED;
+                }
+                nextrelease = 0;
+                break;
             case 0x12: //left SHIFT
             case 0x59: //right SHIFT
                 if (nextrelease) {
@@ -207,7 +220,7 @@
                 }
                 nextrelease = 0;
                 break;
-            case 0x11: //left ALT
+            case 0x11: //left and right ALT (right one also with E0)
                 if (nextrelease) {
                     mode &= ~ALTERED;
                 } else {
@@ -215,8 +228,13 @@
                 }
                 nextrelease = 0;
                 break;
+            case 0xe0:  //extended key following
+                extended = 1;
+                break;
             default:
-                if (nextrelease) flags = RELEASE;
+                if (nextrelease) flags |= RELEASE;
+                if (extended) flags |= EXTENDED;
+                flags |= mode << 8;
                 c = findkey(key, mode);
                 if (c) {
                     queue[q_end] = c | flags;
@@ -225,6 +243,8 @@
                 }
                 if (++q_end >= QSIZE) q_end = 0;
                 nextrelease = 0;
+                extended = 0;
+                break;
         }
     }
 }
@@ -238,17 +258,35 @@
     return c;
 }
 
+#define CLK_HI  P2DIR &= ~CLK
+#define CLK_LO  P2DIR |= CLK
+#define DAT_HI  P2DIR &= ~DAT
+#define DAT_LO  P2DIR |= DAT
+#define WAIT_NEG_PULSE  while ((P2IN & CLK) != 0); while ((P2IN & CLK) == 0)
+#define WAIT_NEG  while ((P2IN & CLK) != 0)
+#define WAIT_POS  while ((P2IN & CLK) == 0)
+#define HIGHLOW   while ((P2IN & CLK) == 0); while ((P2IN & CLK) != 0)
+    //~ while (!(P2IFG & CLK)) {}
+    //~ P2IFG &= ~CLK;
+
 void sendkeyb(char cmd) {
     int i;
     int p = 0;
+    P1OUT |= BIT1;              //debug
     //port as output
+    dint(); nop();
     P2IE  &= ~CLK;              //disable irqs while sending
     P2OUT &= ~(CLK|DAT);        //make sure the out reg is 0
+    eint();
+    //~ P2IES &= ~CLK;
+    //~ P2IFG &= ~CLK;
     //clk pulse
+    P1OUT |= BIT0;              //debug
     CLK_LO;
-    delay(10);
+    delay(100);
     DAT_LO;
     CLK_HI;
+    P1OUT &= ~BIT0;              //debug
     //startbit
     HIGHLOW;
     //data
@@ -273,35 +311,53 @@
     DAT_HI;        //that's it, wait for ACK
     HIGHLOW;               //stop bit from keyb
     //wait for ack
-    while ((P2IN & CLK) != 0) ;
-    if (P2IN & DAT) {
-        //blink once
-        P2OUT |= LED;
-        delay(1000);
-        P2OUT &= ~LED;
-    } else {
-        //blink twice
-        P2OUT |= LED;
-        delay(1000);
-        P2OUT &= ~LED;
-        delay(10000);
-        P2OUT |= LED;
-        delay(1000);
-        P2OUT &= ~LED;
-    }
-    while ((P2IN & CLK) == 0) ;
+    //~ while ((P2IN & CLK) != 0) ;
+    //~ if (P2IN & DAT) {
+        //~ //blink once
+        //~ P2OUT |= LED;
+        //~ delay(1000);
+        //~ P2OUT &= ~LED;
+    //~ } else {
+        //~ //blink twice
+        //~ P2OUT |= LED;
+        //~ delay(1000);
+        //~ P2OUT &= ~LED;
+        //~ delay(10000);
+        //~ P2OUT |= LED;
+        //~ delay(1000);
+        //~ P2OUT &= ~LED;
+    //~ }
+    //~ while ((P2IN & CLK) == 0) ;
+    WAIT_POS;
 
+    //~ P2IES |= CLK;
+    P1OUT &= ~BIT1;              //debug
     //restore interrupt handler function
+    dint(); nop();
     P2IFG &= ~CLK;
     P2IE |= CLK;
+    eint();
 }
 
-
+#define LED_CAPS_LOCK   BIT2
+#define LED_NUM_LOCK    BIT1
+#define LED_SCROLL_LOCK BIT0
+void setLed(unsigned char led, unsigned char state) {
+    static unsigned char leds = 0;
+    if (state) {
+        leds |= led;
+    } else {
+        leds &= ~led;
+    }
+    sendkeyb(0xed);
+    sendkeyb(leds);
+}
 /**
 Main function with ...
 */
 int main(void) {
-    int i = 0, cursor=0;
+    int cursor=0;
+    int caps = 0;
     unsigned int c;
 
     WDTCTL = WDTCTL_INIT;               //Init watchdog timer
@@ -323,6 +379,9 @@
     P1IE   = P1IE_INIT;
     P2IE   = P2IE_INIT;
 
+    BCSCTL1 = XT2OFF|DIVA1|RSEL2|RSEL1|RSEL0;
+    BCSCTL2 = 0;
+
     BCSCTL1 |= DIVA0 | DIVA1;           //setup divider for RTC
     TACTL  = TACTL_INIT;                //setup timer (still stopped)
     CCR0   = ONESECOND;                 //setup first RTC irq
@@ -338,45 +397,61 @@
     lcdInit();                          //setup LCD modes
     P2OUT &= ~LED;                      //switch off LED
 
-    sendkeyb(0xed);
-    delay(1000);
-    sendkeyb(BIT0|BIT1);
     puts("AT keyboard demo");           //say hello
+    setLed(LED_SCROLL_LOCK, 1);
 
     while (1) {                         //main loop, never ends...
-        lcdInstr(LCDLINE2);
+        lcdInstr(LCD_LINE2);
         //show the clock
         //as we are synced with the interrupt, its save to read h,m,s
         //otherwise a dint..eint around the following line would be
         //very helpful to prevent bogus values
         printf("%02d:%02d:%02d", h, m, s);
-        //now show the bargraph. it hasn't to do much with a clock
-        //but we want to show the feature here...
-        lcdInstr(LCDLINE2+15);
-        putc(i);
-        if (++i >= 8) i = 0;            //lets show all 8 downloadable chars
-        LPM0;                           //sync, wakeup by irq
+        if (rawq_start == rawq_end) LPM0;                  //sync, wakeup by irq
         processRawq();
         while( (c = getkey()) ) {
-            lcdInstr(LCDLINE2+10);
+            lcdInstr(LCD_LINE2+10);
             printf("%04x", c);
             if ((c >> 8) == 0) {
-                lcdInstr(LCDLINE1 + cursor);
-                if (++cursor >= 16) cursor = 0;
-                putc(c);
+                lcdInstr(LCD_LINE1 + cursor);
+                putchar(c);
+                if (++cursor >= 20) cursor = 0;
+                lcdInstr(LCD_LINE3);
             } else {
-                switch (c) {
+                lcdInstr(LCD_LINE3);
+                switch (c & ~(X_ALTERED|X_SHIFTED|RELEASE)) {
                     case CAPS:
-                        sendkeyb(0xed);
-                        delay(1000);
-                        sendkeyb((s & 1) ? (BIT0|BIT1) : 0);
+                        if (c & RELEASE) {
+                            caps = !caps;
+                            setLed(LED_CAPS_LOCK, caps);
+                        }
                         break;
                     case F1:
-                        lcdInstr(LCDLINE1);
+                        lcdInstr(LCD_LINE1);
                         puts("                ");
                         cursor = 0;
+                    case F2:
+                        setLed(LED_SCROLL_LOCK, 1);
+                        break;
+                    case F3:
+                        setLed(LED_SCROLL_LOCK, 0);
+                        break;
+                    case F4:
+                        setLed(LED_NUM_LOCK, !(c&RELEASE));
+                        break;
+                    case ARROW_UP: lcdPuts("up"); break;
+                    case ARROW_DOWN: lcdPuts("dn"); break;
+                    case ARROW_LEFT: lcdPuts("<-"); break;
+                    case ARROW_RIGHT: lcdPuts("->"); break;
                 }
             }
+            if (c & RELEASE) lcdPuts("rel");
+            lcdPuts("        ");
+            lcdInstr(LCD_LINE4);
+            if (c & X_SHIFTED) lcdPuts("shift ");
+            if (c & X_ALTERED) lcdPuts("alt");
+            if (c & X_CONTROLLED) lcdPuts("ctrl");
+            lcdPuts("             ");
         }
         //lcdInstr(LCDLINE2+12);
         //printf("%02x", key);

Index: makefile
===================================================================
RCS file: /cvsroot/mspgcc/examples/pc_keyboard/makefile,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -w -d -r1.5 -r1.6
--- makefile	8 Jun 2004 07:05:28 -0000	1.5
+++ makefile	26 Dec 2005 20:41:05 -0000	1.6
@@ -1,7 +1,7 @@
 # makfile configuration
 NAME            = keyboard
 OBJECTS         = main.o lcd.o
-CPU             = msp430x123
+CPU             = msp430x148
 
 CFLAGS          = -mmcu=${CPU} -O2 -Wall -g
 



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.