示例#1
0
static void lcd_read_dummy(void)
{
	lcd_set_port_read();

	// write data
	iop->iop_pddat = LCD_READ_DATA | LCD_CLK_LO;
	udelay(LCD_DELAY);
	iop->iop_pddat = LCD_READ_DATA | LCD_CLK_HI;
	udelay(LCD_DELAY);
}
示例#2
0
static int lcd_read_status(void)
{
	int status;

	lcd_set_port_read();

	iop->iop_pddat = LCD_READ_STATUS | LCD_CLK_LO;
	udelay(LCD_DELAY);
	iop->iop_pddat = LCD_READ_STATUS | LCD_CLK_HI;
	udelay(LCD_DELAY);

	status = (iop->iop_pddat & 0xF0);

	return status;
}
// wait for busy flag to go away
void lcd_busy_wait(void) {
	lcd_set_instruction();
	lcd_set_port_read();
	lcd_set_read();
	lcd_set_enable_on();
	LCD_DELAY;

	while (lcd_read() & LCD_GET_BF) {
		lcd_set_enable_off();
		LCD_DELAY;
		LCD_DELAY;
		lcd_set_enable_on();
		LCD_DELAY;
		LCD_DELAY;
	}

	lcd_set_enable_off();
}
// generic get
uint8_t lcd_get(uint8_t type) {
	uint8_t data;

	lcd_busy_wait();
	lcd_set_port_read();
	lcd_write(0xFF);

	if (type) {
		lcd_set_data();
	} else {
		lcd_set_instruction();
	}

	lcd_set_read();
	lcd_set_enable_on();
	LCD_DELAY;
	LCD_DELAY;
	data = lcd_read();
	lcd_set_enable_off();

	return data;
}