OSDN Git Service

Updated LCD controller.
authorShinichiro Nakamura <shinta.main.jp@gmail.com>
Mon, 28 May 2012 14:45:07 +0000 (23:45 +0900)
committerShinichiro Nakamura <shinta.main.jp@gmail.com>
Mon, 28 May 2012 14:45:07 +0000 (23:45 +0900)
firm/05/bootload/lcd.c
firm/05/bootload/lcd.h
firm/05/bootload/main.c

index 0c6efa6..08d42bc 100644 (file)
     *(LCD_ADDR_LEFT + LCD_AOFS_CMD) = (VAL); \
   } while (0)
 
-#define LCD1_DAT(VAL) \
+#define LCD1_DAT_WRITE(VAL) \
   do { \
     *(LCD_ADDR_LEFT + LCD_AOFS_DAT) = (VAL); \
   } while (0)
 
+#define LCD1_DAT_READ() (*(LCD_ADDR_LEFT + LCD_AOFS_DAT))
+
 #define LCD2_CMD(VAL) \
   do { \
     *(LCD_ADDR_RIGHT + LCD_AOFS_CMD) = (VAL); \
   } while (0)
 
-#define LCD2_DAT(VAL) \
+#define LCD2_DAT_WRITE(VAL) \
   do { \
     *(LCD_ADDR_RIGHT + LCD_AOFS_DAT) = (VAL); \
   } while (0)
 
+#define LCD2_DAT_READ() (*(LCD_ADDR_RIGHT + LCD_AOFS_DAT))
+
 int lcd_init(void)
 {
   *H8_3069F_P4DDR = BIT_LCD_RES;
@@ -67,20 +71,60 @@ int lcd_init(void)
 
 int lcd_clear(void)
 {
-  int c, p;
+  int p, c;
 
   for (p = 0; p <= 3; p++) {
-    LCD1_CMD(0xB8 | (p & 0x03));   // Page Address Setup
-    LCD1_CMD(0x00 | (0 & 0x7F));   // Column Address
+    LCD1_CMD(0xB8 | (p & 0x03));  // Page Address Setup
+    LCD1_CMD(0x00 | (0 & 0x7F));  // Column Address
     for (c = 0; c < 62; c++) {
-      LCD1_DAT(0);
+      LCD1_DAT_WRITE(0);
     }
 
-    LCD2_CMD(0xB8 | (p & 0x03));   // Page Address Setup
-    LCD2_CMD(0x00 | (0 & 0x7F));   // Column Address
+    LCD2_CMD(0xB8 | (p & 0x03));  // Page Address Setup
+    LCD2_CMD(0x00 | (0 & 0x7F));  // Column Address
     for (c = 0; c < 62; c++) {
-      LCD2_DAT(0);
+      LCD2_DAT_WRITE(0);
+    }
+  }
+
+  return 0;
+}
+
+int lcd_pixel(int x, int y, int on)
+{
+  volatile uint8 dat;
+  int p, c;
+
+  if (x < 62) {
+    p = y / 8;
+    c = x;
+    LCD1_CMD(0xB8 | (p & 0x03));  // Page Address Setup
+    LCD1_CMD(0x00 | (c & 0x7F));  // Column Address
+    LCD1_CMD(0xE0);
+    dat = LCD1_DAT_READ();    // Dummy Read
+    dat = LCD1_DAT_READ();    // Real Read
+    if (on) {
+      dat |= (1 << (y % 8));
+    } else {
+      dat &= ~(1 << (y % 8));
+    }
+    LCD1_DAT_WRITE(dat);
+    LCD1_CMD(0xEE);
+  } else {
+    p = y / 8;
+    c = x - 62;
+    LCD2_CMD(0xB8 | (p & 0x03));  // Page Address Setup
+    LCD2_CMD(0x00 | (c & 0x7F));  // Column Address
+    LCD2_CMD(0xE0);
+    dat = LCD2_DAT_READ();    // Dummy Read
+    dat = LCD2_DAT_READ();    // Real Read
+    if (on) {
+      dat |= (1 << (y % 8));
+    } else {
+      dat &= ~(1 << (y % 8));
     }
+    LCD2_DAT_WRITE(dat);
+    LCD2_CMD(0xEE);
   }
 
   return 0;
index 9019a85..7d27a03 100644 (file)
@@ -3,6 +3,7 @@
 
 int lcd_init(void);
 int lcd_clear(void);
+int lcd_pixel(int x, int y, int on);
 
 #endif
 
index 6a46eee..b59551c 100644 (file)
@@ -145,6 +145,10 @@ int main(void)
       if (sw_read(SwRe)) {  puts("SwRe\n"); }
     } else if (!strcmp(buf, "lcd")) {
       lcd_clear();
+      lcd_pixel(0, 0, 1);
+      lcd_pixel(1, 1, 1);
+      lcd_pixel(62, 0, 1);
+      lcd_pixel(63, 1, 1);
     } else {
       puts("unknown.\n");
     }