/*================================================*/ void lcd_put_command(char byte_wr_cmd) // Write a command to the LCD. { lcdbusywait(); // Is the LCD ready to take the command? LCD_RS = COMMAND_RS; // Register Select Low for writing command LCD_RW = WRITE_RW; // R!W low for write LCD_DATA_PTR = byte_wr_cmd; // Command byte to register LCD_RS = COMMAND_RS; LCD_RW = READ_RW; }
/*=============================================*/ void lcdgotoaddr (unsigned char ddram_add) { if(ddram_add < 0x80) { lcdbusywait(); lcd_put_command(LCDHOME + ddram_add); cursor_position = LCDHOME + ddram_add; } }
/*=============================================*/ void lcdputch(char byte_wr) // Write a character to the LCD. { lcdbusywait(); // Is the LCD ready to take the command? LCD_RS = DATA_RS; // Register Select High for writing data LCD_RW = WRITE_RW; // R!W low for write LCD_DATA_PTR = byte_wr; // Data byte to data port switch (cursor_position) { case LINE_0_END: { lcd_put_command(LINE_1_START); cursor_position = LINE_1_START; break; } case LINE_1_END: { lcd_put_command(LINE_2_START); cursor_position = LINE_2_START; break; } case LINE_2_END: { lcd_put_command(LINE_3_START); cursor_position = LINE_3_START; break; } case LINE_3_END: { lcd_put_command(LINE_0_START); cursor_position = LINE_0_START; break; } default: { cursor_position++; break; } } //printf("cursor_position = %x\n\r", cursor_position); LCD_RS = COMMAND_RS; LCD_RW = READ_RW; }
void lcdctrl(int cc) { struct pio *p1 = (struct pio *)0x4D000000; int s; lcdbusywait(); s = splhigh(); p1->cntrl = PIO1_MODE_OUTPUT; p1->portC = POWER | WRITE_CMD | ENABLE; p1->portA = cc; p1->portC = POWER | WRITE_CMD | DISABLE; splx(s); }