From 56670fc2120fa7773a3e569f1b2ce98222ec0a53 Mon Sep 17 00:00:00 2001 From: Damjan Adamic Date: Thu, 1 Jan 2015 09:22:50 +0100 Subject: [PATCH] Re #1963: fixes the case of power switch fast OFF->ON sequence. --- radio/src/targets/taranis/lcd_driver.cpp | 26 ++++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/radio/src/targets/taranis/lcd_driver.cpp b/radio/src/targets/taranis/lcd_driver.cpp index 1a45dc236..4518662b0 100644 --- a/radio/src/targets/taranis/lcd_driver.cpp +++ b/radio/src/targets/taranis/lcd_driver.cpp @@ -350,7 +350,11 @@ static void LCD_Hardware_Init() void lcdOff() { WAIT_FOR_DMA_END(); - AspiCmd(0xE2); //system reset + /* + LCD Sleep mode is also good for draining capacitors and enables us + to re-init LCD without any delay + */ + AspiCmd(0xAE); //LCD sleep Delay(3); //wait for caps to drain } @@ -386,27 +390,31 @@ void lcdInitFinish() initLcdSpi(); #endif - if (WAS_RESET_BY_WATCHDOG()|WAS_RESET_BY_SOFTWARE()) return; //no need to initialize LCD module - /* LCD needs longer time to initialize in low temperatures. The data-sheet mentions a time of at least 150 ms. The delay of 1300 ms was obtained experimentally. It was tested down to -10 deg Celsius. The longer initialization time seems to only be needed for regular Taranis, - the Taranis Plus has been reported by users to work without any problems. + the Taranis Plus (9XE) has been tested to work without any problems at -18 deg Celsius. Therefore the delay for T+ is lower. - If radio is reset by watchdog or boot-loader LCD initialization is skipped, - because it was already initialized in previous run. + If radio is reset by watchdog or boot-loader the wait is skipped, but the LCD + is initialized in any case. + + This initialization is needed in case the user moved power switch to OFF and + then immediately to ON position, because lcdOff() was called. In any case the LCD + initialization (without reset) is also recommended by the data sheet. */ + if (!WAS_RESET_BY_WATCHDOG() && !WAS_RESET_BY_SOFTWARE()) { #if !defined(BOOT) - while(g_tmr10ms < (RESET_WAIT_DELAY_MS/10)) {}; //wait measured from the power-on + while(g_tmr10ms < (RESET_WAIT_DELAY_MS/10)) {}; //wait measured from the power-on #else - Delay(RESET_WAIT_DELAY_MS); + Delay(RESET_WAIT_DELAY_MS); #endif - + } + LCD_Init(); AspiCmd(0xAF); //dc2=1, IC into exit SLEEP MODE, dc3=1 gray=ON, dc4=1 Green Enhanc mode disabled Delay(20); //needed for internal DC-DC converter startup