// Purpose: Reads a byte of data from the specified chip // Ouputs: A byte of data read from the chip BYTE glcd_readByte(BYTE chip) { BYTE data; // Stores the data read from the LCD if(chip == GLCD_CS1) // Choose which chip to read from output_high(GLCD_CS1); else output_high(GLCD_CS2); input_d(); // Set port d to input output_high(GLCD_RW); // Set for reading output_high(GLCD_E); // Pulse the enable pin delay_us(2); output_low(GLCD_E); delay_us(2); output_high(GLCD_E); // Pulse the enable pin delay_us(2); data = input_d(); // Get the data from the display's output register output_low(GLCD_E); output_low(GLCD_CS1); // Reset the chip select lines output_low(GLCD_CS2); return data; // Return the read data }
void Busy() { int LCD_Busy; delay_us(10); // debug do { output_d(0); output_high(LCD_RW); output_high(LCD_CE); LCD_Busy = (input_d()) & 0x80; // busy flag mask : bit7 output_low(LCD_CE); } while (LCD_Busy); delay_ms(2); // debug output_low(LCD_CE); output_low(LCD_RS); output_low(LCD_RW); }