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

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

?? 2410iic.c

?? 嵌入式LINUX的整套實(shí)例程序
?? 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 KS24C080 ]\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
    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 KS24C080\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 KS24C080\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;      
    }
}


//===================================================================
//       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 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;                    //2410 slave address = [7:1]
    rIICSTAT = 0x10;                    //IIC bus data output enable(Rx/Tx)

    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一区二区三区免费野_久草精品视频
精品制服美女丁香| 色综合天天性综合| 91免费看片在线观看| 日韩视频永久免费| 亚洲蜜臀av乱码久久精品| 老司机午夜精品| 欧美在线小视频| 国产亚洲美州欧州综合国| 天天亚洲美女在线视频| 成人aaaa免费全部观看| 久久婷婷国产综合国色天香| 亚洲成人动漫一区| 一本久久a久久免费精品不卡| 精品国产乱码久久久久久浪潮| 亚洲国产日韩在线一区模特| 99国产精品久| 国产精品女同一区二区三区| 久久99热这里只有精品| 制服丝袜中文字幕亚洲| 亚洲国产成人porn| 在线观看日产精品| 亚洲男同性恋视频| 成人av在线一区二区三区| 精品理论电影在线观看| 免费av成人在线| 3d动漫精品啪啪| 日本美女一区二区| 欧美一二三区在线| 日韩精品高清不卡| 在线不卡中文字幕播放| 亚洲国产视频一区| 欧美区在线观看| 亚洲综合男人的天堂| 在线观看网站黄不卡| 亚洲精品国产精品乱码不99| 色综合天天综合| 亚洲在线视频网站| 欧美日本一区二区三区四区| 午夜久久久久久久久| 欧美一级日韩免费不卡| 捆绑紧缚一区二区三区视频 | 亚洲精品一区二区三区在线观看| 日产精品久久久久久久性色| 日韩欧美的一区| 国产一区二区伦理| 国产精品热久久久久夜色精品三区| 国产成+人+日韩+欧美+亚洲| 国产精品视频一二三区| 91看片淫黄大片一级在线观看| 日韩理论片网站| 91国偷自产一区二区使用方法| 亚洲午夜久久久久久久久电影院| 欧美日韩国产欧美日美国产精品| 日韩黄色在线观看| 久久亚洲精品小早川怜子| 高清在线成人网| 一区二区三区在线免费| 欧美疯狂性受xxxxx喷水图片| 久久福利资源站| 亚洲色图清纯唯美| 在线不卡a资源高清| 韩国中文字幕2020精品| 国产精品高潮呻吟| 欧美精品免费视频| 福利91精品一区二区三区| 一区二区三区影院| 精品女同一区二区| 91久久奴性调教| 国模一区二区三区白浆| 亚洲精品免费在线观看| 日韩欧美国产午夜精品| av中文字幕亚洲| 蜜臀久久99精品久久久久宅男| 欧美国产激情一区二区三区蜜月 | 中文字幕一区二区三区av| 欧美亚洲动漫另类| 国产盗摄一区二区| 天堂久久一区二区三区| 国产精品久久久久婷婷二区次| 在线播放91灌醉迷j高跟美女 | 69精品人人人人| 99精品国产91久久久久久| 久久国产成人午夜av影院| 亚洲精品乱码久久久久久黑人| 亚洲精品在线免费观看视频| 欧美日韩精品一二三区| 99亚偷拍自图区亚洲| 另类人妖一区二区av| 亚洲嫩草精品久久| 国产女人aaa级久久久级| 欧美一区日韩一区| 欧美在线观看视频一区二区| 高清国产午夜精品久久久久久| 日本不卡一二三| 一区二区三区四区在线播放| 国产精品另类一区| 久久久久久久综合狠狠综合| 91 com成人网| 欧美视频一区二区三区四区 | 高清国产一区二区| 极品美女销魂一区二区三区免费| 亚洲国产精品久久久久婷婷884| 国产精品免费久久久久| 国产午夜精品理论片a级大结局| 91麻豆精品国产自产在线观看一区| 一本久道中文字幕精品亚洲嫩| 9色porny自拍视频一区二区| 国产精品77777| 国产麻豆精品95视频| 免费在线观看成人| 久久成人麻豆午夜电影| 蜜臀av性久久久久av蜜臀妖精| 午夜伦理一区二区| 视频一区二区三区入口| 偷窥少妇高潮呻吟av久久免费| 亚洲成人av中文| 午夜精品福利久久久| 日韩国产精品久久| 麻豆精品国产传媒mv男同| 麻豆精品视频在线| 国产一区三区三区| 成人免费看片app下载| 成人综合在线观看| 本田岬高潮一区二区三区| gogogo免费视频观看亚洲一| av在线播放不卡| 一本久久a久久精品亚洲 | 91免费视频大全| 欧美片在线播放| 日韩欧美成人一区| 精品国产乱码久久久久久图片| 国产欧美日韩精品一区| 中文字幕在线不卡国产视频| 一区二区日韩电影| 日韩国产欧美在线视频| 国产一区二区在线影院| jvid福利写真一区二区三区| 色欧美88888久久久久久影院| 精品视频在线免费看| 日韩欧美国产wwwww| 国产三级精品三级在线专区| 亚洲免费观看高清| 久久精品国产成人一区二区三区| 国产一区二区三区四区五区入口| 国产成人综合在线观看| 色婷婷av一区二区三区软件| 欧美日韩精品一区二区天天拍小说| 日韩一区二区三区高清免费看看| 久久久久久97三级| 亚洲综合色视频| 国产一区二区电影| 精品视频资源站| 欧美激情在线观看视频免费| 亚洲午夜电影在线观看| 国产专区欧美精品| 在线观看日韩一区| 久久精品人人爽人人爽| 亚洲狠狠丁香婷婷综合久久久| 麻豆国产精品777777在线| eeuss鲁片一区二区三区在线观看| 欧美日韩国产免费一区二区| 国产色一区二区| 日韩电影在线观看一区| 91影院在线观看| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 91色在线porny| 日韩美女视频在线| 亚洲国产aⅴ成人精品无吗| 国产一区二区伦理片| 91精品国产综合久久久久久久久久 | 国产成人午夜精品影院观看视频 | 最新中文字幕一区二区三区| 免费欧美日韩国产三级电影| 色综合婷婷久久| 日本一区二区三区高清不卡| 麻豆国产精品777777在线| 欧美做爰猛烈大尺度电影无法无天| 精品国产乱码久久久久久夜甘婷婷 | 欧美国产综合色视频| 日韩制服丝袜先锋影音| 日本精品视频一区二区| 亚洲欧美一区二区在线观看| 国产精品自产自拍| 精品日韩欧美在线| 午夜日韩在线电影| 欧美伊人精品成人久久综合97| 国产精品国产自产拍高清av王其| 国产精品系列在线播放| 精品欧美久久久| 久久精品国产免费看久久精品| 3atv一区二区三区| 日韩高清欧美激情| 欧美日韩高清影院| 一二三区精品福利视频| 色婷婷av久久久久久久| 一区二区三区中文字幕精品精品 | 奇米亚洲午夜久久精品| 成人欧美一区二区三区视频网页 | 亚洲精选视频在线| 99国产麻豆精品|