📄 lcd_x_s3c2410.c
字号:
rLCDSADDR2=M5D( ((U32)frameBuffer8BitTft800600+(SCR_XSIZE_TFT_800600*LCD_YSIZE_TFT_800600/1))>>1 ); rLCDSADDR3=(((SCR_XSIZE_TFT_800600-LCD_XSIZE_TFT_800600)/2)<<11)|(LCD_XSIZE_TFT_800600/2); rLCDINTMSK|=(3); // MASK LCD Sub Interrupt rLPCSEL&=(~7); // Disable LPC3600 rTPAL=0; // Disable Temp Palette break; case MODE_TFT_16BIT_800600: frameBuffer16BitTft800600=(U32 (*)[SCR_XSIZE_TFT_800600/2])LCDFRAMEBUFFER; rLCDCON1=(CLKVAL_TFT_800600<<8)|(MVAL_USED<<7)|(3<<5)|(12<<1)|0; // TFT LCD panel,16bpp TFT,ENVID=off rLCDCON2=(VBPD_800600<<24)|(LINEVAL_TFT_800600<<14)|(VFPD_800600<<6)|(VSPW_800600); rLCDCON3=(HBPD_800600<<19)|(HOZVAL_TFT_800600<<8)|(HFPD_800600); rLCDCON4=(MVAL<<8)|(HSPW_800600); rLCDCON5=(1<<11)|(1<<10)|(1<<9)|(1<<8); //BPP24BL:x,FRM565:o,INVVCLK:x,INVVLINE:o,INVVFRAME:o,INVVD:x, //INVVDEN:x,INVPWREN:x,INVLEND:x,PWREN:x,ENLEND:x,BSWP:x,HWSWP:x rLCDSADDR1=(((U32)frameBuffer16BitTft800600>>22)<<21)|M5D((U32)frameBuffer16BitTft800600>>1); rLCDSADDR2=M5D( ((U32)frameBuffer16BitTft800600+(SCR_XSIZE_TFT_800600*LCD_YSIZE_TFT_800600*2))>>1 ); rLCDSADDR3=(((SCR_XSIZE_TFT_800600-LCD_XSIZE_TFT_800600)/1)<<11)|(LCD_XSIZE_TFT_800600/1); rLCDINTMSK|=(3); // MASK LCD Sub Interrupt rLPCSEL&=(~7); // Disable LPC3600 rTPAL=0; // Disable Temp Palette break; default: break; } }void Lcd_PowerEnable(int invpwren,int pwren){ rGPGCON &= ~(3 << 8); /* Set LCD_PWREN as output */ rGPGCON |= (1 << 8); rGPGDAT &= ~(1 << 4); /* Backlight ON */} void Lcd_EnvidOnOff(int onoff){ if(onoff==1) rLCDCON1|=1; // ENVID=ON else rLCDCON1 =rLCDCON1 & 0x3fffe; // ENVID Off} /*****************************************************************************// Function name : s3c2410x_lcd_init// Description : LCD显示驱动初始化函数// Return type : void// Argument : 无*****************************************************************************/void s3c2410x_lcd_init(){ Lcd_Port_Init();#ifdef LCD_TFT_3_5 Lcd_Init(MODE_TFT_16BIT_240320);#else #ifdef LCD_TFT_8_0 rGPCCON &= ~(3<<8); rGPCCON |= (2<<8); Lcd_Init(MODE_TFT_16BIT_640480); Lcd_PowerEnable(0, 1); Lcd_EnvidOnOff(1); #else Lcd_Init(MODE_CSTN_8BIT); Lcd_CstnOnOff(1); #endif#endif }void _PutTft16Bit_640480(U32 x,U32 y,U32 c){ if(x<SCR_XSIZE_TFT_640480 && y<SCR_YSIZE_TFT_640480) frameBuffer16BitTft640480[(y)][(x)/2]=( frameBuffer16BitTft640480[(y)][x/2] & ~(0xffff0000>>((x)%2)*16) ) | ( (c&0x0000ffff)<<((2-1-((x)%2))*16) );}void _PutTft16Bit_240320(U32 x,U32 y,U32 c){ U32 tmp = x; if(x<SCR_XSIZE_TFT_240320 && y<SCR_YSIZE_TFT_240320) frameBuffer16BitTft240320[(y)][(x)/2]=( frameBuffer16BitTft240320[(y)][x/2] & ~(0xffff0000>>((x)%2)*16) ) | ( (c&0x0000ffff)<<((2-1-((x)%2))*16) );}void _PutCstn8Bit(U32 x,U32 y,U32 c){ if(x<SCR_XSIZE_CSTN&& y<SCR_YSIZE_CSTN) frameBuffer8Bit[(y)][(x)/4]=( frameBuffer8Bit[(y)][x/4] & ~(0xff000000>>((x)%4)*8) ) | ( (c&0x000000ff)<<((4-1-((x)%4))*8) );}/*****************************************************************************// Function name : lcd_put_pixel// Description : LCD打点函数// Return type : void// Argument : int x : x坐标// Argument : int y : y坐标// Argument : int c : 颜色*****************************************************************************/void lcd_put_pixel(int x,int y,int c){#ifdef LCD_TFT_3_5 _PutTft16Bit_240320(x, y, c);#else #ifdef LCD_TFT_8_0 _PutTft16Bit_640480(x, y, c); #else _PutCstn8Bit(x, y, c); #endif#endif }#if 0int touch_up_poll = 0;static void touch_touched(int irq, void *dev_id, struct pt_regs *regs){ // 清除EINT3中断 rI_ISPC=BIT_EINT3; rPCONG &= 0xff3f; touch_up_poll = 1;}void udelay(){ int loopcnt = 100; while(loopcnt --) { loopcnt -= 1; loopcnt += 1; }}static void read_xy(int *tx, int *ty){ int i; int tmp[32]; rADCPSR = 0x2f; rPCONE &= 0x300ff; rPCONE |= 0x0500; rPDATE = 0x20; udelay(50); for(i=0; i<32; i++){ rADCCON = 1; while(rADCCON&0x01) udelay(1); while(!(rADCCON&0x40)) udelay(1); tmp[i] = (rADCDAT); } *tx = 0; for(i=5; i<27; i++){ *tx += tmp[i]; } *tx /= 22; (rADCPSR) = 0x2f; (rPCONE) &= 0x300ff; (rPCONE) |= 0x5000; (rPDATE) = 0x80; udelay(50); for(i=0; i<32; i++){ (rADCCON) = 1|(1<<2); while((rADCCON)&0x01) udelay(1); while(!((rADCCON)&0x40)) udelay(1); tmp[i] = (rADCDAT); } *ty = 0; for(i=5; i<27; i++){ *ty += tmp[i]; } *ty /= 22;}extern GUI_HID_STATE _State;struct ts_event{ unsigned short status; unsigned short x; unsigned short y; unsigned short pad;};struct ts_device{ struct ts_event last; struct ts_event ebuf[32]; int head, tail; int isdrag;}tsdev;#define PEN_UP 1#define PEN_DOWN 0#define PEN_DISCARD 2static void put_event(int x, int y, int down){ int dx, dy; switch(tsdev.last.status){ case PEN_UP: if(!down){ tsdev.isdrag = 0; return; } tsdev.last.status = PEN_DISCARD; return; case PEN_DISCARD: if(!down){ tsdev.last.status = PEN_UP; tsdev.isdrag = 0; return; } tsdev.last.status = PEN_DOWN; tsdev.last.x = x; tsdev.last.y = y; _State.x = x; _State.y = y; _State.Pressed = 1; break; case PEN_DOWN: if(!down){ tsdev.last.status = PEN_UP; tsdev.isdrag = 0; _State.x = x; _State.y = y; _State.Pressed = 0; break; } if(!tsdev.isdrag){ dx = x-tsdev.last.x; dy = y-tsdev.last.y; if(dx<0) dx = -dx; if(dy<0) dy = -dy; if(dy<6 && dx<4) return; tsdev.isdrag = 1; } tsdev.last.x = x; tsdev.last.y = y; break; } tsdev.ebuf[tsdev.head] = tsdev.last; tsdev.head = (tsdev.head+1)&(32-1); if(tsdev.head == tsdev.tail) tsdev.tail = (tsdev.tail+1)&(32-1);}static void do_touch(){ int tx, ty; int tx1, ty1; int tx2, ty2; if((rPDATG)&0x08) { put_event(0, 0, 0); (rPCONG) |= 0x000c0; touch_up_poll = 0; return; } read_xy(&ty, &tx); // done #define X1_Y 0x1ca #define X1_X 0x75 #define X4_Y 0x89 #define X4_X 0x1c9 #define X2_Y 0x1b7 #define X2_X 0x1c4 #define X3_Y 0xa2 #define X3_X 0x81 #ifdef TS_VERIFY printk("tx = 0x%x , ty = 0x%x\n", tx, ty); #endif tx1 = (int)((tx-X1_X) * 320.0 / (X4_X - X1_X)); ty1 = (int)((ty-X1_Y) * 240.0 / (X4_Y - X1_Y)); tx2 = (int)((tx-X3_X) * 320.0 / (X2_X - X3_X)); ty2 = (int)((ty-X2_Y) * 240.0 / (X3_Y - X2_Y)); //printk("tx1 = 0x%x , ty1 = 0x%x\n", tx1, ty1); //printk("tx2 = 0x%x , ty2 = 0x%x\n", tx2, ty2); tx = (tx2 + tx1) / 2; ty = (ty2 + ty1) / 2; tx = tx<0 ? 0 : tx; ty = ty<0 ? 0 : ty; tx = tx>320 ? 320 : tx; ty = ty>240 ? 240 : ty; put_event(tx, ty, 1);#ifdef TS_VERIFY printk("do_touch (%d, %d)\n", tx, ty); #endif (rPCONE) &= 0x300ff; (rPCONE) |= 0x00400; (rPDATE)&= 0x0000f; touch_up_poll = 1;}void s3c44b0x_touch_init(){ rPCONE &= 0x300ff; rPCONE |= 0x0400; rPUPE = 0xff; rPDATE &= 0x0f; rPCONG |= 0x0c0; pISR_EINT3=(int)touch_touched; rI_ISPC = BIT_EINT3; rINTMSK &= ~BIT_EINT3;}#endif/* ********************************************************* * * * LCD_Init : Init the display * * * **********************************************************/int LCD_L0_Init(void) { int x,y; s3c2410x_lcd_init();// s3c44b0x_touch_init(); // Create Bitmaps to simulate LCD (pages)// for (x=0; x< LCD_XSIZE; x++)// for (y=0; y< LCD_YSIZE; y++)// SETPIXEL( x, y, BKCOLORINDEX); return 0;}int LCD_L0_CheckInit(void) { return 0;} /* ****************************************** * * * Re-initialize LCD * * * ******************************************This routine is supplied for compatibility and interchangability of"C"-sources with embedded versions of the driver. It has no realeffect in the PC-version as there is simply no need to re-initializethe LCD since it is just simulated anyhow.*/void LCD_L0_ReInit (void) {}unsigned LCD_L0_GetPixelIndex(int x, int y) { return LCDSIM_GetPixelIndex(x,y);}/* ********************************************************* * * * LCD_L0_XorPixel * * * *********************************************************Purpose: This routine is called by emWin. It writes 1 pixel into the display.*/void LCD_L0_XorPixel(int x, int y) { XORPIXEL(x, y);}/* ********************************************************* * * * LCD_L0_SetPixelIndex * * * *********************************************************Purpose: This routine is called by emWin. It writes 1 pixel into the display.*/void LCD_L0_SetPixelIndex(int x, int y, int ColorIndex) { SETPIXEL(x, y, ColorIndex);}int LCDSIM_GetPixelIndex(int x, int y){}void LCDSIM_SetPixelIndex(int x, int y, int c) { lcd_put_pixel(x, y, c);}void LCDSIM_SetLUTEntry(U8 Pos, LCD_COLOR color){}//////////////////////////////////////////////////////////////////////////////////////// Keyboard/////////////////////////////////////////////////////////////////////////////////////********************************************************************// Function name : get_key// Description : 如果有键按下返回键,否则返回0// Return type : char// Argument : *********************************************************************/char get_key(){// DrvKeyGet();}char get_key_no_del(){// DrvKeyGetNoDel();}/********************************************************************// Function name : timer1_isr// Description : 定时器1中断服务程序,用于扫描键盘,每隔10ms一次中断// Return type : void// Argument : void*********************************************************************/void touch_poll(void){// // touch// if(touch_up_poll)// do_touch();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -