summaryrefslogtreecommitdiff
path: root/fw/fe310/eos/lcd.c
diff options
context:
space:
mode:
Diffstat (limited to 'fw/fe310/eos/lcd.c')
-rw-r--r--fw/fe310/eos/lcd.c70
1 files changed, 47 insertions, 23 deletions
diff --git a/fw/fe310/eos/lcd.c b/fw/fe310/eos/lcd.c
index cf09018..3080a13 100644
--- a/fw/fe310/eos/lcd.c
+++ b/fw/fe310/eos/lcd.c
@@ -1,5 +1,7 @@
#include <stdlib.h>
#include <stdint.h>
+#include <string.h>
+#include <stdio.h>
#include "encoding.h"
#include "platform.h"
@@ -91,62 +93,84 @@ void eos_lcd_read(uint8_t *data) {
static int _init(void) {
int rv;
+ uint8_t chip_id[3];
rv = eos_lcd_select();
if (rv) return rv;
eos_lcd_cs_set();
/* LCD Setting */
- eos_lcd_write(0, 0xFF); // change to Page 1 CMD
+ eos_lcd_write(0, 0xFF); // change to Page 1 CMD
eos_lcd_write(1, 0xFF);
eos_lcd_write(1, 0x98);
eos_lcd_write(1, 0x06);
eos_lcd_write(1, 0x04);
eos_lcd_write(1, 0x01);
- // eos_lcd_write(0, 0x08); // Output SDA
+ // eos_lcd_write(0, 0x08); // Output SDA
// eos_lcd_write(1, 0x10);
- eos_lcd_write(0, 0x20); // set DE/VSYNC mode
+ eos_lcd_write(0, 0xFE); // enable read
+ eos_lcd_write(1, 0x81);
+
+ eos_lcd_write(0, 0x00); // RDID4
+ eos_lcd_read(&chip_id[0]);
+
+ eos_lcd_write(0, 0x01);
+ eos_lcd_read(&chip_id[1]);
+
+ eos_lcd_write(0, 0x02);
+ eos_lcd_read(&chip_id[2]);
+
+ printf("LCD CHIP ID: %.2x%.2x%.2x\n", chip_id[0], chip_id[1], chip_id[2]);
+
+ eos_lcd_write(0, 0xFE); // disable read
+ eos_lcd_write(1, 0x00);
+
+ if (memcmp(chip_id, "\x98\x06\x04", sizeof(chip_id))) {
+ return EOS_ERR_ABSENT;
+ }
+
+ eos_lcd_write(0, 0x20); // set DE/VSYNC mode
eos_lcd_write(1, 0x00);
- eos_lcd_write(0, 0x21); // DE = 1 Active
+ eos_lcd_write(0, 0x21); // DE = 1 Active
eos_lcd_write(1, 0x01);
- eos_lcd_write(0, 0x30); // resolution setting 480 X 854
+ eos_lcd_write(0, 0x30); // resolution setting 480 X 854
eos_lcd_write(1, 0x01);
- eos_lcd_write(0, 0x31); // inversion setting 2-dot
+ eos_lcd_write(0, 0x31); // inversion setting 2-dot
eos_lcd_write(1, 0x00);
- eos_lcd_write(0, 0x40); // BT AVDD,AVDD
+ eos_lcd_write(0, 0x40); // BT AVDD,AVDD
eos_lcd_write(1, 0x16);
eos_lcd_write(0, 0x41);
- eos_lcd_write(1, 0x33); // 22
+ eos_lcd_write(1, 0x33); // 22
eos_lcd_write(0, 0x42);
- eos_lcd_write(1, 0x03); // VGL=DDVDH+VCIP-DDVDL, VGH=2DDVDL-VCIP
+ eos_lcd_write(1, 0x03); // VGL=DDVDH+VCIP-DDVDL, VGH=2DDVDL-VCIP
eos_lcd_write(0, 0x43);
- eos_lcd_write(1, 0x09); // set VGH clamp level
+ eos_lcd_write(1, 0x09); // set VGH clamp level
eos_lcd_write(0, 0x44);
- eos_lcd_write(1, 0x06); // set VGL clamp level
+ eos_lcd_write(1, 0x06); // set VGL clamp level
- eos_lcd_write(0, 0x50); // VREG1
+ eos_lcd_write(0, 0x50); // VREG1
eos_lcd_write(1, 0x88);
- eos_lcd_write(0, 0x51); // VREG2
+ eos_lcd_write(0, 0x51); // VREG2
eos_lcd_write(1, 0x88);
- eos_lcd_write(0, 0x52); // flicker MSB
+ eos_lcd_write(0, 0x52); // flicker MSB
eos_lcd_write(1, 0x00);
- eos_lcd_write(0, 0x53); // flicker LSB
- eos_lcd_write(1, 0x49); // VCOM
+ eos_lcd_write(0, 0x53); // flicker LSB
+ eos_lcd_write(1, 0x49); // VCOM
- eos_lcd_write(0, 0x55); // flicker
+ eos_lcd_write(0, 0x55); // flicker
eos_lcd_write(1, 0x49);
eos_lcd_write(0, 0x60);
@@ -162,7 +186,7 @@ static int _init(void) {
eos_lcd_write(1, 0x00);
/* Gamma Setting */
- eos_lcd_write(0, 0xA0); // positive Gamma
+ eos_lcd_write(0, 0xA0); // positive Gamma
eos_lcd_write(1, 0x00);
eos_lcd_write(0, 0xA1);
@@ -210,7 +234,7 @@ static int _init(void) {
eos_lcd_write(0, 0xAF);
eos_lcd_write(1, 0x00);
- eos_lcd_write(0, 0xC0); // negative Gamma
+ eos_lcd_write(0, 0xC0); // negative Gamma
eos_lcd_write(1, 0x00);
eos_lcd_write(0, 0xC1);
@@ -258,7 +282,7 @@ static int _init(void) {
eos_lcd_write(0, 0xCF);
eos_lcd_write(1, 0x00);
- eos_lcd_write(0, 0xFF); // change to Page 6 CMD for GIP timing
+ eos_lcd_write(0, 0xFF); // change to Page 6 CMD for GIP timing
eos_lcd_write(1, 0xFF);
eos_lcd_write(1, 0x98);
eos_lcd_write(1, 0x06);
@@ -430,7 +454,7 @@ static int _init(void) {
eos_lcd_write(0, 0x40);
eos_lcd_write(1, 0x22);
- eos_lcd_write(0, 0xFF); // change to Page 7 CMD for GIP timing
+ eos_lcd_write(0, 0xFF); // change to Page 7 CMD for GIP timing
eos_lcd_write(1, 0xFF);
eos_lcd_write(1, 0x98);
eos_lcd_write(1, 0x06);
@@ -446,7 +470,7 @@ static int _init(void) {
eos_lcd_write(0, 0x26);
eos_lcd_write(1, 0xB2);
- eos_lcd_write(0, 0xFF); // change to Page 0 CMD for normal command
+ eos_lcd_write(0, 0xFF); // change to Page 0 CMD for normal command
eos_lcd_write(1, 0xFF);
eos_lcd_write(1, 0x98);
eos_lcd_write(1, 0x06);
@@ -454,7 +478,7 @@ static int _init(void) {
eos_lcd_write(1, 0x00);
eos_lcd_write(0, 0x3A);
- eos_lcd_write(1, 0x70); // 24BIT
+ eos_lcd_write(1, 0x70); // 24BIT
eos_lcd_write(0, 0x11);
eos_time_sleep(120);