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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? iic.c

?? 研勤公司2440開發板的測試程序
?? C
字號:
//====================================================================
// 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;      
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
av亚洲产国偷v产偷v自拍| 久久久久久久久蜜桃| 97久久超碰国产精品电影| 国产成人精品综合在线观看| 国产一区免费电影| 国产精品综合一区二区三区| 激情五月播播久久久精品| 国产在线精品一区二区三区不卡 | 久久成人羞羞网站| 久久av老司机精品网站导航| 韩国精品在线观看| 国产精品一区二区三区99| 国产精品夜夜嗨| 成人精品在线视频观看| 成人精品一区二区三区中文字幕 | 国产日产精品1区| 中国av一区二区三区| 中文字幕一区二区三区色视频 | 理论片日本一区| 国产高清久久久久| 色综合久久天天| 欧美日韩中文字幕一区二区| 777精品伊人久久久久大香线蕉| 欧美一三区三区四区免费在线看| 精品第一国产综合精品aⅴ| 国产三区在线成人av| 综合久久国产九一剧情麻豆| 亚洲美女屁股眼交3| 日日夜夜精品免费视频| 精品一区二区三区在线播放视频| 高清久久久久久| 91国模大尺度私拍在线视频| 3d动漫精品啪啪1区2区免费| 国产拍欧美日韩视频二区| 亚洲日本一区二区三区| 日本三级亚洲精品| 成人免费毛片高清视频| 欧美综合色免费| 久久一区二区视频| 一区二区三区视频在线看| 久久精品国产免费看久久精品| 成人综合激情网| 正在播放亚洲一区| 中文字幕不卡三区| 视频一区视频二区中文字幕| 国产.欧美.日韩| 欧美日韩高清一区二区不卡| 国产人妖乱国产精品人妖| 亚洲小说欧美激情另类| 国产一区二区三区免费观看| 在线精品视频一区二区| 久久久一区二区三区| 夜夜亚洲天天久久| 国产成人精品免费看| 欧美日韩午夜精品| 国产精品二区一区二区aⅴ污介绍| 天天色图综合网| 成人的网站免费观看| 日韩精品一区二区三区四区视频| 亚洲免费观看高清完整版在线观看 | 欧美吞精做爰啪啪高潮| 国产免费成人在线视频| 日产精品久久久久久久性色| 99在线热播精品免费| 欧美tk—视频vk| 亚洲国产精品自拍| 91在线免费看| 国产日韩av一区| 久久99最新地址| 777久久久精品| 亚洲一区在线观看网站| 波多野结衣亚洲| 欧美精品一区二区三区四区| 亚洲午夜精品一区二区三区他趣| 丰满亚洲少妇av| 欧美精品一区二区三区高清aⅴ| 亚洲国产精品天堂| 在线观看国产一区二区| 国产精品高清亚洲| 成人综合婷婷国产精品久久| 亚洲一二三级电影| 91蝌蚪porny成人天涯| 久久综合国产精品| 精品一区二区免费| 日韩欧美国产三级电影视频| 亚洲亚洲人成综合网络| 在线免费视频一区二区| 亚洲男同性恋视频| 色综合欧美在线| 亚洲欧美日韩综合aⅴ视频| 粉嫩嫩av羞羞动漫久久久| 久久综合色一综合色88| 久久国产夜色精品鲁鲁99| 欧美一区日韩一区| 蜜臀av一区二区在线观看| 欧美日韩一区视频| 亚洲国产成人porn| 欧美性大战久久久久久久蜜臀| 亚洲综合在线电影| 在线一区二区三区做爰视频网站| 亚洲欧美一区二区久久| 91麻豆国产精品久久| 亚洲色图19p| 色吧成人激情小说| 亚洲一级片在线观看| 欧美色视频在线观看| 亚洲精品国产无天堂网2021| 欧美在线观看18| 调教+趴+乳夹+国产+精品| 欧美日韩的一区二区| 日日欢夜夜爽一区| 精品动漫一区二区三区在线观看| 国产在线精品一区二区不卡了 | 精品入口麻豆88视频| 精油按摩中文字幕久久| 久久理论电影网| 成人a区在线观看| 亚洲乱码中文字幕| 欧美天天综合网| 免费看黄色91| 久久精品一区二区三区不卡| 不卡高清视频专区| 亚洲电影在线播放| 91精品国产91久久综合桃花| 国产美女精品在线| 国产精品水嫩水嫩| 91久久精品一区二区二区| 亚洲午夜激情网页| 日韩欧美综合一区| 国产不卡一区视频| 亚洲一区成人在线| 欧美α欧美αv大片| 国产成人在线看| 亚洲一区免费观看| 亚洲精品一区二区三区影院| 成人av在线电影| 亚洲成年人网站在线观看| 久久综合久久99| 色婷婷av一区| 麻豆传媒一区二区三区| 中文字幕一区二区在线观看| 欧美日韩日日摸| 国产aⅴ精品一区二区三区色成熟| 成人免费一区二区三区在线观看| 欧美日韩一区视频| 国产宾馆实践打屁股91| 夜夜爽夜夜爽精品视频| 久久婷婷色综合| 色老汉一区二区三区| 理论电影国产精品| 一区二区三区免费| 久久先锋影音av鲁色资源| 在线中文字幕一区二区| 国产一区二区视频在线| 亚洲综合男人的天堂| 久久欧美中文字幕| 欧美日韩免费高清一区色橹橹 | 欧美刺激脚交jootjob| 日本精品一区二区三区高清| 亚洲丝袜自拍清纯另类| 欧美日韩精品一区二区三区蜜桃| 国产精品综合网| 首页综合国产亚洲丝袜| 国产精品人成在线观看免费| 欧美一区欧美二区| 91色在线porny| 国产成人在线免费观看| 免费看日韩精品| 亚洲与欧洲av电影| 国产精品沙发午睡系列990531| 欧美一区二区三区在线观看视频| 99久久夜色精品国产网站| 国产乱人伦精品一区二区在线观看| 一区二区三区 在线观看视频| 国产亚洲福利社区一区| 日韩一区二区精品| 欧美性大战xxxxx久久久| 99久久婷婷国产综合精品电影 | 99久久国产综合精品麻豆| 狠狠色丁香婷婷综合久久片| 午夜免费久久看| 亚洲人一二三区| 国产女同性恋一区二区| 精品噜噜噜噜久久久久久久久试看| 在线视频国产一区| www..com久久爱| 国产成人欧美日韩在线电影| 美女网站色91| 男人操女人的视频在线观看欧美| 一区二区三区.www| 一区av在线播放| 亚洲精品一二三四区| 国产精品久久国产精麻豆99网站| 久久一二三国产| 久久女同互慰一区二区三区| 精品国产1区二区| 欧美成人免费网站| 精品入口麻豆88视频| 精品剧情在线观看| 日韩午夜小视频|