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
00042 #include "glib/glib.h"
00043
00045 static bool runOnce = true;
00046
00047
00050 void TFT_DirectGPIOConfig(void)
00051 {
00052
00053 GPIO_PinModeSet(gpioPortA, 8, gpioModePushPull, 0);
00054
00055 GPIO_PinModeSet(gpioPortA, 9, gpioModePushPull, 0);
00056
00057 GPIO_PinModeSet(gpioPortA, 10, gpioModePushPull, 0);
00058
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
00078 if (BSP_RegisterRead(&BC_REGISTER->UIF_AEM) == BC_UIF_AEM_EFM)
00079 {
00080
00081 if ((BSP_RegisterRead(&BC_REGISTER->ARB_CTRL) != BC_ARB_CTRL_EBI) || runOnce)
00082 {
00083
00084 BSP_PeripheralAccess(BSP_TFT, true);
00085
00086
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
00096 BSP_DisplayControl(BSP_Display_ModeGeneric);
00097 BSP_DisplayControl(BSP_Display_PowerEnable);
00098 BSP_DisplayControl(BSP_Display_ResetRelease);
00099
00100
00101 TFT_DirectGPIOConfig();
00102
00103
00104 DMD_init(0, (uint32_t) EBI_BankAddress(EBI_BANK2));
00105
00106
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 }