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

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

?? 2410iic.c

?? S3C2410_TEST.rar
?? 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("__irq IicInt SETDADDR [ 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("IicPoll() SETRADDR [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资源部| 欧美日韩国产免费| 国产美女精品人人做人人爽| 美女www一区二区| 蜜桃av一区二区三区电影| 亚洲第一福利一区| 亚洲午夜久久久久久久久久久| 一区二区成人在线观看| 亚洲高清免费观看高清完整版在线观看 | 日韩一级免费观看| 欧美一级二级在线观看| 日韩欧美国产麻豆| 精品国产123| 国产欧美日韩三区| 国产精品久久精品日日| 亚洲欧美日韩中文播放| 一区二区三区蜜桃网| 天堂av在线一区| 久久国产精品露脸对白| 国产91精品精华液一区二区三区 | 九一久久久久久| 狠狠色丁香久久婷婷综| 国产成人自拍网| 色综合欧美在线视频区| 欧美精品v日韩精品v韩国精品v| 日韩一级片网址| 国产亚洲综合在线| 亚洲欧洲综合另类| 亚洲福利一区二区三区| 黑人巨大精品欧美一区| av不卡免费在线观看| 欧美色偷偷大香| 日韩女优av电影| 国产精品国产三级国产三级人妇| 亚洲美女在线一区| 九九在线精品视频| 97久久人人超碰| 色婷婷精品大在线视频| 国产成人日日夜夜| 丁香婷婷综合激情五月色| 国产精品羞羞答答xxdd| 91在线观看下载| 欧美本精品男人aⅴ天堂| 激情小说欧美图片| 一区二区三区国产豹纹内裤在线| 色婷婷综合视频在线观看| 中文字幕免费一区| 亚洲成人福利片| 激情五月激情综合网| 99天天综合性| 婷婷国产v国产偷v亚洲高清| 麻豆成人久久精品二区三区红| 色综合中文综合网| 最新不卡av在线| 国产欧美日韩激情| 亚洲国产经典视频| www.性欧美| 欧美白人最猛性xxxxx69交| 亚洲午夜激情网站| 欧美视频在线观看一区| 亚洲毛片av在线| 丝袜美腿亚洲综合| 国产盗摄一区二区| 欧美日本一区二区三区四区| 欧美一级高清大全免费观看| 日韩三级电影网址| 亚洲一区免费观看| 国产精品一区二区三区乱码| 欧美一区二区人人喊爽| 国产精品免费久久久久| 亚洲综合免费观看高清在线观看| 成人免费在线播放视频| 丝瓜av网站精品一区二区| 国产精品亚洲专一区二区三区 | 欧美日韩色综合| 亚洲精品国产视频| 五月天丁香久久| 91在线免费视频观看| 国产欧美日韩精品a在线观看| 国产麻豆日韩欧美久久| 欧美日韩国产高清一区二区| 中文字幕一区二区三区四区不卡| 国产激情一区二区三区四区| 在线观看一区日韩| 日韩电影免费在线看| 亚洲高清不卡在线观看| 欧美午夜精品电影| 看电视剧不卡顿的网站| 欧美一区二区在线观看| 亚洲一区二区三区在线| 91丝袜美女网| 97se狠狠狠综合亚洲狠狠| 色网综合在线观看| 欧美韩日一区二区三区| 九九热在线视频观看这里只有精品| 欧美日韩国产首页| 亚洲午夜激情av| 欧美午夜理伦三级在线观看| 亚洲日本一区二区| 色综合亚洲欧洲| 亚洲三级在线免费| 91社区在线播放| 亚洲女人小视频在线观看| 成人高清视频免费观看| 国产日韩欧美不卡在线| 国产成a人无v码亚洲福利| 久久久久国产精品麻豆ai换脸| 韩国理伦片一区二区三区在线播放| 精品国产污污免费网站入口 | 91精品国产一区二区| 777a∨成人精品桃花网| 成人av在线影院| 久久国产免费看| 日韩中文字幕亚洲一区二区va在线| 欧美日韩国产免费一区二区 | 26uuu国产电影一区二区| 美女爽到高潮91| 精品精品国产高清一毛片一天堂| 久久精品国产亚洲aⅴ| 欧美刺激脚交jootjob| 激情六月婷婷久久| 国产精品色一区二区三区| 97se亚洲国产综合在线| 亚洲亚洲精品在线观看| 欧美一区二区播放| 国产综合色视频| 中文字幕综合网| 欧美日韩国产精品自在自线| 青娱乐精品视频在线| 久久久九九九九| 99re热这里只有精品免费视频| 亚洲伊人色欲综合网| 日韩精品一区二区三区视频在线观看| 国产一区二区调教| 亚洲日本va在线观看| 欧美日韩不卡一区二区| 经典一区二区三区| 国产麻豆精品视频| 欧美日韩精品一区二区天天拍小说| 国产精品视频观看| 日本久久一区二区| 男人的天堂亚洲一区| 欧美激情一区二区三区全黄| 91福利资源站| 国产资源精品在线观看| 国产精品毛片a∨一区二区三区| 欧美自拍丝袜亚洲| 国产一本一道久久香蕉| 一区二区三区四区不卡在线| 日韩欧美亚洲国产另类| 99久久精品国产一区二区三区| 日产国产欧美视频一区精品| 国产精品久久久久精k8| 91精品国产综合久久久久久久| 高清成人免费视频| 日韩中文字幕91| 自拍偷自拍亚洲精品播放| 欧美成人性战久久| 在线观看网站黄不卡| 国产福利一区在线观看| 日本三级韩国三级欧美三级| 亚洲欧洲在线观看av| 亚洲精品一区二区在线观看| 欧美综合视频在线观看| 岛国精品在线观看| 麻豆久久一区二区| 亚洲香肠在线观看| 中文字幕一区二区三区不卡在线 | 欧美xxxxxxxx| 91成人免费电影| 丰满亚洲少妇av| 久久黄色级2电影| 亚洲1区2区3区4区| 亚洲色图在线看| 国产欧美一区二区精品性| 日韩视频国产视频| 欧美日韩中文一区| 91免费国产视频网站| 国产精品一区二区果冻传媒| 欧美aⅴ一区二区三区视频| 一区二区三区在线观看动漫| 中文字幕av一区二区三区高| 日韩精品一区二区三区视频在线观看| 欧美日韩精品一区二区| 色婷婷精品大在线视频| 99麻豆久久久国产精品免费| 国产伦精品一区二区三区在线观看| 午夜久久久久久| 亚洲午夜精品网| 亚洲精品日日夜夜| 亚洲卡通动漫在线| 亚洲欧美综合在线精品| 国产女主播在线一区二区| 精品奇米国产一区二区三区| 91精品午夜视频| 欧美精品一二三| 欧美乱妇20p| 欧美久久久久久蜜桃| 欧美日韩在线观看一区二区| 日本久久一区二区|