⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iic.c

📁 S3C44BOX的BIOS。可使用的命令:help --- show help ? --- = help date --- show or set current date time --
💻 C
字号:
#include <string.h>
#include "../inc/44b.h"
#include "../inc/44blib.h"
#include "../inc/def.h"
#include "../inc/iic.h"


void Init_Iic(void)
{
	int	temp;
    rPCONF |=0xa;	//PF0:IICSCL, PF1:IICSDA
    rPUPF |=0x3;	//pull-up disable

	rIICCON &= 0xef;	//clear  pending bit
    rIICCON=((1<<7)|(0<<6)|(1<<5)|(0xf));
    //Enable interrupt, IICCLK=MCLK/16, Enable ACK
    //60Mhz/16/(15+1) = 234Khz	
    rIICADD=0x10;   // S3C44B0X slave address
    rIICSTAT=0x10;
	rIICCON &= 0xef;	//clear  pending bit

}


void Wr24LCxx(U32 slvAddr,U32 addr,U8 data)
{
    
	U32 iicSt,i;
	    
 	rIICDS = slvAddr;//0xa0
    rIICSTAT=0xf0; //MasTx,Start
    while(!(rIICCON&0x10)){}	//waitting the interrupt
    rIICDS=addr;
	for(i=0;i<10;i++);	//for setup time untill rising edge of IICSCL
    rIICCON = 0xaf;		//Clear pending bit
	while(!(rIICCON&0x10)){}	//waitting the interrupt
	rIICDS=data;
	for(i=0;i<10;i++);	//for setup time untill rising edge of IICSCL
    rIICCON = 0xaf;		//Clear pending bit
	while(!(rIICCON&0x10)){}
	rIICSTAT = 0xd0;	//stop MasTX condtion
	rIICCON=0xaf;		//resume IIC opertion
	Delay(1);	//wait until stop condtion is in effect.
	
	while(1)
	{
		rIICDS = slvAddr;
		iicSt = 0x100;
		rIICSTAT = 0xf0;	//MASTX,Start
		rIICCON = 0xaf;	//resume IIC opertion
		while(!(rIICCON&0x10)){
			iicSt = rIICSTAT;
		}
		if(!(iicSt&0x01))			break;
		rIICSTAT =0xd0;	//stop MasTX condtion
		rIICCON = 0xaf;
		Delay(1);	//wait until stop condtion is in effect.
	} 
    //write is completed.
}
	

void Rd24LCxx(U32 slvAddr,U32 addr,U8 *data)
{
	 U32 iicSt,i;
	 U8	tmp;	
	    
 	rIICDS = slvAddr;//0xa0
    rIICSTAT=0xf0; //MasTx,Start
    while(!(rIICCON&0x10)){}	//waitting the interrupt
    rIICDS=addr;
	for(i=0;i<10;i++);	//for setup time untill rising edge of IICSCL
    rIICCON = 0xaf;		//Clear pending bit
	
	while(!(rIICCON&0x10)){}

	rIICDS=slvAddr;
    rIICSTAT=0xb0; //MasRx,Start
	rIICCON = 0xaf;
	while(!(rIICCON&0x10)){}
	tmp = rIICDS;
	rIICCON = 0x2f;		//resumes IIC opertion with NOACK
	while(!(rIICCON&0x10)){}
	*data = rIICDS;
	rIICSTAT = 0x90;	//stop MasRX condition
	rIICCON = 0xaf;	//resume IICOpertion
	Delay(1);	//wait until stop condtion is in effect.		 
    
}



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -