/* * lcd_an_register * @lcd: LCD data. * This function will register a LCD driver. */ void lcd_an_register(LCD_AN *lcd) { int32_t status = SUCCESS; /* Initialize LCD. */ LCD_AN_TGT_CLR_RS(lcd); LCD_AN_TGT_SET_RW(lcd); LCD_AN_TGT_CLR_EN(lcd); #if (LCD_AN_INIT_DELAY > 0) /* Need to wait at least 15ms on power up. */ sleep_ms(LCD_AN_INIT_DELAY); #endif /* Send first 0x3. */ lcd_an_send_nibble(lcd, 0x3); /* Controller still think that we are using 8bit mode so we can still read * the status bit. */ status = lcd_an_wait_8bit(lcd); if (status == SUCCESS) { /* Send second 0x3. */ LCD_AN_TGT_CLR_RW(lcd); lcd_an_send_nibble(lcd, 0x3); /* Wait for LCD to process the command in 8 bit mode. */ status = lcd_an_wait_8bit(lcd); } if (status == SUCCESS) { /* Send third 0x3. */ LCD_AN_TGT_CLR_RW(lcd); lcd_an_send_nibble(lcd, 0x3); /* Wait for LCD to process the command in 8 bit mode. */ status = lcd_an_wait_8bit(lcd); } if (status == SUCCESS) { /* Switch to 4-bit mode. */ LCD_AN_TGT_CLR_RW(lcd); lcd_an_send_nibble(lcd, 0x2); /* Wait for LCD to process the command in 8 bit mode. */ status = lcd_an_wait_8bit(lcd); } /* LCD configuration. */ if (status == SUCCESS) { status = lcd_an_write_register(lcd, FALSE, 0x28); } if (status == SUCCESS) { status = lcd_an_write_register(lcd, FALSE, 0x28); } if (status == SUCCESS) { status = lcd_an_write_register(lcd, FALSE, 0x08); } if (status == SUCCESS) { status = lcd_an_write_register(lcd, FALSE, 0x01); #if (LCD_AN_CLEAR_DELAY > 0) /* Wait for sometime before writing any more data. */ sleep_ms(LCD_AN_CLEAR_DELAY); #endif } if (status == SUCCESS) { status = lcd_an_write_register(lcd, FALSE, 0x06); } if (status == SUCCESS) { status = lcd_an_write_register(lcd, FALSE, 0x0C); } if (status == SUCCESS) { /* Reset the cursor location. */ lcd->cur_column = lcd->cur_row = 0; /* Register this LCD driver with console. */ lcd->console.fs.write = &lcd_an_write; lcd->console.fs.ioctl = &lcd_an_ioctl; console_register(&lcd->console); /* There is always some space available for data to be sent. */ lcd->console.fs.flags |= FS_SPACE_AVAILABLE; #ifdef LCD_AN_DEBUG lcd_an_fd = fs_open("\\console\\lcd1", 0); /* Connect LCD with debug console. */ fs_connect(lcd_an_fd, debug_fd); #endif } } /* lcd_an_register */
/* * lcd_an_register * @lcd: LCD data. * This function will register a LCD driver. */ void lcd_an_register(LCD_AN *lcd) { int32_t status = SUCCESS; /* Initialize LCD. */ lcd->clr_rs(lcd); lcd->set_rw(lcd); lcd->clr_en(lcd); #if (LCD_AN_INIT_DELAY > 0) /* Need to wait at least 15ms on power up. */ sleep_fms(LCD_AN_INIT_DELAY); #endif /* Initialize LCD in 4-bit mode ignore status from initial commands. */ lcd_an_write_register(lcd, LCD_IGNORE_WAIT, 0x33); lcd_an_write_register(lcd, LCD_IGNORE_WAIT, 0x32); status = lcd_an_write_register(lcd, 0, 0x28); if (status == SUCCESS) { status = lcd_an_write_register(lcd, 0, 0x08); } if (status == SUCCESS) { status = lcd_an_write_register(lcd, 0, 0x01); #if (LCD_AN_CLEAR_DELAY > 0) /* Wait for sometime before writing any more data. */ sleep_fms(LCD_AN_CLEAR_DELAY); #endif } if (status == SUCCESS) { status = lcd_an_write_register(lcd, 0, 0x06); } if (status == SUCCESS) { status = lcd_an_write_register(lcd, 0, 0x0C); } if (status == SUCCESS) { /* Reset the cursor location. */ lcd->cur_column = lcd->cur_row = 0; /* Register this LCD driver with console. */ lcd->console.fs.write = &lcd_an_write; lcd->console.fs.ioctl = &lcd_an_ioctl; console_register(&lcd->console); /* There is always some space available for data to be sent. */ lcd->console.fs.flags |= FS_SPACE_AVAILABLE; #ifdef LCD_AN_DEBUG lcd_an_fd = fs_open("\\console\\lcd1", 0); #endif } } /* lcd_an_register */