|
发表于 2014-2-22 10:21:26
|
显示全部楼层
#define PPL 800 // Pixels per line
#define HSW 1 // HSYNC pulse width, can be 1-48
#define HFP 40 // Horizontal front porch, MUST be 40
#define HBP 88 // Horizontal back porch, MUST be 88
#define LPP 480 // Lines per panel
#define VSW 3 // VSYNC pulse width, MSUT be 3
#define VFP 3 // Vertical front porch, 1,3ÊÇ¿ÉÒÔµÄ
#define VBP 3 // Vertical back porch, °´ÕÕdatasheet¸ø³öµÄ32·´¶øÓÐÎÊÌ⣡1,3ÊÇ¿ÉÒÔµÄ
#define ACB 1 // AC bias frequency (not used)
#define IVS 1 // ? Invert VSYNC
#define IHS 1 // ? Invert HSYNC
#define IPC 1 // ? Invert panel clock
#define CPL PPL // Clock per line (identical to pixels per line)
#define BPP 6 // Bits per pixel b110 = 16 bpp 5:6:5 mode
#define BGR 1 // Swap red and blue
#define LCDTFT 1 // LCD TFT panel
#define OPT_CLK 28500000 // Optimal clock rate (Hz) between 1-8.22 MHz according to SSD1289 datasheet */
MATRIX_ARB = 0 // Set AHB Matrix priorities [0..3] with 3 being highest priority
| (1 << 0) // PRI_ICODE : I-Code bus priority. Should be lower than PRI_DCODE for proper operation.
| (2 << 2) // PRI_DCODE : D-Code bus priority.
| (0 << 4) // PRI_SYS : System bus priority.
| (0 << 6) // PRI_GPDMA : General Purpose DMA controller priority.
| (0 << 8) // PRI_ETH : Ethernet: DMA priority.
| (3 << 10) // PRI_LCD : LCD DMA priority.
| (0 << 12) // PRI_USB : USB DMA priority.
;
//
//
// Init LCDC
//
LPC_SC->PCONP |= (1UL << 0); // Power the LCDC
LPC_LCD->CTRL &= ~(1UL << 0); // Disable the LCDC
LPC_LCD->TIMH = 0 // Configure horizontal axis
| (((PPL / 16) - 1) << 2)
| ((HSW - 1) << 8)
| ((HFP - 1) << 16)
| ((HBP - 1) << 24)
;
LPC_LCD->TIMV = 0 // Configure vertical axis
| ((LPP - 1) << 0)
| ((VSW - 1) << 10)
| ((VFP) << 16)
| ((VBP) << 24)
;
LPC_LCD->POL = 0 // Configure clock and signal polarity
| (_FindClockDivisor(OPT_CLK) << 0)
| ((ACB - 1) << 6)
| ((IVS) << 11)
| ((IHS) << 12)
| ((IPC) << 13)
| ((CPL - 1) << 16)
;
LPC_LCD->CTRL = 0 // Configure operating mode and panel parameters
| (BPP << 1)
| (BGR << 8)
| (LCDTFT << 5)
;
for (i = 0; i < GUI_COUNTOF(LPC_LCD->PAL); i++) {
LPC_LCD->PAL[i] = 0; // Clear the color palette with black
}
LPC_SC->LCD_CFG = 0x0; // No panel clock prescaler
//
// Enable LCDC
//
LPC_LCD->UPBASE = VRAM_ADDR_PHYS;
LPC_LCD->CTRL |= (1 << 0); // Enable LCD signals
LPC_LCD->CTRL |= (1 << 11); // Enable LCD power
LPC_GPIO2->SET |= (1 << LCD_BACKLIGHT_BIT); // Set backlight to on
} |
|