裸奔例程19和21给出的程序貌似是4.3寸屏的,现在实际上卖的都是7寸电容屏,这两个裸奔例程运行起来UART是好的,但是屏幕全亮什么反应都没有。
请问友善有7寸电容屏的裸奔例程么?或者有没有大侠告诉我应该怎么改啊?
按照网上一些说法,我进行了修改。可是效果没有变化,仍然是全亮。
lcd.c我写成了这样
#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)
#define HSPW (0)
#define HBPD (45)
#define HFPD (209)
#define VSPW (0)
#define VBPD (22)
#define VFPD (21)
// 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;
// 设置时序
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);
}
main.c我改成了这样
#include "lib\stdio.h"
#include "lcd.h"
#define WIDTHEIGHT 800
#define HEIGHT 480
void uart_init(void);
int main(void)
{
int c = 0;
// 初始化串口
uart_init();
// 初始化LCD
lcd_init();
// 打印菜单
while(1)
{
printf("\r\n###############LCD Test##############\r\n");
printf("[1] lcd_clear_screen\r\n");
printf("[2] lcd_draw_cross\r\n");
printf("[3] lcd_draw_hline\r\n");
printf("[4] lcd_draw_vline\r\n");
printf("[5] lcd_draw_circle\r\n");
printf("Enter your choice:");
c = getc();
printf("%c\r\n",c);
switch(c)
{
case '1':
// 清屏
lcd_clear_screen(0x000000); // 黑
break;
case '2':
// 划十字
lcd_draw_cross(50, 50, 20, 0x0000ff); // 蓝
break;
case '3':
// 划横线
lcd_draw_hline(HEIGHT/2, 100, WIDTHEIGHT-100, 0xff0000); // 红
break;
case '4':
// 划竖线
lcd_draw_vline(WIDTHEIGHT/2, 50, HEIGHT-50, 0x00ff00); // 绿
break;
default:
break;
}
}
return 0;
}