tiny6410 蜂鸣器字符设备驱动<2>
来源:互联网 发布:论坛推广软件 编辑:程序博客网 时间:2024/06/02 04:16
用户空间程序也就是测试程序,实现蜂鸣器的关闭和打开操作。用if语句做输入参数的字符串比较判断。
测试代码
#include <stdio.h>
#include <string.h>
#include <stdlib.h>#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#define MAGIC 'f'
#define START_CMD0 _IO(MAGIC,0)
#define STOP_CMD1 _IO(MAGIC,1)
int main(int argc,char *argv[])
{
int fp, i;
if(argc > 2)
{
printf("Usage ./beep_test arg");
return -1;
}
fp = open("/dev/beep",O_RDWR,S_IRUSR|S_IWUSR);
if(fp < 0)
{
printf("fail to open\n");
return -1;
}
if(strcmp(argv[1],"start") == 0)
ioctl(fp,START_CMD0,0);
else if(strcmp(argv[1],"stop") == 0)
ioctl(fp,STOP_CMD1,0);
else
{
printf("wrong arg\n");
return -1;
}
close(fp);
return 0;
}
Makefile文件如下:
obj-m := beep_modu.o
CURRENT_PATH = $(shell pwd)
KERNELDIR = /usr/local/FriendlyARM/tiny6410/linux/linux-2.6.38/
all:beep_modu.o beep_test.o
beep_modu.o:beep_modu.c
make -C $(KERNELDIR) M=$(CURRENT_PATH) modules
beep_test.o:beep_test.c
arm-linux-gcc -Wall -o beep_test beep_test.c
clean:
make -C $(KERNELDIR) M=$(CURRENT_PATH) clean
-rm -fr *.o beep_test beep_modu
最后结果:(选择了动态申请设备号)
0 0
- tiny6410 蜂鸣器字符设备驱动<2>
- tiny6410 蜂鸣器字符设备驱动<1>
- Tiny6410 简单的LED字符设备驱动
- Tiny6410 简单的LED字符设备驱动
- Linux字符设备驱动之Tiny6410 LED驱动分析
- 字符设备驱动之蜂鸣器与PWM——FS2410
- 字符设备驱动 2
- mini6410蜂鸣器驱动学习(混杂设备)
- misc类设备与蜂鸣器驱动
- OK6410之蜂鸣器buzzer字符驱动
- 10.字符设备驱动模型(2)-字符设备驱动模型
- Tiny6410 简单的设备驱动helloworld_driver
- tiny6410 linux混杂设备 led驱动
- 驱动开发-字符设备2
- Linux设备驱动--字符设备驱动程序2
- Linux设备驱动(2)字符设备
- [S5PV210 Linux字符驱动之PWM蜂鸣器驱动
- 字符设备驱动之I2C设备驱动(2)
- C/C++的一些杂项
- Java 高新技术(注解)
- [VisualStudio]_[VS实用插件集合*持续更新]
- 【BZOJ】【P1013】【JSOI2008】【球形空间产生器sphere】【题解】【高斯消元】
- sxstrace.exe 工具的解决办法
- tiny6410 蜂鸣器字符设备驱动<2>
- 跨框架弹层
- Find the median of 2 sort ed array.
- .Java的垃圾回收机制(GC)
- 把heritrix抓取的网页在eclipse里读进,然后写出文件时出现乱码
- update-rc.d使用
- ruby on rails 指导入门 http://ihower.tw/rails3/firststep.html
- 剖析网页从浏览器输入地址到加载完毕的全过程——建立连接
- 练习题(2)