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

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

?? 2410iic.c

?? s3c2410的啟動代碼
?? 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
      // 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("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;      
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美视频在线一区| 91精品国产色综合久久不卡电影| 亚洲自拍偷拍网站| 亚洲精品在线三区| 欧美丝袜第三区| 丰满放荡岳乱妇91ww| 日韩和欧美的一区| 亚洲人精品一区| 久久久91精品国产一区二区三区| 在线观看91精品国产入口| 国产精品中文字幕欧美| 五月激情六月综合| 亚洲精品福利视频网站| 国产午夜三级一区二区三| 91精品在线免费| 色婷婷狠狠综合| 大尺度一区二区| 麻豆传媒一区二区三区| 亚洲成在线观看| 亚洲制服丝袜一区| 日韩理论片一区二区| 国产欧美精品国产国产专区| 日韩视频不卡中文| 欧美日韩综合不卡| gogo大胆日本视频一区| 毛片av一区二区| 亚洲风情在线资源站| 一区在线观看免费| 久久女同精品一区二区| 欧美日韩黄视频| 国产一区久久久| 久久se精品一区二区| 亚洲国产成人91porn| 成人免费小视频| 国产日韩精品视频一区| 日韩午夜电影av| 欧美三级在线看| 色八戒一区二区三区| 高清不卡在线观看| 精品一区二区免费看| 香蕉乱码成人久久天堂爱免费| 国产欧美日韩久久| 亚洲精品一区二区三区香蕉| 制服.丝袜.亚洲.中文.综合| 在线视频你懂得一区| 高清成人免费视频| 国产精品一区二区久久不卡| 看电视剧不卡顿的网站| 日本在线播放一区二区三区| 亚洲一区二区av在线| 亚洲精品国产品国语在线app| 国产精品久久免费看| 亚洲国产精品精华液2区45| 久久只精品国产| 精品国产一区二区三区忘忧草| 欧美一区二区三区在线观看| 8v天堂国产在线一区二区| 欧美色国产精品| 欧美老肥妇做.爰bbww| 欧美日本精品一区二区三区| 欧美日韩一本到| 91精品免费在线观看| 欧美一区二区三区人| 日韩欧美一区二区视频| 欧美日韩国产三级| 欧美午夜精品免费| 欧美三级蜜桃2在线观看| 欧美丝袜丝nylons| 日韩欧美中文一区| 国产亚洲精品超碰| 中文天堂在线一区| 亚洲私人影院在线观看| 亚洲一区二区欧美| 五月婷婷另类国产| 九九久久精品视频| 国产精品一区二区你懂的| 成人黄色软件下载| 在线观看国产日韩| 日韩欧美视频一区| 日韩女优视频免费观看| 精品久久五月天| 亚洲精品久久嫩草网站秘色| 亚洲va韩国va欧美va精品| 久久精品国产亚洲高清剧情介绍 | 国产精品乱子久久久久| 最新国产成人在线观看| 亚洲第一电影网| 韩国三级在线一区| 国产另类ts人妖一区二区| av电影在线观看一区| 欧美日韩在线综合| 精品国产123| 中文字幕一区二区三区四区| 亚洲电影在线播放| 国产成人一级电影| 欧美中文字幕一二三区视频| 日韩一区二区三区在线观看| 久久久久久久久岛国免费| 亚洲视频在线一区二区| 久久精品免费观看| 一本久久a久久免费精品不卡| 91精品国产麻豆国产自产在线| 日韩欧美国产wwwww| 亚洲免费资源在线播放| 精品亚洲porn| 91久久免费观看| 欧美videos大乳护士334| 亚洲视频一二三| 精品午夜一区二区三区在线观看| 91天堂素人约啪| 欧美不卡123| 亚洲免费在线观看| 国产一区二区三区在线观看精品| 在线观看免费亚洲| 中文字幕精品在线不卡| 日韩av成人高清| 91免费版pro下载短视频| 精品国内片67194| 午夜a成v人精品| 成人a级免费电影| 欧美精品一区二区三区视频| 亚洲黄色小视频| 成人免费黄色大片| 精品国产乱码久久久久久浪潮| 亚洲精品乱码久久久久久久久| 国产精品一区二区免费不卡 | 成人晚上爱看视频| 日韩美女主播在线视频一区二区三区| 中文字幕在线不卡国产视频| 激情小说欧美图片| 欧美一区二区三区婷婷月色| 亚洲精品第1页| 国产乱人伦偷精品视频不卡| 精品成人免费观看| 日韩高清中文字幕一区| 色诱亚洲精品久久久久久| 国产欧美日本一区二区三区| 蜜桃在线一区二区三区| 欧美日产在线观看| 亚洲成av人片在线观看无码| 不卡的av在线播放| 国产欧美日韩综合| 国产成人综合在线观看| 久久综合视频网| 久久超碰97中文字幕| 精品少妇一区二区三区免费观看| 日产国产欧美视频一区精品| 欧美二区乱c少妇| 视频一区免费在线观看| 欧美在线一区二区| 亚洲永久精品国产| 欧美色倩网站大全免费| 亚洲18色成人| 欧美久久高跟鞋激| 日本aⅴ免费视频一区二区三区| 欧美丝袜丝交足nylons图片| 亚洲成人手机在线| 色噜噜狠狠色综合中国| 午夜一区二区三区视频| 欧美日韩色一区| 视频一区二区国产| 日韩午夜av电影| 韩国av一区二区三区四区 | 91老师片黄在线观看| 成人免费一区二区三区视频| 91视频你懂的| 亚洲一区精品在线| 欧美日韩国产精选| 老司机精品视频导航| 久久久蜜臀国产一区二区| 国产成人精品影院| 国产精品色在线观看| 91福利精品视频| 日韩福利视频网| 久久看人人爽人人| 99久久精品免费观看| 一片黄亚洲嫩模| 制服丝袜在线91| 高清免费成人av| 一区二区成人在线| 制服丝袜在线91| 成人高清视频在线| 亚洲成人动漫精品| 日韩欧美一区中文| 不卡欧美aaaaa| 婷婷综合在线观看| 国产午夜一区二区三区| 日本韩国精品在线| 亚洲国产成人精品视频| 日本一区二区三级电影在线观看| 91年精品国产| 日本成人在线一区| 亚洲欧洲韩国日本视频| 成人av片在线观看| 日韩成人免费电影| 中文字幕一区二区在线播放 | www久久精品| 色婷婷综合久色| 久久精品国产秦先生| 国产精品久久二区二区|