最近在弄一个,arm的最底层驱动,但怎么调,都的不到想要的结果,主要是对硬件i/o的读写还不是怎么的理解,望诸位指点,下面是源代码,
目的是,当数据线上出现D2D1D0=011时,地址线的信号A15---A0=0000 1000 0000 0000
源代码:诚盼各位指点,小弟以迷糊了几个星期了
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define ADC0809_MAJOR 231
#define adc0809_sle (*(volatile unsigned long *)ADC_GPACON)
#define adc0809_sle_data (*(volatile unsigned long *)ADC_GPADATA)
unsigned long ADC_GPACON, ADC_GPADATA;
unsigned long ADC_4051;
devfs_handle_t devfs_adc;
int adc0809_open(struct inode *, struct file *);
int adc0809_release(struct inode *, struct file *);
ssize_t adc0809_write(struct file *, const char *, size_t , loff_t *);
static struct file_operations adc0809_fops = {
open: adc0809_open,
write: adc0809_write,
release: adc0809_release,
};
/*
* Open/close code for raw IO.
*/
int adc0809_open(struct inode *inode, struct file *filp)
{
printk("open ok\n");
return 0;
}
ssize_t adc0809_write(struct file *filp, const char *buf,
size_t size,loff_t *offp)
{
char key; /int(key)=3;
if(get_user(key,buf))
return -EFAULT;
(*(volatile unsigned char *)ADC_4051)=key;
printk("addr=0x%x\n",addr);
udelay(100000);
return key;
}
//__ioremap
int adc0809_release(struct inode *inode, struct file *filp)
{
printk("release ok\n");
return 0;
}
int __init adc0809_init(void)
{
volatile unsigned int bankcon2;
printk("*********************adc0809_init**************\n");
ADC_GPACON = (unsigned int)ioremap(0x56000000,4);
ADC_GPADATA =(unsigned int)ioremap(0x56000004,4);
ADC_4051 = (unsigned int)ioremap(0x10000800,4);
bankcon2=(volatile unsigned int)ioremap(0x4800000c,4);
*(volatile unsigned int*)bankcon2 |= 3<<13;
/* select NGCS2 */
adc0809_sle |= 0x2000;
adc0809_sle_data &= (~0x2000);
/* register char device */
devfs_adc =
devfs_register(NULL,"adc0809",DEVFS_FL_DEFAULT,
ADC0809_MAJOR, 0,
S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
&adc0809_fops,NULL);
return 0;
}
int __init adc0809_exit(void)
{
devfs_unregister(devfs_adc);
return 0;
}
/*
__initcall(adc0809_init);
*/
module_init(adc0809_init);
module_exit(adc0809_exit);
主要帮我看看那个写函数,是不是能实现我要实现的目的?