/**************************************************************************************
 *
 *       Filename:  button_test.c
 *
 *    Description:  
 *        Created:  2008年06月18日 19时05分25秒 CST
 *         Author:   
 *        Company:  
 *
 *************************************************************************************/

#include  <stdio.h>
#include  <unistd.h>
#include  <sys/types.h>
#include  <sys/ioctl.h>
#include  <fcntl.h>
//#include "74HC165_button.h"
#define KBD_DEV "/dev/ls1b_buttons"

static  int kbd_fd = -1;


static  int init_device(void){
  int i;
  if((kbd_fd = open(KBD_DEV,O_RDONLY)) < 0){
    printf("Error opening %s deivce\n",KBD_DEV);
    return -1;
  }
  return 0;
}

int main(void){
  int   ret;
  int   i;
  unsigned int  data;
  if(init_device() < 0){
    return -1;
  }
  while(1){
  	read(kbd_fd,&data,sizeof(int));
  	if(data){
  		usleep(100000);
 		printf("data is 0x%04X\n",data);
 		data = 0;
  	}
  }
  return 0;
}