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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? usbjtag.c

?? FPGA、CPLD芯片的usb數(shù)據(jù)下載線(xiàn)
?? C
字號(hào):
/*----------------------------------------------------------------------------- * Code that turns a Cypress FX2 USB Controller into an USB JTAG adapter *----------------------------------------------------------------------------- * Copyright (C) 2005..2007 Kolja Waschk, ixo.de *----------------------------------------------------------------------------- * Check hardware.h/.c if it matches your hardware configuration (e.g. pinout). * Changes regarding USB identification should be made in product.inc! *----------------------------------------------------------------------------- * This code is part of usbjtag. usbjtag 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. usbjtag 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 in the file * COPYING; if not, write to the Free Software Foundation, Inc., 51 Franklin * St, Fifth Floor, Boston, MA  02110-1301  USA *----------------------------------------------------------------------------- */#include "isr.h"#include "timer.h"#include "delay.h"#include "fx2regs.h"#include "fx2utils.h"#include "usb_common.h"#include "usb_descriptors.h"#include "usb_requests.h"#include "syncdelay.h"#include "eeprom.h"#include "hardware.h"//-----------------------------------------------------------------------------// Define USE_MOD256_OUTBUFFER:// Saves about 256 bytes in code size, improves speed a little.// A further optimization could be not to use an extra output buffer at // all, but to write directly into EP1INBUF. Not implemented yet. When // downloading large amounts of data _to_ the target, there is no output// and thus the output buffer isn't used at all and doesn't slow down things.#define USE_MOD256_OUTBUFFER 1//-----------------------------------------------------------------------------// Global datatypedef bit BOOL;#define FALSE 0#define TRUE  1static BOOL Running;static BOOL WriteOnly;static BYTE ClockBytes;static WORD Pending;#ifdef USE_MOD256_OUTBUFFER  static BYTE FirstDataInOutBuffer;  static BYTE FirstFreeInOutBuffer;#else  static WORD FirstDataInOutBuffer;  static WORD FirstFreeInOutBuffer;#endif#ifdef USE_MOD256_OUTBUFFER  /* Size of output buffer must be exactly 256 */  #define OUTBUFFER_LEN 0x100  /* Output buffer must begin at some address with lower 8 bits all zero */  xdata at 0xE000 BYTE OutBuffer[OUTBUFFER_LEN];#else  #define OUTBUFFER_LEN 0x200  static xdata BYTE OutBuffer[OUTBUFFER_LEN];#endif//-----------------------------------------------------------------------------void usb_jtag_init(void)              // Called once at startup{   WORD tmp;   Running = FALSE;   ClockBytes = 0;   Pending = 0;   WriteOnly = TRUE;   FirstDataInOutBuffer = 0;   FirstFreeInOutBuffer = 0;   ProgIO_Init();   ProgIO_Enable();   // Make Timer2 reload at 100 Hz to trigger Keepalive packets   tmp = 65536 - ( 48000000 / 12 / 100 );   RCAP2H = tmp >> 8;   RCAP2L = tmp & 0xFF;   CKCON = 0; // Default Clock   T2CON = 0x04; // Auto-reload mode using internal clock, no baud clock.   // Enable Autopointer   EXTACC = 1;  // Enable   APTR1FZ = 1; // Don't freeze   APTR2FZ = 1; // Don't freeze   // define endpoint configuration   FIFORESET = 0x80; SYNCDELAY;    // From now on, NAK all   REVCTL = 3; SYNCDELAY;          // Allow FW access to FIFO buffer   EP1OUTCFG  = 0xA0; SYNCDELAY;   EP1INCFG   = 0xA0; SYNCDELAY;   EP2FIFOCFG = 0x00; SYNCDELAY;   FIFORESET  = 0x02; SYNCDELAY;   EP2CFG     = 0xA2; SYNCDELAY;   EP4FIFOCFG = 0x00; SYNCDELAY;   FIFORESET  = 0x04; SYNCDELAY;   EP4CFG     = 0xA0; SYNCDELAY;   EP6FIFOCFG = 0x00; SYNCDELAY;   FIFORESET  = 0x06; SYNCDELAY;   EP6CFG     = 0xE2; SYNCDELAY;   EP8FIFOCFG = 0x00; SYNCDELAY;   FIFORESET  = 0x08; SYNCDELAY;   EP8CFG     = 0xE0; SYNCDELAY;   FIFORESET  = 0x00; SYNCDELAY;   // Restore normal behaviour   REVCTL = 0; SYNCDELAY;          // Reset FW access to FIFO buffer   // out endpoints do not come up armed   // since the defaults are double buffered we must write dummy byte counts twice   SYNCDELAY;                    //    EP2BCL = 0x80;                // arm EP2OUT by writing byte count w/skip.   SYNCDELAY;                    //    EP4BCL = 0x80;       SYNCDELAY;                    //    EP2BCL = 0x80;                // arm EP4OUT by writing byte count w/skip.   SYNCDELAY;                    //    EP4BCL = 0x80;    }void OutputByte(BYTE d){#ifdef USE_MOD256_OUTBUFFER   OutBuffer[FirstFreeInOutBuffer] = d;   FirstFreeInOutBuffer = ( FirstFreeInOutBuffer + 1 ) & 0xFF;#else   OutBuffer[FirstFreeInOutBuffer++] = d;   if(FirstFreeInOutBuffer >= OUTBUFFER_LEN) FirstFreeInOutBuffer = 0;#endif   Pending++;}//-----------------------------------------------------------------------------// usb_jtag_activity does most of the work. It now happens to behave just like// the combination of FT245BM and Altera-programmed EPM7064 CPLD in Altera's// USB-Blaster. The CPLD knows two major modes: Bit banging mode and Byte// shift mode. It starts in Bit banging mode. While bytes are received// from the host on EP2OUT, each byte B of them is processed as follows://// Please note: nCE, nCS, LED pins and DATAOUT actually aren't supported here.// Support for these would be required for AS/PS mode and isn't too complicated,// but I haven't had the time yet.//// Bit banging mode:// //   1. Remember bit 6 (0x40) in B as the "Read bit".////   2. If bit 7 (0x40) is set, switch to Byte shift mode for the coming//      X bytes ( X := B & 0x3F ), and don't do anything else now.////    3. Otherwise, set the JTAG signals as follows://        TCK/DCLK high if bit 0 was set (0x01), otherwise low//        TMS/nCONFIG high if bit 1 was set (0x02), otherwise low//        nCE high if bit 2 was set (0x04), otherwise low//        nCS high if bit 3 was set (0x08), otherwise low//        TDI/ASDI/DATA0 high if bit 4 was set (0x10), otherwise low//        Output Enable/LED active if bit 5 was set (0x20), otherwise low////    4. If "Read bit" (0x40) was set, record the state of TDO(CONF_DONE) and//        DATAOUT(nSTATUS) pins and put it as a byte ((DATAOUT<<1)|TDO) in the//        output FIFO _to_ the host (the code here reads TDO only and assumes//        DATAOUT=1)//// Byte shift mode:////   1. Load shift register with byte from host////   2. Do 8 times (i.e. for each bit of the byte; implemented in shift.a51)//      2a) if nCS=1, set carry bit from TDO, else set carry bit from DATAOUT//      2b) Rotate shift register through carry bit//      2c) TDI := Carry bit//      2d) Raise TCK, then lower TCK.////   3. If "Read bit" was set when switching into byte shift mode,//      record the shift register content and put it into the FIFO//      _to_ the host.//// Some more (minor) things to consider to emulate the FT245BM:////   a) The FT245BM seems to transmit just packets of no more than 64 bytes//      (which perfectly matches the USB spec). Each packet starts with//      two non-data bytes (I use 0x31,0x60 here). A USB sniffer on Windows//      might show a number of packets to you as if it was a large transfer//      because of the way that Windows understands it: it _is_ a large//      transfer until terminated with an USB packet smaller than 64 byte.////   b) The Windows driver expects to get some data packets (with at least//      the two leading bytes 0x31,0x60) immediately after "resetting" the//      FT chip and then in regular intervals. Otherwise a blue screen may//      appear... In the code below, I make sure that every 10ms there is//      some packet.////   c) Vendor specific commands to configure the FT245 are mostly ignored//      in my code. Only those for reading the EEPROM are processed. See//      DR_GetStatus and DR_VendorCmd below for my implementation.////   All other TD_ and DR_ functions remain as provided with CY3681.////-----------------------------------------------------------------------------void usb_jtag_activity(void) // Called repeatedly while the device is idle{   if(!Running) return;   ProgIO_Poll();      if(!(EP1INCS & bmEPBUSY))   {      if(Pending > 0)      {         BYTE o, n;         AUTOPTRH2 = MSB( EP1INBUF );         AUTOPTRL2 = LSB( EP1INBUF );                XAUTODAT2 = 0x31;         XAUTODAT2 = 0x60;                if(Pending > 0x3E) { n = 0x3E; Pending -= n; }                      else { n = Pending; Pending = 0; };                o = n;#ifdef USE_MOD256_OUTBUFFER         APTR1H = MSB( OutBuffer );         APTR1L = FirstDataInOutBuffer;         while(n--)         {            XAUTODAT2 = XAUTODAT1;            APTR1H = MSB( OutBuffer ); // Stay within 256-Byte-Buffer         };         FirstDataInOutBuffer = APTR1L;#else         APTR1H = MSB( &(OutBuffer[FirstDataInOutBuffer]) );         APTR1L = LSB( &(OutBuffer[FirstDataInOutBuffer]) );         while(n--)         {            XAUTODAT2 = XAUTODAT1;            if(++FirstDataInOutBuffer >= OUTBUFFER_LEN)            {               FirstDataInOutBuffer = 0;               APTR1H = MSB( OutBuffer );               APTR1L = LSB( OutBuffer );            };         };#endif         SYNCDELAY;         EP1INBC = 2 + o;         TF2 = 1; // Make sure there will be a short transfer soon      }      else if(TF2)      {         EP1INBUF[0] = 0x31;         EP1INBUF[1] = 0x60;         SYNCDELAY;         EP1INBC = 2;         TF2 = 0;      };   };   if(!(EP2468STAT & bmEP2EMPTY) && (Pending < OUTBUFFER_LEN-0x3F))   {      BYTE i, n = EP2BCL;      APTR1H = MSB( EP2FIFOBUF );      APTR1L = LSB( EP2FIFOBUF );      for(i=0;i<n;)      {         if(ClockBytes > 0)         {            BYTE m;            m = n-i;            if(ClockBytes < m) m = ClockBytes;            ClockBytes -= m;            i += m;            /* Shift out 8 bits from d */                     if(WriteOnly) /* Shift out 8 bits from d */            {               while(m--) ProgIO_ShiftOut(XAUTODAT1);            }            else /* Shift in 8 bits at the other end  */            {               while(m--) OutputByte(ProgIO_ShiftInOut(XAUTODAT1));            }        }        else        {            BYTE d = XAUTODAT1;            WriteOnly = (d & bmBIT6) ? FALSE : TRUE;            if(d & bmBIT7)            {               /* Prepare byte transfer, do nothing else yet */               ClockBytes = d & 0x3F;            }            else            {               if(WriteOnly)                   ProgIO_Set_State(d);               else                   OutputByte(ProgIO_Set_Get_State(d));            };            i++;         };      };      SYNCDELAY;      EP2BCL = 0x80; // Re-arm endpoint 2   };}//-----------------------------------------------------------------------------// Handler for Vendor Requests (//-----------------------------------------------------------------------------unsigned char app_vendor_cmd(void){  // OUT requests. Pretend we handle them all...  if ((bRequestType & bmRT_DIR_MASK) == bmRT_DIR_OUT)  {    if(bRequest == RQ_GET_STATUS)    {      Running = 1;    };    return 1;  }  // IN requests.  if(bRequest == 0x90)  {    BYTE addr = (wIndexL<<1) & 0x7F;    EP0BUF[0] = eeprom[addr];    EP0BUF[1] = eeprom[addr+1];  }  else  {    // dummy data    EP0BUF[0] = 0x36;    EP0BUF[1] = 0x83;  }  EP0BCH = 0;  EP0BCL = (wLengthL<2) ? wLengthL : 2; // Arm endpoint with # bytes to transfer  return 1;}//-----------------------------------------------------------------------------static void main_loop(void){  while(1)  {    if(usb_setup_packet_avail()) usb_handle_setup_packet();    usb_jtag_activity();  }}//-----------------------------------------------------------------------------void main(void){  EA = 0; // disable all interrupts  usb_jtag_init();  eeprom_init();  setup_autovectors ();  usb_install_handlers ();  EA = 1; // enable interrupts  fx2_renumerate(); // simulates disconnect / reconnect  main_loop();}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
肉色丝袜一区二区| 日本韩国精品一区二区在线观看| 国产91精品精华液一区二区三区| 91免费国产视频网站| 91精品国产色综合久久不卡电影| 国产精品久久久久毛片软件| 日韩精品午夜视频| 色综合天天视频在线观看| 欧美v国产在线一区二区三区| 亚洲人妖av一区二区| 国内成人免费视频| 欧美在线一区二区| 国产人伦精品一区二区| 免费看日韩精品| 色婷婷av久久久久久久| 中文字幕免费观看一区| 美女网站一区二区| 精品视频在线视频| 亚洲欧美另类久久久精品2019| 色综合天天综合网天天看片| 欧美成人午夜电影| 天天做天天摸天天爽国产一区| 日本道精品一区二区三区| 日本一区二区三区在线不卡| 狠狠狠色丁香婷婷综合久久五月| 欧美另类一区二区三区| 亚洲靠逼com| 成人国产一区二区三区精品| 久久色在线观看| 美女视频一区在线观看| 欧美美女bb生活片| 五月婷婷激情综合网| 欧美日韩dvd在线观看| 亚洲卡通动漫在线| 91久久精品一区二区三| 最好看的中文字幕久久| 99免费精品视频| 国产精品伦理一区二区| 成人性生交大片免费看中文 | 自拍偷自拍亚洲精品播放| 高清视频一区二区| 国产日韩亚洲欧美综合| 国产91丝袜在线播放九色| 久久亚洲捆绑美女| 国产精品香蕉一区二区三区| 国产亚洲欧美激情| 成人三级伦理片| 亚洲女人****多毛耸耸8| 色综合天天综合给合国产| 自拍偷拍欧美激情| wwwwxxxxx欧美| 国产乱妇无码大片在线观看| 国产欧美一区二区三区网站 | 久久久噜噜噜久久中文字幕色伊伊 | 国产亚洲欧美色| 99久久99久久免费精品蜜臀| 亚洲免费电影在线| 91精品欧美综合在线观看最新| 久久国产精品区| 中文字幕一区免费在线观看| 色8久久精品久久久久久蜜| 午夜不卡在线视频| 久久蜜桃av一区二区天堂| 99久久久无码国产精品| 亚洲h动漫在线| 久久麻豆一区二区| 一本大道av伊人久久综合| 性久久久久久久久| 欧美国产精品v| 欧美日韩国产片| 懂色av一区二区三区免费观看 | 91麻豆成人久久精品二区三区| 香蕉影视欧美成人| 欧美激情中文字幕| 欧美绝品在线观看成人午夜影视| 国内精品视频666| 一区二区三区波多野结衣在线观看 | 成人免费视频网站在线观看| 午夜影院久久久| 中文字幕欧美区| 日韩欧美国产麻豆| 91在线观看一区二区| 蜜臀av一区二区| 亚洲精品中文在线| 欧美mv日韩mv| 欧美二区三区91| 色综合天天综合网国产成人综合天| 免费成人在线播放| 一区二区三区中文在线| 久久久www成人免费无遮挡大片| 欧美在线免费播放| 成人精品视频一区| 激情偷乱视频一区二区三区| 亚洲国产婷婷综合在线精品| 日本一区二区电影| 精品国产精品网麻豆系列| 色婷婷狠狠综合| 波多野结衣欧美| 国产乱码精品一区二区三区忘忧草 | 免费观看91视频大全| 一区二区在线观看视频| 欧美激情在线免费观看| 欧美成人伊人久久综合网| 欧美三级一区二区| 色成年激情久久综合| av爱爱亚洲一区| 国产精品99久| 国产精品自在在线| 久久99久久久欧美国产| 成人理论电影网| 国产成人一级电影| 国内精品伊人久久久久影院对白| 日韩精品一二三区| 舔着乳尖日韩一区| 午夜一区二区三区视频| 一区二区成人在线| 亚洲精品自拍动漫在线| 亚洲日本韩国一区| 亚洲欧美怡红院| 亚洲男女一区二区三区| 亚洲欧美另类小说| 亚洲综合色在线| 亚洲国产三级在线| 秋霞午夜鲁丝一区二区老狼| 日本视频中文字幕一区二区三区| 视频一区中文字幕国产| 日日欢夜夜爽一区| 精品一区二区三区在线播放 | 91麻豆精品国产91久久久久久| 在线观看三级视频欧美| 欧美色爱综合网| 欧美一区二区三区不卡| 亚洲精品一区二区在线观看| 久久九九久精品国产免费直播| 国产日韩欧美高清在线| 中文字幕中文字幕一区| 亚洲视频 欧洲视频| 一区二区成人在线视频 | 国产黑丝在线一区二区三区| 成人污视频在线观看| 色婷婷综合视频在线观看| 欧美视频在线观看一区| 日韩一级免费一区| 国产免费成人在线视频| 一区二区三区在线看| 日日欢夜夜爽一区| 丁香一区二区三区| 欧美午夜影院一区| 久久久久88色偷偷免费| 亚洲色图在线视频| 青青草97国产精品免费观看| 成人不卡免费av| 欧美日韩美女一区二区| 国产日韩av一区| 五月婷婷综合激情| 国产 日韩 欧美大片| 56国语精品自产拍在线观看| 国产三级一区二区| 亚洲图片欧美综合| 国产成人免费视频精品含羞草妖精| 日本黄色一区二区| 久久久高清一区二区三区| 亚洲成av人片在线观看无码| 国产精品一级片在线观看| 一本色道久久综合亚洲91 | 色综合天天综合狠狠| 欧美精品视频www在线观看| 国产精品素人一区二区| 亚洲亚洲精品在线观看| 精品在线免费观看| 91一区二区三区在线播放| 日韩欧美视频一区| 亚洲日韩欧美一区二区在线| 日本成人在线网站| 欧美影视一区二区三区| 欧美精品一区二区精品网| 亚洲女性喷水在线观看一区| 亚洲成人高清在线| 色久优优欧美色久优优| 精品国产乱码久久久久久闺蜜| 国产精品九色蝌蚪自拍| 国产高清成人在线| 欧美日韩视频专区在线播放| 国产蜜臀av在线一区二区三区| 亚洲美女免费视频| 91首页免费视频| 欧美大肚乱孕交hd孕妇| 亚洲综合色在线| 日本高清不卡aⅴ免费网站| 久久青草欧美一区二区三区| 午夜电影网亚洲视频| 国产盗摄一区二区三区| 久久综合久久久久88| 天天免费综合色| av电影天堂一区二区在线| 国产精品美女一区二区三区 | 欧美日韩视频第一区| 亚洲天堂2014| 东方欧美亚洲色图在线| 欧美日韩精品一区视频|