00001 /**************************************************************************/ 00035 #include <stdbool.h> 00036 #include "em_device.h" 00037 #include "em_gpio.h" 00038 #include "em_ebi.h" 00039 #include "bsp.h" 00040 #include "tftamapped.h" 00041 /* DMD init from dmd_ssd2119_direct.c */ 00042 #include "glib/glib.h" 00043 00045 static bool runOnce = true; 00046 00047 /**************************************************************************/ 00054 bool TFT_AddressMappedInit(void) 00055 { 00056 bool ret; 00057 EMSTATUS status; 00058 uint32_t i, freq; 00059 00060 /* If we are in BC_UIF_AEM_EFM state, we can redraw graphics */ 00061 if (BSP_RegisterRead(&BC_REGISTER->UIF_AEM) == BC_UIF_AEM_EFM) 00062 { 00063 /* If we're not BC_ARB_CTRL_EBI state, we need to reconfigure display controller */ 00064 if ((BSP_RegisterRead(&BC_REGISTER->ARB_CTRL) != BC_ARB_CTRL_EBI) || runOnce) 00065 { 00066 /* Configure for EBI mode and reset display */ 00067 BSP_DisplayControl(BSP_Display_EBI); 00068 BSP_DisplayControl(BSP_Display_ResetAssert); 00069 BSP_DisplayControl(BSP_Display_PowerDisable); 00070 /* Short reset delay */ 00071 freq = SystemCoreClockGet(); 00072 for (i = 0; i < (freq / 100); i++) 00073 { 00074 __NOP(); 00075 } 00076 /* Configure display for Direct Drive + SPI mode */ 00077 BSP_DisplayControl(BSP_Display_Mode8080); 00078 BSP_DisplayControl(BSP_Display_PowerEnable); 00079 BSP_DisplayControl(BSP_Display_ResetRelease); 00080 00081 /* Initialize graphics - abort on failure */ 00082 status = DMD_init(BC_SSD2119_BASE, BC_SSD2119_BASE + 2); 00083 if ((status != DMD_OK) && (status != DMD_ERROR_DRIVER_ALREADY_INITIALIZED)) while (1) ; 00084 /* Make sure display is configured with correct rotation */ 00085 if ((status == DMD_OK)) DMD_flipDisplay(1, 1); 00086 00087 runOnce = false; 00088 } 00089 ret = true; 00090 } 00091 else 00092 { 00093 ret = false; 00094 } 00095 return ret; 00096 }