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

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

?? iic.c

?? YLE2410開發板的測試程序,優龍自帶的測試通過
?? 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一区二区三区免费野_久草精品视频
日韩av中文字幕一区二区| 紧缚捆绑精品一区二区| 久久久久久影视| 不卡的av中国片| 一区二区三区四区精品在线视频 | 亚洲免费观看高清在线观看| 日韩视频在线一区二区| 色综合天天综合| 国产一区二区精品久久99| 一卡二卡欧美日韩| 国产精品白丝在线| 欧美videofree性高清杂交| 91丨porny丨户外露出| 国产一区久久久| 亚洲精品日日夜夜| 久久蜜桃av一区二区天堂| 色猫猫国产区一区二在线视频| 琪琪一区二区三区| 一区二区在线免费| 久久日一线二线三线suv| 欧美一区二区三区日韩| 666欧美在线视频| 欧美三片在线视频观看| 91福利社在线观看| 一本色道**综合亚洲精品蜜桃冫| 成人在线视频一区| 成人开心网精品视频| 国产高清无密码一区二区三区| 久久99国产精品免费| 久久99国产精品久久99| 亚洲影院在线观看| 日日欢夜夜爽一区| 久久爱另类一区二区小说| 国产一区在线观看麻豆| www.视频一区| 欧美日韩视频在线一区二区| 欧美老女人第四色| 欧美一区二区黄色| 国产精品嫩草久久久久| 亚洲欧美偷拍另类a∨色屁股| 亚洲日本在线观看| 亚洲伊人色欲综合网| 喷白浆一区二区| 国产福利一区二区三区在线视频| 91影视在线播放| 欧美日韩黄视频| 久久毛片高清国产| 亚洲国产一二三| 国产成人在线网站| 99国产精品视频免费观看| 欧美一区二区三区免费观看视频| 久久午夜老司机| 亚洲日本中文字幕区| 麻豆中文一区二区| 成人免费高清视频| 精品奇米国产一区二区三区| 中文字幕亚洲一区二区va在线| 亚洲成人资源网| 欧美日韩在线播放三区| 精品国产网站在线观看| 亚洲美女视频在线| 国内精品不卡在线| 精品视频一区二区三区免费| 国产精品美女久久久久久| 蜜桃视频免费观看一区| 成人app在线观看| 久久免费偷拍视频| 天堂在线亚洲视频| youjizz国产精品| 国产亚洲成年网址在线观看| 日本亚洲视频在线| 欧美一区二区日韩一区二区| 亚洲国产成人tv| 欧美精品在线一区二区| 一区二区三区免费网站| 国产成人精品综合在线观看 | 日韩欧美中文一区二区| 午夜视频一区二区三区| 在线观看欧美精品| 日韩不卡一区二区| 日韩欧美亚洲一区二区| 亚洲国产sm捆绑调教视频 | 麻豆精品在线看| 欧美日韩国产高清一区二区三区 | 国产欧美va欧美不卡在线| 成人免费高清在线| 亚洲大型综合色站| 日韩久久精品一区| 国产精品18久久久久久久网站| 日本一区二区三区四区在线视频| 国产一区二区导航在线播放| 国产亚洲欧美色| 91亚洲精品久久久蜜桃| 日本欧美一区二区三区乱码| 欧美大片在线观看一区| 成人久久18免费网站麻豆 | 亚洲国产美国国产综合一区二区| 3d动漫精品啪啪| 大白屁股一区二区视频| 偷拍一区二区三区四区| 欧美国产1区2区| 欧美天堂一区二区三区| 激情六月婷婷久久| 最新国产成人在线观看| 欧美色图激情小说| 久久爱另类一区二区小说| 国产亚洲一区二区三区| 欧美调教femdomvk| 高清免费成人av| 亚洲青青青在线视频| 日韩三级av在线播放| 一本久久a久久精品亚洲| 国产麻豆精品theporn| 久久成人精品无人区| 一区二区免费看| 精品国产电影一区二区| 欧美午夜影院一区| 国产一区二区在线视频| 国产精品福利一区二区三区| 欧美一区二区久久久| 一本大道久久精品懂色aⅴ| 日韩av中文字幕一区二区三区| 亚洲6080在线| 亚洲成人免费av| 蜜臀91精品一区二区三区| 亚洲视频中文字幕| 成人免费视频在线观看| 欧美精品久久一区| 日韩三级免费观看| 久久久精品2019中文字幕之3| 91精品国产色综合久久ai换脸| 天天影视涩香欲综合网| 综合中文字幕亚洲| 国产精品乱码妇女bbbb| 久久精品人人做人人爽97| 欧美亚洲国产一区二区三区| 色噜噜狠狠成人网p站| 国产盗摄一区二区| 国产精品综合网| 狠狠色综合播放一区二区| 亚洲一区免费观看| 亚洲精品免费看| 韩国女主播成人在线| 成人一区二区三区在线观看| 91啪亚洲精品| av在线一区二区三区| 91麻豆免费看片| 欧美日韩国产小视频在线观看| 91精品国产aⅴ一区二区| 91麻豆精品国产自产在线| 欧美视频一区二区三区在线观看 | 日本不卡中文字幕| 国产曰批免费观看久久久| av不卡免费电影| 成人精品小蝌蚪| 欧美日韩性生活| 天天爽夜夜爽夜夜爽精品视频| 精品福利一区二区三区| 国产91露脸合集magnet| 91福利视频久久久久| 日韩免费视频一区| 中文字幕一区二区三区乱码在线| 一区二区在线看| 国产盗摄精品一区二区三区在线 | 日本道精品一区二区三区| 欧美一区二区在线免费播放| 中文字幕不卡一区| 性久久久久久久久久久久| 国产成人精品一区二| 3d动漫精品啪啪一区二区竹菊| 中文无字幕一区二区三区| 日韩国产欧美视频| 日韩影视精彩在线| 在线观看区一区二| 国产精品乱码一区二区三区软件 | 99免费精品在线| 精品国产伦一区二区三区观看方式| 一区二区高清免费观看影视大全 | 国产日韩三级在线| 亚洲国产va精品久久久不卡综合| www.成人在线| 欧美激情一区二区三区蜜桃视频| 蜜臀久久久久久久| 91精品国产综合久久婷婷香蕉| 亚洲伊人色欲综合网| 在线亚洲一区二区| 亚洲黄色免费电影| 欧美在线观看禁18| 亚洲一区二区三区国产| 亚洲午夜精品17c| 精品制服美女丁香| 久久久久国产成人精品亚洲午夜| 日韩专区一卡二卡| 制服丝袜日韩国产| 不卡av电影在线播放| 久久er精品视频| 亚洲国产另类av| ...av二区三区久久精品| 欧美不卡一区二区三区四区| 1024国产精品|