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

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

?? 2410iic.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 <string.h>
#include "2410addr.h"
#include "2410lib.h"
#include "def.h"
#include "2410IIC.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("[ IIC Test(Interrupt) using AT24C16 ]\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;                    //2410 slave address = [7:1]
    rIICSTAT = 0x10;                    //IIC bus data output enable(Rx/Tx)


    Uart_Printf("\nPlease input the start number will be writed to EEPROM: ");
    j = Uart_GetIntNum();
    Uart_Printf("\n");

    Uart_Printf("Start number will be %d\n",j);

	
	//Write the data to EEPROM
    Uart_Printf("Write test data into AT24C16\n");

    for(i=0;i<256;i++)
    {
        Wr24C080(0xa0,(U8)i,j);
        j++;
	    Uart_Printf(".");
    }
    Uart_Printf("\n");            
           
    //Clear the DataBuffer
    for(i=0;i<256;i++)
        data[i] = 0;

	//Read the data from EEPROM
    Uart_Printf("Read test data from AT24C16\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");
    }
    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("__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 = 0xaf;                     //Resumes IIC operation.
            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 AT24C16 ]\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;                    //2410 slave address = [7:1]
    rIICSTAT = 0x10;                    //IIC bus data output enable(Rx/Tx)

    Uart_Printf("Write test data into AT24C16\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 AT24C16\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("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 = 0xaf;             //resumes IIC operation.
            break;

        default:
            break;      
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产91色综合久久免费分享| 亚洲男人天堂av| 在线免费不卡电影| 99久久精品国产观看| 国产成人免费在线观看不卡| 极品少妇xxxx精品少妇| 另类的小说在线视频另类成人小视频在线| 一区二区久久久久| 亚洲一区二区三区爽爽爽爽爽| 亚洲精品一二三| 一区二区三区不卡视频| 亚洲午夜精品网| 日欧美一区二区| 久久99国产精品久久| 韩国在线一区二区| 国产一区在线观看视频| 国产精品一区二区你懂的| 国产精品2024| 99久久精品免费看国产| 在线影视一区二区三区| 91精品国产91热久久久做人人| 91精品国产综合久久婷婷香蕉| 91精品国产综合久久久久久久久久| 91精品国产乱| 国产欧美一区二区在线观看| 亚洲私人影院在线观看| 亚洲午夜久久久久久久久电影院| 喷白浆一区二区| 国产精品88av| 91久久久免费一区二区| 欧美一区二区三区免费视频| 国产日韩欧美在线一区| 亚洲精品菠萝久久久久久久| 日韩国产精品久久| 岛国精品一区二区| 欧美丝袜丝nylons| 国产午夜精品一区二区三区四区| 亚洲人成在线观看一区二区| 日韩福利视频导航| 成人午夜电影久久影院| 欧美日韩日本视频| 欧美国产精品中文字幕| 亚洲福利一二三区| 成人综合在线观看| 欧美情侣在线播放| 国产精品久久久久久久久免费丝袜 | 免费高清在线一区| 成人黄色小视频| 欧美一级黄色录像| 一区二区激情视频| 国产69精品久久久久毛片 | 日韩精品一二区| 成人久久久精品乱码一区二区三区 | 在线观看一区不卡| 国产人成亚洲第一网站在线播放 | 91精品国产综合久久小美女| 欧美激情综合在线| 日韩av成人高清| 欧美色网一区二区| 亚洲欧洲制服丝袜| 国产激情一区二区三区四区| 国产精品剧情在线亚洲| 蜜臀av一区二区三区| 91国产免费看| 亚洲日本在线观看| 成人v精品蜜桃久久一区| 欧美第一区第二区| 亚洲第一搞黄网站| 欧美在线一区二区三区| 最近日韩中文字幕| 国产白丝精品91爽爽久久| 日韩精品一区二区三区视频在线观看 | 欧美二区三区的天堂| 亚洲小说欧美激情另类| 色狠狠一区二区三区香蕉| 中文字幕一区二区视频| 国产成人av电影在线观看| 久久久777精品电影网影网| 精品在线免费观看| 久久综合狠狠综合久久综合88 | 久久色在线观看| 久久精品久久综合| 精品福利在线导航| 国内国产精品久久| 久久精品人人做| 成人国产精品免费网站| 日韩一区欧美小说| 色婷婷综合久久| 亚洲国产成人va在线观看天堂| 色94色欧美sute亚洲线路一久 | 精品国产一区二区亚洲人成毛片 | 色综合一区二区三区| 亚洲精品免费视频| 欧美视频在线观看一区二区| 亚洲v精品v日韩v欧美v专区| 欧美一区二区性放荡片| 久久精品久久久精品美女| 国产欧美综合在线观看第十页| 成人aa视频在线观看| 亚洲在线视频网站| 在线不卡一区二区| 国产真实精品久久二三区| 亚洲国产精品二十页| 色婷婷一区二区| 理论片日本一区| 中文av一区特黄| 欧美午夜电影网| 麻豆国产精品一区二区三区| 欧美国产日韩在线观看| 欧美三电影在线| 国产乱对白刺激视频不卡| 国产一区二区伦理片| 国产精品亲子伦对白| 欧美精品自拍偷拍| 国产精品 欧美精品| 亚洲高清视频在线| 国产欧美精品一区二区色综合 | 亚洲女人的天堂| 欧美电影免费观看高清完整版在线观看 | 中文字幕久久午夜不卡| 在线观看日韩国产| 国产精品夜夜爽| 五月天国产精品| 中文字幕亚洲欧美在线不卡| 日韩亚洲欧美一区| 91浏览器在线视频| 国产毛片精品视频| 亚洲成在人线在线播放| 国产精品素人一区二区| 91精品国产综合久久精品app | 91麻豆免费视频| 国产米奇在线777精品观看| 亚洲成在线观看| 亚洲精品日韩综合观看成人91| 国产三级欧美三级日产三级99| 自拍偷拍亚洲欧美日韩| 91精品蜜臀在线一区尤物| 91麻豆精品视频| 成人小视频免费观看| 精品一区二区在线播放| 午夜激情一区二区三区| 亚洲日本在线看| 中文字幕色av一区二区三区| 久久久久久久网| 精品电影一区二区三区| 欧美一区国产二区| 欧美精品在欧美一区二区少妇| 91福利国产成人精品照片| www.欧美色图| av不卡在线播放| 成人ar影院免费观看视频| 国产盗摄精品一区二区三区在线| 狂野欧美性猛交blacked| 青青草国产成人av片免费| 亚洲18影院在线观看| 亚洲国产综合人成综合网站| 一区二区三区日韩欧美| 亚洲乱码国产乱码精品精可以看| 国产精品灌醉下药二区| 成人免费一区二区三区在线观看| 国产精品国产三级国产三级人妇| 中文字幕av一区二区三区高 | 一区二区免费在线播放| 一区二区三区精品在线| 一区二区免费视频| 午夜精品福利一区二区蜜股av| 视频一区视频二区在线观看| 欧美a一区二区| 国产精品一区二区久久不卡| 风流少妇一区二区| 97久久精品人人做人人爽50路| 色综合久久中文综合久久97 | 亚洲成人av福利| 日韩激情av在线| 国产综合久久久久久鬼色| 国产91色综合久久免费分享| 91天堂素人约啪| 91精品国产综合久久福利软件| 久久―日本道色综合久久| 国产欧美va欧美不卡在线| 亚洲男人天堂av| 麻豆视频一区二区| 成人av网址在线| 欧美日韩国产天堂| 久久久噜噜噜久久中文字幕色伊伊| 国产亚洲欧洲997久久综合| 亚洲女女做受ⅹxx高潮| 另类小说综合欧美亚洲| av动漫一区二区| 欧美成人性战久久| 亚洲免费大片在线观看| 日韩国产一二三区| 99re这里都是精品| 欧美一级欧美一级在线播放| 国产精品午夜在线观看| 不卡一区在线观看| 这里只有精品视频在线观看| 国产精品久久久久婷婷二区次| 免费av成人在线| 99国内精品久久|