用法与驱动LED类似。
话不多说,直接贴上例程
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <sys/ioctl.h> #include <string.h> int main(int argc, char**argv) { int fd; char *buzz_path = "/dev/buzzer_ctl"; fd = open(buzz_path, O_RDWR|O_NOCTTY|O_NDELAY); if(fd<0) { printf("open error"); exit(1); } else { ioctl(fd, atoi(argv[1]), atoi(argv[2])); } close(fd); }
由于ioctl 规定传入两个参数...但实际驱动蜂鸣器只用到 argv[1], 所以第二个参数不起作用,但必须传入。
argv[1] = 1 启动蜂鸣器;
argv[2] = 0 关闭蜂鸣器;
最后
以上就是感性茉莉最近收集整理的关于嵌入式开发 :字符类 蜂鸣器的全部内容,更多相关嵌入式开发内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复