LED点灯驱动
来源:互联网 发布:linux虚拟机网络文件 编辑:程序博客网 时间:2024/06/07 21:42
/** HYfirstdrvtest.c* 应用程序,通过传入的参数来判断是否点灯*/#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <stdio.h>/* firstdrvtest on * firstdrvtest off */int main(int argc, char **argv){int fd;int val = 1;fd = open("/dev/xxx", O_RDWR);if (fd < 0){printf("can't open!\n");}write(fd, &val, 4);return 0;}
/** HYfirst_drv.c* 点灯的驱动*/#include <linux/module.h>#include <linux/kernel.h>#include <linux/fs.h>#include <linux/init.h>#include <linux/delay.h>#include <asm/uaccess.h>#include <asm/irq.h>#include <asm/io.h>#include <asm/arch/regs-gpio.h>#include <asm/hardware.h>static int first_drv_open(struct inode *inode, struct file *file){printk("open ok ..........\n");return 0;}static ssize_t first_drv_write(struct file *file, const char __user *buf, size_t count, loff_t * ppos){printk("write ok ..........\n");return 0;}static struct file_operations first_drv_fops = { .owner = THIS_MODULE, /* 这是一个宏,推向编译模块时自动创建的__this_module变量 */ .open = first_drv_open, .write=first_drv_write, };int major;static int first_drv_init(void){ major = register_chrdev(0, "first_drv", &first_drv_fops); // 注册, 告诉内核return 0;}static void first_drv_exit(void){unregister_chrdev(major, "first_drv"); // 卸载}module_init(first_drv_init);module_exit(first_drv_exit);MODULE_LICENSE("GPL");/** Makefile* */
KERN_DIR = /work/system/linux-2.6.22.6all:make -C $(KERN_DIR) M=`pwd` modules clean:make -C $(KERN_DIR) M=`pwd` modules cleanrm -rf modules.orderobj-m += HYfirst_drv.o
阅读全文
0 0
- led点灯驱动
- LED点灯驱动
- 字符设备驱动第十五课-----LED点灯
- arduino学习之:LED点灯
- 6410之点灯驱动
- 字符设备驱动点灯
- 通过ADS1.2编写LED点灯程序
- s3c2440的LED点灯裸机汇编程序
- s3c2440的LED点灯裸机C程序
- dm8168点灯的驱动代码
- Android驱动开发-Ok6410点灯
- Linux第一个驱动--点灯
- led驱动
- led驱动
- led驱动
- LED驱动
- led驱动
- LED驱动
- show slave status 参数详解
- spring mvc中使用ModelAndView向前台传值
- 根据判断条件置灰按钮
- 7.24 数据结构
- Android设置横屏后锁屏问题
- LED点灯驱动
- python连接mysql
- Return of the Nim----博弈(2017山东ACM-ICPC省赛)
- javaConfig
- 服务容错保护Hystrix
- spring消息转化器
- canvas requestAnimationFrame
- 勃大精深的设计模式--面向接口编程
- Android 開發 常見工具類收集