tftdirect.c

Go to the documentation of this file.
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 "tftdirect.h"
00041 /* DMD init from dmd_ssd2119_direct.c */
00042 #include "glib/glib.h"
00043 
00045 static bool runOnce = true;
00046 
00047 /**************************************************************************/
00050 void TFT_DirectGPIOConfig(void)
00051 {
00052   /* EBI TFT DCLK/Dot Clock */
00053   GPIO_PinModeSet(gpioPortA, 8, gpioModePushPull, 0);
00054   /* EBI TFT DATAEN */
00055   GPIO_PinModeSet(gpioPortA, 9, gpioModePushPull, 0);
00056   /* EBI TFT VSYNC  */
00057   GPIO_PinModeSet(gpioPortA, 10, gpioModePushPull, 0);
00058   /* EBI TFT HSYNC */
00059   GPIO_PinModeSet(gpioPortA, 11, gpioModePushPull, 0);
00060 }
00061 
00062 
00063 /**************************************************************************/
00072 bool TFT_DirectInit(const EBI_TFTInit_TypeDef *tftInit)
00073 {
00074   bool     ret;
00075   uint32_t i, freq;
00076 
00077   /* If we are in BC_UIF_AEM_EFM state, we can redraw graphics */
00078   if (BSP_RegisterRead(&BC_REGISTER->UIF_AEM) == BC_UIF_AEM_EFM)
00079   {
00080     /* If we're not BC_ARB_CTRL_EBI state, we need to reconfigure display controller */
00081     if ((BSP_RegisterRead(&BC_REGISTER->ARB_CTRL) != BC_ARB_CTRL_EBI) || runOnce)
00082     {
00083       /* Enable SSD2119 Serial Port Interface */
00084       BSP_PeripheralAccess(BSP_TFT, true);
00085 
00086       /* Enable EBI mode of operation on SSD2119 controller */
00087       BSP_DisplayControl(BSP_Display_EBI);
00088       BSP_DisplayControl(BSP_Display_ResetAssert);
00089       BSP_DisplayControl(BSP_Display_PowerDisable);
00090       freq = SystemCoreClockGet();
00091       for (i = 0; i < (freq / 100); i++)
00092       {
00093         __NOP();
00094       }
00095       /* Configure display for Direct Drive "Mode Generic" + 3-wire SPI mode */
00096       BSP_DisplayControl(BSP_Display_ModeGeneric);
00097       BSP_DisplayControl(BSP_Display_PowerEnable);
00098       BSP_DisplayControl(BSP_Display_ResetRelease);
00099 
00100       /* Configure GPIO for EBI and TFT */
00101       TFT_DirectGPIOConfig();
00102 
00103       /* Initialize display */
00104       DMD_init(0, (uint32_t) EBI_BankAddress(EBI_BANK2));
00105 
00106       /* Configure EBI TFT direct drive */
00107       EBI_TFTInit(tftInit);
00108 
00109       runOnce = false;
00110     }
00111     ret = true;
00112   }
00113   else
00114   {
00115     ret = false;
00116   }
00117 
00118   return ret;
00119 }