在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
芯片精品文章合集(500篇!) 创芯人才网--重磅上线啦!
查看: 2242|回复: 0

请大家帮我看一下一个简单的字符设备驱动程序问题。片选信号一直为高,不解

[复制链接]
发表于 2005-7-2 09:00:07 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
请大家帮我看一下一个简单的字符设备驱动程序问题。
我对2410 datasheet的理解:当对0x10000001~0x18000000地址空间寻址时,nGCS2会变为低电平一片选外部芯片。但是当我读取这个设备的时候,为什么nGCS2老是保持为高啊?请教大牛!
#include <linux/config.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <asm/io.h>
#include <linux/miscdevice.h>
#include <linux/sched.h>
#include <linux/delay.h>
#include <linux/poll.h>
#include <linux/spinlock.h>
#include <linux/irq.h>
#include <linux/delay.h>
#include <asm/arch/S3C2410.h>
#include <asm/hardware.h>
#define DEVICE_NAME"FPGA_LINUX"
#define FPGA_LINUX_MAJOR 232
#define IRQ_FPGA_LINUX IRQ_EINT0
#define MAX_COLUMN 720
#define GET_DATA(x) (*(volatile unsigned int *)x)
unsigned long FPGA_DATA;
static int key_value[MAX_COLUMN];
static void s3c2410_io_port_init(void)
{
set_gpio_ctrl(GPIO_F0 | GPIO_PULLUP_DIS | GPIO_MODE_ALT0);
(void *)FPGA_DATA=ioremap(0x11000000,4);
}
static int s3c2410_read(struct file * file, char * buffer, size_t count, loff_t *ppos)
{
int i;
        if (count != sizeof key_value)
                return -EINVAL;
for(i=0;i<720;i++)
{
key_value = GET_DATA(FPGA_DATA);
}
        copy_to_user(buffer, &key_value, i*4);
        return i;
}
static struct file_operations s3c2410_fops = {
owner:THIS_MODULE,
read: s3c2410_read,
};
static devfs_handle_t devfs_handle;
static int __init s3c2410_init(void)
{
int ret;
int i;
for(i=0;i<MAX_COLUMN;i++)  key_value=0;
ret = register_chrdev(FPGA_LINUX_MAJOR, DEVICE_NAME, &s3c2410_fops);
if (ret < 0) {
  printk(DEVICE_NAME " can't register major number\n");
  return ret;
}
s3c2410_io_port_init();
                devfs_handle = devfs_register(NULL, DEVICE_NAME, DEVFS_FL_DEFAULT,FPGA_LINUX_MAJOR, 0, S_IFCHR | S_IRUSR | S_IWUSR,&s3c2410_fops, NULL);
return 0;
}
static void __exit s3c2410_exit(void)
{
devfs_unregister(devfs_handle);
unregister_chrdev(FPGA_LINUX_MAJOR, DEVICE_NAME);
}
module_init(s3c2410_init);
module_exit(s3c2410_exit);
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /1 下一条

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-6-16 20:05 , Processed in 0.022502 second(s), 8 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表