From 25c0f8ebb1f5498a4a6f78400edc988082a6b015 Mon Sep 17 00:00:00 2001 From: Akira Tsukamoto Date: Tue, 31 May 2016 17:17:43 +0900 Subject: [PATCH] LCD:jhd1313m1:HD44780 Adding workaround of errata on init HD44780 fails to initialize unsuccessfully without the workaround. Adding workaround based on HD77480 datasheet for initialization and software reset. Signed-off-by: Akira Tsukamoto Signed-off-by: Abhishek Malik --- src/lcd/jhd1313m1.cxx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/lcd/jhd1313m1.cxx b/src/lcd/jhd1313m1.cxx index f8ae980a..2063b4b8 100644 --- a/src/lcd/jhd1313m1.cxx +++ b/src/lcd/jhd1313m1.cxx @@ -46,13 +46,19 @@ Jhd1313m1::Jhd1313m1(int bus, int lcdAddress, int rgbAddress) ": I2c.address() failed"); } + /* HD44780 requires writing three times to initialize or reset + according to the hardware errata on page 45 figure 23 of + the Hitachi HD44780 datasheet */ + /* First try */ usleep(50000); - ret = command(LCD_FUNCTIONSET | LCD_2LINE); - - if (!ret) { - ret = command(LCD_FUNCTIONSET | LCD_2LINE); - UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the LCD controller"); - } + ret = command(LCD_FUNCTIONSET | LCD_8BITMODE); + /* Second try */ + usleep(4500); + ret = command(LCD_FUNCTIONSET | LCD_8BITMODE); + /* Third try */ + usleep(150); + ret = command(LCD_FUNCTIONSET | LCD_8BITMODE); + UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the LCD controller"); usleep(100); ret = displayOn();