static int temp_open(struct inode * pnode, struct file * pfile)
{
_io_gpjcon = (unsigned long*)ioremap(GPJCON,4);
_io_gpjdat = (unsigned long*)ioremap(GPJDAT,4);
_io_gpjup = (unsigned long*)ioremap(GPJUP,4);
printk("18b20 open\n");
return 0;
}
static int temp_release(struct inode *pnode, struct file *pfile)
{
printk("18b20 release\n");
return 0;
}
module_init(temp_init);
module_exit(temp_exit);
////////////////////////////registerover/////////////////////////////////
void DQ_OUTP()//GPJCON为输出模式
{
unsigned long temp;
temp = *(unsigned long*)_io_gpjcon;
temp &=(~0x3);
temp |= 0x1;
*(unsigned long*)_io_gpjcon = temp;
}
void DQ_INTP()//GPJCON为输入状态
{
unsigned long temp;
temp = *(unsigned long*)_io_gpjcon;
temp &=(~0x3);
*(unsigned long*)_io_gpjcon = temp;
}
void set_DQ(unsigned int flag)//设置GPJ0的高低电平
{
unsigned long temp;
temp = *(unsigned long*)_io_gpjdat;
temp &= ~0x1;
if(flag&0x1)
temp |= 0x1;
*(unsigned long*)_io_gpjdat = temp;
}
unsigned long get_DQ()//获得当前18B20的DQ状态
{
unsigned long temp;
temp = *(unsigned long*)_io_gpjdat;
temp &=0x01;
return temp;
}
/*
复位流程:
&nbs
上一页 [1] [2] [3] [4] [5] [6] [7] 下一页