nios的免 费ip中只有16207的驱动。 在nios 的commponent中的src中,你包含了头文件后便可以调用了。 altera_avalon_lcd_16207.c 。。。。。。。。就是lcd函数。如果型号不对,你可以自己写,不难! 节选如下 static void lcd_write_data(alt_LCD_16207_dev * dev, unsigned char data) { unsigned int base = dev->base; /* We impose a timeout on the driver in case the LCD panel isn't connected. * The first time we call this function the timeout is approx 25ms * (assuming 5 cycles per loop and a 200MHz clock). Obviously systems * with slower clocks, or debug builds, or slower memory will take longer. */ int i = 1000000; /* Don't bother if the LCD panel didn't work before */ if (dev->broken) return; /* Wait until LCD isn't busy. */ while (IORD_ALTERA_AVALON_LCD_16207_STATUS(base) & ALTERA_AVALON_LCD_16207_STATUS_BUSY_MSK) if (--i == 0) { dev->broken = 1; return; } /* Despite what it says in the datasheet, the LCD isn't ready to accept * a write immediately after it returns BUSY=0. Wait for 100us more. */ usleep(100); IOWR_ALTERA_AVALON_LCD_16207_DATA(base, data); dev->address++; } /* --------------------------------------------------------------------- */ static void lcd_clear_screen(alt_LCD_16207_dev * dev) { int y; lcd_write_command(dev, LCD_CMD_CLEAR); dev->x = 0; dev->y = 0; dev->address = 0; for (y = 0 ; y < ALT_LCD_HEIGHT ; y++) { memset(dev->line[y].data, ' ', sizeof(dev->line[0].data)); memset(dev->line[y].visible, ' ', sizeof(dev->line[0].visible)); dev->line[y].width = 0; } } /* --------------------------------------------------------------------- */ static void lcd_repaint_screen(alt_LCD_16207_dev * dev) { int y, x; /* scrollpos controls how much the lines have scrolled round. The speed * each line scrolls at is controlled by its speed variable - while * scrolline lines will wrap at the position set by width */ int scrollpos = dev->scrollpos; for (y = 0 ; y < ALT_LCD_HEIGHT ; y++) { int width = dev->line[y].width; int offset = (scrollpos * dev->line[y].speed) >> 8; if (offset >= width) offset = 0; for (x = 0 ; x < ALT_LCD_WIDTH ; x++) { char c = dev->line[y].data[(x + offset) % width]; /* Writing data takes 40us, so don't do it unless required */ if (dev->line[y].visible[x] != c) { unsigned char address = x + colstart[y]; if (address != dev->address) { lcd_write_command(dev, LCD_CMD_WRITE_DATA | address); dev->address = address; } lcd_write_data(dev, c); dev->line[y].visible[x] = c; } } } } /* --------------------------------------------------------------------- */ static void lcd_scroll_up(alt_LCD_16207_dev * dev) { int y; for (y = 0 ; y < ALT_LCD_HEIGHT ; y++) { if (y < ALT_LCD_HEIGHT-1) memcpy(dev->line[y].data, dev->line[y+1].data, ALT_LCD_VIRTUAL_WIDTH); else memset(dev->line[y].data, ' ', ALT_LCD_VIRTUAL_WIDTH); } dev->y--; } /* --------------------------------------------------------------------- */ static void lcd_handle_escape(alt_LCD_16207_dev * dev, char c) { |