完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我使用STM32L4R9ZGT6,移植了UCOSIII 和 STEMWIN,参考了正点原子的STM429开发板,实验2,文本显示,UCOSIII STEMWIN都移植了,显示缓冲用的是内部RAM ,没有使用DMA2D,直接LTDC驱动了,程序如下
void TFT_LCD_Init(void) { LTDC_HandleTypeDef hltdc; LTDC_LayerCfgTypeDef pLayerCfg = {0}; LTDC_LayerCfgTypeDef pLayerCfg1 = {0}; /* USER CODE BEGIN LTDC_Init 0 */ Ltdc_GPIO_Init(); // __HAL_RCC_DMA2D_CLK_ENABLE(); // 源地址-> 目的地址图像格式混合格式 __HAL_RCC_LTDC_CLK_ENABLE(); // 产生LCD需要的各种时钟 /* USER CODE END LTDC_Init 0 */ /* USER CODE BEGIN LTDC_Init 1 */ // USER CODE END LTDC_Init 1 hltdc.Instance = LTDC; // Polarity configuration // Initialize the horizontal synchronization polarity as active low hltdc.Init.HSPolarity = LTDC_HSPOLARITY_AL; // Initialize the vertical synchronization polarity as active low hltdc.Init.VSPolarity = LTDC_VSPOLARITY_AL; // Initialize the data enable polarity as active low hltdc.Init.DEPolarity = LTDC_DEPOLARITY_AL; // Initialize the pixel clock polarity as input pixel clock hltdc.Init.PCPolarity = LTDC_PCPOLARITY_IPC; // The RK043FN48H LCD 480x272 is selected // Timing Configuration hltdc.Init.HorizontalSync = (TM043NDH02_HSYNC - 1); hltdc.Init.VerticalSync = (TM043NDH02_VSYNC - 1); hltdc.Init.AccumulatedHBP = (TM043NDH02_HSYNC + TM043NDH02_HBP - 1); hltdc.Init.AccumulatedVBP = (TM043NDH02_VSYNC + TM043NDH02_VBP - 1); hltdc.Init.AccumulatedActiveW = (TM043NDH02_WIDTH + TM043NDH02_HSYNC + TM043NDH02_HBP - 1); hltdc.Init.AccumulatedActiveH = (TM043NDH02_HEIGHT + TM043NDH02_VSYNC + TM043NDH02_VBP - 1); hltdc.Init.TotalWidth = (TM043NDH02_WIDTH + TM043NDH02_HSYNC + TM043NDH02_HBP + TM043NDH02_HFP - 1); hltdc.Init.TotalHeigh = (TM043NDH02_HEIGHT + TM043NDH02_VSYNC + TM043NDH02_VBP + TM043NDH02_VFP - 1); // Configure R,G,B component values for LCD background color : all black background hltdc.Init.Backcolor.Blue = 0; hltdc.Init.Backcolor.Green = 0; hltdc.Init.Backcolor.Red = 0; // Configure the LTDC if (HAL_LTDC_Init( hltdc) != HAL_OK) { Error_Handler(); } // Layer1 Configuration ------------------------------------------------------ // Windowing configuration // In this case all the active display area is used to display a picture then : // Horizontal start = horizontal synchronization + Horizontal back porch = 43 // Vertical start = vertical synchronization + vertical back porch = 12 // Horizontal stop = Horizontal start + window width -1 = 43 + 480 -1 // Vertical stop = Vertical start + window height -1 = 12 + 272 -1 pLayerCfg.WindowX0 = 0; pLayerCfg.WindowX1 = 0; pLayerCfg.WindowY0 = 0; pLayerCfg.WindowY1 = 0; pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_RGB565; pLayerCfg.Alpha = 0; pLayerCfg.Alpha0 = 0; pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA; pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA; pLayerCfg.FBStartAdress = 0; pLayerCfg.ImageWidth = 0; pLayerCfg.ImageHeight = 0; pLayerCfg.Backcolor.Blue = 0; pLayerCfg.Backcolor.Green = 0; pLayerCfg.Backcolor.Red = 0; if (HAL_LTDC_ConfigLayer( hltdc, pLayerCfg, LTDC_LAYER_1) != HAL_OK) { Error_Handler(); } pLayerCfg1.WindowX0 = 0; pLayerCfg1.WindowX1 = 480; pLayerCfg1.WindowY0 = 0; pLayerCfg1.WindowY1 = 272; pLayerCfg1.PixelFormat = LTDC_PIXEL_FORMAT_L8; // Alpha constant (255 == totally opaque) pLayerCfg1.Alpha = 255; // Default Color configuration (configure A,R,G,B component values) : no background color pLayerCfg1.Alpha0 = 255; pLayerCfg1.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA; pLayerCfg1.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA; pLayerCfg1.FBStartAdress = (uint32_t) RGBL8_480x272; pLayerCfg1.ImageWidth = 480; pLayerCfg.ImageHeight = 272; pLayerCfg1.Backcolor.Blue = 0; pLayerCfg1.Backcolor.Green = 0; pLayerCfg1.Backcolor.Red = 0; if (HAL_LTDC_ConfigLayer( hltdc, pLayerCfg1, LTDC_LAYER_2) != HAL_OK) { Error_Handler(); } //##-2- CLUT Configuration ################################################ HAL_LTDC_ConfigCLUT( hltdc, (uint32_t *)L8_480x272_CLUT, 256, LTDC_LAYER_2); if (HAL_LTDC_SetPitch( hltdc, 0, 0) != HAL_OK) { Error_Handler(); } if (HAL_LTDC_SetPitch( hltdc, 0, 1) != HAL_OK) { Error_Handler(); } // USER CODE BEGIN LTDC_Init 2 // USER CODE END LTDC_Init 2 //##-3- Enable CLUT For Layer 1 ############################################ HAL_LTDC_EnableCLUT( hltdc, LTDC_LAYER_2); // Assert backlight LCD_BL_CTRL pin HAL_GPIO_WritePin(GPIOB, LCD_On_Off, GPIO_PIN_SET);// } 这个是直接初始化LTDC的层2 在显示缓冲区RGBL8_480x272里修改数据,能变化画面 然后移植 STEMWIN, 没有用层, 程序如下 //设置EMWIN内存大小 #define GUI_NUMBYTES (20*1024) #define GUI_BLOCKSIZE 0x80 //块大小 //GUI_X_Config //初始化的时候调用,用来设置emwin所使用的内存 void GUI_X_Config(void) { U32 *aMemory = mymalloc(SRAMIN,GUI_NUMBYTES); //从内部RAM中分配GUI_NUMBYTES字节的内存 GUI_ALLOC_AssignMemory((U32 *)aMemory, GUI_NUMBYTES); //为存储管理系统分配一个存储块 GUI_ALLOC_SetAvBlockSize(GUI_BLOCKSIZE); //设置存储快的平均尺寸,该区越大,可用的存储快数量越少 GUI_SetDefaultFont( GUI_Font16B_1); //设置默认字体 } void LCD_X_Config(void) { //设置第一层 GUI_DEVICE_CreateAndLink(GUIDRV_LIN_8,GUICC_M332,0,0); GUI_SelectLayer(0); // 设置层0 LCD_SetSizeEx(0,XSIZE_PHYS,YSIZE_PHYS); LCD_SetVSizeEx(0,XSIZE_PHYS,YSIZE_PHYS); LCD_SetVRAMAddrEx(0, RGBL8_480x272); } 应用程序如下 GUI_Init(); //STemWin初始化 WM_MULTIBUF_Enable(1); // 开启stemwin 多缓冲,RGB屏可能会用到 WM_SetCreateFlags(WM_CF_MEMDEV); //Use memory devices on all windows to avoid flicker WM_SetCallback(WM_HBKWIN, _cbBkWindow); //Set callback for background window GUI_SetBkColor(GUI_RED); GUI_Clear(); GUI_SetBkColor(GUI_BLACK); GUI_Clear(); GUI_SetColor(GUI_WHITE); GUI_DispStringAt("Hello!", 0, 0); GUI_Delay(10); 显示缓冲区使用的8位L8 , GUI_SetBkColor(GUI_RED); GUI_Clear(); 显示缓冲区填充的是0xe0 红色 GUI_SetBkColor(GUI_BLACK); GUI_Clear(); 显示缓冲区填充的是0x00 黑色 GUI_SetColor(GUI_WHITE); GUI_DispStringAt("Hello!", 0, 0); 显示不出来字符,显示缓冲区没有变化,都是0x00 怎么回事情? |
|
相关推荐
1个回答
|
|
把TFT_LCD_Init 里的两个HAL_LTDC_SetPitch 注释掉,就可以了
|
|
|
|
只有小组成员才能发言,加入小组>>
调试STM32H750的FMC总线读写PSRAM遇到的问题求解?
1621 浏览 1 评论
X-NUCLEO-IHM08M1板文档中输出电流为15Arms,15Arms是怎么得出来的呢?
1546 浏览 1 评论
980 浏览 2 评论
STM32F030F4 HSI时钟温度测试过不去是怎么回事?
686 浏览 2 评论
ST25R3916能否对ISO15693的标签芯片进行分区域写密码?
1599 浏览 2 评论
1867浏览 9评论
STM32仿真器是选择ST-LINK还是选择J-LINK?各有什么优势啊?
650浏览 4评论
STM32F0_TIM2输出pwm2后OLED变暗或者系统重启是怎么回事?
518浏览 3评论
534浏览 3评论
stm32cubemx生成mdk-arm v4项目文件无法打开是什么原因导致的?
506浏览 3评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-23 21:17 , Processed in 0.645955 second(s), Total 49, Slave 42 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号