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

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

?? iic.c

?? 基于優龍ST2410開發板的原代碼,包括各種驅動程序
?? 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一区二区三区免费野_久草精品视频
久久99久久久欧美国产| 免费在线观看一区| 蜜臀av性久久久久蜜臀av麻豆| 黄色资源网久久资源365| 91麻豆swag| 2020国产精品自拍| 天堂av在线一区| 91麻豆精品秘密| 日本一区二区三区dvd视频在线| 三级影片在线观看欧美日韩一区二区 | 亚洲影视资源网| 国产高清亚洲一区| 日韩欧美中文字幕一区| 亚洲午夜久久久久中文字幕久| 成人午夜视频网站| 久久亚洲一级片| 奇米色777欧美一区二区| 在线亚洲精品福利网址导航| 国产精品欧美一级免费| 国产一区二区精品在线观看| 欧美一二区视频| 五月激情综合婷婷| 欧美日韩你懂得| 午夜不卡av免费| 欧美日韩www| 亚洲国产三级在线| 欧美在线一区二区| 亚洲第四色夜色| 欧美在线三级电影| 一区二区三区在线免费观看| 91麻豆国产福利在线观看| 综合av第一页| 91久久精品一区二区| 亚洲精品第一国产综合野| 色欧美日韩亚洲| 亚洲自拍偷拍图区| 欧美日韩中文字幕一区| 首页综合国产亚洲丝袜| 欧美剧情电影在线观看完整版免费励志电影 | 亚洲一区成人在线| 在线免费观看不卡av| 午夜一区二区三区在线观看| 欧美浪妇xxxx高跟鞋交| 奇米在线7777在线精品| 日韩女优电影在线观看| 国产成人精品一区二区三区四区| 中文无字幕一区二区三区| 不卡视频免费播放| 亚洲国产精品久久人人爱蜜臀| 欧美精品在线一区二区| 韩国女主播成人在线| 国产精品拍天天在线| 91久久久免费一区二区| 日韩成人伦理电影在线观看| 欧美精品一区二区三区高清aⅴ| 国产一区二三区| 亚洲人精品一区| 欧美日韩大陆在线| 国产乱码精品一品二品| 亚洲精品久久7777| 欧美成人精品二区三区99精品| 国产一区二区三区av电影| 18欧美亚洲精品| 欧美一区二区三区公司| 国产成人在线视频网站| 亚洲高清视频在线| 中文字幕成人网| 正在播放亚洲一区| www.66久久| 奇米影视7777精品一区二区| 欧美经典一区二区| 欧美浪妇xxxx高跟鞋交| www.亚洲色图.com| 日韩va亚洲va欧美va久久| 亚洲欧洲另类国产综合| 日韩一区二区电影在线| 一本到一区二区三区| 久久99精品国产麻豆不卡| 亚洲欧美日韩国产另类专区| 欧美sm极限捆绑bd| 欧美日韩一级片网站| av福利精品导航| 国产尤物一区二区| 亚洲成人av一区二区三区| 国产精品久久久久久久久晋中| 欧美一区二区二区| 一本到不卡精品视频在线观看| 国产呦萝稀缺另类资源| 日韩电影一二三区| 一区二区三区蜜桃网| 中文字幕中文字幕一区二区 | 中文字幕在线观看一区二区| 欧美一区二区三区系列电影| 一本色道久久综合亚洲aⅴ蜜桃| 国产乱人伦偷精品视频不卡| 蜜桃视频免费观看一区| 亚洲成av人综合在线观看| 亚洲精品高清在线| 亚洲日本在线a| 国产精品乱码妇女bbbb| 国产色综合一区| 精品99一区二区三区| 欧美一区二区三区在线观看 | 国产日韩精品一区| 亚洲精品一区二区三区影院| 日韩欧美国产一区二区在线播放| 欧美色男人天堂| 欧美高清www午色夜在线视频| 在线亚洲精品福利网址导航| 在线中文字幕一区二区| 在线观看日韩电影| 欧美在线观看视频在线| 欧美视频一区在线| 欧美日韩中文精品| 在线播放一区二区三区| 日韩一级成人av| 日韩一级在线观看| 精品国产一区二区三区不卡 | 国产裸体歌舞团一区二区| 国产一区二区网址| 国产精品乡下勾搭老头1| 国产精品主播直播| 国产黑丝在线一区二区三区| 国产成人亚洲综合a∨猫咪| 国产成人高清在线| 懂色av一区二区三区免费看| 成人激情免费电影网址| 一本久久a久久精品亚洲| 色婷婷av一区二区三区软件| 在线观看日韩av先锋影音电影院| 欧美日韩国产免费一区二区| 在线成人午夜影院| 精品国产成人在线影院| 国产精品视频九色porn| 最新国产精品久久精品| 亚洲一区二区三区爽爽爽爽爽| 午夜久久久影院| 精品亚洲porn| 99久久精品国产观看| 欧美性猛片xxxx免费看久爱| 欧美成人精品二区三区99精品| 欧美国产日本视频| 洋洋成人永久网站入口| 麻豆精品一区二区三区| 成人黄色免费短视频| 欧美男人的天堂一二区| 久久久蜜桃精品| 亚洲一区精品在线| 激情综合色丁香一区二区| 成人午夜在线播放| 欧美日韩二区三区| 欧美极品美女视频| 青青草97国产精品免费观看无弹窗版| 国产精品一区在线观看你懂的| 一本一道波多野结衣一区二区| 日韩一二三区视频| 亚洲人成精品久久久久| 国内不卡的二区三区中文字幕| 91香蕉视频黄| 久久―日本道色综合久久| 亚洲精品乱码久久久久久久久| 精品系列免费在线观看| 欧美日韩精品一区二区三区四区| 欧美精品一区二| 天堂久久一区二区三区| 成人av电影在线观看| 日韩欧美国产综合| 亚洲国产一二三| 成人综合在线视频| 日韩一本二本av| 亚洲成人自拍偷拍| 91丨九色丨国产丨porny| 精品美女被调教视频大全网站| 一区二区三区四区蜜桃| 成人在线视频首页| 日韩美女在线视频| 日韩av二区在线播放| 一本一本久久a久久精品综合麻豆| 国产亚洲人成网站| 久久精品国产精品亚洲红杏| 欧美久久久影院| 亚洲激情六月丁香| 成人app下载| 国产精品区一区二区三| 国产乱子伦视频一区二区三区| 日韩欧美一二三区| 日韩精品一二三| 欧美日韩电影在线| 午夜不卡在线视频| 91.成人天堂一区| 亚瑟在线精品视频| 欧美在线免费观看亚洲| 亚洲欧美视频在线观看| 99久久国产综合精品麻豆| 中文字幕 久热精品 视频在线| 国产精品18久久久久久久久| 久久亚洲综合色| 国产一区在线视频| 国产欧美一区二区精品性色超碰| 国产乱淫av一区二区三区|