tftamapped.c

Go to the documentation of this file.
00001 /**************************************************************************/
00017 #include <stdbool.h>
00018 #include "em_device.h"
00019 #include "em_gpio.h"
00020 #include "em_ebi.h"
00021 #include "bsp.h"
00022 #include "tftamapped.h"
00023 /* DMD init from dmd_ssd2119_direct.c */
00024 #include "dmd/ssd2119/dmd_ssd2119.h"
00025 #include "glib/glib.h"
00026 
00028 static bool runOnce = true;
00029 
00030 /**************************************************************************/
00037 bool TFT_AddressMappedInit(void)
00038 {
00039   bool     ret;
00040   EMSTATUS status;
00041   uint32_t i, freq;
00042 
00043   /* If we are in BC_UIF_AEM_EFM state, we can redraw graphics */
00044   if (BSP_RegisterRead(&BC_REGISTER->UIF_AEM) == BC_UIF_AEM_EFM)
00045   {
00046     /* If we're not BC_ARB_CTRL_EBI state, we need to reconfigure display controller */
00047     if ((BSP_RegisterRead(&BC_REGISTER->ARB_CTRL) != BC_ARB_CTRL_EBI) || runOnce)
00048     {
00049       /* Configure for EBI mode and reset display */
00050       BSP_DisplayControl(BSP_Display_EBI);
00051       BSP_DisplayControl(BSP_Display_ResetAssert);
00052       BSP_DisplayControl(BSP_Display_PowerDisable);
00053       /* Short reset delay */
00054       freq = SystemCoreClockGet();
00055       for (i = 0; i < (freq / 100); i++)
00056       {
00057         __NOP();
00058       }
00059       /* Configure display for Direct Drive + SPI mode */
00060       BSP_DisplayControl(BSP_Display_Mode8080);
00061       BSP_DisplayControl(BSP_Display_PowerEnable);
00062       BSP_DisplayControl(BSP_Display_ResetRelease);
00063 
00064       /* Initialize graphics - abort on failure */
00065       status = DMDIF_init(BC_SSD2119_BASE, BC_SSD2119_BASE + 2);
00066       if (status == DMD_OK) status = DMD_init(0);
00067       if ((status != DMD_OK) && (status != DMD_ERROR_DRIVER_ALREADY_INITIALIZED)) while (1) ;
00068       /* Make sure display is configured with correct rotation */
00069       if ((status == DMD_OK)) DMD_flipDisplay(1, 1);
00070 
00071       runOnce = false;
00072     }
00073     ret = true;
00074   }
00075   else
00076   {
00077     ret = false;
00078   }
00079   return ret;
00080 }