新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應用 > 基于新唐NUC120RD2BN的EBI接口的ILI9327的驅(qū)動程序

基于新唐NUC120RD2BN的EBI接口的ILI9327的驅(qū)動程序

作者: 時間:2016-11-29 來源:網(wǎng)絡(luò) 收藏

void ILI9327_Init(void)
{
printf("*** ILI9327 Driver V1.00 Build byyuanxihua@21cn.comon ("__DATE__ " - " __TIME__ ")");

EBI_Init();

ILI9327_RESET();
ILI9327_READ_ID();

ILI9327_CMD(0xE9);//
ILI9327_DAT(0x20);
ILI9327_CMD(0x11); //exit_sleep_mode
DrvSYS_Delay(100000);//100 ms

ILI9327_CMD(0xD1); //VCOM Control
ILI9327_DAT(0x00);
ILI9327_DAT(0x6b);
ILI9327_DAT(0x18);
ILI9327_CMD(0xD0); //Power_Setting
ILI9327_DAT(0x07);
ILI9327_DAT(0x04);
ILI9327_DAT(0x88);
ILI9327_CMD(0x36);//set_address_mode
ILI9327_DAT(0x88);
ILI9327_CMD(0xC1);//Display_Timing_Setting for Normal/Partial Mode
ILI9327_DAT(0x10);
ILI9327_DAT(0x10);
ILI9327_DAT(0x02);
ILI9327_DAT(0x02);
ILI9327_CMD(0xC0); //Panel Driving Setting
ILI9327_DAT(0x00);
ILI9327_DAT(0x35);
ILI9327_DAT(0x00);
ILI9327_DAT(0x00);
ILI9327_DAT(0x01);
ILI9327_DAT(0x02);
ILI9327_CMD(0xC5); //Frame Rate Control
ILI9327_DAT(0x02);
ILI9327_CMD(0xD2); //Power_Setting for Normal Mode
ILI9327_DAT(0x01);
ILI9327_DAT(0x44);
ILI9327_CMD(0xC8);//Gamma Setting
ILI9327_DAT(0x00);
ILI9327_DAT(0x56);
ILI9327_DAT(0x45);
ILI9327_DAT(0x04);
ILI9327_DAT(0x03);
ILI9327_DAT(0x01);
ILI9327_DAT(0x23);
ILI9327_DAT(0x12);
ILI9327_DAT(0x77);
ILI9327_DAT(0x40);
ILI9327_DAT(0x09);
ILI9327_DAT(0x06);
ILI9327_DAT(0x88);
ILI9327_DAT(0x88);
ILI9327_DAT(0x88);
ILI9327_CMD(0x3A); //set_pixel_format
ILI9327_DAT(0x55);
ILI9327_CMD(0x2A);//set_column_address
ILI9327_DAT(0x00);
ILI9327_DAT(0x00);
ILI9327_DAT(0x00);
ILI9327_DAT(0xEF);
ILI9327_CMD(0x2B);//set_page_address
ILI9327_DAT(0x00);
ILI9327_DAT(0x20);
ILI9327_DAT(0x01);
ILI9327_DAT(0xAF);
ILI9327_CMD(0x29); //set_display_on
ILI9327_CMD(0x2C);//write_memory_start

DrvGPIO_SetBit(TFT_BL );

ILI9327_TEST();
}

void ILI9327_SLEEP(void)
{
ILI9327_CMD(0x10);//enter_sleep_mode
}

void ILI9327_WAKEUP(void)
{
ILI9327_CMD(0x11);//exit_sleep_mode
}


void EBI_test(void)
{
uint32_t i,j=0;
uint32_t data;

printf("%s(%d): Running: %s()",__FILE__,__LINE__,__FUNCTION__);

EBI_Init();

printf("MCLK of EBI colck is %d KHz.", (DrvSYS_GetHCLKFreq()/4)/1000);

//PA9 PB6 is defined as GPIO;
outpw(&SYS->GPAMFP, inpw(&SYS->GPAMFP) & ~(0x1<<9));
outpw(&SYS->GPBMFP, inpw(&SYS->GPBMFP) & ~(0x1<<6));

//TFT_RST TFT_DC TFT_BLis defined as Output;
DrvGPIO_Open(TFT_RST, E_IO_OUTPUT);
DrvGPIO_Open(TFT_DC , E_IO_OUTPUT);
DrvGPIO_Open(TFT_BL , E_IO_OUTPUT);
DrvGPIO_Open(E_GPB, 1 , E_IO_OUTPUT); //LED test...

DrvGPIO_SetBit(TFT_DC );
DrvGPIO_SetBit(TFT_RST);
DrvGPIO_ClrBit(TFT_BL );

while(0)
{
//test for write
*(__IO uint16_t *)((uint32_t)0x60000000) = 0xffff;
*(__IO uint16_t *)((uint32_t)0x60000000) = 0x0000;
}
while(0)
{
//test for read
data = *(__IO uint16_t *)((uint32_t)0x60000000);
printf("Running %d Times : D15-D0:%1d%1d%1d%1d%1d%1d%1d%1d_%1d%1d%1d%1d%1d%1d%1d%1dB",j++,
(data>>15)&0x1,(data>>14)&0x1,(data>>13)&0x1,(data>>12)&0x1,
(data>>11)&0x1,(data>>10)&0x1,(data>> 9)&0x1,(data>> 8)&0x1,
(data>> 7)&0x1,(data>> 6)&0x1,(data>> 5)&0x1,(data>> 4)&0x1,
(data>> 3)&0x1,(data>> 2)&0x1,(data>> 1)&0x1,(data>> 0)&0x1);
for(i=0;i<0x200000;i++); //delay about 1 second
}
while(1)
{
printf("Running %d Times...",j++);
//test for IO
DrvGPIO_SetBit(TFT_RST);
DrvGPIO_SetBit(TFT_DC );
DrvGPIO_SetBit(TFT_BL );
GPIOB->DOUT |= (1 << 1);
for(i=0;i<0x200000;i++);
DrvGPIO_ClrBit(TFT_RST);
DrvGPIO_ClrBit(TFT_DC );
DrvGPIO_ClrBit(TFT_BL );
GPIOB->DOUT &= ~(1 << 1);

for(i=0;i<0x200000;i++);
}
}

文件結(jié)束。


上一頁 1 2 下一頁

評論


技術(shù)專區(qū)

關(guān)閉