/** * Writes a raw instruction to the LCD. * @param command The 4-bit instruction code. * @param data The 8-bit paramater/data to the specified instruction. */ void lcd_write_command(unsigned char command, unsigned char data) { /* Wait for the busy flag to clear */ lcd_wait_busy(); /* Set Enable low, RW low, RS high to write the instruction command */ lcd_enable_low(); lcd_rw_low(); lcd_rs_high(); __asm("nop;"); __asm("nop;"); __asm("nop;"); __asm("nop;"); __asm("nop;"); __asm("nop;"); __asm("nop;"); __asm("nop;"); __asm("nop;"); /* Instruction commands are a maximum of 4 bits long, so * just mask off the rest. */ LCD_DATA_PORT = (command&0x0F); lcd_enable_high(); __asm("nop;"); __asm("nop;"); __asm("nop;"); __asm("nop;"); __asm("nop;"); __asm("nop;"); __asm("nop;"); __asm("nop;"); __asm("nop;"); /* Set RW low, RW low to write the instruction data */ lcd_rw_low(); lcd_rs_low(); LCD_DATA_PORT = data; __asm("nop;"); __asm("nop;"); __asm("nop;"); __asm("nop;"); __asm("nop;"); __asm("nop;"); lcd_strobe_enable(); __asm("nop;"); __asm("nop;"); __asm("nop;"); __asm("nop;"); __asm("nop;"); __asm("nop;"); }
/** * Strobes the Enable control line to trigger the lcd to process the * transmitted instruction. */ void lcd_strobe_enable(void) { lcd_enable_high(); __asm("nop;"); __asm("nop;"); __asm("nop;"); lcd_enable_low(); __asm("nop;"); __asm("nop;"); __asm("nop;"); }