首页下载资源物联网gec6818蜂鸣器LED内核模块文件下载(驱动)

ZIPgec6818蜂鸣器LED内核模块文件下载(驱动)

yxl136hv28.93KB需要积分:1

资源文件列表:

beep.zip 大约有3个文件
  1. beep/buz_test.c 497B
  2. beep/gec6818_beep.c 4.04KB
  3. beep/gec6818_beep.ko 60.95KB

资源介绍:

gec6818蜂鸣器LED内核模块文件下载(驱动)
#include #include #include #include #include #include #include #include #include #include #include #include #define DEVICE_NAME "beep" //�豸���� #define BUZZER_GPIO (PAD_GPIO_C + 14) //�ܽź� //#define BUZ_ON _IOW('B', 1, unsigned long) //#define BUZ_OFF _IOW('B', 0, unsigned long) //struct cdev /************************************************* *���ƺ��� *cmd ���÷�������״̬ 1 ---off 0 ----on *args ���÷������Ĺܽ� *************************************************/ //static long test_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long args) static long test_ioctl(struct file *file, unsigned int cmd, unsigned long args) { if(args!=1) { printk("the args is out of range 1 \n"); return -EINVAL; } switch(cmd){ case 1: gpio_set_value(BUZZER_GPIO, 0); //off���ù̵ܽ�ֵ0 printk("cmd = 0 , args=%ld\n", args); break; case 0: gpio_set_value(BUZZER_GPIO, 1) ; //on���ù̵ܽ�ֵ1 printk("cmd = 1 , args=%ld\n", args); break; default: printk("the cmd is out of range(0,1) \n"); return -EINVAL; break; } return 0; } /************************************************* *�ļ������� *************************************************/ static const struct file_operations chrdev_fops = { .owner = THIS_MODULE, .unlocked_ioctl = test_ioctl, }; /************************************************* *�����豸 *************************************************/ static struct miscdevice buz_misc = { .minor = MISC_DYNAMIC_MINOR, .name = DEVICE_NAME, .fops = &chrdev_fops, }; /******************************************************************** *�����ij�ʼ������--->���ں���������Դ���ںˡ��жϡ��豸�š���....�� ********************************************************************/ static int __init gec6818_buzzer_init(void) { int ret; ret = gpio_request( BUZZER_GPIO , "BUZZER"); //gpio�ܽ����� if(ret <0) { printk("EXYNOS6818_GPX3(5) can not request \n" ); goto fail_gpio_request; } gpio_direction_output( BUZZER_GPIO, 0); //��GPIO����Ϊ���"0" ret = misc_register(&buz_misc); //�Զ������豸�ļ� if(ret <0){ printk("can not register buz_misc \n"); goto err_misc_register; } return 0; //����ע��ɹ�������0������ע��ʧ�ܣ�����һ������������ //�������� err_misc_register: fail_gpio_request: gpio_free(BUZZER_GPIO); return ret; } /***************************************************************** *�����˳����� --->���������Դ�����ں� *****************************************************************/ static void __exit gec6818_buzzer_exit(void) { gpio_free(BUZZER_GPIO); misc_deregister(&buz_misc); printk("the driver is exiting!\n"); } module_init(gec6818_buzzer_init); //��������ں��������һ���û��ij�ʼ������ module_exit(gec6818_buzzer_exit); //�����ij��ں��������һ���û����˳����� //������������Ϣ�� #modinfo *.ko , ������������Ϣ�����DZ���ġ� MODULE_AUTHOR("ZOROE@GEC"); //���������� MODULE_DESCRIPTION("Buzzer of driver"); //���������� MODULE_LICENSE("GPL"); //��ѭ��Э��
100+评论
captcha