蜂鸣器驱动代码

驱动程序:beep_drv.c

[cpp]  view plain   copy
  1. #include <mach/gpio.h>  
  2. #include <linux/fs.h>  
  3. #include <linux/cdev.h>  
  4. #include <linux/device.h>  
  5.   
  6. static int beep_major = 0;  
  7. static struct class *pClass = NULL;  
  8. module_param(beep_major, int, 0);  
  9. MODULE_AUTHOR("woshishui");  
  10. MODULE_LICENSE("GPL");  
  11.   
  12. #define BEEP_MAGIC 'k'  
  13. #define BEEP_START_CMD _IO (BEEP_MAGIC, 1)  
  14. #define BEEP_STOP_CMD _IO (BEEP_MAGIC, 2)  
  15.   
  16. /* 
  17.  * Open the device; in fact, there's nothing to do here. 
  18.  */  
  19. int beep_open (struct inode *inode, struct file *filp)  
  20. {  
  21.     return 0;  
  22. }  
  23.   
  24. ssize_t beep_read(struct file *file, char __user *buff, size_t count, loff_t *offp)  
  25. {  
  26.   
  27.     *buff = gpio_get_value(S5PV210_GPD0(0));//获取引脚的电平值  
  28.   
  29.     return 0;  
  30. }  
  31.   
  32. ssize_t beep_write(struct file *file, const char __user *buff, size_t count, loff_t *offp)  
  33. {  
  34.     return 0;  
  35. }  
  36.   
  37. void
  • 4
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值