#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <string.h>
#define NODE_EXP "/dev/fpga_char_lcd"
#define LCD_ON 1 /* Device name */
#define LCD_CLEAR 2
#define LCD_SET_HOME 3
#define LCD_CURSOR_BLINK 4
#define LCD_DATA_WRITE 5
#define LCD_OFF 6
/* Application : To test the functionaity of LCD Driver */
int main ()
{
int exp_dev= 0; /* exp_dev is file descriptor */
int ret,res= 0; /* return value of system call */
char name[10];
exp_dev = open(NODE_EXP, O_RDWR);
if (exp_dev < 0)
{
fprintf(stderr, "Open error: %s\n", NODE_EXP);
return 1;
}
if (res=ioctl(exp_dev,LCD_ON, NULL) < 0 ) /* Ioctl */
{
printf("%d---> Error in switching OFF the LCD \r\n",res);
getchar();
close(exp_dev);
return 1;
}
if (res=ioctl(exp_dev,LCD_CLEAR, NULL) < 0 )
{
printf("%d---> Error in Clearing the LCD \r\n",res);
getchar();
close(exp_dev);
return 1;
}
if (res=ioctl(exp_dev,LCD_SET_HOME, NULL) < 0 )
{
printf("Error in Set home the LCD \r\n");
getchar();
close(exp_dev);
return 1;
}
if (ioctl(exp_dev,LCD_CURSOR_BLINK , NULL) < 0 )
{
printf("Error inCursor blink in LCD \r\n");
getchar();
close(exp_dev);
return 1;
}
/* *******************INPUT TAKEN FROM USER ****************** */
printf("Enter your name :");
scanf("%s",&name);
/* *******************INPUT TAKEN FROM USER ****************** */
if (ioctl(exp_dev,LCD_DATA_WRITE, name) < 0 )
{
printf("Error in switching OFF the LCD \r\n");
getchar();
close(exp_dev);
return 1;
}
if (ioctl(exp_dev,LCD_OFF, NULL) < 0 )
{
printf("Error in switching OFF the LCD \r\n");
getchar();
close(exp_dev);
return 1;
}
close(exp_dev);
printf("\n Hit A Key To Stop...");
getchar();
exit(1);
}
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <string.h>
#define NODE_EXP "/dev/fpga_char_lcd"
#define LCD_ON 1 /* Device name */
#define LCD_CLEAR 2
#define LCD_SET_HOME 3
#define LCD_CURSOR_BLINK 4
#define LCD_DATA_WRITE 5
#define LCD_OFF 6
/* Application : To test the functionaity of LCD Driver */
int main ()
{
int exp_dev= 0; /* exp_dev is file descriptor */
int ret,res= 0; /* return value of system call */
char name[10];
exp_dev = open(NODE_EXP, O_RDWR);
if (exp_dev < 0)
{
fprintf(stderr, "Open error: %s\n", NODE_EXP);
return 1;
}
if (res=ioctl(exp_dev,LCD_ON, NULL) < 0 ) /* Ioctl */
{
printf("%d---> Error in switching OFF the LCD \r\n",res);
getchar();
close(exp_dev);
return 1;
}
if (res=ioctl(exp_dev,LCD_CLEAR, NULL) < 0 )
{
printf("%d---> Error in Clearing the LCD \r\n",res);
getchar();
close(exp_dev);
return 1;
}
if (res=ioctl(exp_dev,LCD_SET_HOME, NULL) < 0 )
{
printf("Error in Set home the LCD \r\n");
getchar();
close(exp_dev);
return 1;
}
if (ioctl(exp_dev,LCD_CURSOR_BLINK , NULL) < 0 )
{
printf("Error inCursor blink in LCD \r\n");
getchar();
close(exp_dev);
return 1;
}
/* *******************INPUT TAKEN FROM USER ****************** */
printf("Enter your name :");
scanf("%s",&name);
/* *******************INPUT TAKEN FROM USER ****************** */
if (ioctl(exp_dev,LCD_DATA_WRITE, name) < 0 )
{
printf("Error in switching OFF the LCD \r\n");
getchar();
close(exp_dev);
return 1;
}
if (ioctl(exp_dev,LCD_OFF, NULL) < 0 )
{
printf("Error in switching OFF the LCD \r\n");
getchar();
close(exp_dev);
return 1;
}
close(exp_dev);
printf("\n Hit A Key To Stop...");
getchar();
exit(1);
}
No comments:
Post a Comment