亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? iic.c

?? samsung arm2440開(kāi)發(fā)板 數(shù)模轉(zhuǎn)換測(cè)試程序
?? C
字號(hào):
//====================================================================
// File Name : IIC.c
// Function  : S3C2440 IIC-bus Master Tx/Rx mode Test Program
//             (Interrupt / Non Interrupt (Polling))
// Program   : Shin, On Pil (SOP)
// Date      : May 21, 2002
// Version   : 0.0
// History
//   0.0 : Programming start (March 11, 2002) -> SOP
//====================================================================

#include <string.h>
#include "2440addr.h"
#include "2440lib.h"
#include "def.h"
#include "IIC.h"

static U8 _iicData[IICBUFSIZE];
static volatile int _iicDataCount;
static volatile int _iicStatus;
static volatile int _iicMode;
static int _iicPt;

//===================================================================
//       SMDK2440 IIC configuration
//  GPE15=IICSDA, GPE14=IICSCL
//  "Interrupt mode" for IIC block
//=================================================================== 


void * func_iic_test[][2]=
{	
//									    "0123456789012345" max 15磊 肺茄瀝竅咯 comment竅技夸.
//IIC 	
	(void *)Test_Iic, 											"IIC(KS24C080)INT",
	(void *)Test_Iic2,											"IIC(KS24C080)POL",
	0,0
};

void Iic_Test(void)
{
	int i;
	
	Uart_Printf("\n======  IIC Test program start ======\n");
		
	while(1)
	{
		i=0;
		Uart_Printf("\n\n");
		while(1)
		{   //display menu
			Uart_Printf("%2d:%s",i,func_iic_test[i][1]);
			i++;
			if((int)(func_iic_test[i][0])==0)
			{
				Uart_Printf("\n");
				break;
			}
			if((i%4)==0)
			Uart_Printf("\n");
		}

		Uart_Printf("\nPress Enter key to exit : ");
		i = Uart_GetIntNum();
		if(i==-1) break;		// return.
		if(i>=0 && (i<((sizeof(func_iic_test)-1)/8)) )	// select and execute...
			( (void (*)(void)) (func_iic_test[i][0]) )();
	}
	
	Uart_Printf("\n====== IIC Test program end ======\n");
}



//******************[ Test_Iic ]**************************************
void Test_Iic(void)
{
    unsigned int i,j,save_E,save_PE;
    static U8 data[256];

    Uart_Printf("[ IIC Test(Interrupt) using KS24C080 ]\n");

    save_E   = rGPECON;
    save_PE  = rGPEUP;
    rGPEUP  |= 0xc000;                  //Pull-up disable
    rGPECON |= 0xa00000;                //GPE15:IICSDA , GPE14:IICSCL 

    pISR_IIC = (unsigned)IicInt;
    rINTMSK &= ~(BIT_IIC);

      //Enable ACK, Prescaler IICCLK=PCLK/16, Enable interrupt, Transmit clock value Tx clock=IICCLK/16
      // If PCLK 50.7MHz, IICCLK = 3.17MHz, Tx Clock = 0.198MHz
    rIICCON = (1<<7) | (0<<6) | (1<<5) | (0xf);

    rIICADD  = 0x10;                    //2440 slave address = [7:1]
    rIICSTAT = 0x10;                    //IIC bus data output enable(Rx/Tx)
	rIICLC = (1<<2)|(1);  				// Filter enable, 15 clocks SDA output delay       added by junon
    
    Uart_Printf("Write test data into KS24C080\n");

    for(i=0;i<256;i++)
        Wr24C080(0xa0,(U8)i,i);
           
    for(i=0;i<256;i++)
        data[i] = 0;

    Uart_Printf("Read test data from KS24C080\n");
    
    for(i=0;i<256;i++)
        Rd24C080(0xa0,(U8)i,&(data[i])); 

        //Line changed 0 ~ f
    for(i=0;i<16;i++)
    {
        for(j=0;j<16;j++)
            Uart_Printf("%2x ",data[i*16+j]);
        Uart_Printf("\n");
    }
    rINTMSK |= BIT_IIC;    
    rGPEUP  = save_PE;
    rGPECON = save_E;
}


//*************************[ Wr24C080 ]****************************
void Wr24C080(U32 slvAddr,U32 addr,U8 data)
{
    _iicMode      = WRDATA;
    _iicPt        = 0;
    _iicData[0]   = (U8)addr;
    _iicData[1]   = data;
    _iicDataCount = 2;
    
    rIICDS   = slvAddr;                 //0xa0
    rIICSTAT = 0xf0;                    //MasTx,Start
      //Clearing the pending bit isn't needed because the pending bit has been cleared.
    
    while(_iicDataCount!=-1);

    _iicMode = POLLACK;

    while(1)
    {
        rIICDS     = slvAddr;
        _iicStatus = 0x100;
        rIICSTAT   = 0xf0;              //MasTx,Start
        rIICCON    = 0xaf;              //Resumes IIC operation. 
           
        while(_iicStatus==0x100);
           
        if(!(_iicStatus&0x1))
            break;                      //When ACK is received
    }
    rIICSTAT = 0xd0;                    //Stop MasTx condition 
    rIICCON  = 0xaf;                    //Resumes IIC operation. 
    Delay(1);                           //Wait until stop condtion is in effect.
       //Write is completed.
}
        
//**********************[ Rd24C080 ] ***********************************
void Rd24C080(U32 slvAddr,U32 addr,U8 *data)
{
    _iicMode      = SETRDADDR;
    _iicPt        = 0;
    _iicData[0]   = (U8)addr;
    _iicDataCount = 1;

    rIICDS   = slvAddr;
    rIICSTAT = 0xf0;                    //MasTx,Start  
      //Clearing the pending bit isn't needed because the pending bit has been cleared.
    while(_iicDataCount!=-1);

    _iicMode      = RDDATA;
    _iicPt        = 0;
    _iicDataCount = 1;
    
    rIICDS        = slvAddr;
    rIICSTAT      = 0xb0;               //MasRx,Start
    rIICCON       = 0xaf;               //Resumes IIC operation.   
    while(_iicDataCount!=-1);

    *data = _iicData[1];
}


//-------------------------------------------------------------------------
void __irq IicInt(void)
{
    U32 iicSt,i;
    
    rSRCPND = BIT_IIC;          //Clear pending bit
    rINTPND = BIT_IIC;
    iicSt   = rIICSTAT; 
    
    if(iicSt & 0x8){}           //When bus arbitration is failed.
    if(iicSt & 0x4){}           //When a slave address is matched with IICADD
    if(iicSt & 0x2){}           //When a slave address is 0000000b
    if(iicSt & 0x1){}           //When ACK isn't received

    switch(_iicMode)
    {
       case POLLACK:
           _iicStatus = iicSt;
           break;

       case RDDATA:
           if((_iicDataCount--)==0)
           {
               _iicData[_iicPt++] = rIICDS;
            
               rIICSTAT = 0x90;                 //Stop MasRx condition 
               rIICCON  = 0xaf;                 //Resumes IIC operation.
               Delay(1);                        //Wait until stop condtion is in effect.
                                                //Too long time... 
                                                //The pending bit will not be set after issuing stop condition.
               break;    
           }      
           _iicData[_iicPt++] = rIICDS;         //The last data has to be read with no ack.

           if((_iicDataCount)==0)
               rIICCON = 0x2f;                  //Resumes IIC operation with NOACK.  
           else 
               rIICCON = 0xaf;                  //Resumes IIC operation with ACK
               break;

        case WRDATA:
            if((_iicDataCount--)==0)
            {
                rIICSTAT = 0xd0;                //Stop MasTx condition 
                rIICCON  = 0xaf;                //Resumes IIC operation.
                Delay(1);                       //Wait until stop condtion is in effect.
                       //The pending bit will not be set after issuing stop condition.
                break;    
            }
            rIICDS = _iicData[_iicPt++];        //_iicData[0] has dummy.
            for(i=0;i<10;i++);                  //for setup time until rising edge of IICSCL
              
            rIICCON = 0xaf;                     //resumes IIC operation.
            break;

        case SETRDADDR:
//          Uart_Printf("[ S%d ]",_iicDataCount);
            if((_iicDataCount--)==0)
                break;                          //IIC operation is stopped because of IICCON[4]    
            rIICDS = _iicData[_iicPt++];
            for(i=0;i<10;i++);                  //For setup time until rising edge of IICSCL
            rIICCON = 0xaf;                     //Resumes IIC operation.
            break;

        default:
            break;      
    }
}


//===================================================================
//       SMDK2440 IIC configuration
//  GPE15=IICSDA, GPE14=IICSCL
//  "Non-Interrupt" mode for IIC block
//=================================================================== 

//*********************[ Test_Iic2 ]*********************************
void Test_Iic2(void)
{
    unsigned int i,j,save_E,save_PE;
    static U8 data[256];
    
    Uart_Printf("[ IIC Test(Polling) using KS24C080 ]\n");

    save_E   = rGPECON;
    save_PE  = rGPEUP;

    rGPEUP  |= 0xc000;                  //Pull-up disable
    rGPECON |= 0xa00000;                //GPE15:IICSDA , GPE14:IICSCL    

      //Enable ACK, Prescaler IICCLK=PCLK/16, Enable interrupt, Transmit clock value Tx clock=IICCLK/16
    rIICCON  = (1<<7) | (0<<6) | (1<<5) | (0xf);

    rIICADD  = 0x10;                    //2440 slave address = [7:1]
    rIICSTAT = 0x10;                    //IIC bus data output enable(Rx/Tx)
	//rIICLC = (1<<2)|(3);  // Filter enable, 15 clocks SDA output delay     added by junon
    
    Uart_Printf("Write test data into KS24C080\n");

    for(i=0;i<256;i++)
        _Wr24C080(0xa0,(U8)i,255-i);
    for(i=0;i<256;i++)
        data[i] = 0;

    Uart_Printf("Read test data from KS24C080\n");
    for(i=0;i<256;i++)
        _Rd24C080(0xa0,(U8)i,&(data[i])); 

    for(i=0;i<16;i++)
    {
        for(j=0;j<16;j++)
            Uart_Printf("%2x ",data[i*16+j]);
        Uart_Printf("\n");
    }
    
    rGPEUP  = save_PE;
    rGPECON = save_E;
}

//**************[ _Wr24C080 ]*****************************************
void _Wr24C080(U32 slvAddr,U32 addr,U8 data)
{
    _iicMode      = WRDATA;
    _iicPt        = 0;
    _iicData[0]   = (U8)addr;
    _iicData[1]   = data;
    _iicDataCount = 2;
    
    rIICDS        = slvAddr;            //0xa0
      //Master Tx mode, Start(Write), IIC-bus data output enable
      //Bus arbitration sucessful, Address as slave status flag Cleared,
      //Address zero status flag cleared, Last received bit is 0
    rIICSTAT      = 0xf0;      
      //Clearing the pending bit isn't needed because the pending bit has been cleared.
    while(_iicDataCount!=-1)
       Run_IicPoll();

    _iicMode = POLLACK;

    while(1)
    {
        rIICDS     = slvAddr;
        _iicStatus = 0x100;             //To check if _iicStatus is changed 
        rIICSTAT   = 0xf0;              //Master Tx, Start, Output Enable, Sucessful, Cleared, Cleared, 0
        rIICCON    = 0xaf;              //Resumes IIC operation. 
        while(_iicStatus==0x100)  
            Run_IicPoll();
              
        if(!(_iicStatus & 0x1))
            break;                      //When ACK is received
    }
    rIICSTAT = 0xd0;                    //Master Tx condition, Stop(Write), Output Enable
    rIICCON  = 0xaf;                    //Resumes IIC operation. 
    Delay(1);                           //Wait until stop condtion is in effect.
      //Write is completed.
}
        
//************************[ _Rd24C080 ]********************************
void _Rd24C080(U32 slvAddr,U32 addr,U8 *data)
{
    _iicMode      = SETRDADDR;
    _iicPt        = 0;
    _iicData[0]   = (U8)addr;
    _iicDataCount = 1;

    rIICDS   = slvAddr;
    rIICSTAT = 0xf0;                    //MasTx,Start  
      //Clearing the pending bit isn't needed because the pending bit has been cleared.
    while(_iicDataCount!=-1)
        Run_IicPoll();

    _iicMode      = RDDATA;
    _iicPt        = 0;
    _iicDataCount = 1;
    
    rIICDS   = slvAddr;
    rIICSTAT = 0xb0;                    //Master Rx,Start
    rIICCON  = 0xaf;                    //Resumes IIC operation.   
    while(_iicDataCount!=-1)
        Run_IicPoll();

    *data = _iicData[1];
}

//**********************[ Run_IicPoll ]*********************************
void Run_IicPoll(void)
{
    if(rIICCON & 0x10)                  //Tx/Rx Interrupt Enable
       IicPoll();
}       
    
//**********************[IicPoll ]**************************************
void IicPoll(void)
{
    U32 iicSt,i;
    
    iicSt = rIICSTAT; 
    if(iicSt & 0x8){}                   //When bus arbitration is failed.
    if(iicSt & 0x4){}                   //When a slave address is matched with IICADD
    if(iicSt & 0x2){}                   //When a slave address is 0000000b
    if(iicSt & 0x1){}                   //When ACK isn't received

    switch(_iicMode)
    {
        case POLLACK:
            _iicStatus = iicSt;
            break;

        case RDDATA:
            if((_iicDataCount--)==0)
            {
                _iicData[_iicPt++] = rIICDS;
            
                rIICSTAT = 0x90;                //Stop MasRx condition 
                rIICCON  = 0xaf;                //Resumes IIC operation.
                Delay(1);                       //Wait until stop condtion is in effect.
                                                //Too long time... 
                                                //The pending bit will not be set after issuing stop condition.
                break;    
            }      
            _iicData[_iicPt++] = rIICDS;
                        //The last data has to be read with no ack.
            if((_iicDataCount)==0)
                rIICCON = 0x2f;                 //Resumes IIC operation with NOACK.  
            else 
                rIICCON = 0xaf;                 //Resumes IIC operation with ACK
            break;

        case WRDATA:
            if((_iicDataCount--)==0)
            {
                rIICSTAT = 0xd0;                //stop MasTx condition 
                rIICCON  = 0xaf;                //resumes IIC operation.
                Delay(1);                       //wait until stop condtion is in effect.
                       //The pending bit will not be set after issuing stop condition.
                break;    
            }
            rIICDS = _iicData[_iicPt++];        //_iicData[0] has dummy.
            for(i=0;i<10;i++);                  //for setup time until rising edge of IICSCL
            rIICCON = 0xaf;                     //resumes IIC operation.
            break;

        case SETRDADDR:
//          Uart_Printf("[S%d]",_iicDataCount);
            if((_iicDataCount--)==0)
            {
                break;                  //IIC operation is stopped because of IICCON[4]    
            }
            rIICDS = _iicData[_iicPt++];
            for(i=0;i<10;i++);          //for setup time until rising edge of IICSCL
            rIICCON = 0xaf;             //resumes IIC operation.
            break;

        default:
            break;      
    }
}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产成人夜色高潮福利影视| 欧美aaaaaa午夜精品| eeuss鲁片一区二区三区| 日韩成人一级大片| 亚洲伦理在线免费看| 在线电影欧美成精品| 欧美日韩一区二区在线观看视频| 91精品国产色综合久久ai换脸| 欧美激情综合五月色丁香| 91在线视频在线| 国产传媒一区在线| 国产剧情av麻豆香蕉精品| 国产又黄又大久久| 国产一区 二区 三区一级| 国模娜娜一区二区三区| 国产在线不卡一卡二卡三卡四卡| 国模冰冰炮一区二区| 国产成人8x视频一区二区| 国产精品资源网| av亚洲精华国产精华精华| 欧美亚洲国产一区在线观看网站| 欧美日韩高清在线| 日韩午夜激情免费电影| 国产日产欧美一区二区视频| 国产精品国产三级国产专播品爱网| 亚洲免费观看高清完整版在线 | 欧美日韩你懂的| 欧美日韩免费高清一区色橹橹| 欧美老肥妇做.爰bbww视频| 欧美视频在线播放| 2024国产精品| 亚洲精品少妇30p| 另类欧美日韩国产在线| www.亚洲在线| 欧美一区二区三区视频在线 | jlzzjlzz亚洲日本少妇| 欧美丝袜自拍制服另类| 精品久久人人做人人爱| 中文字幕永久在线不卡| 日韩av一区二区在线影视| 黄色资源网久久资源365| 色一情一伦一子一伦一区| 精品久久五月天| 亚洲精品成a人| 成人丝袜18视频在线观看| 欧美另类久久久品| 国产精品短视频| 久久se精品一区精品二区| 日本高清不卡在线观看| 久久亚洲一级片| 日本成人在线一区| 99精品视频一区| 国产人成亚洲第一网站在线播放| 日韩精品三区四区| 99久久99久久精品免费看蜜桃| 中文字幕欧美日本乱码一线二线| 2020国产精品自拍| 国产成人在线视频播放| 国产精品久久久久久久裸模| 555www色欧美视频| 久久99国产乱子伦精品免费| 欧美久久久久久久久久 | 国产精品入口麻豆原神| 色老综合老女人久久久| 亚洲丝袜另类动漫二区| 中文无字幕一区二区三区| 亚洲成人免费看| 欧美在线高清视频| 成人欧美一区二区三区1314| 国产福利一区在线| 久久色视频免费观看| 国产呦萝稀缺另类资源| 日韩视频在线你懂得| 日本欧美一区二区| 7777精品久久久大香线蕉| 亚洲一区在线视频| 91高清视频免费看| 亚洲精品高清视频在线观看| 欧美亚洲一区三区| 亚洲一二三四久久| 欧美日韩国产影片| 日韩va亚洲va欧美va久久| 欧美日本视频在线| 免费观看一级欧美片| 日韩美一区二区三区| 美女mm1313爽爽久久久蜜臀| 久久久久一区二区三区四区| 国产一区二区导航在线播放| 国产亚洲污的网站| 99久久99久久综合| 亚洲一区在线观看免费观看电影高清| 在线观看av不卡| 蜜桃一区二区三区在线观看| 亚洲精品一区二区三区在线观看| 国产盗摄精品一区二区三区在线| 18成人在线观看| 欧美日韩高清一区二区三区| 蜜桃av噜噜一区二区三区小说| 26uuu久久综合| 一本一道久久a久久精品综合蜜臀| 亚洲精品日日夜夜| 日韩免费高清av| 97久久超碰国产精品| 一区二区三区蜜桃| 欧美xxxxx牲另类人与| 91在线无精精品入口| 午夜一区二区三区在线观看| 精品国产乱码91久久久久久网站| av在线一区二区| 婷婷一区二区三区| 久久久一区二区| 欧美三级韩国三级日本一级| 国产综合久久久久影院| 亚洲精品久久7777| 精品人在线二区三区| 色吧成人激情小说| 日本一区二区三区高清不卡| 激情综合五月天| 久久久夜色精品亚洲| 在线看不卡av| 欧美激情一区二区| 精彩视频一区二区三区| 欧美日本高清视频在线观看| 国产精品区一区二区三区| 久久精品国产99| 欧美电影在线免费观看| 亚洲a一区二区| 6080日韩午夜伦伦午夜伦| 日韩av网站免费在线| 91精品办公室少妇高潮对白| 日韩中文字幕1| 国产精品视频一二| 日韩欧美久久久| 色狠狠一区二区| av在线播放成人| 韩国精品一区二区| 午夜精品福利视频网站| 亚洲欧美日韩国产中文在线| 日本一区二区免费在线观看视频| 在线视频一区二区三| 成人av在线资源网站| 成人午夜电影网站| 精品无人区卡一卡二卡三乱码免费卡| 亚洲va韩国va欧美va| 亚洲精品免费一二三区| 欧美国产激情一区二区三区蜜月| 欧美成人高清电影在线| 91精品国产综合久久婷婷香蕉 | 日韩专区中文字幕一区二区| 一区二区三区国产豹纹内裤在线| 中文字幕乱码亚洲精品一区 | 亚洲国产毛片aaaaa无费看| 亚洲人成精品久久久久| 国产精品久久久久久妇女6080 | 国产99精品国产| 国产老女人精品毛片久久| 国内外成人在线| 精久久久久久久久久久| 韩国欧美一区二区| 国产成人精品aa毛片| 国产精品一二三区| 国产成人精品免费网站| 岛国精品在线观看| 91美女蜜桃在线| 欧美三级在线看| 欧美二区三区91| 精品裸体舞一区二区三区| 日韩三级在线免费观看| 欧美大片日本大片免费观看| 国产午夜亚洲精品午夜鲁丝片 | 久久精品综合网| 国产精品九色蝌蚪自拍| 一区二区三区小说| 午夜电影久久久| 久久精品噜噜噜成人av农村| 国产高清成人在线| av男人天堂一区| 欧美日韩一区二区三区在线看| 欧美一区二区三区四区久久| 国产欧美视频一区二区| 亚洲色图欧美激情| 青青草国产精品亚洲专区无| 国产成人亚洲精品狼色在线 | 国内偷窥港台综合视频在线播放| 国产精品88888| 欧美伊人久久大香线蕉综合69| 日韩丝袜美女视频| 亚洲私人影院在线观看| 人人狠狠综合久久亚洲| 成人免费毛片嘿嘿连载视频| 精品视频一区二区不卡| 国产人妖乱国产精品人妖| 亚洲444eee在线观看| 不卡区在线中文字幕| 日韩午夜在线观看视频| 亚洲欧洲日韩av| 精品影视av免费| 欧美日韩国产bt| 亚洲精选一二三| 国产69精品久久99不卡|