|
数据没写进去,写入和读出的地址定义的是一样的。现在改变写入的值根本就不影响读出的值,读出的值老是524288.运行测试程序的时候用printk观察,是能够进入驱动的每一个函数的,当写的时候,会进入fops里的写函数,会执行在6楼提到的赋值操作,读的时候,也会进入fops里的读函数,只是读出来的东西不受写的东西的影响,我怀疑是根本就没写进去。实在没辙了,贴主要代码了,大家爱帮我看看。
short int *vbase;
vbase=(short int *)ioremap_nocache(0x30000000,0x1b);
static int __init hpi_init (void)//初始化代码,在加载模块的时候执行{
AT91_SYS->EBI_SMC2_CSR[2] = 0x22003484;
if (!request_mem_region (HPI_PHYSICAL_BASEADDR,HPI_PHYSICAL_size, "HPI"))
{ printk ("Error request mem \n"); }
else
{ PDEBUG ("request mem success!\n"); }
hpi_vbase = (short int *) ioremap_nocache (HPI_PHYSICAL_BASEADDR, HPI_PHYSICAL_size);
ret = register_chrdev (254, "HPI", &hpi_fops);}
ssize_t hpi_write (struct file *file, const char *buf, size_t count,loff_t * offp)//写函数 写函数里调用了三个函数:写控制寄存器HPIC_Write (0x00010001);写地址寄存器HPIA_Write (0x0003ffe0);写数据寄存器HPID_AutoWrite (*pwritetmp++);
inline void HPIC_Write (int w)
{short int t1, t2;
t1 = (short int)(0xffff & (w >> 16));
t2 = (short int)(0xffff & w);
mb();writew (t1, (u16 *)(hpi_vbase + 0x00));mb();writew (t2, (u16 *)(hpi_vbase + 0x02));
delay();
}
inline void HPIA_Write (int w)
{ short int t1, t2;
t1 = (short int)(0xffff & (w >> 16));
t2 = (short int)(0xffff & w);
mb();writew (t1, (u16 *)(hpi_vbase + 0x04));mb();writew (t2, (u16 *)(hpi_vbase + 0x06));
delay();
}
void HPID_AutoWrite (int w)
{ short int t1, t2;
t1 = (short int)(0xffff & (w >> 16));
t2 = (short int)(0xffff & w);
mb();outw (t1, hpi_vbase + 0x08);mb();outw (t2, hpi_vbase + 0x0a);mb();
delay();
}
上面的函数都会执行到,就是执行贴出来的三个内联函数的时候,数据没有写入到指定的外设地址中去。 |
|