驱动程序:beep_drv.c
- #include <mach/gpio.h>
- #include <linux/fs.h>
- #include <linux/cdev.h>
- #include <linux/device.h>
- static int beep_major = 0;
- static struct class *pClass = NULL;
- module_param(beep_major, int, 0);
- MODULE_AUTHOR("woshishui");
- MODULE_LICENSE("GPL");
- #define BEEP_MAGIC 'k'
- #define BEEP_START_CMD _IO (BEEP_MAGIC, 1)
- #define BEEP_STOP_CMD _IO (BEEP_MAGIC, 2)
- /*
- * Open the device; in fact, there's nothing to do here.
- */
- int beep_open (struct inode *inode, struct file *filp)
- {
- return 0;
- }
- ssize_t beep_read(struct file *file, char __user *buff, size_t count, loff_t *offp)
- {
- *buff = gpio_get_value(S5PV210_GPD0(0));//获取引脚的电平值
- return 0;
- }
- ssize_t beep_write(struct file *file, const char __user *buff, size_t count, loff_t *offp)
- {
- return 0;
- }
- void