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

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

?? iic.c

?? mini2440 non-OS test code
?? C
字號(hào):
//====================================================================
// File Name : IIC.c
// Function  : S3C2440 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 "2440addr.h"
#include "2440lib.h"
#include "def.h"
#include "IIC.h"

static U8 _iicData[IICBUFSIZE];
static volatile int _iicDataCount;
static volatile int _iicStatus;
static volatile int _iicMode;
static int _iicPt;

//===================================================================
//       SMDK2440 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 |= 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;                    //2440 slave address = [7:1]
    rIICSTAT = 0x10;                    //IIC bus data output enable(Rx/Tx)
	rIICLC = (1<<2)|(1);  				// Filter enable, 15 clocks SDA output delay       added by junon
    
    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])); 

        //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;      
    }
}


//===================================================================
//       SMDK2440 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;                    //2440 slave address = [7:1]
    rIICSTAT = 0x10;                    //IIC bus data output enable(Rx/Tx)
	//rIICLC = (1<<2)|(3);  // Filter enable, 15 clocks SDA output delay     added by junon
    
    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
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩三级电影网址| 91性感美女视频| 99精品视频在线免费观看| 亚洲男人的天堂av| 亚洲电影一区二区| 国产黄人亚洲片| 欧美区视频在线观看| 国产精品视频线看| 蜜桃视频一区二区| 欧美日韩中文字幕一区| 国产精品美女久久久久久久久久久 | 岛国一区二区在线观看| 欧美色偷偷大香| 国产在线播放一区三区四| 国产欧美一区二区精品仙草咪| 日韩一级精品视频在线观看| 中文字幕国产一区| 国产精品伊人色| 色婷婷综合久久久| 91免费观看视频在线| 中文字幕一区二区视频| 日本一区中文字幕| 黄色小说综合网站| 色狠狠一区二区三区香蕉| 欧美在线影院一区二区| 日本sm残虐另类| 日韩一区二区三区在线| 成人毛片在线观看| 性做久久久久久| 久久色视频免费观看| 欧美一区二区三区啪啪| 色综合久久88色综合天天免费| 成人福利视频网站| 日本成人超碰在线观看| 91免费看`日韩一区二区| 91玉足脚交白嫩脚丫在线播放| heyzo一本久久综合| 国产精品一区三区| 成人app下载| 91香蕉视频在线| 欧美日韩国产综合视频在线观看 | 国产精品午夜电影| 欧美色图12p| 男女男精品视频| 亚洲欧洲精品一区二区三区不卡 | 色婷婷综合久久久| 亚洲美女电影在线| 国产午夜亚洲精品午夜鲁丝片| 国产精品白丝在线| 日韩一区二区在线观看视频| 亚洲精品高清在线| 色中色一区二区| 99久久婷婷国产综合精品电影 | 欧美一区国产二区| 91九色02白丝porn| 在线一区二区三区| 欧美日韩一区二区三区不卡| 欧美白人最猛性xxxxx69交| 国产日产亚洲精品系列| 亚洲一区在线观看视频| 国产自产视频一区二区三区| 成人小视频免费观看| 国产美女在线观看一区| 亚洲少妇最新在线视频| 亚洲电影中文字幕在线观看| 亚洲一区二区三区四区在线观看 | 国产精品私房写真福利视频| 国产露脸91国语对白| 中文字幕永久在线不卡| 欧美一区二区三区在| 国产精品12区| 亚洲第一久久影院| 国产午夜精品一区二区三区嫩草 | 成人黄色网址在线观看| 午夜精品爽啪视频| 国产婷婷一区二区| 欧美性生活一区| 国产成人av自拍| 日韩av一二三| 日韩一区中文字幕| 欧美日韩国产一区| 成人一区二区三区在线观看| 五月婷婷综合网| 国产精品久久777777| 日韩一级大片在线| 91美女片黄在线观看91美女| 国产精一区二区三区| 亚洲国产精品久久人人爱蜜臀| 久久影院午夜片一区| 9191成人精品久久| 91最新地址在线播放| 精品在线一区二区三区| 亚洲高清在线精品| 亚洲图片另类小说| 久久九九99视频| 日韩免费视频一区| 欧美日韩国产成人在线91| 91麻豆国产福利在线观看| 国产一区视频导航| 久草在线在线精品观看| 亚洲va国产va欧美va观看| 最新热久久免费视频| 欧美极品少妇xxxxⅹ高跟鞋| 日韩欧美一级片| 欧美一区二区视频在线观看2020| 欧美网站大全在线观看| 91国产视频在线观看| 91精品1区2区| 色婷婷综合久久久| 日本高清不卡视频| 91传媒视频在线播放| 一本色道久久加勒比精品| 92精品国产成人观看免费| 成人av网站在线| 成人福利视频网站| 99re这里只有精品视频首页| 成人一区二区在线观看| av资源网一区| 在线观看亚洲成人| 欧美主播一区二区三区美女| 色综合色综合色综合| 色婷婷精品久久二区二区蜜臀av| 99久久777色| 色妹子一区二区| 欧美探花视频资源| 欧美一区二区三区四区高清| 日韩欧美卡一卡二| 久久精品网站免费观看| 国产精品久久影院| 亚洲综合在线免费观看| 午夜精品久久久久久久99水蜜桃| 日本大胆欧美人术艺术动态 | 精品乱人伦小说| 欧美国产综合色视频| 亚洲你懂的在线视频| 日韩精品欧美精品| 国产美女娇喘av呻吟久久| www.爱久久.com| 欧美日韩色一区| www激情久久| 亚洲精品视频一区| 免费成人小视频| 丁香五精品蜜臀久久久久99网站| 91免费国产在线| 91精品国产入口| 国产日韩欧美一区二区三区乱码 | 国产精品毛片无遮挡高清| 一区二区三区四区中文字幕| 免费高清不卡av| av一本久道久久综合久久鬼色| 欧美午夜理伦三级在线观看| 久久九九99视频| 午夜av一区二区三区| 成人性生交大合| 欧美久久久影院| 国产日韩v精品一区二区| 五月综合激情日本mⅴ| 风间由美中文字幕在线看视频国产欧美 | 精品国产乱码91久久久久久网站| 国产精品国模大尺度视频| 麻豆国产欧美日韩综合精品二区| 成人禁用看黄a在线| 日韩一区二区高清| 亚洲天堂av一区| 国产精品羞羞答答xxdd| 欧美日韩中文精品| 自拍偷拍国产精品| 国产精一区二区三区| 91精品视频网| 一区二区三区中文在线| 成人晚上爱看视频| 精品国产一区二区三区av性色| 一区二区三区四区在线| 不卡的电视剧免费网站有什么| 亚洲精品一区二区三区四区高清 | 国产乱妇无码大片在线观看| 在线综合亚洲欧美在线视频| 亚洲黄色性网站| 99久久亚洲一区二区三区青草| 久久久国产一区二区三区四区小说 | 日韩黄色片在线观看| 91蝌蚪porny九色| 亚洲国产成人私人影院tom| 久久激五月天综合精品| 8x福利精品第一导航| 亚洲成人一区二区在线观看| 在线观看亚洲专区| 亚洲精品久久嫩草网站秘色| 91在线精品一区二区| 中文久久乱码一区二区| 国产一区二区三区在线观看免费视频| 欧美精品在欧美一区二区少妇| 亚洲欧美一区二区三区极速播放| 99视频超级精品| 国产精品初高中害羞小美女文| 成人午夜视频网站| 中文久久乱码一区二区| 丁香另类激情小说| 亚洲天堂精品视频| 欧美天堂亚洲电影院在线播放|