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

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

?? iic.c

?? s3c2440_driver.rar
?? C
字號:
//====================================================================
// 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;      
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧洲亚洲精品在线| 国产三级精品三级在线专区| 精品国产乱码久久久久久浪潮| 久久久精品黄色| 亚洲成人免费av| 国产乱子伦视频一区二区三区 | 亚洲精品视频在线观看网站| 免费观看91视频大全| 97精品国产露脸对白| 欧美电影免费观看高清完整版在线观看 | 91丨九色丨尤物| 日韩欧美激情四射| 亚洲va欧美va人人爽午夜| 成人av手机在线观看| 精品少妇一区二区三区在线播放| 一区二区欧美视频| 99re这里只有精品视频首页| 久久久久久久久久久电影| 免费成人av资源网| 欧美视频在线播放| 亚洲国产va精品久久久不卡综合| 成人精品视频.| 国产欧美综合在线观看第十页| 麻豆精品一区二区三区| 欧美日韩1区2区| 亚洲国产精品一区二区久久恐怖片| 99久久精品国产观看| 国产精品国产三级国产专播品爱网| 国精品**一区二区三区在线蜜桃| 日韩美一区二区三区| 日韩电影一区二区三区| 51精品久久久久久久蜜臀| 亚洲精品成人悠悠色影视| 91麻豆文化传媒在线观看| 亚洲视频一区二区在线| 97se亚洲国产综合自在线观| 国产精品二区一区二区aⅴ污介绍| 国产精品一区二区久久精品爱涩 | 中文字幕一区二区三区在线不卡| 国产一区二区三区日韩| 久久久久久久免费视频了| 国产麻豆精品在线| 国产日韩精品一区二区三区| 国产成人免费9x9x人网站视频| 久久久久久一级片| 不卡电影一区二区三区| 亚洲美女视频在线观看| 欧美日韩三级在线| 美女视频网站久久| 国产丝袜在线精品| 91色视频在线| 爽好久久久欧美精品| 欧美第一区第二区| 国产电影一区在线| 亚洲精品欧美综合四区| 欧美猛男男办公室激情| 久久精品久久久精品美女| 久久精品欧美一区二区三区不卡 | 一区二区三区在线观看欧美| 欧美视频在线不卡| 黄色日韩三级电影| 亚洲人一二三区| 欧美精品久久久久久久多人混战| 久久99久久99精品免视看婷婷| 久久久91精品国产一区二区精品 | 成人激情开心网| 亚洲一区二三区| 久久夜色精品一区| 在线视频你懂得一区| 免费视频一区二区| 亚洲欧美日韩国产一区二区三区 | 偷拍自拍另类欧美| 久久久精品国产免大香伊 | 91精品国产一区二区三区香蕉| 国产最新精品精品你懂的| 亚洲精品中文在线观看| 337p粉嫩大胆色噜噜噜噜亚洲| 99综合电影在线视频| 青青青伊人色综合久久| 亚洲欧洲av另类| 欧美xxxxxxxx| 4438x成人网最大色成网站| 丰满少妇在线播放bd日韩电影| 亚洲va韩国va欧美va| 国产蜜臀97一区二区三区 | 国产精品久久久久7777按摩 | 久久精品噜噜噜成人88aⅴ| 亚洲你懂的在线视频| 久久久www免费人成精品| 欧美精品在线观看一区二区| 不卡电影免费在线播放一区| 久久国产精品99精品国产| 一区二区三区视频在线看| 国产色婷婷亚洲99精品小说| 91精品国产乱| 欧美亚洲日本一区| 97国产精品videossex| 国产成人啪午夜精品网站男同| 麻豆国产精品777777在线| 亚洲成av人片www| 亚洲激情网站免费观看| 国产精品高清亚洲| 欧美极品少妇xxxxⅹ高跟鞋| 26uuu另类欧美| 欧美va亚洲va国产综合| 欧美一区二区三区在线看| 欧美日韩精品欧美日韩精品| 欧美亚洲综合一区| 欧美中文字幕亚洲一区二区va在线| 99精品视频一区二区| 成人免费看黄yyy456| 成人丝袜高跟foot| 高清av一区二区| 国产一区二区三区免费在线观看| 九九国产精品视频| 蜜桃视频在线观看一区| 麻豆中文一区二区| 精品在线亚洲视频| 国产真实精品久久二三区| 国产一区二区三区蝌蚪| 国产一区二区不卡在线| 国产精品中文字幕日韩精品| 国产一区二区精品在线观看| 国产成人鲁色资源国产91色综| 成人免费高清在线| 99麻豆久久久国产精品免费优播| youjizz久久| 在线欧美一区二区| 538prom精品视频线放| 日韩视频国产视频| 欧美精品一区视频| 国产精品久久久久久久久动漫| 成人欧美一区二区三区黑人麻豆| 亚洲精品中文在线观看| 日韩黄色在线观看| 久草这里只有精品视频| 成人国产电影网| 91福利社在线观看| 欧美一级高清片在线观看| 久久九九99视频| 亚洲精品乱码久久久久久黑人| 亚洲va欧美va人人爽| 久久99国内精品| 成人在线一区二区三区| 欧美性欧美巨大黑白大战| 欧美一二三区精品| 国产精品乱码人人做人人爱| 亚洲一二三区视频在线观看| 六月丁香婷婷色狠狠久久| 成人黄色av电影| 91精品国产色综合久久| 国产日韩精品久久久| 婷婷中文字幕一区三区| 国产高清精品网站| 欧美欧美午夜aⅴ在线观看| 久久久久99精品国产片| 亚洲成人激情av| 从欧美一区二区三区| 欧美老肥妇做.爰bbww视频| 26uuu国产一区二区三区| 亚洲自拍与偷拍| 高清久久久久久| 91精品国产色综合久久| 亚洲男人天堂一区| 久久精品免费观看| 精品1区2区3区| 国产精品久久久久永久免费观看| 天天影视网天天综合色在线播放| 成人污视频在线观看| 欧美变态凌虐bdsm| 亚洲成人综合网站| caoporn国产精品| 久久久午夜精品| 美女精品自拍一二三四| 欧美亚一区二区| 中文字幕一区二区三区蜜月| 狠狠网亚洲精品| 欧美变态tickle挠乳网站| 三级精品在线观看| 91精品福利视频| 亚洲欧洲国产专区| 成人国产精品免费观看| 久久久久久久久久久久久久久99 | 99精品欧美一区| 国产午夜久久久久| 久久99精品国产麻豆不卡| 欧美日韩在线精品一区二区三区激情| 国产精品婷婷午夜在线观看| 国产精品一区二区你懂的| 日韩欧美综合在线| 天天综合网 天天综合色| 欧美在线你懂得| 亚洲一区二区3| 日本韩国视频一区二区| 亚洲久本草在线中文字幕| 成人av网在线| 成人欧美一区二区三区1314| 成人一区二区三区视频在线观看| 久久久久九九视频| 国产毛片一区二区|