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

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

?? at24c256.c

?? 8051 c code for AT24c256
?? C
字號:
/*-------------------------------------------------------------------------
  AT24C256 I2C Serial Memory

   Written By - Dipl.-Ing. (FH) Michael Schmitt
    michael.schmitt@t-online.de

    Initial Version Mai 2000

   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
   Free Software Foundation; either version 2, or (at your option) any
   later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

   In other words, you are welcome to use, share and improve this program.
   You are forbidden to forbid anyone else to use, share and improve
   what you give them.   Help stamp out software-hoarding!
-------------------------------------------------------------------------*/
#ifndef __FILE_AT24C256_C
#define __FILE_AT24C256_C

// Read one or a couple of bytes (maybe all) from the target.
// this is done using the burst mode (or page read mode)
// this is the fastest way to receive more than one byte
// after a byte is received, we send an ACK to the target, to make clear that we
// want another byte from it. The slower way would be to send a stop command
// and restart the byte read mode with a new adress. But this would mean
// at least 21 clock pulses more before the next byte can be received. So every additional
// byte needs only 1/3 of clock pulses to be received.
// ensured: WD is triggered at paragaph bounderies (16 bytes) MK
//
// AT24C256 ONLY !!
unsigned char I2CReadBurst24C256( unsigned char deviceAdr, unsigned int startAdr, unsigned int length, unsigned char xdata *destination)
{
//    unsigned char i;
//    unsigned char res;
    unsigned int  xdata endAdr;

    endAdr = startAdr + length;
    WatchDog();

    /* Start I2C */
    I2CSendStart();

    /* Send Device Adr. + Page + WriteCMD */
    I2CSendByte( 0xA0 | deviceAdr ); // Send Device Adress 1010 A2/P2 A1/P1 A0/P0 R/W=0(Write Word Adress)
    if( !I2CCheckACK() ) goto NO_ACK;
    I2CSendByte( (startAdr >> 8) & 0x00FF ); // HighByte Adress
    /* Did Device send an ACK ? */
    if( !I2CCheckACK() ) goto NO_ACK;

    I2CSendByte( startAdr & 0x00FF );       // LowByte Adress
    /* Did Device send an ACK ? */
    if( !I2CCheckACK() ) goto NO_ACK;

    I2CSendStop();
    /* OK, send Start again */
    I2CSendStart();
    /* Send Device Adr. + Page + ReadCMD */
    I2CSendByte( 0xA1 | deviceAdr ); // Send Device Adress 1010 A2/P2 A1/P1 A0/P0 R/W=1(Read from Word Adress)

    /* Did Device send an ACK ? */
    if( !I2CCheckACK() ) goto NO_ACK;

    /* Yes, now start read in Bytes, until finished */
    while( startAdr < endAdr )
    {

//      res = I2CGetByte();

        *destination++=I2CGetByte();        // writing to destination and incrementing
        startAdr++;                         // incrementing addresscounter for device

/*        if (startAdr <= endAdr) FE */
        if (startAdr < endAdr)
        {
            /* Send ACK, because we want more Bytes */
            I2CSendACK();
//            I2CSDA = 0;
        }
        else
        {
            /* Send NACK, we have all Bytes */
            I2CSendNACK();
//            I2CSDA = 1;
        }
//        NOP; /* Now follows the 1/0 clock transition for NACK or ACK */
//        I2CSCL = 1;
//        NOP;
//        I2CSCL = 0;

        /* Retrigger Watchdog every 256 Bytes - this is rarely called */
        if ( (startAdr & 0xFF) == 0 )
           WatchDog();
    }

    /* OK, if finished or not, send STOP to tell Device, that burst read mode is finished */
    I2CSendStop();

    return TRUE;                        // success exit

NO_ACK:
#ifdef EXT_ERRHAN
    // cleanup lost clock
    I2CClkSyncByte();
#endif
    /* OK, if finished or not, make shure i2c is stopped */
    I2CSendStop();

    return FALSE;                       // failure exit
}

// although this function has been called writeburst, we do not write all bytes in the
// way, they were read in in function readburst. Because most of the I2C serial EEProms
// need about 10msec write time for each byte. (ATMEL can receive 4 bytes at once and
// write them at once but 4 x 10msec). So, to be on the safe way, i choose to write the
// old way. STARTCMD DEVCODE ADRESS BYTE ACK STOP
// This is not really a burst mode, i know

// AT24C256 ONLY !!
unsigned char I2CWriteBurst24C256( unsigned char deviceAdr, unsigned int startAdr, unsigned int length, unsigned char xdata *source)
{
    unsigned int  xdata endAdr;
    unsigned char AckLoopCount;
    unsigned char TempAck;

    /* Check here if Chip is currently writing a byte and busy. */
    /* This should be done with single byte write's and the ACK-Polling mechanism */
    endAdr = startAdr + length;
    WatchDog();

    for( ; startAdr < endAdr; startAdr++ )
    {

    /* Start I2C */
    I2CSendStart();

    /* Send Device Adr. + Page + WriteCMD */
    I2CSendByte( 0xA0 | deviceAdr ); // Send Device Adress 1010 A2/P2 A1/P1 A0/P0 R/W=0(Write Word Adress)

    /* Did Device send an ACK ? */
    if( !I2CCheckACK() ) goto NO_ACK;
//    {
//      return FALSE;
//  }

         /* Yes, send StartAdr */
        I2CSendByte( ((startAdr >> 8) & 0x00FF) );      // HighByte Adress
        /* Did Device send an ACK ? */
        if( !I2CCheckACK() ) goto NO_ACK;

        I2CSendByte( startAdr & 0x00FF );               // LowByte Adress
        /* Did Device send an ACK ? */
        if( !I2CCheckACK() ) goto NO_ACK;

        I2CSendByte(*source);
        /* Did Device send an ACK ? */
        if( !I2CCheckACK() ) goto NO_ACK;
        /* YES, this Byte is stored, now we have to wait 10msec */
        source++;

        /* OK, if finished or not, send STOP to tell Device, that burst write mode is finished */
        I2CSendStop();

        /* now wait until device acknowledges again */
        AckLoopCount = 0;
        do{
           /* Start I2C */
           I2CSendStart();
           /* Send Device Adr. + Page + WriteCMD */
           I2CSendByte( 0xA0 | deviceAdr); // Send Device Adress 1010 A2/P2 A1/P1 A0/P0 R/W=0(Write Word Adress)
           /* Did Device send an ACK ? */
           AckLoopCount++;
           TempAck = I2CCheckACK();
           /* Stoppe I2C */
           I2CSendStop();
          }
        while ( !TempAck && (128 >= AckLoopCount) );    // AckLoopCount is unsigned char!! (Loop takes 80us @ 24MHz)
                                                        // so 128 gives the 10ms which are the maximum
                                                        // of the datasheet (even for VCC=2.7 devices)
//        if (!TempAck) return FALSE;                     // Only OK if exit on Ack
        if (!TempAck) goto NO_ACK;                      // Only OK if exit on Ack

        /* calm Watchdog every now and then */
        if ( (startAdr & 0x07) == 0 )   // Retrigger Watchdog every xx Bytes
            WatchDog();
       }

//    I2CSendStop();

    return TRUE;                        // success exit

NO_ACK:
#ifdef EXT_ERRHAN
    // cleanup lost clock
    I2CClkSyncByte();
#endif

    I2CSendNACK();
    /* OK, if finished or not, make shure i2c is stopped */
    I2CSendStop();

    return FALSE;                       // failure exit
}

#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产一区二区三区免费在线观看| 精品国产凹凸成av人网站| 激情深爱一区二区| 蜜桃一区二区三区在线| 青青草原综合久久大伊人精品优势| 午夜免费久久看| 日韩精品一二三区| 久久精品国产亚洲5555| 蜜臀91精品一区二区三区| 国内外精品视频| 成人免费高清视频在线观看| 91丨九色丨蝌蚪丨老版| 色欧美88888久久久久久影院| 91日韩在线专区| 在线视频一区二区三区| 欧美猛男男办公室激情| 欧美videossexotv100| www国产成人免费观看视频 深夜成人网| 日韩视频一区二区三区在线播放 | 粉嫩欧美一区二区三区高清影视| 国产精品系列在线播放| 91小视频在线免费看| 欧美艳星brazzers| 欧美一区二区精美| 国产精品每日更新在线播放网址| 亚洲理论在线观看| 免播放器亚洲一区| 国产成人免费在线视频| 91亚洲精品乱码久久久久久蜜桃| 91精品欧美福利在线观看| 国产日韩视频一区二区三区| 亚洲图片激情小说| 理论电影国产精品| 色先锋久久av资源部| 欧美一级在线观看| 国产精品久久夜| 日韩电影在线观看电影| 99精品国产99久久久久久白柏| 制服丝袜亚洲色图| 中文字幕一区二区三区四区不卡 | 国产精品自拍三区| 欧美伦理视频网站| 国产喷白浆一区二区三区| 一区二区三区不卡视频在线观看| 极品美女销魂一区二区三区| 91老师国产黑色丝袜在线| 日韩视频永久免费| 亚洲一二三四在线观看| 成人av电影在线网| 久久午夜羞羞影院免费观看| 亚洲成a人片在线观看中文| 成人看片黄a免费看在线| 欧美成人精精品一区二区频| 亚洲国产精品久久艾草纯爱| av一二三不卡影片| 久久久久久久久蜜桃| 看电视剧不卡顿的网站| 欧美日韩国产123区| 亚洲色图在线播放| 国产成人av网站| 337p日本欧洲亚洲大胆精品 | 蜜桃av一区二区在线观看| 91国产免费看| 亚洲精选视频免费看| 成人国产一区二区三区精品| 国产欧美在线观看一区| 国产综合色产在线精品| 精品国产一二三| 麻豆高清免费国产一区| 欧美高清精品3d| 视频一区中文字幕国产| 欧美色图第一页| 亚洲午夜久久久久久久久电影网 | 日韩一区二区在线观看视频| 婷婷久久综合九色综合绿巨人 | 丰满岳乱妇一区二区三区| 久久久久久久综合色一本| 国模一区二区三区白浆| 久久色.com| 成人黄色在线视频| 亚洲男帅同性gay1069| 91浏览器在线视频| 亚洲欧美日韩系列| 欧美日韩一区三区| 麻豆精品蜜桃视频网站| 久久综合色婷婷| 国产98色在线|日韩| 国产精品传媒在线| 91国偷自产一区二区三区观看| 一区二区三区国产豹纹内裤在线| 欧美日韩成人一区二区| 蜜桃av一区二区| 国产亚洲欧美在线| 色综合天天综合给合国产| 伊人一区二区三区| 日韩欧美中文字幕一区| 国产一区999| 亚洲精品免费在线| 欧美一级精品大片| 成人自拍视频在线| 亚洲一区二区三区四区在线观看 | 午夜视频久久久久久| 日韩欧美精品在线| 成人aaaa免费全部观看| 亚洲一级二级在线| 久久综合99re88久久爱| av亚洲精华国产精华| 蜜桃一区二区三区四区| 亚洲同性gay激情无套| 7777精品伊人久久久大香线蕉经典版下载 | 精品国产乱码久久久久久图片 | 欧美色偷偷大香| 国产精品1024久久| 污片在线观看一区二区| 欧美国产97人人爽人人喊| 日本道在线观看一区二区| 看电影不卡的网站| 一区二区三区精品视频| 久久精品视频在线看| 欧美亚洲日本一区| www.亚洲人| 久久精品国产精品青草| 一区二区激情小说| 亚洲国产精品精华液ab| 欧美一级片免费看| 欧美在线观看一区| 懂色一区二区三区免费观看| 麻豆国产精品一区二区三区 | 日韩精品一区二区三区在线播放 | 精品sm捆绑视频| 91福利在线播放| proumb性欧美在线观看| 国内精品视频一区二区三区八戒| 亚洲第一av色| 亚洲综合成人在线视频| 国产精品盗摄一区二区三区| 久久九九久精品国产免费直播| 欧美一区二区三区的| 欧美理论片在线| 色综合久久88色综合天天 | 日韩精品一级中文字幕精品视频免费观看 | 日韩综合小视频| 一区二区三区四区激情| 国产精品美女久久久久aⅴ | 国产一区二区三区综合| 久久精品国产99国产| 日本中文一区二区三区| 亚洲动漫第一页| 亚洲不卡一区二区三区| 亚洲国产另类av| 午夜一区二区三区视频| 亚洲国产精品综合小说图片区| 亚洲激情欧美激情| 亚洲五月六月丁香激情| 手机精品视频在线观看| 日产国产欧美视频一区精品| 水野朝阳av一区二区三区| 亚洲高清视频中文字幕| 婷婷开心激情综合| 蜜桃av一区二区在线观看| 激情文学综合网| 国产成人亚洲综合a∨猫咪| 风间由美性色一区二区三区| 成人av在线网站| 日本高清不卡在线观看| 欧美绝品在线观看成人午夜影视| 欧美日本国产视频| 精品福利在线导航| 欧美国产丝袜视频| 一区二区成人在线| 男女性色大片免费观看一区二区| 国产综合色精品一区二区三区| 国产成人啪午夜精品网站男同| 91麻豆产精品久久久久久| 欧美色网一区二区| 精品卡一卡二卡三卡四在线| 国产欧美日韩精品一区| 一区二区三区美女| 激情av综合网| 99国产精品一区| 欧美一区二区三区在线电影| 国产欧美日韩另类视频免费观看| 亚洲私人黄色宅男| 裸体健美xxxx欧美裸体表演| 国产不卡视频在线观看| 欧美日韩精品三区| 国产精品―色哟哟| 日韩黄色免费电影| gogo大胆日本视频一区| 欧美日韩成人在线一区| 国产精品久久久久久久久免费樱桃| 日本女人一区二区三区| 99久久精品99国产精品| 日韩一级在线观看| 亚洲图片激情小说| 国产成人亚洲综合色影视| 欧美日韩不卡在线| 一区免费观看视频| 久国产精品韩国三级视频| 在线欧美日韩国产|