//----------------------------------------------------------------------------- // FUNCTION: D4DLCDHW_Init_DragonFireLCDC // SCOPE: Low Level Driver API function // DESCRIPTION: The function is used for initialization of this low level driver // // PARAMETERS: none // // RETURNS: result: 1 - Success // 0 - Failed //----------------------------------------------------------------------------- static unsigned char D4DLCDHW_Init_DragonFireLCDC(void) { Configure_VEEEN_ON(); Configure_LCD_Ports(); #if D4DLCDHWFB_MIRROWED == 1 MCF_LCDC_LCD_SSAR = D4DLCDHWFB_START_ADDRESS + D4DLCDHWFB_X_MAX * D4DLCDHWFB_Y_MAX * 2; #else MCF_LCDC_LCD_SSAR = D4DLCDHWFB_START_ADDRESS; #endif MCF_LCDC_LCD_SR = (D4DLCDHWFB_X_MAX / 16) << 20 | (D4DLCDHWFB_Y_MAX); MCF_LCDC_LCD_VPW = (D4DLCDHWFB_X_MAX / 2); MCF_LCDC_LCD_DCR = ( 0 | MCF_LCDC_LCD_DCR_HM(4) | MCF_LCDC_LCD_DCR_TM(8) ); Configure_Bursting(); LCDC_Init(TFT_PANEL, D4DLCDHWFB_PANEL_TYPE, BPP16, ACD_DIV_0, D4DLCDHWFB_PANEL_CLKDIV); LCDC_Enable(); //raise LCDC priority //(*(vuint32*)(0xFC004100)) = 0x76000021; return 1; }
/* RT-Thread Device Interface */ static rt_err_t rt_lcd_init(rt_device_t dev) { /* Route Main clock to LCD. */ CLOCK_AttachClk(kMCLK_to_LCD_CLK); CLOCK_SetClkDiv(kCLOCK_DivLcdClk, 1, true); /*LCD管脚配置*/ lcd_gpio_init(); /* Set the back light PWM. */ { sctimer_config_t config; sctimer_pwm_signal_param_t pwmParam; uint32_t event; CLOCK_AttachClk(kMCLK_to_SCT_CLK); CLOCK_SetClkDiv(kCLOCK_DivSctClk, 2, true); SCTIMER_GetDefaultConfig(&config); SCTIMER_Init(SCT0, &config); pwmParam.output = kSCTIMER_Out_5; pwmParam.level = kSCTIMER_HighTrue; pwmParam.dutyCyclePercent = 5; SCTIMER_SetupPwm(SCT0, &pwmParam, kSCTIMER_CenterAlignedPwm, 1000U, CLOCK_GetFreq(kCLOCK_Sct), &event); } lcd_framebuffer = rt_malloc_align(sizeof(rt_uint16_t) * RT_HW_LCD_HEIGHT * RT_HW_LCD_WIDTH, 32); rt_memset(lcd_framebuffer, 0, sizeof(rt_uint16_t) * RT_HW_LCD_HEIGHT * RT_HW_LCD_WIDTH); { /* Initialize the display. */ lcdc_config_t lcdConfig; LCDC_GetDefaultConfig(&lcdConfig); lcdConfig.panelClock_Hz = LCD_PANEL_CLK; lcdConfig.ppl = LCD_PPL; lcdConfig.hsw = LCD_HSW; lcdConfig.hfp = LCD_HFP; lcdConfig.hbp = LCD_HBP; lcdConfig.lpp = LCD_LPP; lcdConfig.vsw = LCD_VSW; lcdConfig.vfp = LCD_VFP; lcdConfig.vbp = LCD_VBP; lcdConfig.polarityFlags = LCD_POL_FLAGS; lcdConfig.upperPanelAddr = (uint32_t)lcd_framebuffer;//VRAM_ADDR; lcdConfig.bpp = kLCDC_16BPP565; lcdConfig.display = kLCDC_DisplayTFT; lcdConfig.swapRedBlue = true; LCDC_Init(LCD, &lcdConfig, CLOCK_GetFreq(kCLOCK_LCD)); /* Trigger interrupt at start of every vertical back porch. */ LCDC_SetVerticalInterruptMode(LCD, kLCDC_StartOfBackPorch); LCDC_EnableInterrupts(LCD, kLCDC_VerticalCompareInterrupt); NVIC_EnableIRQ(LCD_IRQn); LCDC_Start(LCD); LCDC_PowerUp(LCD); } return RT_EOK; }