主题 : smart210 7寸 S70 LCD裸机程序 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 98696
精华: 1
发帖: 21
金钱: 160 两
威望: 32 点
贡献值: 1 点
综合积分: 62 分
注册时间: 2013-12-04
最后登录: 2015-04-22
楼主  发表于: 2013-12-21 22:11

 smart210 7寸 S70 LCD裸机程序

管理提醒: 本帖被 xoom 执行加亮操作(2013-12-22)
#define GPF0CON   (*(volatile unsigned long *)0xE0200120)
#define GPF1CON   (*(volatile unsigned long *)0xE0200140)
#define GPF2CON   (*(volatile unsigned long *)0xE0200160)
#define GPF3CON   (*(volatile unsigned long *)0xE0200180)
#define GPD0CON   (*(volatile unsigned long *)0xE02000A0)
#define GPD0DAT   (*(volatile unsigned long *)0xE02000A4)
#define CLK_SRC1  (*(volatile unsigned long *)0xe0100204)
#define CLK_DIV1  (*(volatile unsigned long *)0xe0100304)
#define DISPLAY_CONTROL (*(volatile unsigned long *)0xe0107008)
#define VIDCON0   (*(volatile unsigned long *)0xF8000000)
#define VIDCON1   (*(volatile unsigned long *)0xF8000004)
#define VIDTCON2  (*(volatile unsigned long *)0xF8000018)
#define WINCON0   (*(volatile unsigned long *)0xF8000020)
#define WINCON2   (*(volatile unsigned long *)0xF8000028)
#define SHADOWCON   (*(volatile unsigned long *)0xF8000034)
#define VIDOSD0A   (*(volatile unsigned long *)0xF8000040)
#define VIDOSD0B   (*(volatile unsigned long *)0xF8000044)
#define VIDOSD0C   (*(volatile unsigned long *)0xF8000048)
#define VIDW00ADD0B0  (*(volatile unsigned long *)0xF80000A0)
#define VIDW00ADD1B0  (*(volatile unsigned long *)0xF80000D0)
#define VIDTCON0   (*(volatile unsigned long *)0xF8000010)
#define VIDTCON1   (*(volatile unsigned long *)0xF8000014)
//这是根据屏参数修改的        七寸S70
#define HSPW    (0)
#define HBPD   (46 - 1)
#define HFPD    (210 - 1)
#define VSPW   (0)
#define VBPD    (23 - 1)
#define VFPD    (22 - 1)

// FB地址
#define FB_ADDR   (0x23000000)
#define ROW    (480)
#define COL    (800)
#define HOZVAL   (COL-1)
#define LINEVAL   (ROW-1)

// 初始化LCD
void lcd_init(void)
{
 // 配置引脚用于LCD功能
 GPF0CON = 0x22222222;
 GPF1CON = 0x22222222;
 GPF2CON = 0x22222222;
 GPF3CON = 0x22222222;
 // 打开背光
 GPD0CON &= ~(0xf<<4);
 GPD0CON |= (1<<4);
 GPD0DAT |= (1<<1);
 // 10: RGB=FIMD I80=FIMD ITU=FIMD
 DISPLAY_CONTROL = 2<<0;
 // bit[26~28]:使用RGB接口
 // bit[18]:RGB 并行
 // bit[2]:选择时钟源为HCLK_DSYS=166MHz
 VIDCON0 &= ~( (3<<26)|(1<<18)|(1<<2) );
 // bit[1]:使能lcd控制器
 // bit[0]:当前帧结束后使能lcd控制器
 VIDCON0 |= ( (1<<0)|(1<<1) );
 // bit[6]:选择需要分频
 // bit[6~13]:分频系数为15,即VCLK = 166M/(14+1) = 11M
 VIDCON0 |= 14<<6 | 1<<4;

 // H43-HSD043I9W1.pdf(p13) 时序图:VSYNC和HSYNC都是低脉冲
 // s5pv210芯片手册(p1207) 时序图:VSYNC和HSYNC都是高脉冲有效,所以需要反转
 VIDCON1 |= 1<<5 | 1<<6;
  //   VIDCON1 & =0 <<5 | 0<<6;
 // 设置时序
 VIDTCON0 = VBPD<<16 | VFPD<<8 | VSPW<<0;
 VIDTCON1 = HBPD<<16 | HFPD<<8 | HSPW<<0;
 // 设置长宽
 VIDTCON2 = (LINEVAL << 11) | (HOZVAL << 0);
 // 设置windows1
 // bit[0]:使能
 // bit[2~5]:24bpp
 WINCON0 |= 1<<0;
 WINCON0 &= ~(0xf << 2);
 WINCON0 |= (0xB<<2) | (1<<15);
#define LeftTopX     0
#define LeftTopY     0
//还有这里
#define RightBotX   799
#define RightBotY   479

 // 设置windows1的上下左右
 VIDOSD0A = (LeftTopX<<11) | (LeftTopY << 0);
 VIDOSD0B = (RightBotX<<11) | (RightBotY << 0);
 VIDOSD0C = (LINEVAL + 1) * (HOZVAL + 1);

 // 设置fb的地址
 VIDW00ADD0B0 = FB_ADDR;
 VIDW00ADD1B0 = (((HOZVAL + 1)*4 + 0) * (LINEVAL + 1)) & (0xffffff);
 // 使能channel 0传输数据
 SHADOWCON = 0x1;
}

// 描点
void lcd_draw_pixel(int row, int col, int color)
{
 unsigned long * pixel = (unsigned long  *)FB_ADDR;
 *(pixel + row * COL + col) = color;
}
// 清屏
void lcd_clear_screen(int color)
{
 int i, j;
 for (i = 0; i < ROW; i++)
  for (j = 0; j < COL; j++)
   lcd_draw_pixel(i, j, color);
}
// 划横线
void lcd_draw_hline(int row, int col1, int col2, int color)
{
 int j;
 // 描第row行,第j列
 for (j = col1; j <= col2; j++)
  lcd_draw_pixel(row, j, color);
}
// 划竖线
void lcd_draw_vline(int col, int row1, int row2, int color)
{
 int i;
 // 描第i行,第col列
 for (i = row1; i <= row2; i++)
  lcd_draw_pixel(i, col, color);
}
// 划十字
void lcd_draw_cross(int row, int col, int halflen, int color)
{
 lcd_draw_hline(row, col-halflen, col+halflen, color);
 lcd_draw_vline(col, row-halflen, row+halflen, color);
}
级别: 新手上路
UID: 107619
精华: 0
发帖: 2
金钱: 15 两
威望: 3 点
贡献值: 0 点
综合积分: 4 分
注册时间: 2014-08-30
最后登录: 2014-11-10
1楼  发表于: 2014-09-06 21:45
您好,我是小白,我想问一下编写裸机程序需要那几个软件哈