我现在使用LVGL,想把disp_flush效率提升。于是就使用了DMA,将color_p的数据搬运到LCD的buffer中,但是每次只能搬运几个字节。感觉像是cache同步问题,对cache进行了强制更新,也没用。请问有什么好办法?
DMA设置:
DMA_Init();
g_dma.Type = NDMA;//类型
g_dma.Ch = 0;//通道
g_dma.Continuous_Mode_Enable = 0;//连续模式
g_dma.Read_Byte_Counter_Enable = 0;//读计数值使能
//---------
g_dma.Source_Address_Type = DMA_ADDRESS_TYEP_LINEER;//源地址类型
g_dma.Source_DRQ_Type = NDMAS_DRQ_Type_SDRAM_Memory;//源类型
g_dma.Source_Data_Width = DMA_DATA_WIDTH_32;//源数据宽度
g_dma.Source_Burst_Length = DMA_BURST_LENGTH_4;//BURST
//-----------
g_dma.Destination_Address_Type = DMA_ADDRESS_TYEP_LINEER;//目标地址类型
g_dma.Destination_DRQ_Type = NDMAD_DRQ_Type_SDRAM_Memory;//目标类型
g_dma.Destination_Data_Width = DMA_DATA_WIDTH_32;//目标数据宽度
g_dma.Destination_Burst_Length = DMA_BURST_LENGTH_4;//BURST
更改后的disp_flush函数
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*/
int32_t x;
int32_t y;
g_dma.Source_Address = (unsigned int)color_p;
g_dma.Byte_Counter = (area->x2 + 1 - area->x1) * 2;//Byte计数
for(y = area->y1; y <= area->y2; y++) {
MMU_CleanDCacheArray(g_dma.Source_Address, g_dma.Byte_Counter);
g_dma.Destination_Address = (unsigned int)BT + y * LV_HOR_RES_MAX * 2 + area->x1 * 2;
DMA_Config(&g_dma);
DMA_Enable(&g_dma);
while (DMA_Get_Full_TIP(&g_dma));
DMA_Disable(&g_dma);
MMU_InvalidateDCacheArray(g_dma.Destination_Address, g_dma.Byte_Counter);
g_dma.Source_Address += (area->x2 + 1 - area->x1) * 2;
}
/* IMPORTANT!!!
* Inform the graphics library that you are ready with the flushing*/
lv_disp_flush_ready(disp_drv);
}
离线