/* * Sends a command byte to the 44780. */ void lcdCmd(uint8_t cmd) { wait_not_busy(); PORTC = (PORTC | PORTC_44780_DATA) & (cmd | (0x0F & ~PORTC_44780_RS)); e_pulse(); PORTC = (PORTC | PORTC_44780_DATA) & ((cmd << 4) | (0x0F & ~PORTC_44780_RS)); e_pulse(); }
/* * Writes a char on the LCD at the current position. */ void lcdPutc(char c) { uint8_t b; wait_not_busy(); b = c | 0x0F; PORTC = (PORTC | PORTC_44780_DATA | PORTC_44780_RS) & (c | 0x0F); e_pulse(); PORTC = (PORTC | PORTC_44780_DATA | PORTC_44780_RS) & ((c << 4) | 0x0F); e_pulse(); }
void send_char(unsigned char data) { RS=1; //set rs into write mode LCD_DATA=data; delay(50); e_pulse(); }
//======================================================================================== // LCD functions //======================================================================================== void send_config(unsigned char data) { RS=0; //clear rs into config mode LCD_DATA=data; delay(50); e_pulse(); }
/* * 44780 soft reset procedure. */ void lcdInit(void) { PORTC = (PORTC & ~(PORTC_44780_DATA | PORTC_44780_RS | PORTC_44780_E | PORTC_44780_RW)) | (LCD_CMD_INIT8 & PORTC_44780_DATA); chThdSleep(50); e_pulse(); chThdSleep(10); e_pulse(); chThdSleep(2); e_pulse(); wait_not_busy(); PORTC = (PORTC & ~(PORTC_44780_DATA | PORTC_44780_RS | PORTC_44780_E | PORTC_44780_RW)) | (LCD_CMD_INIT4 & PORTC_44780_DATA); e_pulse(); lcdCmd(LCD_CMD_INIT4); lcdCmd(LCD_SET_DM | LCD_DM_DISPLAY_ON); lcdCmd(LCD_SET_INCREMENT_MODE); }