void SendLCD(UCHAR command, UCHAR data1) { /* Wait for the busy flag to clear */ LCD_busy(); /* Set RW low, RS high, CS low to write the instruction command */ LCD_rw = 0; LCD_rs = 1; LCD_cs = 0; LCD_data = swap(command); LCD_busy(); lcd_strobe_enable(); LCD_busy(); /* Set RW low, RS low to write the instruction data */ LCD_rw = 0; LCD_rs = 0; LCD_data = swap(data1); LCD_busy(); lcd_strobe_enable(); LCD_busy(); }
/** * 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 RW low, RS high to write the instruction command */ lcd_rw_low(); lcd_rs_high(); /* Instruction commands are a maximum of 4 bits long, so * just mask off the rest. */ LCD_DATA_PORT = (command&0x0F); __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;"); /* 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;"); }