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

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

?? iic.c

?? 嵌入式的簡單測試程序
?? C
字號:
//====================================================================
// File Name : 2410IIC.c
// Function  : S3C2410 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 "def.h"
#include "2410addr.h"
#include "2410lib.h"
#include "2410slib.h"
#include "IIC.h"

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

//===================================================================
//       SMDK2410 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 &= ~0xf0000000;
    rGPECON |= 0xa0000000;              //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);
    //IIC clock = PCLK/(512*1)
    rIICCON = (1<<7) | (1<<6) | (1<<5) | (0);	//hzh

    rIICADD  = 0x10;                    //2410 slave address = [7:1]
    rIICSTAT = 0x10;                    //IIC bus data output enable(Rx/Tx)

    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])); 

    printf("The follow is the data writed to IIC EEPROM just now:\n");

    for(i=0;i<8;i++)
    {
        for(j=0;j<8;j++)
            Uart_Printf("%2x ",data[i*8+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    = 0xe0;//0xaf;              //Resumes IIC operation. 	//hzh
           
        while(_iicStatus==0x100);
           
        if(!(_iicStatus&0x1))
            break;                      //When ACK is received
    }
    rIICSTAT = 0xd0;                    //Stop MasTx condition 
    rIICCON  = 0xe0;//0xaf;                    //Resumes IIC operation. 	//hzh
    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       = 0xe0;//0xaf;               //Resumes IIC operation.	//hzh
    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  = 0xe0;//0xaf;                 //Resumes IIC operation.	//hzh
               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 = 0x60;//0x2f;                  //Resumes IIC operation with NOACK.	//hzh
           else 
               rIICCON = 0xe0;//0xaf;                  //Resumes IIC operation with ACK	//hzh
               break;

        case WRDATA:
            if((_iicDataCount--)==0)
            {
                rIICSTAT = 0xd0;                //Stop MasTx condition 
                rIICCON  = 0xe0;//0xaf;                //Resumes IIC operation.	//hzh
                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 = 0xe0;//0xaf;                     //resumes IIC operation.	//hzh
            break;

        case SETRDADDR:
//            Uart_Printf("__irq IicInt SETDADDR [ 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 = 0xe0;//0xaf;                     //Resumes IIC operation.	//hzh
            break;

        default:
            break;      
    }
}


//===================================================================
//       SMDK2410 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 AT24C02\n");

    save_E   = rGPECON;
    save_PE  = rGPEUP;
    rGPEUP  |= 0xc000;                  //Pull-up disable
    rGPECON &= ~0xf0000000;
    rGPECON |= 0xa0000000;              //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);	//0xaf
    //IIC clock = PCLK/(512*1)
    rIICCON  = (1<<7) | (1<<6) | (1<<5) | (0);		//0xe0

    rIICADD  = 0x10;                    //2410 slave address = [7:1]
    rIICSTAT = 0x10;                    //IIC bus data output enable(Rx/Tx)

    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])); 

    for(i=0;i<8;i++)
    {
        for(j=0;j<8;j++)
            Uart_Printf("%2x ",data[i*8+j]);
        Uart_Printf("\n");
    }
    
    Uart_Printf("OK! Write data is same to Read data!\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    = 0xe0;//0xaf;              //Resumes IIC operation. //hzh
        while(_iicStatus==0x100)  
            Run_IicPoll();
              
        if(!(_iicStatus & 0x1))
            break;                      //When ACK is received
    }
    rIICSTAT = 0xd0;                    //Master Tx condition, Stop(Write), Output Enable
    rIICCON  = 0xe0;//0xaf;                    //Resumes IIC operation. 	//hzh
    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  = 0xe0;//0xaf;                    //Resumes IIC operation.	//hzh
    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  = 0xe0;//0xaf;                //Resumes IIC operation.	//hzh
                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 = 0x60;//0x2f;                 //Resumes IIC operation with NOACK.  	//hzh
            else 
                rIICCON = 0xe0;//0xaf;                 //Resumes IIC operation with ACK	//hzh
            break;

        case WRDATA:
            if((_iicDataCount--)==0)
            {
                rIICSTAT = 0xd0;                //stop MasTx condition 
                rIICCON  = 0xe0;//0xaf;                //resumes IIC operation.	//hzh
                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 = 0xe0;//0xaf;                     //resumes IIC operation.	//hzh
            break;

        case SETRDADDR:
//            Uart_Printf("IicPoll() SETRADDR [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 = 0xe0;//0xaf;             //resumes IIC operation.	//hzh
            break;

        default:
            break;      
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品一级二级三级| 91亚洲精品一区二区乱码| 91无套直看片红桃| 欧美一区二区啪啪| 亚洲视频免费看| 精品一区二区三区免费播放| 色婷婷狠狠综合| 久久久久久久久久久99999| 一区二区三区四区精品在线视频| 九九在线精品视频| 欧美日韩激情一区二区三区| 国产精品国产精品国产专区不片| 美女免费视频一区| 欧美优质美女网站| 1000部国产精品成人观看| 韩国av一区二区| 这里只有精品免费| 亚洲图片一区二区| 日本精品一级二级| 国产精品久久久久久久久免费相片| 看电影不卡的网站| 欧美一区二区视频在线观看2020 | 97精品久久久午夜一区二区三区| 欧美xfplay| 美女一区二区三区在线观看| 欧美视频一区在线观看| 亚洲精品国产a久久久久久| 国产成a人亚洲精品| 久久久亚洲国产美女国产盗摄| 奇米精品一区二区三区在线观看| 欧美日韩成人在线| 婷婷综合另类小说色区| 欧美日韩一区成人| 日本一道高清亚洲日美韩| 欧美日韩和欧美的一区二区| 亚洲国产欧美日韩另类综合| 日本韩国欧美一区| 亚洲精品一二三四区| 成人av第一页| 亚洲欧美二区三区| 欧美综合一区二区三区| 亚洲一二三四久久| 欧美日韩国产系列| 蜜桃精品视频在线| 欧美成人a在线| 国产黄色精品网站| 国产精品理论在线观看| 色哟哟国产精品| 亚洲第一久久影院| 日韩一级大片在线观看| 国产乱码精品1区2区3区| 国产亚洲欧洲997久久综合| 成人小视频免费在线观看| 欧美国产国产综合| 色综合色狠狠天天综合色| 亚洲va韩国va欧美va精品| 日韩欧美色电影| 成人黄色av电影| 亚洲综合色丁香婷婷六月图片| 欧美蜜桃一区二区三区| 国内一区二区视频| 亚洲精品乱码久久久久久日本蜜臀| 欧美亚洲综合色| 九九**精品视频免费播放| 欧美激情一区二区| 欧美日韩高清一区二区三区| 九九精品视频在线看| 亚洲蜜臀av乱码久久精品蜜桃| 91精品国产综合久久久久| 国产精品99久久久久| 一区二区三区四区亚洲| 亚洲精品一区在线观看| 日本久久一区二区| 国产精品亚洲第一区在线暖暖韩国 | 日韩欧美在线123| 国产精品一区二区在线观看不卡 | 国产精品一区二区久激情瑜伽 | 狠狠色狠狠色综合系列| 国产精品久久久久久亚洲毛片| 欧美性大战久久| 国产精品66部| 视频精品一区二区| 中文一区二区在线观看| 日韩色视频在线观看| 色999日韩国产欧美一区二区| 国产专区综合网| 肉色丝袜一区二区| 亚洲人成网站在线| 久久久久久久精| 日韩欧美国产一区二区在线播放| 色婷婷精品大视频在线蜜桃视频| 国产一区二区三区四区五区入口 | 亚洲国产视频网站| 国产精品视频九色porn| 精品久久久久久亚洲综合网| 欧美色精品在线视频| 色哟哟国产精品| 91热门视频在线观看| 成人禁用看黄a在线| 国产在线精品一区二区不卡了 | eeuss鲁片一区二区三区在线看| 日韩精彩视频在线观看| 亚洲国产日韩a在线播放| 亚洲日本va午夜在线影院| 中文乱码免费一区二区| 久久亚洲捆绑美女| 精品欧美一区二区三区精品久久 | 91精品国产手机| 欧美揉bbbbb揉bbbbb| 在线观看视频欧美| 在线观看91视频| 在线观看欧美黄色| 在线一区二区三区| 欧美视频精品在线观看| 在线亚洲免费视频| 欧美色图在线观看| 欧美色视频一区| 7777女厕盗摄久久久| 7777精品伊人久久久大香线蕉超级流畅 | 国产精品丝袜在线| 精品剧情v国产在线观看在线| 国产成都精品91一区二区三| 国产真实乱偷精品视频免| 丝瓜av网站精品一区二区| 丝袜诱惑制服诱惑色一区在线观看| 亚洲视频香蕉人妖| 亚洲视频在线一区| 亚洲乱码国产乱码精品精的特点| 久久久www免费人成精品| 国产精品美女久久福利网站| 久久蜜桃av一区精品变态类天堂 | 国产成人精品亚洲777人妖| 久久精品国产99国产精品| 国产乱码字幕精品高清av| 国产九九视频一区二区三区| 久久99国产精品免费| 久久99精品一区二区三区三区| 激情文学综合插| 午夜久久福利影院| 激情欧美一区二区| 国产精品18久久久久| av成人老司机| 日本精品免费观看高清观看| 91成人免费在线| 欧美日韩一区二区三区视频| 2020日本不卡一区二区视频| 久久综合色一综合色88| 国产欧美日韩在线| 中文字幕亚洲区| 综合婷婷亚洲小说| 日本在线观看不卡视频| 国产精品一区二区黑丝| 不卡视频免费播放| 欧美中文字幕一二三区视频| 久久综合久久久久88| 国产精品欧美久久久久一区二区| 亚洲精品高清在线| 亚洲国产乱码最新视频| 美女任你摸久久| 色网综合在线观看| 欧美一级淫片007| 国产欧美一区二区精品性| 亚洲欧美日韩国产一区二区三区| 亚洲第一av色| av不卡在线观看| 91精品国产乱码| 欧美经典三级视频一区二区三区| 一区二区在线免费观看| 国产成人精品亚洲午夜麻豆| 日本韩国欧美在线| 久久这里只有精品首页| 亚洲欧美国产高清| 高清在线不卡av| 91麻豆精品91久久久久同性| 久久久久久久久久电影| 亚洲一级在线观看| 久久精品国产亚洲5555| 欧美日韩一级片网站| 中文字幕欧美国产| 蜜桃av噜噜一区| 91色乱码一区二区三区| 中文在线免费一区三区高中清不卡| 日韩精品一级中文字幕精品视频免费观看 | 色婷婷av一区二区| www.成人在线| 国产馆精品极品| 久久电影网电视剧免费观看| 99久久综合国产精品| 91麻豆精品国产综合久久久久久| 日本一区二区成人| 久久精品国产澳门| 欧美日韩久久久一区| 夜夜精品视频一区二区| 99久久国产免费看| 91.com视频| 亚洲电影视频在线| 一本大道久久a久久综合婷婷| 精品久久人人做人人爰| 日韩高清不卡在线| 在线观看日韩电影|