/**************************************************************************//** * @brief TFT initialize or reinitialize to Address Mapped Mode * Assumes EBI has been configured correctly in BSP_Init() * * @return true if we should redraw into buffer, false if BC has control * over display *****************************************************************************/ bool TFT_AddressMappedInit(void) { bool ret; EMSTATUS status; /* If we are in BC_UIF_AEM_EFM state, we can redraw graphics */ if (BSP_RegisterRead(BC_AEMSTATE) == 1) { /* If we're not BC_ARB_CTRL_EBI state, we need to reconfigure display controller */ if ((BSP_RegisterRead(BC_BUS_CFG) == BC_BUS_CFG_FSMC) || runOnce) { /* Initialize graphics - abort on failure */ status = DMDIF_init(BC_SSD2119_BASE, BC_SSD2119_BASE + 2); if (status == DMD_OK) status = DMD_init(0); if ((status != DMD_OK) && (status != DMD_ERROR_DRIVER_ALREADY_INITIALIZED)) while (1) ; /* Make sure display is configured with correct rotation */ if ((status == DMD_OK)) DMD_flipDisplay(1, 1); runOnce = false; } ret = true; } else { ret = false; } return ret; }
/**************************************************************************//** * @brief Intializes TFT serial output *****************************************************************************/ void RETARGET_SerialInit(void) { int x, y; volatile int i; EMSTATUS status; /* Initialize color for font */ /* Use \b for red text (bell/warning) */ rgbColor[0] = 0xff; rgbColor[1] = 0xff; rgbColor[2] = 0xff; /* Character buffer */ if (bufferReset) { /* Clear character buffer */ for (y = 0; y < LINES; y++) { for (x = 0; x < CHARS; x++) { charBuffer[y][x] = 0; } } /* Set cursor position to upper left */ xpos = 0; ypos = 0; } /* Display controller */ if (tftReset) { /* Configure for EBI mode and reset display */ BSP_DisplayControl(BSP_Display_EBI); BSP_DisplayControl(BSP_Display_ResetAssert); BSP_DisplayControl(BSP_Display_PowerDisable); /* Short delay */ for (i = 0; i < 10000; i++) ; /* Configure display for Direct Drive + SPI mode */ BSP_DisplayControl(BSP_Display_Mode8080); BSP_DisplayControl(BSP_Display_PowerEnable); BSP_DisplayControl(BSP_Display_ResetRelease); /* Initialize graphics - abort on failure */ status = DMDIF_init(BC_SSD2119_BASE, BC_SSD2119_BASE + 2); if (status == DMD_OK) status = DMD_init(0); if ((status != DMD_OK) && (status != DMD_ERROR_DRIVER_ALREADY_INITIALIZED)) while (1) ; /* Make sure display is configured with correct rotation */ if ((status == DMD_OK)) status = DMD_flipDisplay(1, 1); #if !defined(__CROSSWORKS_ARM) && defined(__GNUC__) setvbuf(stdout, NULL, _IONBF, 0); /*Set unbuffered mode for stdout (newlib)*/ #endif } initialized = true; }
/**************************************************************************//** * @brief TFT initialize or reinitialize to Address Mapped Mode * Assumes EBI has been configured correctly in BSP_Init(BSP_INIT_DK_EBI) * * @return true if we should redraw into buffer, false if BC has control * over display *****************************************************************************/ bool TFT_AddressMappedInit(void) { bool ret; EMSTATUS status; uint32_t i, freq; /* If we are in BC_UIF_AEM_EFM state, we can redraw graphics */ if (BSP_RegisterRead(&BC_REGISTER->UIF_AEM) == BC_UIF_AEM_EFM) { /* If we're not BC_ARB_CTRL_EBI state, we need to reconfigure display controller */ if ((BSP_RegisterRead(&BC_REGISTER->ARB_CTRL) != BC_ARB_CTRL_EBI) || runOnce) { /* Configure for EBI mode and reset display */ BSP_DisplayControl(BSP_Display_EBI); BSP_DisplayControl(BSP_Display_ResetAssert); BSP_DisplayControl(BSP_Display_PowerDisable); /* Short reset delay */ freq = SystemCoreClockGet(); for (i = 0; i < (freq / 100); i++) { __NOP(); } /* Configure display for Direct Drive + SPI mode */ BSP_DisplayControl(BSP_Display_Mode8080); BSP_DisplayControl(BSP_Display_PowerEnable); BSP_DisplayControl(BSP_Display_ResetRelease); /* Initialize graphics - abort on failure */ status = DMDIF_init(BC_SSD2119_BASE, BC_SSD2119_BASE + 2); if (status == DMD_OK) status = DMD_init(0); if ((status != DMD_OK) && (status != DMD_ERROR_DRIVER_ALREADY_INITIALIZED)) while (1) ; /* Make sure display is configured with correct rotation */ if ((status == DMD_OK)) DMD_flipDisplay(1, 1); runOnce = false; } ret = true; } else { ret = false; } return ret; }