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

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

?? 2410iic.c

?? s3c2410 Monitor program srource
?? 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高潮流白浆在线麻豆 | 欧美亚洲精品一区| 一区二区三区中文在线| 91黄色免费看| 午夜精品影院在线观看| 91精品国产美女浴室洗澡无遮挡| 日本三级亚洲精品| 欧美tk—视频vk| 国产91在线|亚洲| 成人免费在线观看入口| 欧美日韩免费一区二区三区视频| 日韩一区欧美二区| 日韩精品专区在线影院重磅| 国产一区免费电影| 亚洲欧洲国产日韩| 欧美精品日韩一本| 国产最新精品免费| 亚洲精品日韩综合观看成人91| 色噜噜夜夜夜综合网| 日韩专区中文字幕一区二区| 久久久久久97三级| 色老汉av一区二区三区| 精品一区二区免费看| 国产精品女主播av| 综合网在线视频| 欧美精品三级在线观看| 大美女一区二区三区| 视频一区在线播放| 国产欧美日韩久久| 91精品国产一区二区人妖| 国产a级毛片一区| 午夜精品久久久久久久久久| 国产欧美精品在线观看| 91 com成人网| 94色蜜桃网一区二区三区| 美国三级日本三级久久99| 一区二区中文视频| 精品国一区二区三区| 91碰在线视频| 九一久久久久久| 亚洲最新视频在线观看| 久久精品亚洲精品国产欧美kt∨| 欧美午夜寂寞影院| 成人美女视频在线看| 美女mm1313爽爽久久久蜜臀| 一区二区三区视频在线观看| 国产日韩精品视频一区| 7878成人国产在线观看| 一本一道久久a久久精品综合蜜臀| 热久久免费视频| 一区二区三区蜜桃| 国产精品麻豆视频| 久久久三级国产网站| 日韩欧美自拍偷拍| 日本道精品一区二区三区| 成人一级片网址| 激情五月婷婷综合网| 蜜臀av一级做a爰片久久| 亚洲成人你懂的| 亚洲欧美日本在线| 亚洲日本在线看| 欧美韩日一区二区三区| 26uuu国产一区二区三区| 亚洲午夜免费电影| 亚洲视频在线一区二区| 中文一区二区完整视频在线观看 | 99久精品国产| 韩国成人精品a∨在线观看| 奇米精品一区二区三区四区| 午夜av一区二区三区| 亚洲成年人网站在线观看| 亚洲激情在线激情| 亚洲亚洲精品在线观看| 一区二区三区四区高清精品免费观看 | 蜜臀91精品一区二区三区| 亚洲一区二区在线免费观看视频 | 国产在线视频一区二区三区| 日韩高清不卡一区二区三区| 日韩国产欧美在线播放| 日韩高清欧美激情| 精品一区二区在线免费观看| 久久精品国产77777蜜臀| 美女一区二区三区在线观看| 久久精品久久综合| 精品午夜久久福利影院 | 久久色.com| 精品动漫一区二区三区在线观看| 日韩欧美中文字幕公布| 精品免费99久久| 久久精品欧美一区二区三区不卡 | 国产综合色视频| 国产一区二区三区在线观看免费| 国产尤物一区二区在线| 国产成人综合亚洲网站| www.久久精品| 欧美午夜视频网站| 日韩美一区二区三区| 精品成人一区二区| 国产精品久久久久婷婷二区次| 亚洲日本在线a| 天天射综合影视| 国产在线看一区| 91亚洲国产成人精品一区二区三 | 欧美影院一区二区三区| 欧美一区二区三区人| 久久精品一区蜜桃臀影院| 国产精品国产馆在线真实露脸 | 欧美裸体一区二区三区| 日韩精品一区二区三区三区免费 | 美腿丝袜亚洲一区| 成人激情免费网站| 欧美色视频在线观看| 婷婷综合另类小说色区| 久草热8精品视频在线观看| 国产成人在线观看免费网站| 色婷婷一区二区| 久久网站热最新地址| 亚洲精品日韩专区silk| 日韩av一区二区三区| 成人一区在线观看| 在线成人高清不卡| 国产精品嫩草久久久久| 视频一区二区三区入口| 成人精品gif动图一区| 911精品国产一区二区在线| 亚洲国产岛国毛片在线| 青青青伊人色综合久久| 91麻豆自制传媒国产之光| 久久亚洲捆绑美女| 日韩中文字幕不卡| 91视频com| 久久久久国产精品人| 日本在线不卡一区| 91成人免费网站| 国产精品网曝门| 久久激情五月婷婷| 欧美三级乱人伦电影| 国产精品久久久久桃色tv| 国内欧美视频一区二区| 欧美日本乱大交xxxxx| 国产精品二三区| 欧美一区二区三区四区久久| 国产精品国产三级国产aⅴ原创| 麻豆精品视频在线观看视频| 欧美日韩一区二区在线观看| 国产精品美女一区二区在线观看| 蜜臀久久久久久久| 欧美高清视频不卡网| 一区二区在线观看av| 成人av资源在线| 国产日产欧美精品一区二区三区| 免费欧美在线视频| 8v天堂国产在线一区二区| 亚洲尤物视频在线| 色婷婷综合五月| 中文字幕视频一区| 国产69精品一区二区亚洲孕妇| www日韩大片| 狠狠久久亚洲欧美| 精品国产髙清在线看国产毛片| 日韩电影在线免费| 欧美剧在线免费观看网站 | 亚洲亚洲人成综合网络| 色综合天天综合| 中文字幕一区av| 91原创在线视频| 亚洲色图清纯唯美| 91网站在线播放| 最新不卡av在线| 一本色道久久综合亚洲91| 亚洲欧美在线观看| 91在线视频观看| 一区二区三区欧美视频| 一本一道久久a久久精品| 亚洲另类在线视频| 欧美日韩一区三区四区| 日韩电影在线免费看| 欧美电影精品一区二区| 国产一区二区免费在线| 国产精品亲子乱子伦xxxx裸| 99久久久国产精品免费蜜臀| 亚洲欧洲99久久| 91激情在线视频| 日本不卡免费在线视频| 久久综合成人精品亚洲另类欧美 | 日日夜夜精品视频天天综合网| 91精品国产色综合久久久蜜香臀| 免费成人在线观看| 国产亚洲成aⅴ人片在线观看| www.av精品| 午夜精品影院在线观看| 日韩欧美色电影| 成人app网站| 亚洲午夜电影在线| 久久综合色天天久久综合图片| 成人h版在线观看| 偷窥少妇高潮呻吟av久久免费| 日韩欧美www| av电影一区二区|