FMC+DAM驱动LVGL刷屏

前提条件

使用FMC驱动LCD刷屏

LVGL移植

image-20231104161909949

image-20231104161953845

image-20231104162200083

image-20231104162258368

image-20231104170428986

image-20231104162451767

image-20231104162537900

image-20231104162607733

image-20231104162628618

开启DMA

image-20231104165030378

需要开启MEMTOMEMDMA。

开启MPU

有MPU时需要

使能I-cache D-cache时

使用DMA传输数据时要保证数据的完整行和准确性

image-20231104171419262

修改代码

逻辑

等待DMA传输完成然后再刷屏。

修改

  1. 在DMA初始化函数中最后添加

    注册DMA传输完成调用函数。

HAL_DMA_RegisterCallback(&hdma_memtomem_dma2_stream0, HAL_DMA_XFER_CPLT_CB_ID, LVGL_LCD_FSMC_DMA_pCallback);
  1. 修改disp_flush函数
/*Flush the content of the internal buffer the specific area on the display
 *You can use DMA or any hardware acceleration to do this operation in the background but
 *'lv_disp_flush_ready()' has to be called when finished.*/
static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
{
    /*The most simple case (but also the slowest) to put all pixels to the screen one-by-one*/

//     LCD_ShowPicture(area->x1, area->y1, area->x2 - area->x1+1, area->y2- area->y1+1, (uint16_t *)color_p);

	LCD_Address_Set(area->x1,area->y1,area->x2,area->y2); //写地址
	
	HAL_DMA_Start_IT(&hdma_memtomem_dma2_stream0, (uint32_t)color_p, Bank1_LCD_DATA, ((area->x2+1) - area->x1) * ((area->y2+1) - area->y1)); //写数据
    /*IMPORTANT!!!
//     *Inform the graphics library that you are ready with the flushing*/
//    lv_disp_flush_ready(disp_drv);
}
  1. 添加刷屏函数

    刷屏函数

void LVGL_LCD_FSMC_DMA_pCallback(DMA_HandleTypeDef *_hdma)
{
	lv_disp_flush_ready(&disp_drv);
}
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值