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

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

?? usrp_primes.cc

?? 嵌入式開發板USB測試
?? CC
?? 第 1 頁 / 共 3 頁
字號:
/* -*- c++ -*- */ 
/* 
 * Copyright 2003,2004,2006 Free Software Foundation, Inc. 
 *  
 * This file is part of GNU Radio 
 *  
 * GNU Radio 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 3, or (at your option) 
  * any later version. 
  *  
  * GNU Radio 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 GNU Radio; see the file COPYING.  If not, write to 
  * the Free Software Foundation, Inc., 51 Franklin Street, 
  * Boston, MA 02110-1301, USA. 
  */ 
  
 #ifdef HAVE_CONFIG_H 
 #include "config.h" 
 #endif 
  
 #include "usrp_prims.h" 
 #include "usrp_commands.h" 
 #include "usrp_ids.h" 
 #include "usrp_i2c_addr.h" 
 #include "fpga_regs_common.h" 
 #include "fpga_regs_standard.h" 
 #include <usb.h> 
 #include <errno.h> 
 #include <stdio.h> 
 #include <unistd.h> 
 #include <stdlib.h> 
 #include <string.h> 
 #include <ctype.h> 
 #include <time.h>               // FIXME should check with autoconf (nanosleep) 
 #include <algorithm> 
 #include <ad9862.h> 
 #include <assert.h> 
  
 extern "C" { 
 #include "md5.h" 
 }; 
  
 #define VERBOSE 0 
  
 using namespace ad9862; 
  
 static const int FIRMWARE_HASH_SLOT     = 0; 
 static const int FPGA_HASH_SLOT         = 1; 
  
 static const int hash_slot_addr[2] = { 
   USRP_HASH_SLOT_0_ADDR, 
   USRP_HASH_SLOT_1_ADDR 
 }; 
  
 static const char *default_firmware_filename = "std.ihx"; 
 static const char *default_fpga_filename     = "std_2rxhb_2tx.rbf"; 
  
 #include "std_paths.h" 
 #include <stdio.h> 
  
 static char * 
 find_file (const char *filename, int hw_rev) 
 { 
   const char **sp = std_paths; 
   static char path[1000]; 
   char *s; 
  
   s = getenv("USRP_PATH"); 
   if (s) { 
     snprintf (path, sizeof (path), "%s/rev%d/%s", s, hw_rev, filename); 
     if (access (path, R_OK) == 0) 
       return path; 
   } 
  
   while (*sp){ 
     snprintf (path, sizeof (path), "%s/rev%d/%s", *sp, hw_rev, filename); 
     if (access (path, R_OK) == 0) 
       return path; 
     sp++; 
   } 
   return 0; 
 } 
  
 static const char * 
 get_proto_filename(const std::string user_filename, const char *env_var, const char *def) 
 { 
   if (user_filename.length() != 0) 
     return user_filename.c_str(); 
  
   char *s = getenv(env_var); 
   if (s && *s) 
     return s; 
  
  return def; 
} 
 
 
static void power_down_9862s (struct usb_dev_handle *udh); 
 
void 
usrp_one_time_init () 
{ 
  static bool first = true; 
 
  if (first){ 
    first = false; 
    usb_init ();                        // usb library init 
    usb_find_busses (); 
    usb_find_devices (); 
  } 
} 
 
void 
usrp_rescan () 
{ 
  usb_find_busses (); 
  usb_find_devices (); 
} 
 
 
// ---------------------------------------------------------------- 
// Danger, big, fragile KLUDGE.  The problem is that we want to be 
// able to get from a usb_dev_handle back to a usb_device, and the 
// right way to do this is buried in a non-installed include file. 
 
static struct usb_device * 
dev_handle_to_dev (usb_dev_handle *udh) 
{ 
  struct usb_dev_handle_kludge { 
    int                  fd; 
    struct usb_bus      *bus; 
    struct usb_device   *device; 
  }; 
 
  return ((struct usb_dev_handle_kludge *) udh)->device; 
} 
 
// ---------------------------------------------------------------- 
 
/* 
 * q must be a real USRP, not an FX2.  Return its hardware rev number. 
 */ 
int 
usrp_hw_rev (struct usb_device *q) 
{ 
  return q->descriptor.bcdDevice & 0x00FF; 
} 
 
/* 
 * q must be a real USRP, not an FX2.  Return true if it's configured. 
 */ 
static bool 
_usrp_configured_p (struct usb_device *q) 
{ 
  return (q->descriptor.bcdDevice & 0xFF00) != 0; 
} 
 
bool 
usrp_usrp_p (struct usb_device *q) 
{ 
  return (q->descriptor.idVendor == USB_VID_FSF 
          && q->descriptor.idProduct == USB_PID_FSF_USRP); 
} 
 
bool 
usrp_fx2_p (struct usb_device *q) 
{ 
  return (q->descriptor.idVendor == USB_VID_CYPRESS 
          && q->descriptor.idProduct == USB_PID_CYPRESS_FX2); 
} 
 
bool 
usrp_usrp0_p (struct usb_device *q) 
{ 
  return usrp_usrp_p (q) && usrp_hw_rev (q) == 0; 
} 
 
bool 
usrp_usrp1_p (struct usb_device *q) 
{ 
  return usrp_usrp_p (q) && usrp_hw_rev (q) == 1; 
} 
 
bool 
usrp_usrp2_p (struct usb_device *q) 
{ 
  return usrp_usrp_p (q) && usrp_hw_rev (q) == 2; 
} 
 
 
bool 
usrp_unconfigured_usrp_p (struct usb_device *q) 
{ 
  return usrp_usrp_p (q) && !_usrp_configured_p (q); 
} 
 
bool 
usrp_configured_usrp_p (struct usb_device *q) 
{ 
  return usrp_usrp_p (q) && _usrp_configured_p (q); 
} 
 
// ---------------------------------------------------------------- 
 
struct usb_device * 
usrp_find_device (int nth, bool fx2_ok_p) 
{ 
  struct usb_bus *p; 
  struct usb_device *q; 
  int    n_found = 0; 
 
  usrp_one_time_init (); 
   
  p = usb_get_busses(); 
  while (p != NULL){ 
    q = p->devices; 
    while (q != NULL){ 
      if (usrp_usrp_p (q) || (fx2_ok_p && usrp_fx2_p (q))){ 
        if (n_found == nth)     // return this one 
          return q; 
        n_found++;              // keep looking 
      } 
      q = q->next; 
    } 
    p = p->next; 
  } 
  return 0;     // not found 
} 
 
static struct usb_dev_handle * 
usrp_open_interface (struct usb_device *dev, int interface, int altinterface) 
{ 
  struct usb_dev_handle *udh = usb_open (dev); 
  if (udh == 0) 
    return 0; 
 
  if (dev != dev_handle_to_dev (udh)){ 
    fprintf (stderr, "%s:%d: internal error!\n", __FILE__, __LINE__); 
    abort (); 
  } 
 
#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) 
  // There's no get get_configuration function, and with some of the newer kernels 
  // setting the configuration, even if to the same value, hoses any other processes 
  // that have it open.  Hence we opt to not set it at all (We've only 
  // got a single configuration anyway).  This may hose the win32 stuff... 
 
  // Appears to be required for libusb-win32 and Cygwin -- dew 09/20/06 
  if (usb_set_configuration (udh, 1) < 0){ 
    /* 
     * Ignore this error.   
     * 
     * Seems that something changed in drivers/usb/core/devio.c:proc_setconfig such that 
     * it returns -EBUSY if _any_ of the interfaces of a device are open. 
     * We've only got a single configuration, so setting it doesn't even seem 
     * like it should be required. 
     */ 
  } 
#endif 
 
  if (usb_claim_interface (udh, interface) < 0){ 
    fprintf (stderr, "%s:usb_claim_interface: failed interface %d\n", __FUNCTION__,interface); 
    fprintf (stderr, "%s\n", usb_strerror()); 
    usb_close (udh); 
    return 0; 
  } 
 
  if (usb_set_altinterface (udh, altinterface) < 0){ 
    fprintf (stderr, "%s:usb_set_alt_interface: failed\n", __FUNCTION__); 
    fprintf (stderr, "%s\n", usb_strerror()); 
    usb_release_interface (udh, interface); 
    usb_close (udh); 
    return 0; 
  } 
 
  return udh; 
} 
 
struct usb_dev_handle * 
usrp_open_cmd_interface (struct usb_device *dev) 
{ 
  return usrp_open_interface (dev, USRP_CMD_INTERFACE, USRP_CMD_ALTINTERFACE); 
} 
 
struct usb_dev_handle * 
usrp_open_rx_interface (struct usb_device *dev) 
{ 
  return usrp_open_interface (dev, USRP_RX_INTERFACE, USRP_RX_ALTINTERFACE); 
} 
 
struct usb_dev_handle * 
usrp_open_tx_interface (struct usb_device *dev) 
{ 
  return usrp_open_interface (dev, USRP_TX_INTERFACE, USRP_TX_ALTINTERFACE); 
} 
 
bool 
usrp_close_interface (struct usb_dev_handle *udh) 
{ 
  // we're assuming that closing an interface automatically releases it. 
  return usb_close (udh) == 0; 
} 
 
// ---------------------------------------------------------------- 
// write internal ram using Cypress vendor extension 
 
static bool 
write_internal_ram (struct usb_dev_handle *udh, unsigned char *buf, 
                    int start_addr, size_t len) 
{ 
  int addr; 
  int n; 
  int a; 
  int quanta = MAX_EP0_PKTSIZE; 
 
  for (addr = start_addr; addr < start_addr + (int) len; addr += quanta){ 
    n = len + start_addr - addr; 
    if (n > quanta) 
      n = quanta; 
 
    a = usb_control_msg (udh, 0x40, 0xA0, 
                         addr, 0, (char *)(buf + (addr - start_addr)), n, 1000); 
 
    if (a < 0){ 
      fprintf(stderr,"write_internal_ram failed: %s\n", usb_strerror()); 
      return false; 
    } 
  } 
  return true; 
} 
 
// ---------------------------------------------------------------- 
// whack the CPUCS register using the upload RAM vendor extension 
 
static bool 
reset_cpu (struct usb_dev_handle *udh, bool reset_p) 
{ 
  unsigned char v; 
 
  if (reset_p) 
    v = 1;              // hold processor in reset 
  else 
    v = 0;              // release reset 
 
  return write_internal_ram (udh, &v, 0xE600, 1); 
} 
 
// ---------------------------------------------------------------- 
// Load intel format file into cypress FX2 (8051) 
 
static bool 
_usrp_load_firmware (struct usb_dev_handle *udh, const char *filename, 
                     unsigned char hash[USRP_HASH_SIZE]) 
{ 
  FILE  *f = fopen (filename, "ra"); 
  if (f == 0){ 
    perror (filename); 
    return false; 
  } 
 
  if (!reset_cpu (udh, true))   // hold CPU in reset while loading firmware 
    goto fail; 
 
   
  char s[1024]; 
  int length; 
  int addr; 
  int type; 
  unsigned char data[256]; 
  unsigned char checksum, a; 
  unsigned int b; 
  int i; 
 
  while (!feof(f)){ 
    fgets(s, sizeof (s), f); /* we should not use more than 263 bytes normally */ 
    if(s[0]!=':'){ 
      fprintf(stderr,"%s: invalid line: \"%s\"\n", filename, s); 
      goto fail; 
    } 
    sscanf(s+1, "%02x", &length); 
    sscanf(s+3, "%04x", &addr); 
    sscanf(s+7, "%02x", &type); 
 
    if(type==0){ 
 
      a=length+(addr &0xff)+(addr>>8)+type; 
      for(i=0;i<length;i++){ 
        sscanf (s+9+i*2,"%02x", &b); 
        data[i]=b; 
        a=a+data[i]; 
      } 
 
      sscanf (s+9+length*2,"%02x", &b); 
      checksum=b; 
      if (((a+checksum)&0xff)!=0x00){ 
        fprintf (stderr, "  ** Checksum failed: got 0x%02x versus 0x%02x\n", (-a)&0xff, checksum); 
        goto fail; 
      } 
      if (!write_internal_ram (udh, data, addr, length)) 
        goto fail; 
    } 
    else if (type == 0x01){      // EOF 
      break; 
    } 
    else if (type == 0x02){ 
      fprintf(stderr, "Extended address: whatever I do with it?\n"); 
      fprintf (stderr, "%s: invalid line: \"%s\"\n", filename, s); 
      goto fail; 
    } 
  } 
 
  // we jam the hash value into the FX2 memory before letting 
  // the cpu out of reset.  When it comes out of reset it 
  // may renumerate which will invalidate udh. 
 
  if (!usrp_set_hash (udh, FIRMWARE_HASH_SLOT, hash)) 
    fprintf (stderr, "usrp: failed to write firmware hash slot\n"); 
 
  if (!reset_cpu (udh, false))          // take CPU out of reset 
    goto fail; 
 
  fclose (f); 
  return true; 
 
 fail: 
  fclose (f); 
  return false; 
} 
 
// ---------------------------------------------------------------- 
// write vendor extension command to USRP 
 
static int 
write_cmd (struct usb_dev_handle *udh, 
           int request, int value, int index, 
           unsigned char *bytes, int len) 
{ 
  int   requesttype = (request & 0x80) ? VRT_VENDOR_IN : VRT_VENDOR_OUT; 
 
  int r = usb_control_msg (udh, requesttype, request, value, index, 
                           (char *) bytes, len, 1000); 
  if (r < 0){ 
    // we get EPIPE if the firmware stalls the endpoint. 
    if (errno != EPIPE) 
      fprintf (stderr, "usb_control_msg failed: %s\n", usb_strerror ()); 
  } 
 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
午夜av区久久| 国产精品久久久久永久免费观看| 国产成人午夜精品影院观看视频| 视频一区视频二区在线观看| 亚洲综合区在线| 亚洲一区二区三区在线播放| 亚洲精品视频一区| 一区二区三区四区在线播放| 亚洲女与黑人做爰| 一区二区国产盗摄色噜噜| 性做久久久久久免费观看| 亚洲一区在线看| 午夜av区久久| 精品一区二区三区久久| 国内精品第一页| 粉嫩av一区二区三区粉嫩| 成人av动漫在线| 欧美又粗又大又爽| 91麻豆精品国产91久久久资源速度 | 日本欧美一区二区| 久久99九九99精品| 成人小视频在线观看| 91麻豆成人久久精品二区三区| 欧洲生活片亚洲生活在线观看| 欧美日韩五月天| 精品国产一二三| 亚洲欧洲精品一区二区精品久久久 | 日精品一区二区| 久久97超碰色| 91丨porny丨国产| 日韩一区二区三区精品视频 | 国产精品不卡视频| 午夜视频在线观看一区二区| 激情都市一区二区| 一本久道久久综合中文字幕| 欧美人动与zoxxxx乱| 久久精品综合网| 亚洲va天堂va国产va久| 国产高清不卡一区| 在线观看免费成人| 久久久久一区二区三区四区| 一区二区三区日韩| 久久99精品国产麻豆不卡| 91看片淫黄大片一级在线观看| 欧美一区二区性放荡片| 国产精品美女久久久久aⅴ| 五月天国产精品| 91啪在线观看| 国产欧美日韩视频一区二区 | 精品成人私密视频| 亚洲激情av在线| 高清国产午夜精品久久久久久| 欧美色图片你懂的| 国产精品福利一区| 国产精品一级在线| 日韩欧美国产麻豆| 一区二区在线观看不卡| 成人美女视频在线观看18| 欧美电影影音先锋| 夜夜夜精品看看| 一本色道综合亚洲| 国产精品人妖ts系列视频| 精品在线一区二区| 91精品久久久久久久91蜜桃| 亚洲精品你懂的| 91在线精品秘密一区二区| 久久先锋影音av鲁色资源网| 青青草成人在线观看| 欧美电影影音先锋| 日韩高清在线不卡| 欧美精品高清视频| 婷婷久久综合九色综合绿巨人| 91亚洲男人天堂| 亚洲欧美区自拍先锋| 99v久久综合狠狠综合久久| 国产精品第五页| 成人h动漫精品| 中文字幕亚洲区| 成人免费高清视频在线观看| 国产精品视频一二| 91农村精品一区二区在线| 亚洲日本一区二区| 欧美亚一区二区| 偷偷要91色婷婷| 日韩一级片在线观看| 日本不卡的三区四区五区| 日韩免费看网站| 国产精品自在在线| 久久精品亚洲一区二区三区浴池| 国产91精品在线观看| 欧美日韩综合在线免费观看| av影院午夜一区| 国产精品色婷婷| 97精品电影院| 亚洲第一福利一区| 欧美一区二区免费| 国产伦精品一区二区三区视频青涩| 日韩午夜电影在线观看| 国产精品一区二区男女羞羞无遮挡| 久久综合久久久久88| 成人激情动漫在线观看| 亚洲色图在线播放| 欧美日韩中文另类| 国内欧美视频一区二区| 中文字幕精品—区二区四季| 色偷偷88欧美精品久久久| 男男视频亚洲欧美| 亚洲国产精品ⅴa在线观看| 色综合中文字幕国产| 美女网站在线免费欧美精品| 欧美经典一区二区| 欧美日本在线看| 日韩成人av影视| 国产在线一区二区| 国产精品国产三级国产有无不卡| 91丨九色丨蝌蚪丨老版| 免费看欧美女人艹b| 国产精品免费免费| 欧美丰满高潮xxxx喷水动漫| 成人激情小说网站| 久久精品久久综合| 亚洲男人电影天堂| 欧美精品一区二区久久久| 欧美中文字幕一区| 国产福利一区二区| 日本不卡一区二区| 亚洲精品久久久蜜桃| 久久久久久久国产精品影院| 精品视频在线免费观看| caoporen国产精品视频| 久久99精品视频| 视频在线观看国产精品| 亚洲日本在线天堂| 国产精品全国免费观看高清| 337p亚洲精品色噜噜噜| 在线观看区一区二| 成人a免费在线看| 国产一区二区导航在线播放| 亚洲成人在线网站| 日本视频在线一区| 一区二区三区在线视频播放| 国产精品亲子乱子伦xxxx裸| 欧美精品一区二区三区视频| 欧美电影一区二区| 欧美日韩综合色| 欧美日韩一区三区| 91国内精品野花午夜精品| 成人av午夜影院| 国产99一区视频免费| 国产成人亚洲综合a∨婷婷图片| 男男成人高潮片免费网站| 日韩经典一区二区| 天天射综合影视| 亚洲大片精品永久免费| 亚洲国产视频a| 亚洲亚洲人成综合网络| 亚洲综合成人网| 午夜av电影一区| 天天亚洲美女在线视频| 人人精品人人爱| 精品一区二区日韩| 国产精品一二三四五| 国产成人在线色| 成人三级伦理片| 欧洲在线/亚洲| 日韩视频一区二区| 久久综合一区二区| 中文字幕va一区二区三区| 中文字幕在线一区免费| 亚洲色图制服诱惑| 天堂在线亚洲视频| 国产一区二区三区四| 国产精品一区二区三区乱码| 99热这里都是精品| 欧美精品丝袜久久久中文字幕| 91精品国产手机| 国产性做久久久久久| 亚洲免费看黄网站| 久久精品999| aaa亚洲精品| 欧美肥大bbwbbw高潮| 久久精品视频在线免费观看 | 成人va在线观看| 欧美日本在线一区| 久久嫩草精品久久久精品一| 综合久久一区二区三区| 青青青伊人色综合久久| 国产成人精品免费视频网站| 在线视频亚洲一区| 精品国产一区二区三区av性色 | 亚洲丶国产丶欧美一区二区三区| 蜜臀av性久久久久蜜臀av麻豆| 粉嫩欧美一区二区三区高清影视| 欧美性猛交xxxx乱大交退制版| 欧美不卡在线视频| 亚洲人午夜精品天堂一二香蕉| 奇米精品一区二区三区在线观看一| 粉嫩av亚洲一区二区图片| 欧美精品xxxxbbbb| 亚洲天堂久久久久久久|