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

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

?? 2410iic.c

?? s3c2410勤研的開發板的測試程序.可以測試通用的s3c2410芯片的各個功能,包括ad,usb,lcd,uart
?? 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一区二区三区免费野_久草精品视频
日韩国产在线一| 中文字幕欧美三区| 日韩三级免费观看| 欧美性高清videossexo| 国产成人免费在线观看| 成人蜜臀av电影| 欧美亚洲免费在线一区| 欧美日韩国产电影| 91精品国产aⅴ一区二区| av电影一区二区| 欧洲av一区二区嗯嗯嗯啊| 欧美午夜精品久久久久久孕妇| 色婷婷综合视频在线观看| 91麻豆精品国产91久久久久| 欧美日韩日日摸| 欧美亚洲国产一区二区三区| 555夜色666亚洲国产免| 国产日韩欧美不卡| 性做久久久久久免费观看欧美| 日韩和的一区二区| 97久久精品人人做人人爽50路| 色8久久精品久久久久久蜜| 欧美日韩成人在线| 国产精品私房写真福利视频| 午夜精品免费在线| 国产精品99久久久久久似苏梦涵| 色哟哟亚洲精品| 亚洲国产精品精华液2区45| 日韩国产精品91| 99久久99久久久精品齐齐| 91精品国产欧美一区二区18| 自拍偷拍亚洲欧美日韩| 秋霞午夜av一区二区三区| 色拍拍在线精品视频8848| 欧美激情一区二区三区不卡| 美女mm1313爽爽久久久蜜臀| 91黄色免费版| 日本一区二区三区国色天香 | 亚洲一区在线观看网站| 99在线精品一区二区三区| 日韩一级片网站| 日韩美女视频一区二区| 国产成人av福利| 国产视频一区二区在线| 狠狠色丁香婷婷综合| 91色视频在线| 亚洲国产日韩a在线播放| 色综合激情五月| 性久久久久久久久| 91成人免费在线| 日韩一区精品视频| 欧美影视一区在线| 亚洲视频一二三区| 91污在线观看| 亚洲3atv精品一区二区三区| 欧美少妇xxx| 日韩精品1区2区3区| 91精品免费观看| 国产美女主播视频一区| 亚洲欧洲色图综合| 色婷婷激情久久| 午夜一区二区三区在线观看| 精品奇米国产一区二区三区| 国产不卡视频在线播放| 日韩一区二区精品葵司在线 | 高清免费成人av| 亚洲免费观看高清完整版在线| 欧洲精品视频在线观看| 久久99久久精品欧美| 亚洲欧洲日韩在线| 欧美精品乱码久久久久久按摩| 久久成人久久爱| 一区二区三区在线影院| 在线不卡中文字幕| 99国产精品久久久久久久久久久| 午夜精品免费在线观看| 国产精品美女久久久久久久| 日韩一区二区三区三四区视频在线观看 | 无码av免费一区二区三区试看 | 精品国产伦理网| 4hu四虎永久在线影院成人| 成人伦理片在线| 久久69国产一区二区蜜臀| 国产日韩欧美制服另类| 精品国产伦一区二区三区观看体验| 欧美视频中文字幕| 欧美日韩免费电影| 欧美精品亚洲二区| 91精品福利在线一区二区三区| 日韩欧美激情一区| 国产精品狼人久久影院观看方式| 国产亚洲福利社区一区| 久久久精品免费网站| **欧美大码日韩| 五月开心婷婷久久| 午夜精品免费在线观看| 久久精品国产99久久6| 欧美日韩国产区一| 日韩欧美一区二区在线视频| 精品福利一区二区三区| 国产亚洲va综合人人澡精品| 亚洲另类色综合网站| 婷婷夜色潮精品综合在线| 国产一区二区在线免费观看| 不卡欧美aaaaa| 91精品国产乱码久久蜜臀| 中文无字幕一区二区三区| 日韩极品在线观看| 成人美女在线视频| 欧美一区二区国产| 日本一区二区三级电影在线观看| 依依成人综合视频| 国内成人免费视频| 欧美日韩一级黄| 国产精品福利一区| 国模一区二区三区白浆| 91精品一区二区三区在线观看| 国产精品对白交换视频| 国产一区二区视频在线播放| 欧美日韩国产成人在线91| 综合欧美亚洲日本| 成人av高清在线| 精品sm在线观看| gogo大胆日本视频一区| 欧美成人高清电影在线| 亚洲妇女屁股眼交7| 色综合激情五月| 亚洲主播在线观看| 91老师国产黑色丝袜在线| 国产精品色眯眯| 色屁屁一区二区| 亚洲精品高清视频在线观看| 色婷婷精品大视频在线蜜桃视频| 亚洲色欲色欲www| 色呦呦国产精品| 亚洲成人精品一区| 欧美精品丝袜中出| 日韩电影一二三区| 久久精品人人爽人人爽| 99精品久久99久久久久| 日韩精品一级中文字幕精品视频免费观看| 在线视频你懂得一区二区三区| 亚洲一区二区三区精品在线| 欧洲国内综合视频| 日韩区在线观看| 懂色av一区二区三区免费看| 中文字幕一区免费在线观看| 在线中文字幕不卡| 精久久久久久久久久久| 国产日韩v精品一区二区| 99久久免费视频.com| 三级在线观看一区二区| 久久久久国产精品免费免费搜索| 不卡视频免费播放| 老司机精品视频在线| 亚洲美女少妇撒尿| 精品卡一卡二卡三卡四在线| 欧美影视一区在线| fc2成人免费人成在线观看播放| 九色porny丨国产精品| 亚洲一区二区三区不卡国产欧美| 久久只精品国产| 日韩三级免费观看| 欧美视频自拍偷拍| 欧美日韩一区二区三区四区| 成人天堂资源www在线| 久久精品国产免费看久久精品| 一区二区三区视频在线观看| 国产情人综合久久777777| 日韩免费福利电影在线观看| 欧美丰满少妇xxxbbb| 欧美精品色一区二区三区| 欧美精品在线观看一区二区| 欧美美女直播网站| 日韩欧美电影一二三| 国产亚洲精品中文字幕| 亚洲理论在线观看| 一区二区在线看| 香蕉影视欧美成人| 欧美aⅴ一区二区三区视频| 麻豆91精品视频| 国产凹凸在线观看一区二区| 国产精品1024| 久久久亚洲精品一区二区三区| 亚洲欧洲色图综合| 日韩av电影一区| 成人h动漫精品一区二区| 精品1区2区3区| 国产精品久久久久久一区二区三区| 亚洲欧美偷拍另类a∨色屁股| 久久99久久99小草精品免视看| 99精品热视频| 日韩欧美成人午夜| 亚洲欧洲三级电影| 国产精品99精品久久免费| 制服丝袜av成人在线看| 国产精品每日更新在线播放网址| 亚洲第一精品在线| 99视频精品全部免费在线| 91精品久久久久久久久99蜜臂|