vibrator.c
资源名称:fmradio.zip [点击查看]
上传用户:ledjyj
上传日期:2014-08-27
资源大小:2639k
文件大小:1k
源码类别:
驱动编程
开发平台:
Unix_Linux
- /* *****************************************************************************
- * Vibrator interface for application
- * Scource code: vibrator.c
- * Author: Rick Li
- * Data: May 17, 2007
- * Copyright: Tech-Yeh Computer Co.,Ltd
- ********************************************************************************/
- #include <stdio.h>
- #include <fcntl.h>
- #include <stdlib.h>
- #include <errno.h>
- #include "vibrator.h"
- int fd=0;
- char *vib_dev_name="/dev/vibrator";
- int vibrator_on(void)
- {
- fd= open(vib_dev_name,O_RDWR);
- if(fd<0)
- {
- printf("device %s open failedn",vib_dev_name);
- return -1;
- }
- if(ioctl(fd,1,NULL))
- {
- printf("device %s can't workn",vib_dev_name);
- return -1;
- }
- return 0;
- }
- int vibrator_off(void)
- {
- if(fd==0)
- {
- printf("device %s not workn",vib_dev_name);
- return -1;
- }
- if(ioctl(fd,2,NULL))
- {
- printf("device %s can't stopn",vib_dev_name);
- return -1;
- }
- else
- {
- close(fd);
- }
- return 0;
- }
- /*int main(void)
- {
- vibrator_on();
- getchar ();
- vibrator_off();
- getchar ();
- vibrator_on();
- getchar ();
- vibrator_off();
- return 0;
- }*/