#include "LPC177x_8x.h" // Device header #include "TFT_LCD.H" #include "SDRAM.H" #include "math.h" #include "string.h" #include "ASCII_LIB.h" #include "UART.h" #include "ICONS_LIB.h" #include "TIMER.H" uint8_t start_bit, stop_bit, start_bit_for_ascii11, stop_bit_for_ascii11; #define WHITE 0xFFFFFF #define BLACK 0x000000 #define BLUE 0xFF0000 #define RED 0x0000FF #define GREEN 0x00FF00 #define YELLOW 0x00FFFF #define PURPLE COLOUR(127,0,255) #define ORANGE 0X00A5FF//COLOUR(255,165,0) #define LIGHTBLUE COLOUR(23,208,255) #define SKYBLUE 0xFFFF00//COLOUR(0,255,255) #define NAVY_BLUECOLOUR(0,0,128) #define GREY COLOUR(61,60,59) #define COMM_BOARDER_GREY COLOUR(121,120,119) #define RTC_GREYCOLOUR(0,0,50) #define BLACK_GreyCOLOUR(10,10,10) #define SILVERCOLOUR(192,192,192) #define TOMATO_REDCOLOUR(255,99,71) #define SPRING_GREEN COLOUR(0,255,127) //#define COLOUR(R,G,B)((B<<16)|(G<<8)|(R<<0)) #define LCD_VRAM_BASE_ADDR ((unsigned long )SDRAM_BASE_ADDRESS) #define TFT_H_SIZE 1024 #define TFT_H_PULSE 40//1//30--606088 #define TFT_H_FRONTPORCH 56//40//210 #define TFT_H_BACKPORCH 124//88//16 #define TFT_V_SIZE 600 #define TFT_V_PULSE 48//3//13--602223 #define TFT_V_FRONTPORCH 28//3//22 #define TFT_V_BACKPORCH 56//3//10 #define HORIZONTAL0XFF #define VERTICAL0X00 /******************************************************************************* * Function Name : LCD_ClockDivide * Description : find closest clock divider to get the desired clock rate. * Input : None * Output : None * Return : None * Attention : None *******************************************************************************/ static uint32_t LCD_ClockDivide(uint32_t LCD_clock) { uint32_t divide, result; divide = 1; while ( ( (120000000 / divide) > LCD_clock ) && (divide <= 0x3F) ) { divide++; } if (divide <= 1) { result = (1 << BCD_BIT); /* Skip divider logic if clock divider is 1 */ } else { result = 0 | (((divide >> 0) & 0x1F) | (((divide >> 5) & 0x1F) << 27)); } return result; } /************************************************************************************* 1. Function name:glcd_initialization 2. Purpose:glcd initialisation 3. Input :void 4. Return type:void *************************************************************************************/ void glcd_initialization (){ unsigned long i; unsigned long *pDst = (unsigned long *)LCD_VRAM_BASE_ADDR; IOCON_P0_4 = LCD_RED; IOCON_P0_5 = LCD_RED; IOCON_P4_28 = LCD_RED; IOCON_P4_29 = LCD_RED; IOCON_P2_6 = LCD_RED; IOCON_P2_7 = LCD_RED; IOCON_P2_8 = LCD_RED; IOCON_P2_9 = LCD_RED; IOCON_P0_6 = LCD_GREEN; IOCON_P0_7 = LCD_GREEN; IOCON_P1_20 = LCD_GREEN; IOCON_P1_21 = LCD_GREEN; IOCON_P1_22 = LCD_GREEN; IOCON_P1_23 = LCD_GREEN; IOCON_P1_24 = LCD_GREEN; IOCON_P1_25 = LCD_GREEN; IOCON_P0_8 = LCD_BLUE ; IOCON_P0_9 = LCD_BLUE ; IOCON_P2_12 = LCD_BLUE ; IOCON_P2_13 = LCD_BLUE ; IOCON_P1_26 = LCD_BLUE ; IOCON_P1_27 = LCD_BLUE ; IOCON_P1_28 = LCD_BLUE ; IOCON_P1_29 = LCD_BLUE ; IOCON_P2_2 = LCD_DCLK ; IOCON_P2_5 = LCD_HSYNC; IOCON_P2_3 = LCD_VSYNC; IOCON_P2_4 = LCD_LCDDEN; IOCON_P2_0 = LCD_PWR; LPC_SC->PCONP |= 1<<0; LCD_CTRL_REG &= 0; LCD_CTRL_REG |= (5<<1)|LCDTFT; LCD_CTRL_REG &= ~BGR; LCD_CTRL_REG &= ~LCDPWR; LCD_POL_REG &= 0; LCD_POL_REG |=(1<<0); LCD_POL_REG |=IVS|IHS; LCD_POL_REG |= (TFT_H_SIZE-1)<<16; LPC_LCD->POL |= (LCD_ClockDivide(72300000)<<0); LPC_SC->LCD_CFG =0;// 120000000 / ((unsigned long) C_GLCD_PIX_CLK); 120 MHZ /*Refresh time 41msec*/ LCD_TIMH_REG &= 0; LCD_TIMH_REG |= (TFT_H_BACKPORCH - 1)<<24; LCD_TIMH_REG |= (TFT_H_FRONTPORCH - 1)<<16; LCD_TIMH_REG |= (TFT_H_PULSE - 1)<<8;//*same LCD_TIMH_REG |= ((TFT_H_SIZE/16) - 1)<<2;//*same LCD_TIMV_REG &= 0; LCD_TIMV_REG |= (TFT_V_BACKPORCH)<<24; LCD_TIMV_REG |= (TFT_V_FRONTPORCH)<<16; LCD_TIMV_REG |= (TFT_V_PULSE - 1)<<10; LCD_TIMV_REG |= TFT_V_SIZE - 1; LCD_UPBASE_REG = LCD_VRAM_BASE_ADDR & ~7UL ; LCD_LPBASE_REG = LCD_VRAM_BASE_ADDR & ~7UL ; for( i = 0; (TFT_H_SIZE * TFT_V_SIZE) > i; i++) *pDst++ = WHITE; for(i = 10000; i; i--); //LCD_CTRL_REG |= LCDPWR| LCD_EN; LCD_CTRL_REG |= LCDPWR;//| LCD_EN; } void lcd_powerenable(){ LCD_CTRL_REG |= LCD_EN; } void lcd_powerdisable(){ LCD_CTRL_REG &= LCD_EN; } int main() { int a=102,b=290; sdram_initialization(); glcd_initialization (); lcd_powerenable(); set_color(WHITE); //init_timer1(1000); while(1) { //lcd_color_pixel(102,190,RED);lcd_color_pixel(102,191,RED);lcd_color_pixel(102,192,RED); lcd_14arial_writestr(a,b,"WELCOME",'B',RED,WHITE);// Its a function for displaying 14 Arial font character. a=horizontal location,b=vertical location,welcome =character should display in TFT lcd(accessing from ASCII Library), red=character color,white=screen border color. } } |