資源簡介
基于STM32的12832液晶顯示驅動,包含LCD的初始化,字符顯示,清屏等操作。
代碼片段和文件信息
#include?“stm32f10x.h“
#include?“user_Config.h“
#include?“SysTick.h“
//#include?“ds18b20.h“
extern?u8?keyval;?
extern?u8?flash_value;
extern?u8?time_data_flag;
extern?u8?flash_flag;
extern?__IO?u32?TimingDelay;
extern?__IO?uint32_t?TimeDisplay;
unsigned?char??AC_TABLE[]={???
??0x800x810x820x830x840x850x860x87??????//第一行漢字位置????
??0x900x910x920x930x940x950x960x97??????//第二行漢字位置????
};???
void?CheckBusy(?void?)???
{???
??unsigned?char?retb;
??GPIO_InitTypeDef?GPIO_InitStructure;
??GPIO_InitStructure.GPIO_Pin?=?LCD_DATA0|LCD_DATA1|LCD_DATA2|LCD_DATA3;
??GPIO_InitStructure.GPIO_Mode?=?GPIO_Mode_IPU; //GPIO工作在輸出模式
??GPIO_InitStructure.GPIO_Speed?=?GPIO_Speed_50MHz;
??GPIO_Init(GPIO_LCDDATA_C?&GPIO_InitStructure);??
??
??GPIO_InitStructure.GPIO_Pin?=LCD_DATA4|LCD_DATA5|LCD_DATA6|LCD_DATA7;?
??GPIO_InitStructure.GPIO_Mode?=?GPIO_Mode_IPU; //GPIO工作在輸出模式
??GPIO_InitStructure.GPIO_Speed?=?GPIO_Speed_50MHz;
??GPIO_Init(GPIO_LCDDATA_A?&GPIO_InitStructure);????????
??
??do{
????LCD_RS_LOW;//GPIO_ResetBits(GPIO_LCDCTLlcd_rs);
????LCD_RW_HIGH;//GPIO_SetBits(GPIO_LCDCTLlcd_rw);
????delay_us(1);
????LCD_E_HIGH;//GPIO_SetBits(GPIO_LCDCTLlcd_e);
????delay_us(1);?????
????retb=GPIO_ReadInputDataBit(GPIO_LCDDATA_ALCD_DATA7);
????LCD_E_LOW;//GPIO_ResetBits(GPIO_LCDCTLlcd_e);
??}
??while((retb)!=0);
??delay_us(1);
??GPIO_InitStructure.GPIO_Pin?=?LCD_DATA0|LCD_DATA1|LCD_DATA2|LCD_DATA3;
??GPIO_InitStructure.GPIO_Mode?=?GPIO_Mode_Out_PP; //GPIO工作在輸出模式
??GPIO_InitStructure.GPIO_Speed?=?GPIO_Speed_50MHz;
??GPIO_Init(GPIO_LCDDATA_C?&GPIO_InitStructure);??
??
??GPIO_InitStructure.GPIO_Pin?=LCD_DATA4|LCD_DATA5|LCD_DATA6|LCD_DATA7;?
??GPIO_InitStructure.GPIO_Mode?=?GPIO_Mode_Out_PP; //GPIO工作在輸出模式
??GPIO_InitStructure.GPIO_Speed?=?GPIO_Speed_50MHz;
??GPIO_Init(GPIO_LCDDATA_A?&GPIO_InitStructure);????????
}?
void?WriteCommand(?unsigned?char?Cbyte?)???
{???
??CheckBusy();???
??LCD_RS_LOW;//GPIO_ResetBits(GPIO_LCDCTLlcd_rs);
??LCD_RW_LOW;//GPIO_ResetBits(GPIO_LCDCTLlcd_rw);
??delay_us(1);?
??GPIO_WriteBit(GPIO_LCDDATA_CLCD_DATA0(BitAction)((Cbyte>>0)&0x01));
??GPIO_WriteBit(GPIO_LCDDATA_CLCD_DATA1(BitAction)((Cbyte>>1)&0x01));
??GPIO_WriteBit(GPIO_LCDDATA_CLCD_DATA2(BitAction)((Cbyte>>2)&0x01));
??GPIO_WriteBit(GPIO_LCDDATA_CLCD_DATA3(BitAction)((Cbyte>>3)&0x01));
??GPIO_WriteBit(GPIO_LCDDATA_ALCD_DATA4(BitAction)((Cbyte>>4)&0x01));
??GPIO_WriteBit(GPIO_LCDDATA_ALCD_DATA5(BitAction)((Cbyte>>5)&0x01));
??GPIO_WriteBit(GPIO_LCDDATA_ALCD_DATA6(BitAction)((Cbyte>>6)&0x01));
??GPIO_WriteBit(GPIO_LCDDATA_ALCD_DATA7(BitAction)((Cbyte>>7)&0x01));
??LCD_E_HIGH;//GPIO_SetBits(GPIO_LCDCTLlcd_e);
??delay_us(1);???????
??LCD_E_LOW;//GPIO_ResetBits(GPIO_LCDCTLlcd_e);
}???
void?WriteData(?unsigned?char?Dbyte?)???
{???
??CheckBusy();???
??LCD_RS_HIGH;//GPIO_SetBits(GPIO_LCDCTLlcd_rs);
??LCD_RW_LOW;//GPIO_ResetBits(GPIO_LCDCTLlcd_rw);
??delay_us(1);???????
??G
- 上一篇:IIS PUT Scanner 1.3
- 下一篇:基于des前后端加密解密
評論
共有 條評論