LCD DMA day59
十四:LCD 显示屏
一:基础概念
访问:
1.传输bank地址和行地址
2传输列地址及读写信号
3.写:写数据到DATA(先写到数据总线中,再数据操作)
读: (先数据操作,再从数据总线拿出数据)从DATA获取数据
二:代码
#include "lcd.h"
#include <s3c2440.h>void lcd0_init(void)
{//引脚GPCCON |= 0xffff;GPCCON = 0xaaaaaaaa;GPDUP |= 0xffff;GPDCON = 0xaaaaaaaa; //LCDCON1LCDCON1 |= (7 << 8) | (0x3 << 5) | (0xc << 1);//LCDCON2LCDCON2 |= (13 << 24) | (319 << 14);//LCDCON3LCDCON3 |= (80 << 19) | (239 << 8);//LCDCON5LCDCON5 |= (1 << 11) |(1 << 10) | (1 << 3);//LCDSADDRLCDSADDR1 | FRAMEBUFFER >> 1;LCDSADDR2 = (LCDSADDR1 & 0x1fffff) + 240*320;//最终使能LCDCON1 |= (0x1<< 0);
}void display_point(int x, int y, unsigned short col)
{*((unsigned short *)FRAMEBUFFER+y*240+x) = col;
}void clear(unsigned short col)
{int i = 0;int j = 0;for(i = 0; i < 320; i++)for(j = 0; j < 240; j++)display_point(j, i, col);
}-----------------------------------------------------clear(0xf800);display_point(120, 160, 0);display_point(125, 160, 0);display_point(120, 165, 0);display_point(125, 165, 0);
十五:DMA
从内存空间操作的,所以是AHB
#include "dma.h"
#include <s3c2440.h>void dma_init(void)
{DISRCC1 &= ~(0x3 << 0); //AHB 增加DIDST1 &= ~(0x3 << 0); //AHB 增加 DCON1 |= (1 << 31) | (1 << 30) | (1 << 27)| (1 << 22) | (0x2 << 20);DSTAT1 = 0;
}
void memcpy(unsigned long * dest,unsigned long * src,int len)
{unsigned char i = 0;DISRC1 &= ~(0x3fffffff << 0);DISRC1 = (unsigned long)src;DIDST1 &= ~(0x3fffffff << 0);DIDST1 = (unsigned long)dest;DCON1 &= ~(0xfffff << 0);DCON1 |= (len << 0);DMASKTRIG1 |= (1 << 1) | (1 << 0);while((DSTAT1 & (1 << 20)));
}