test.c ----------------------------------------------------------------------------------------- #include "LCD.h" // LCD1602 //---------------------------------------------------------- int main(void) { // -> ---------------- <- // 16bits char Line1[16] = "LCD1602 Test"; char Line2[16] = "by yf.c"; LCD_Test(Line1, Line2); return 0; } //---------------------------------------------------------- ----------------------------------------------------------------------------------------- LCD.h ----------------------------------------------------------------------------------------- #ifndef __LCD_H__ #define __LCD_H__ // LCD Module 16*2 #define lcd_write_cmd(data) IOWR(LCD1602_BASE, 0, data) #define lcd_read_cmd() IORD(LCD1602_BASE, 1) #define lcd_write_data(data) IOWR(LCD1602_BASE, 2, data) #define lcd_read_data() IORD(LCD1602_BASE, 3) //---------------------------------------------------------- void LCD_Init(); void LCD_Show_Text(char* Text); void LCD_Line2(); void LCD_Test(char* Text1, char* Text2); //---------------------------------------------------------- #endif ----------------------------------------------------------------------------------------- LCD.c ----------------------------------------------------------------------------------------- #include #include #include #include "system.h" #include "LCD.h" //---------------------------------------------------------- void LCD_Init() { lcd_write_cmd(0x38); usleep(5000); // Display Mode lcd_write_cmd(0x0C); usleep(5000); // Cursor Glint Mode lcd_write_cmd(0x01); usleep(5000); // Clear Display lcd_write_cmd(0x06); usleep(5000); // Cursor Move Forward Mode lcd_write_cmd(0x80); usleep(5000); // Point to the Initial Address } //---------------------------------------------------------- void LCD_Show_Text(char* Text) { int i; for(i=0;i