应用层:
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
/* thirddrvtest
*/
int main(int argc, char **argv)
{
int fd;
unsigned char key_val;
fd = open("/dev/buttons", O_RDWR);
if (fd < 0)
{
printf("can't open!\n");
}
while (1)
{
//read(fd, &key_val, 1);
//printf("key_val = 0x%x\n", key_val);
sleep(5);
}
return 0;
}
--------------------------------------------------------------------------------------------------------------------
linux内核2.22.6驱动部份:
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/fs.h>