//******************************************* //*函数名称:void LCD_CheckBusy(void) * //*函数功能:并行方式查忙 * //*形式参数:无 * //*形参说明:无 * //*返回参数:无 * //*使用说明:无 * //******************************************* void LCD_CheckBusy(void) { #if PARALLEL == 1 unsigned char temp; LCD_DATA_IN(); //P1 = 0xff; //输入前置1 LCD_RS_LOW(); //RS = 0; //指令 LCD_RW_HIGH(); //RW = 1; //读模式 _delay_us(5); //延时 LCD_E_HIGH(); //E = 1; //使能 do { temp = LCD_DATA_GET(); //temp = BUSY; } while( 0x80==(temp&0x80) ); //等待不忙,temp=0x00时不忙 LCD_E_LOW(); //E = 0; //_delay_ms(20); #else unsigned char temp = 0xFC,temp2; do { LCD_SendByte(temp); temp = LCD_ReceiveByte(); temp2 = LCD_ReceiveByte(); temp &= 0x80; }while( temp==0x80 ); #endif //#if PARALLEL == 1 }
/***************************************************************************//** * @brief Read status of LCD controller * @return status : Status of LCD controller ******************************************************************************/ static unsigned char Lcd_Read_Status (void) { unsigned char status; LCD_DATA_DIR_IN(); GPIO_WriteBit(GPIOA, RS, Bit_RESET); GPIO_WriteBit(GPIOA, RW, Bit_SET); Delay(10000); GPIO_WriteBit(GPIOA, EN, Bit_SET); Delay(10000); status = LCD_DATA_IN() << 4; GPIO_WriteBit(GPIOA, EN, Bit_RESET); Delay(10000); GPIO_WriteBit(GPIOA, EN, Bit_SET); Delay(10000); status |= LCD_DATA_IN(); GPIO_WriteBit(GPIOA, EN, Bit_RESET); LCD_DATA_DIR_OUT(); return (status); }
//******************************************** //*函数名称:LCD_ReadData * //*函数功能:并行读LCD数据 * //*形式参数:无 * //*形参说明:无 * //*返回参数:读回的数据 * //*使用说明:无 * //******************************************** unsigned char LCD_ReadData(void) { #if PARALLEL == 1 unsigned char uc_Content; LCD_CheckBusy(); //_delay_us(2); LCD_DATA_IN(); //P1 = 0xff;//输入前置1 LCD_RS_HIGH(); //RS = 1; //数据 LCD_RW_HIGH(); //RW = 1; //读模式 LCD_E_HIGH(); //E = 1; //使能 _delay_us(1); //延时很重要 uc_Content = LCD_DATA_GET(); //uc_Content = P1; //P1口的内容放到变量中 LCD_E_LOW(); //E = 0; _delay_us(1); //延时很重要 return uc_Content; #endif //#if PARALLEL == 1 }
uint8_t ReadStatus (char Need){ uint8_t res, TimeOut; res=0; TimeOut=0; while (1) { // CLREA; LCD_DATA_DIR_IN(); SetCMD; ClrRD; //Разрешение дисплея ClrCE; res=LCD_DATA_IN(); //Прием статуса из дисплея SetRD; SetCE; LCD_DATA_DIR_OUT(); // SETEA; if ((res & Need) ==Need) return 1; TimeOut++; if (TimeOut > MaxTimeOut) {/*not=100;ton=6;*/ return 0; } } }