tftdirect.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 "tftdirect.h"
00023
00024 #include "glib/glib.h"
00025
00027 static bool runOnce = true;
00028
00029
00032 void TFT_DirectGPIOConfig(void)
00033 {
00034
00035 GPIO_PinModeSet(gpioPortA, 8, gpioModePushPull, 0);
00036
00037 GPIO_PinModeSet(gpioPortA, 9, gpioModePushPull, 0);
00038
00039 GPIO_PinModeSet(gpioPortA, 10, gpioModePushPull, 0);
00040
00041 GPIO_PinModeSet(gpioPortA, 11, gpioModePushPull, 0);
00042 }
00043
00044
00045
00054 bool TFT_DirectInit(const EBI_TFTInit_TypeDef *tftInit)
00055 {
00056 bool ret;
00057 uint32_t i, freq;
00058 EMSTATUS stat;
00059
00060
00061 if (BSP_RegisterRead(&BC_REGISTER->UIF_AEM) == BC_UIF_AEM_EFM)
00062 {
00063
00064 if ((BSP_RegisterRead(&BC_REGISTER->ARB_CTRL) != BC_ARB_CTRL_EBI) || runOnce)
00065 {
00066
00067 BSP_PeripheralAccess(BSP_TFT, true);
00068
00069
00070 BSP_DisplayControl(BSP_Display_EBI);
00071 BSP_DisplayControl(BSP_Display_ResetAssert);
00072 BSP_DisplayControl(BSP_Display_PowerDisable);
00073 freq = SystemCoreClockGet();
00074 for (i = 0; i < (freq / 100); i++)
00075 {
00076 __NOP();
00077 }
00078
00079 BSP_DisplayControl(BSP_Display_ModeGeneric);
00080 BSP_DisplayControl(BSP_Display_PowerEnable);
00081 BSP_DisplayControl(BSP_Display_ResetRelease);
00082
00083
00084 TFT_DirectGPIOConfig();
00085
00086
00087 stat = DMD_init(0);
00088 if (DMD_OK == stat) stat = DMD_selectFramebuffer((void*)EBI_BankAddress(EBI_BANK2));
00089 if (DMD_OK != stat) while (1) ;
00090
00091
00092 EBI_TFTInit(tftInit);
00093
00094 runOnce = false;
00095 }
00096 ret = true;
00097 }
00098 else
00099 {
00100 ret = false;
00101 }
00102
00103 return ret;
00104 }