#include “system.h”
#include
int main (void)
{
FILE *lcd1;
lcd1 = fopen(“/dev/lcd”, “w”);
if (lcd1 == NULL)
printf(“lcd not ready…n”);
else
{
printf(“lcd ready…n”);
fprintf(lcd1, “111111111111111111111n”);
}
fclose(lcd1);
printf(“can you see something?”);
return 0;
}
#include
#include<altera_avalon_lcd_16207_regs.h>
#include
alt_u8 lcd_string1[] = “HELLO”;
alt_u8 lcd_string2[] = “2010”;
void check_busy() //读液晶的忙标志位并检测
{
alt_u8 status;
do
{
status=IORD_ALTERA_AVALON_LCD_16207_STATUS(LCD_BASE);
}while(status&0x80);
}
void lcd_init() //液晶1602初始化
{
IOWR_ALTERA_AVALON_LCD_16207_COMMAND(LCD_BASE, 0x38); //功用设置
check_busy();
IOWR_ALTERA_AVALON_LCD_16207_COMMAND(LCD_BASE, 0x01); //清屏
check_busy();
IOWR_ALTERA_AVALON_LCD_16207_COMMAND(LCD_BASE, 0x06); //Y地址主动加1形式
check_busy();
IOWR_ALTERA_AVALON_LCD_16207_COMMAND(LCD_BASE, 0x0c); //显现开,不显现光标
}
void lcd_prints(alt_u8 *string) //打印字符串
{
while(*string!=)
{
check_busy();
IOWR_ALTERA_AVALON_LCD_16207_DATA(LCD_BASE, *string);
string++;
}
}
void select_xy(alt_u8 x,alt_u8 y) //挑选屏幕坐标,x=0为第1行,x=1为第2行
{ //y=0~15,别离对应第1列到第16列
check_busy();
if(x%2==0)
{
IOWR_ALTERA_AVALON_LCD_16207_COMMAND(LCD_BASE, 0x80+y);
}
else
{
IOWR_ALTERA_AVALON_LCD_16207_COMMAND(LCD_BASE, 0xc0+y);
}
}
int main (void) __attribute__ ((weak, alias (“alt_main”))); //将程序的进口改为alt_main(),能够使
//许多驱动不会加载,能够大大减小代码长度
void alt_main()
{
lcd_init();
select_xy(0,0);
lcd_prints(lcd_string1);
select_xy(1,7);
lcd_prints(lcd_string2);
}
////////////
#include
#include “priv/alt_busy_sleep.h”
#include “system.h”
#include “altera_avalon_pio_regs.h”
#include “alt_types.h”
alt_u8 table[]=”i love you”;
alt_u8 table1[]=”www.renren.cn”;
void write_com(alt_u8 command)
{
alt_busy_sleep(5000);
}
void write_date(alt_u8 date)
{
IOWR_ALTERA_AVALON_PIO_DATA(LCDE_BASE,1);
IOWR_ALTERA_AVALON_PIO_DATA(LCDE_BASE,0);
alt_busy_sleep(5000);
}
void intit()
{
}
int main()
{
}