STM8學(xué)習(xí)筆記(三):GPIO操作
主要是各種液晶吧,手上正好有1602的液晶,12864的液晶,主控芯片是s6b0108的
本文引用地址:http://www.ex-cimer.com/article/201611/320893.htm不帶字庫(kù),還有上次買的一個(gè)2.4寸的TFT彩屏,320*240的,主控芯片是ILI9325的
因?yàn)橹坝?1和STM32都驅(qū)動(dòng)過(guò),所以這次就沒(méi)寫什么,只是簡(jiǎn)單的移植了
下面只是最簡(jiǎn)單的底層驅(qū)動(dòng)
/*************************TFT*************************/
/*************************************************************
函數(shù)名稱:LCD_Write_Cmd
功 能:寫命令函數(shù)
參 數(shù):DH:高八位
DL:低八位
返 回 值:無(wú)
說(shuō) 明:無(wú)
*************************************************************/
void LCD_Write_Cmd(unsigned char DH,unsigned char DL)
{
LCD_CS0;
LCD_RS0;
GPIO_Write(LCD_DataBus,0xff);
GPIO_Write(LCD_DataBus,DH);
LCD_RW0;
LCD_RW1;
GPIO_Write(LCD_DataBus,0xff);
GPIO_Write(LCD_DataBus,DL);
LCD_RW0;
LCD_RW1;
LCD_CS1;
}
/*************************************************************
函數(shù)名稱:LCD_Write_Data
功 能:寫數(shù)據(jù)函數(shù)
參 數(shù):DH:高八位
DL:低八位
返 回 值:無(wú)
說(shuō) 明:無(wú)
*************************************************************/
void LCD_Write_Data(unsigned char DH,unsigned char DL)
{
LCD_CS0;
LCD_RS1;
GPIO_Write(LCD_DataBus,0xff);
GPIO_Write(LCD_DataBus,DH);
LCD_RW0;
LCD_RW1;
GPIO_Write(LCD_DataBus,0xff);
GPIO_Write(LCD_DataBus,DL);
LCD_RW0;
LCD_RW1;
LCD_CS1;
}
/*********************12864*****************************/
void LCD_WriteCmd(u8 Dat)
{
LCD_RS0;
LCD_RW0;
delayus(1);
LCD_ENABLE1;
delayus(1);
GPIO_Write(LCD_DataBus,0xff);
GPIO_Write(LCD_DataBus,Dat);
delayus(1);
LCD_ENABLE0;
delayus(1);
}
void LCD_WriteData(u8 Dat)
{
LCD_RS1;
LCD_RW0;
delayus(1);
LCD_ENABLE1;
delayus(1);
GPIO_Write(LCD_DataBus,0xff);
GPIO_Write(LCD_DataBus,Dat);
delayus(1);
LCD_ENABLE0;
delayus(1);
}
/*******************1602********************/
/******************************************************************/
/* 寫入命令函數(shù) */
/******************************************************************/
void LCD_WriteCmd(unsigned char cmd)
{
LCD_DelayMs(5);//操作前短暫延時(shí),保證信號(hào)穩(wěn)定
LCD_EA_L;
LCD_RS_L;
LCD_RW_L;
LCD_EA_H;
GPIO_Write(LCD_BUS,cmd);
LCD_EA_L;
}
/******************************************************************/
/* 寫入數(shù)據(jù)函數(shù) */
/******************************************************************/
void LCD_WriteData(unsigned char dat)
{
LCD_DelayMs(5); //操作前短暫延時(shí),保證信號(hào)穩(wěn)定
LCD_EA_L;
LCD_RS_H;
LCD_RW_L;
LCD_EA_H;
GPIO_Write(LCD_BUS,dat);
LCD_EA_L;
LCD_RS_L;
}
/*************************************************************
評(píng)論