<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          ZipAmp中英文對(duì)照表

          作者: 時(shí)間:2011-07-23 來(lái)源:網(wǎng)絡(luò) 收藏

          ZipAmp中英文對(duì)照表

          /*********************************************
          ZipAmp

          Author : Nasif Akand
          Copyright : (C) Nasif Akand 2003
          Notice :
          Copyright 2003 Nasif Akand (nasif@yifan.net)
          http://go.to/zipamp
          http://zipamp.virtualave.net

          This file is part of ZipAmp MP3 software.

          ZipAmp 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 of the License or
          (at your option) any later version.

          ZipAmp 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 code; if not write to the Free Software
          Foundation Inc. 59 Temple Place Suite 330 Boston MA 02111-1307 USA
          這一個(gè)文件是 ZipAmp MP3 軟件的一部份。

          ZipAmp 是免費(fèi)的軟件;你能重新分配它及[或] 修正
          它在角馬公眾執(zhí)照的術(shù)語(yǔ)之下當(dāng)做出版被
          免費(fèi)的軟件基礎(chǔ); 或執(zhí)照的 2 版 或
          (在你的選項(xiàng))任何的較遲版本。

          ZipAmp 在希望中被分配它將會(huì)是有用的
          但是沒(méi)有任何的擔(dān)保; 沒(méi)有更甚至被暗示的擔(dān)保
          為一個(gè)特別的目的 MERCHANTABILITY 或健身。 那
          為較多的細(xì)節(jié)角馬公眾執(zhí)照。

          你應(yīng)該要接受角馬公眾執(zhí)照的副本
          連同這一個(gè)密碼一起; 如果不 寫(xiě)到免費(fèi)的軟件
          基礎(chǔ),公司, 59個(gè)寺廟地方,隨員 330 ,波士頓 文學(xué)碩士 02111-1307 美國(guó)

          Chip type : AT90S8515
          Clock frequency : 12.00000 MHz
          Memory model : Small
          Internal SRAM size : 512 bytes
          External SRAM size : 0 byte
          Data Stack size : 64 bytes

          這個(gè)是用來(lái)設(shè)置Codevision的,按照這個(gè)設(shè)置然后添加下面所提示的包含就可以編譯了。
          芯片類(lèi)型 : AT90S8515
          時(shí)鐘頻率 : 12.00000 MHz
          內(nèi)存模式 : 小的
          內(nèi)在的 SRAM 大小 : 512 bytes
          外部 SRAM 大小 : 0 byte
          數(shù)據(jù)堆棧大小 : 64 bytes

          Tested ATA Drive
          Samsung SpinPoint SV3064D 30 GB

          Test Drive Access Time:
          Track to Track : 0.8 m/s
          Average : 9.0m/s
          Full Stroke : 17 m/s

          Test Drive Playback:
          Full speed MP3 playback at 320KBps.

          測(cè)試時(shí)使用的是三星的 SV3064D 30 GB 硬盤(pán)

          測(cè)試硬盤(pán)的平均時(shí)間:
          軌跡到軌跡 : 0.8 m/s
          平均 : 9.0m/s
          完全的讀取 : 17 m/s

          測(cè)試硬盤(pán)重放:
          使用的是編碼率高達(dá)320KBps的mp3.
          *********************************************/

          #define DataReq PINB.2

          #include 90s8515.h> //8515 header file
          #include //Codevision spi
          #include "zfat.h"
          #include "zata.h"
          #include "ztype.h"
          #include "zcontrol.h"
          #include "zlcd.h"
          #include //Codevision delay
          #include "i2c.h"
          //下面是按照Datazyb所提示而添加進(jìn)的。添加這些包含后就能順利的編譯了。
          //編譯好了的程序能讀取我的富士通3g的硬盤(pán),但是出來(lái)的聲音不流暢,可能示由于硬盤(pán)太老的緣故吧。
          #include "zata.c"
          #include "zfat.c"
          #include "ztype.c"
          #include "zcontrol.c"
          #include "zlcd.c"
          #include "i2c.c"

          // External Interrupt 0 service routine
          // 外部中斷 0個(gè)服務(wù)常式
          //這里說(shuō)明一下,這里是按鈕輸入的反應(yīng)設(shè)置,也就是說(shuō)當(dāng)按鈕按下zipmap要干些什么就是在這里設(shè)置的。
          //情形(case)按照1,2,4,8...這樣排列是照按鍵接口ad0,ad1...來(lái)的,
          interrupt [EXT_INT0] void ext_int0_isr(void)
          {
          unsigned char in;
          #asm("cli");
          in=PINC; //Read the input buttons /讀輸入按鈕
          in=~in; //Invert them to see which one is high (thats the one pressed) /判斷它們是哪一個(gè)按下了。

          while ((!PIND.2)); //wait until interrupt key released /等候按紐松開(kāi)了才輸出

          switch (in) {

          //Case 1= STOP /情形 1= 停止
          case 1: //play=0 is pause play=1 is play play=2 is stop
          //播放=0 代表暫停 播放=1 代表播放 播放=2 代表停止

          play=2; //STOP /停止
          STAPlay(); //Stop player /停止播放器
          UnBusy(); //Remove HD Busy light /使硬盤(pán)指示燈長(zhǎng)亮
          currentCluster=firstCluster; //Remember file start cluster /記憶文件開(kāi)始群
          clusterBufferReadPos=clusterBufferWritePos; //Clear cluster buffer /清除群緩沖

          filePos=0; //Set filestart pos at beginning
          sectorPos=0;
          mp3Pos=0;
          break;

          //Case 2= Play or Pause /情形 2= 播放或暫停
          case 2: play=(~play) 1; //Invert play. If play then pause if pause then play
          //反轉(zhuǎn)播放.如果是播放就暫停,如果暫停就播放
          STAPlay(); //Load command /讀取命令
          break;

          //Case 4=
          case 4:
          if (currentFileNum=1) currentFileNum=totalFiles-1;
          else currentFileNum=currentFileNum-2;
          dirReadOffset.fileNum=0; //To reread dir from start.

          break;

          case 8: currentFileNum+=advance; //FF
          if (currentFileNum>totalFiles) {
          currentFileNum=1;
          dirReadOffset.fileNum=0;
          }
          break;

          case 16: filePos=FileSize; //NEXT
          break;

          case 32: //聲音模式設(shè)置
          soundMode = (soundMode+1) soundModeMask;
          SetBassTreble();
          break;

          case 64: playMode = (playMode+1) playModeMask; //播放模式設(shè)定
          break;
          };

          intFlag=1; //Set interrupt occured flag /設(shè)置中斷發(fā)生情況
          }

          /*
          // External Interrupt 1 service routine / 外部中斷 1個(gè)服務(wù)常式
          interrupt [EXT_INT1] void ext_int1_isr(void)
          {
          // Place your code here
          // 把你的代碼放到這里,實(shí)際上在zipamp里這里可以不用理會(huì),因?yàn)樗闹袛?口根本就沒(méi)有接?xùn)|西上去
          //不過(guò)你如果想添加遙控的話(huà),把代碼放到這里是再合適不過(guò)的了。
          printf("Entered Interrupt 2");
          } */


          // Declare your global variables here
          //全局變量在這里

          void main(void)
          {
          // Declare your local variables here
          byte temp; dword extension;

          //這些設(shè)置要結(jié)合硬件電路圖才能看得明白。
          // Input/Output Ports initialization /設(shè)定輸入輸出口初始值。
          // Port A /PA口
          DDRA=0x00; //Start as Input port /開(kāi)始為輸入口
          PORTA=0x00; //Set to High-Z state /設(shè)定為高阻狀態(tài)

          // Port B /PA口
          DDRB=0xBB;
          PORTB=0x0B; //Enable Reset for STA013 Disable ATA IOR and IOW. /允許重啟STA013 禁止ATA IOR與IOW.

          // Port C /PA口
          DDRC=0xFF; //Output port /輸出口
          PORTC=0x00; //Set 0 /設(shè)定 0

          // Port D /PA口
          DDRD=0xF2;
          PORTD=0x20; //Disable Latch and Buffer. Never pull PORTD.1 high that will cause damage to STA013
          //使門(mén)電路和緩沖器失去能力。千萬(wàn)別拉高“PORTD.1”(這里注釋可能有誤,應(yīng)該為PORTD.0)那樣做會(huì)損壞到STA013

          //這些設(shè)置要結(jié)合90s8515的說(shuō)明書(shū)才會(huì)明白
          // Timer/Counter 0 initialization / 定時(shí)/計(jì)數(shù)器0初始值設(shè)定
          // Clock source: System Clock / 時(shí)鐘來(lái)源: 系統(tǒng)時(shí)鐘
          // Clock value: Timer 0 Stopped / 時(shí)鐘值: 時(shí)鐘0停止
          // Mode: Output Compare / 模式: 輸出比較
          // OC0 output: Disconnected / OC0 輸出: 分離
          TCCR0=0x00;
          TCNT0=0x00;

          // Timer/Counter 1 initialization / 定時(shí)/計(jì)數(shù)器1初始值設(shè)定
          // Clock source: System Clock / 時(shí)鐘來(lái)源: 系統(tǒng)時(shí)鐘
          // Clock value: 14318.180 kHz / 時(shí)鐘值: 14318.180 kHz
          // Mode: Output Compare / 模式: 輸出比較
          // OC1A output: Discon. / OC1A 輸出: 不精讀.
          // OC1B output: Discon. / OC1B 輸出: 不精讀.
          // Noise Canceler: Off / 噪音取消: 關(guān)
          // Input Capture on Falling Edge / 輸入取下下降沿
          TCCR1A=0x00;
          TCCR1B=0x01;
          TCNT1H=0x00;
          TCNT1L=0x00;
          OCR1AH=0x00;
          OCR1AL=0x00;
          OCR1BH=0x00;
          OCR1BL=0x00;

          // External Interrupt(s) initialization /設(shè)定外部(s)初始值
          // INT0: On /INT0: 開(kāi)
          // INT0 Mode: Low level /INT0 模式: 低電平有效
          // INT1: On /INT1: 開(kāi)
          // INT1 Mode: Low level /INT1 模式: 低電平有效
          GIMSK=0x40;
          MCUCR=0x00;
          GIFR=0x40;


          // Timer(s)/Counter(s) Interrupt(s) initialization /設(shè)定定時(shí)(s)/計(jì)數(shù)器(s)中斷(s)初始值
          TIMSK=0x00;

          // UART initialization /串口初始值設(shè)定
          // Communication Parameters: 8 Data 1 Stop No Parity /溝通叁數(shù): 8 數(shù)據(jù) 1 沒(méi)有同等
          // UART Receiver: Off /串口接收器(rx):開(kāi)
          // UART Transmitter: On /串口發(fā)射器(tx):關(guān)


          // UART Baud rate: 19200 at 14.3181 /串口通訊波特率: 19200到14.3181之間
          UCR=0x08;
          UBRR=0x2E;


          // Analog Comparator initialization
          // Analog Comparator: Off
          // Analog Comparator Input Capture by Timer/Counter 1: Off
          ACSR=0x80;

          // SPI initialization
          // SPI Type: Master
          // SPI Clock Rate: 2460.000 kHz
          // SPI Clock Phase: Cycle Half
          // SPI Clock Polarity: Low
          // SPI Data Order: MSB First
          // SPI 初始值設(shè)定
          // SPI 類(lèi)型: Master
          // SPI 時(shí)鐘頻率: 2460.000 kHz
          // SPI 時(shí)鐘周期: 一半
          // SPI 時(shí)鐘極性: 低
          // SPI 數(shù)據(jù)次序: MSB第一
          SPCR=0x50;

          #asm("cli");

          //好了,設(shè)置好8515各個(gè)端口的初始之后,我們要開(kāi)始干正事了,先初始化lcd屏,然后延時(shí)3000ms,這是為了在
          //屏上顯示logo
          InitLCD();
          delay_ms(3000);
          //DDRC=0x00;
          //PORTC=0x00;

          //接下來(lái)就初始話(huà)ata與fta
          ATA_Init();
          InitFAT();

          currentFileNum=0;
          temp=0;

          //Find two required files in root dir ZIPAMP.SYS and ZIPAMP.CFG and save their LBA address
          //查找兩個(gè)必須的文件ZIPAMP.SYS和ZIPAMP.CFG并保存它們的LBA地址
          while ((temp2)(getDirEntry(0)==1)) {
          extension = (*(dword *)fileExtension) 0x00FFFFFF;
          //low-case z "logic AND" up-case Z =will equal up-case Z. Thus following checks for both 'z' and 'Z'
          //通過(guò)邏輯或來(lái)檢測(cè)zipamp文件的存在
          if ((fileName[0] 0x5A)==0x5A) { //if the name starts with Z then see if it is SYS or CFG file
          //如果有文件名字為zipamp那么檢查它是否為SYS或CFG文件
          if (extension==0x00535953) { dirStackLBA=clust2LBA(currentCluster); temp++; } //ZIPAMP.SYS Stack file address
          // 如果是ZIPAMP.SYS文件則保存文件地址
          if (extension==0x00474643) { cfgFileLBA=clust2LBA(currentCluster); temp++; } //ZIPAMP.CFG Config file address
          // 如果是ZIPAMP.CFG文件則保存文件地址,這里不知是否有錯(cuò),cfg文件名轉(zhuǎn)換成bin碼應(yīng)該為0x00434647
          }
          }

          if (temp2) Halt(4); //Missing SYS or CFG file. /如果找不到SYS或CFG文件則停止并顯示錯(cuò)誤.

          STA013Setup(); //Setup STA013 decoder. /裝載STA013解碼器.

          currentFileNum=0;
          if (loadConfig()!=1) {//goto LOADED; /轉(zhuǎn)到裝載;
          while (getDirEntry(1)==1) { //count # of MP3 files. /計(jì)數(shù)MP3文件.
          totalFiles++;
          gotoxy(3 0
          writeNumber(totalFiles); //這里要用到數(shù)字輸出,因?yàn)榻y(tǒng)計(jì)出來(lái)的數(shù)字是16進(jìn)制的,所以需要通過(guò)數(shù)字輸出
          //將其轉(zhuǎn)換成10進(jìn)制的顯示在屏幕上面。
          }
          }

          //gotoxy(3 0
          writestring(" Wait.."); //顯示等待種,如果是中文屏的話(huà),這里可以輸入中文字

          dirReadOffset.fileNum=0;
          SetSoundCg(); //Load Sound Mode character bars into LCD CGRAM. /載如聲音模式特性圖形到LCD CGRAM.
          play=1; //ZipAmp will start playing after boot finish. /ZipAmp會(huì)在啟動(dòng)完畢后開(kāi)始播放.
          SetBassTreble(); //Setup Bass Treble registers in STA013. /裝備低音使 STA013 的寄存器增為三倍
          SongSelect();
          while (1) { //Main loop /主體循環(huán)

          key=1;
          if (key==0) key=1;
          PORTC=~key;
          DDRC=key;
          #asm("sei");

          //下面這段還不是太清楚,暫時(shí)不進(jìn)行翻譯。
          //Following "if" is True when INTR in NEXT FF PREV occurs. filePos and FileSize is set equal there.
          //In first iteration filePos will be greater than FileSize because STA013.BIN has been read to the finish
          //thus this becomes true.
          if (filePos>=FileSize) SongSelect(); //Song is selected when playing finished or NEXT/PREV button pressed
          ///當(dāng)歌曲在播放的時(shí)候被按下了NEXT或PREV按紐時(shí)
          if (intFlag) { //Interrupt occured and LCD display wasn't fixed fix it.
          intFlag=0;
          printInfo();
          }

          while ((DataReq)(filePos if (mp3Pos==0) read();
          spi(sectorBuffer.data[mp3Pos++]);
          spi(sectorBuffer.data[mp3Pos++]);
          }

          //If finished reading one cluster and head hasn't been moved
          if ((sectorPos==Sectors_Per_Cluster) (headMoved==0)) {

          //if we have buffered next cluster then move head
          if (readClusterBuffer()==1) ATA_Move_Head(clust2LBA(currentCluster));


          else { //we didn't buffer it so find next cluster and move head
          currentCluster=findNextCluster();
          ATA_Move_Head(clust2LBA(currentCluster)); //Move head to read position
          }
          //Reset all parameters /重新安排全部數(shù)
          sectorPos=0;
          readPos=0;
          headMoved=1;
          }

          //if we have already moved head then we can buffer next clusters
          else if ((readPos|DataReq)==0) {
          //check if datareq is set if set then get out of buffering
          temp=sectorPos;
          if (writeClusterBuffer()==1) { //if buffering was successful then move head to original location.
          sectorPos=temp;
          ATA_Move_Head(clust2LBA(currentCluster)+sectorPos); //move head to the current reading cluster.
          headMoved=1;
          readPos=0;
          }
          }

          } // end of main loop /主體循環(huán)結(jié)束


          } //END. /結(jié)束.

          i2c.c
          /*
          Copyright 2003 Nasif Akand (nasif@yifan.net)
          http://go.to/zipamp
          http://zipamp.virtualave.net

          This file is part of ZipAmp MP3 software.

          ZipAmp 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 of the License or
          (at your option) any later version.

          ZipAmp 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 code; if not write to the Free Software
          Foundation Inc. 59 Temple Place Suite 330 Boston MA 02111-1307 USA
          這一個(gè)文件是 ZipAmp MP3 軟件的一部份。

          ZipAmp 是免費(fèi)的軟件;你能重新分配它及[或] 修正
          它在角馬公眾執(zhí)照的術(shù)語(yǔ)之下當(dāng)做出版被
          免費(fèi)的軟件基礎(chǔ); 或執(zhí)照的 2 版 或
          (在你的選項(xiàng))任何的較遲版本。

          ZipAmp 在希望中被分配它將會(huì)是有用的
          但是沒(méi)有任何的擔(dān)保; 沒(méi)有更甚至被暗示的擔(dān)保
          為一個(gè)特別的目的 MERCHANTABILITY 或健身。 那
          為較多的細(xì)節(jié)角馬公眾執(zhí)照。

          你應(yīng)該要接受角馬公眾執(zhí)照的副本
          連同這一個(gè)密碼一起; 如果不 寫(xiě)到免費(fèi)的軟件
          基礎(chǔ),公司, 59個(gè)寺廟地方,隨員 330 ,波士頓 文學(xué)碩士 02111-1307 美國(guó)

          */

          //This module performs I2C operations for ZipAmp /這是zipamp的i2c程序組件
          //Nasif Akand

          //If using CodeVision then following includes aren't needed. /如果使用 CodeVision 不需要包括下列各項(xiàng)
          //#include "zcontrol.h"
          //#include "zfat.h"
          //#include "zata.h"
          //#include "ztype.h"
          #include "i2c.h"
          //#include "" //CodeVision AVR internal delay routines /CodeVision AVR 內(nèi)在的延遲常式

          //I2C implementation for STA013 通過(guò)i2c控制sta013

          //Port D bit 7 (pin 17) is SDA output while bit 0 (pin 10) is input Pin 16 is SCL
          //SDA input is always at HighZ state. If this pin is pulled up or output high STA013 will be damaged.
          //這里是定意的i2c sda數(shù)據(jù)的輸入輸出口,輸出為17腳,輸入為10腳,時(shí)鐘信號(hào)scl為16腳。

          #define SDA PORTD.7
          #define SCL PORTD.6
          #define SDAIn PIND.0
          #define Out DDRD.7=1
          #define In DDRD.7=0

          #define qDelay delay_us(3) //According to Phillips I2C specs in all modes.. /這里是按照菲利普i2c總線模式寫(xiě)的
          #define delay delay_us(3) //..max I2C delay can be 5 micro seconds. /最大 I2C 延遲可能是 5個(gè)微秒。
          #define Read 0x87 //STA013 I2C Read address /STA013 I2C 讀取地址
          #define Write 0x86 //STA013 I2C Write Address /STA013 I2C 寫(xiě)入地址

          //下面這段函數(shù)是復(fù)位sta013
          void STA013Reset() {
          DDRB.3=1; //Set bit3 to Output mode /設(shè)置pb3為輸出狀態(tài)
          PORTB.3=0; //Set to 0 for reset /這里可以參看原理圖就明白。pb3是連在sta013的26腳/reset上的.
          delay_ms(500); //Wait
          PORTB.3=1; //Set to 1
          delay_ms(500); //Wait
          }


          //下面這段數(shù)據(jù)類(lèi)型聲明是用來(lái)測(cè)試i2c是否有正確應(yīng)答,如果有就輸出0則表示成功
          unsigned char wait_Ack (void) {
          //returns 1 if ACK was 0 (meaning transfer was successful). In I2C ACK=0 means success.

          unsigned char t=1;
          delay;

          // Take clock high
          SCL=1;
          delay;

          // Test of ACK
          delay;
          if (PIND.0) { /*test of SDA level if high -> problem*/
          t=0;
          }

          delay;
          if (PIND.0) { /*test of SDA level if high -> problem*/
          t=0;
          }

          // Take clock back low
          delay;
          SCL=0;
          delay;

          return t;
          }



          //數(shù)據(jù)聲明,聲明i2c的閱讀地址 adr為地址的縮寫(xiě)
          unsigned char i2cReadAddress(unsigned char adr) {
          //Returns data read from register given in adr./從寄存器中讀取數(shù)據(jù)后返回
          //In most cases we don't have to worry about it. If we don't get ACK try 10 times before giving up.
          //在大部分的情況下,我們不需要為它擔(dān)憂(yōu),在拿不到正確的應(yīng)答之前要嘗試十次。
          unsigned char data try=0 ack;
          do {
          i2cStart(); //I2c start /i2c開(kāi)始
          ack=i2cSend(Write); //Send i2c write address /發(fā)送i2c寫(xiě)入地址
          ack =i2cSend(adr); //Send register address /發(fā)送記錄地址
          i2cStart(); //i2c re-start
          delay; //wait
          ack = i2cSend(Read); //Send i2c read address
          data=i2cReceive(0); //Receive data without sending ACK
          i2cStop(); //Stop
          try++;
          }
          while ((ack==0)(try10)); //try 10 times if failed /嘗試10次后返回

          return data;
          }

          //數(shù)據(jù)聲明,聲明i2c的寫(xiě)入地址。這段和上面一段類(lèi)似只不過(guò)由讀變成了寫(xiě)
          unsigned char i2cWriteAddress(unsigned char adr unsigned char data) {
          // Writes data to register adr.
          //Returns 1 on successful write tries 10 times before giving up.

          unsigned char ack try=0;
          do {
          i2cStart(); //Start
          ack = i2cSend(Write); //Send i2c write address
          ack = i2cSend(adr); //Send register address
          delay; //wait
          ack = i2cSend(data); //Send data
          i2cStop(); //Stop
          try++;
          }
          while ((ack==0)(try10)); //give up after 10 tries
          return ack;
          }

          //這段函數(shù)是初始化i2c
          void i2cInit() {
          DDRD.7=1; //Set to output mode for SDA
          DDRD.6=1; //Set to output mode for SCL
          }

          //下面這段函數(shù)是i2c開(kāi)始的必要條件
          void i2cStart() {
          //I2C start condition.

          DDRD.7=1; //SDA output mode
          SDA=1;
          delay;
          SCL=1;
          delay;
          SDA=0;
          delay;
          SCL=0;
          }

          //數(shù)據(jù)聲明,發(fā)送i2c數(shù)據(jù)到sta013后返回,成功為1,失敗為0,這里發(fā)送的字節(jié)不大,一次為8個(gè)2進(jìn)制數(shù)據(jù),也就是1bit
          unsigned char i2cSend(unsigned char value){
          //Sends byte value and returs ACK from STA013 1=Success 0=Fail

          unsigned char i;
          DDRD.7=1;
          for (i=0; i8; i++) {
          DDRD.7=1;
          if (((value >> (7-i)) 0x01)==0x01) SDA=1; //Send bit by bit
          else SDA=0;
          SCL=1;
          delay;
          SCL=0;
          DDRD.7=1;
          SDA=1;
          delay;
          }
          delay;
          i=wait_Ack();
          return i;
          }


          //數(shù)據(jù)聲明,和上面的聲明類(lèi)似,不過(guò)變成了接收。
          unsigned char i2cReceive(unsigned char ack) {
          //Receives data byte. Sends back acknoledge if ack is true

          unsigned char value=0 i;
          DDRD.7=1;
          SDA=1;
          for (i=0; i8; i++) {
          delay;
          SCL=1;
          delay;
          value = (value 1) + PIND.0; //leftshift previous value and add one more bit that's read
          delay;
          SCL=0;
          }
          if (ack) { //send ack if requested
          DDRD.7=1;
          SDA=0;
          delay;
          SCL=1;
          delay;
          SCL=0;
          }
          return value;
          }

          //此函數(shù)是i2c停止的條件
          void i2cStop(){
          //I2C stop condition.

          delay;
          DDRD.7=1; //SDA output mode
          SDA=0;
          delay;
          SCL=1;
          delay;
          SDA=1;
          delay;
          }

          i2c.h
          /*
          Copyright 2003 Nasif Akand (nasif@yifan.net)
          http://go.to/zipamp
          http://zipamp.virtualave.net

          This file is part of ZipAmp MP3 software.

          ZipAmp 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 of the License or
          (at your option) any later version.

          ZipAmp 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 code; if not write to the Free Software
          Foundation Inc. 59 Temple Place Suite 330 Boston MA 02111-1307 USA
          這一個(gè)文件是 ZipAmp MP3 軟件的一部份。

          ZipAmp 是免費(fèi)的軟件;你能重新分配它及[或] 修正
          它在角馬公眾執(zhí)照的術(shù)語(yǔ)之下當(dāng)做出版被
          免費(fèi)的軟件基礎(chǔ); 或執(zhí)照的 2 版 或
          (在你的選項(xiàng))任何的較遲版本。

          ZipAmp 在希望中被分配它將會(huì)是有用的
          但是沒(méi)有任何的擔(dān)保; 沒(méi)有更甚至被暗示的擔(dān)保
          為一個(gè)特別的目的 MERCHANTABILITY 或健身。 那
          為較多的細(xì)節(jié)角馬公眾執(zhí)照。

          你應(yīng)該要接受角馬公眾執(zhí)照的副本
          連同這一個(gè)密碼一起; 如果不 寫(xiě)到免費(fèi)的軟件
          基礎(chǔ),公司, 59個(gè)寺廟地方,隨員 330 ,波士頓 文學(xué)碩士 02111-1307 美國(guó)
          */

          //This module performs I2C operations for ZipAmp /這是zipamp的i2c程序組件
          //Nasif Akand

          //I2C implementation for STA013 /用i2c來(lái)操控sta013

          #ifndef __I2C_H__
          #define __I2C_H__

          unsigned char wait_Ack (void);
          unsigned char i2cReadAddress(unsigned char adr);
          unsigned char i2cWriteAddress(unsigned char adr unsigned char data);
          void i2cInit();
          void i2cStart();
          unsigned char i2cSend(unsigned char value);
          unsigned char i2cReceive(unsigned char ack);
          void i2cStop();
          void STA013Reset();

          #endif

          塵埃粒子計(jì)數(shù)器相關(guān)文章:塵埃粒子計(jì)數(shù)器原理


          評(píng)論


          相關(guān)推薦

          技術(shù)專(zhuān)區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();