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

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

?? iic.c

?? 2440開發(fā)板的測試程序.包含了一些外圍的測試.
?? 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
//=================================================================== 

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

    Uart_Printf("\nIIC Test(Interrupt) using AT24C02\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 AT24C02\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 AT24C02\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;      
    }
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲三级电影网站| 欧美色图天堂网| 久久精品网站免费观看| 国产精品1区2区3区在线观看| 精品噜噜噜噜久久久久久久久试看| 免费看欧美女人艹b| 久久久久国产精品麻豆| 国产91精品久久久久久久网曝门| 国产精品欧美久久久久一区二区| 91蜜桃免费观看视频| 亚洲一线二线三线久久久| 91精品欧美一区二区三区综合在| 久久国产精品露脸对白| 国产午夜亚洲精品理论片色戒| 成人v精品蜜桃久久一区| 一区二区三区中文字幕| 日韩午夜在线播放| 成人网页在线观看| 亚洲成人午夜电影| 久久久亚洲精品石原莉奈| 99热这里都是精品| 免费观看91视频大全| 国产精品美女久久久久久| 欧美久久一区二区| 丁香激情综合国产| 性欧美疯狂xxxxbbbb| 国产亚洲自拍一区| 欧美日韩免费一区二区三区视频| 久久电影国产免费久久电影| 国产精品日韩精品欧美在线| 欧美日韩亚洲另类| 波多野结衣在线aⅴ中文字幕不卡| 午夜在线成人av| 国产精品美女久久久久久久网站| 欧美日韩一区小说| 波多野结衣91| 麻豆国产欧美一区二区三区| 亚洲图片激情小说| 久久嫩草精品久久久久| 欧美日韩国产一二三| 成人av电影免费在线播放| 麻豆久久久久久久| 一区二区三区日韩| 国产欧美日韩在线观看| 7777精品伊人久久久大香线蕉最新版| 高清国产一区二区| 久久精品国产99国产精品| 亚洲va韩国va欧美va| 国产精品国产馆在线真实露脸| 精品美女被调教视频大全网站| 99在线热播精品免费| 国产成人精品综合在线观看| 日韩电影网1区2区| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆| 精品国产网站在线观看| 欧美手机在线视频| 色噜噜夜夜夜综合网| 成人午夜视频福利| 国产一区视频在线看| 麻豆精品视频在线| 午夜精品福利在线| 精品一区二区三区av| 亚洲成人资源网| 亚洲自拍偷拍图区| 亚洲欧洲美洲综合色网| 欧美精彩视频一区二区三区| 欧美videossexotv100| 日韩亚洲欧美中文三级| 欧美精品久久久久久久多人混战| 色94色欧美sute亚洲线路一ni | 国产欧美日韩三级| 精品久久国产字幕高潮| 欧美一级日韩不卡播放免费| 欧美色精品在线视频| 欧美性大战xxxxx久久久| 91福利在线免费观看| 色8久久人人97超碰香蕉987| 91久久精品日日躁夜夜躁欧美| 91女厕偷拍女厕偷拍高清| av电影在线观看一区| a在线欧美一区| 99re这里只有精品6| 在线精品视频免费观看| 欧美日韩一区在线| 欧美一区二区久久久| 精品捆绑美女sm三区| 久久综合久色欧美综合狠狠| 久久精品免费在线观看| 国产精品女人毛片| 中文字幕日韩av资源站| 亚洲黄色小视频| 亚洲成va人在线观看| 奇米综合一区二区三区精品视频| 日本欧美在线观看| 精品一区二区三区在线播放| 国产高清不卡一区| 99精品视频在线观看| 91久久精品一区二区三| 91麻豆精品国产91久久久更新时间| 91精品国产一区二区三区香蕉| 日韩精品一区二区三区视频在线观看 | 26uuu色噜噜精品一区| 亚洲国产精品v| 亚洲夂夂婷婷色拍ww47| 久色婷婷小香蕉久久| 国产成人在线电影| 色伊人久久综合中文字幕| 欧美日韩激情在线| 精品成人在线观看| 亚洲视频资源在线| 蜜桃视频一区二区| av中文字幕在线不卡| 欧美巨大另类极品videosbest| 精品国产免费一区二区三区四区| 国产精品美女久久福利网站| av在线不卡免费看| 欧美视频第二页| 久久久久久夜精品精品免费| 亚洲一区二区三区视频在线| 韩国av一区二区三区| 91成人免费网站| 久久久久久9999| 亚洲超丰满肉感bbw| 成人中文字幕合集| 欧美一级淫片007| 综合分类小说区另类春色亚洲小说欧美| 亚洲一区二区欧美日韩| 国产精品亚洲视频| 欧美一区二区三区四区久久| 亚洲同性同志一二三专区| 九色|91porny| 欧美顶级少妇做爰| 亚洲免费观看高清| 国产一区福利在线| 日韩一区二区电影在线| 亚洲综合999| 97久久超碰精品国产| 久久精品亚洲国产奇米99| 日韩av一二三| 在线观看日韩电影| 日韩一区欧美小说| 成人污污视频在线观看| 精品国产网站在线观看| 日本在线播放一区二区三区| 色婷婷国产精品| 亚洲欧美中日韩| www.欧美日韩| 日本一区二区三区四区在线视频| 免费美女久久99| 欧美一区二区三区影视| 亚洲www啪成人一区二区麻豆| 日韩欧美成人一区二区| 亚洲成av人片在线| 色偷偷一区二区三区| 亚洲少妇最新在线视频| 99久久精品久久久久久清纯| 国产精品欧美综合在线| 成人激情开心网| 国产精品日韩精品欧美在线| 国产sm精品调教视频网站| 国产亚洲成年网址在线观看| 国产精品 欧美精品| 久久综合九色综合久久久精品综合| 免费人成网站在线观看欧美高清| 这里只有精品电影| 日本美女一区二区三区| 日韩三级视频在线观看| 久久激情五月激情| 精品第一国产综合精品aⅴ| 国产一区在线观看麻豆| 久久久久久夜精品精品免费| 国产91在线观看丝袜| 中日韩免费视频中文字幕| 成人av在线资源网站| 日韩美女视频一区二区| 色婷婷综合五月| 亚洲午夜精品一区二区三区他趣| 欧美三级电影在线观看| 亚洲综合成人在线视频| 欧美肥妇free| 精品系列免费在线观看| 久久久久国产精品人| 97久久精品人人澡人人爽| 亚洲香肠在线观看| 日韩欧美国产综合在线一区二区三区 | 在线看日本不卡| 日韩精品1区2区3区| 日韩欧美久久一区| 国产大陆亚洲精品国产| 一区精品在线播放| 欧美日韩一区久久| 久久成人羞羞网站| 中文字幕免费一区| 色婷婷久久综合| 青青青爽久久午夜综合久久午夜| 久久久.com| 欧美性大战xxxxx久久久| 久久国产三级精品| 亚洲精品中文在线观看| 91精品国产高清一区二区三区蜜臀|