11.LED驱动程序设计(2)-LED驱动程序设计

这篇博客介绍了如何在Linux环境下设计LED驱动程序。通过包含必要的头文件并定义LED寄存器地址,实现了LED的打开和关闭操作。在`led_open`函数中,初始化LED配置并映射内存;在`led_ioctl`函数中,根据命令执行LED开关。博客还展示了如何注册和注销字符设备驱动。
摘要由CSDN通过智能技术生成
#include <linux/module.h>
#include <linux/init.h>
#include <linux/cdev.h>
#include <linux/fs.h>
#include <linux/io.h>
#include <mach/gpio-bank-k.h>
#include "led.h"

#define LEDCON 0x7f008800
#define LEDDAT 0x7f008808
unsigned int *led_config; 
unsigned int *led_data; 

struct cdev cdev;
dev_t devno;

int led_open(struct inode *node, struct file *filp)
{
led_config = ioremap(LEDCON,4);
writel(0x11110000,led_config);

led_data = ioremap(LEDDAT,4);

return 0;
}

long led_ioctl(struct file *filp, unsigned int cmd,
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值