arm6410按键驱动程序

本文介绍了一种ARM6410处理器上的按键驱动程序实现,包括在`botton_drive.c`中配置GPIO进行读取,并提供了一个测试程序`botton_test.c`。然而,由于使用查询方式获取按键值导致高CPU占用,作者计划通过中断方式优化。
摘要由CSDN通过智能技术生成
arm6410按键驱动程序
通过查询的方法获取按键值
驱动程序  botton_drive.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 <linux/device.h>
//#include <asm/arch/regs-gpio.h>
//#include <asm/hardware.h>

static struct class *seconddrv_class;
static struct class_device *seconddrv_class_dev;

volatile unsigned long *gpmcon = NULL;
volatile unsigned long *gpmdat = NULL;
volatile unsigned long *gpncon = NULL;
volatile unsigned long *gpndat = NULL;


static int second_drv_open(struct inode *inode, struct file *file)
{
//printk("second_drv_open\n");
/* 配置GPm0,1,2,3为输出 */
*gpmcon &= ~((0xf<<(4*0)) | (0xf<<(4*1)) | (0xf<<(4*2)) | (0xf<<(4*3)));
*gpmcon |=  ((0x1<<(4*0)) | (0x1<<(4*1)) | (0x1<<(4*2)) | (0x1<<(4*3)));
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值