Changeset 9761

Show
Ignore:
Timestamp:
10/08/08 22:22:38
Author:
eb
Message:

Add support for ATR and REFCLK to usrp_basic.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_basic.cc

    r9748 r9761  
    2929#include "usrp_interfaces.h" 
    3030#include "fpga_regs_common.h" 
     31#include "fpga_regs_standard.h" 
    3132#include "fusb.h" 
    3233#include <usb.h> 
     
    426427} 
    427428 
     429bool 
     430usrp_basic::write_atr_tx_delay(int value) 
     431{ 
     432  return _write_fpga_reg(FR_ATR_TX_DELAY, value); 
     433} 
     434 
     435bool 
     436usrp_basic::write_atr_rx_delay(int value) 
     437{ 
     438  return _write_fpga_reg(FR_ATR_RX_DELAY, value); 
     439} 
     440 
    428441/* 
    429442 * ---------------------------------------------------------------- 
     
    448461 
    449462static int 
     463slot_id_to_refclk_reg(int slot_id) 
     464{ 
     465  static int reg[4]  = { FR_TX_A_REFCLK, FR_RX_A_REFCLK, FR_TX_B_REFCLK, FR_RX_B_REFCLK }; 
     466  assert (0 <= slot_id && slot_id < 4); 
     467  return reg[slot_id]; 
     468} 
     469 
     470static int 
     471slot_id_to_atr_mask_reg(int slot_id) 
     472{ 
     473  static int reg[4]  = { FR_ATR_MASK_0, FR_ATR_MASK_1, FR_ATR_MASK_2, FR_ATR_MASK_3 }; 
     474  assert (0 <= slot_id && slot_id < 4); 
     475  return reg[slot_id]; 
     476} 
     477 
     478static int 
     479slot_id_to_atr_txval_reg(int slot_id) 
     480{ 
     481  static int reg[4]  = { FR_ATR_TXVAL_0, FR_ATR_TXVAL_1, FR_ATR_TXVAL_2, FR_ATR_TXVAL_3 }; 
     482  assert (0 <= slot_id && slot_id < 4); 
     483  return reg[slot_id]; 
     484} 
     485 
     486static int 
     487slot_id_to_atr_rxval_reg(int slot_id) 
     488{ 
     489  static int reg[4]  = { FR_ATR_RXVAL_0, FR_ATR_RXVAL_1, FR_ATR_RXVAL_2, FR_ATR_RXVAL_3 }; 
     490  assert (0 <= slot_id && slot_id < 4); 
     491  return reg[slot_id]; 
     492} 
     493 
     494static int 
    450495to_slot(txrx_t txrx, int which_side) 
    451496{ 
     
    588633    return READ_FAILED; 
    589634  return value; 
     635} 
     636 
     637bool 
     638usrp_basic::common_write_refclk(txrx_t txrx, int which_side, int value) 
     639{ 
     640  if (! (0 <= which_side && which_side <= 1)) 
     641    return false; 
     642 
     643  return _write_fpga_reg(slot_id_to_refclk_reg(to_slot(txrx, which_side)), 
     644                         value); 
     645} 
     646 
     647bool 
     648usrp_basic::common_write_atr_mask(txrx_t txrx, int which_side, int value) 
     649{ 
     650  if (! (0 <= which_side && which_side <= 1)) 
     651    return false; 
     652 
     653  return _write_fpga_reg(slot_id_to_atr_mask_reg(to_slot(txrx, which_side)), 
     654                         value); 
     655} 
     656 
     657bool 
     658usrp_basic::common_write_atr_txval(txrx_t txrx, int which_side, int value) 
     659{ 
     660  if (! (0 <= which_side && which_side <= 1)) 
     661    return false; 
     662 
     663  return _write_fpga_reg(slot_id_to_atr_txval_reg(to_slot(txrx, which_side)), 
     664                         value); 
     665} 
     666 
     667bool 
     668usrp_basic::common_write_atr_rxval(txrx_t txrx, int which_side, int value) 
     669{ 
     670  if (! (0 <= which_side && which_side <= 1)) 
     671    return false; 
     672 
     673  return _write_fpga_reg(slot_id_to_atr_rxval_reg(to_slot(txrx, which_side)), 
     674                         value); 
    590675} 
    591676 
     
    676761                                           fusb_block_size, fusb_nblocks); 
    677762 
    678   _write_fpga_reg(FR_ATR_MASK_1, 0);   // zero Rx side Auto Transmit/Receive regs 
    679   _write_fpga_reg(FR_ATR_TXVAL_1, 0); 
    680   _write_fpga_reg(FR_ATR_RXVAL_1, 0); 
    681   _write_fpga_reg(FR_ATR_MASK_3, 0); 
    682   _write_fpga_reg(FR_ATR_TXVAL_3, 0); 
    683   _write_fpga_reg(FR_ATR_RXVAL_3, 0); 
     763  write_atr_mask(0, 0);                // zero Rx A Auto Transmit/Receive regs 
     764  write_atr_txval(0, 0); 
     765  write_atr_rxval(0, 0); 
     766  write_atr_mask(1, 0);                // zero Rx B Auto Transmit/Receive regs 
     767  write_atr_txval(1, 0); 
     768  write_atr_rxval(1, 0); 
    684769} 
    685770 
     
    9321017 
    9331018bool 
     1019usrp_basic_rx::write_refclk(int which_side, int value) 
     1020{ 
     1021  return common_write_refclk(C_RX, which_side, value); 
     1022} 
     1023 
     1024bool 
     1025usrp_basic_rx::write_atr_mask(int which_side, int value) 
     1026{ 
     1027  return common_write_atr_mask(C_RX, which_side, value); 
     1028} 
     1029 
     1030bool 
     1031usrp_basic_rx::write_atr_txval(int which_side, int value) 
     1032{ 
     1033  return common_write_atr_txval(C_RX, which_side, value); 
     1034} 
     1035 
     1036bool 
     1037usrp_basic_rx::write_atr_rxval(int which_side, int value) 
     1038{ 
     1039  return common_write_atr_rxval(C_RX, which_side, value); 
     1040} 
     1041 
     1042bool 
    9341043usrp_basic_rx::write_aux_dac (int which_side, int which_dac, int value) 
    9351044{ 
     
    10381147                                           fusb_block_size, fusb_nblocks); 
    10391148 
    1040   _write_fpga_reg(FR_ATR_MASK_0, 0); // zero Tx side Auto Transmit/Receive regs 
    1041   _write_fpga_reg(FR_ATR_TXVAL_0, 0); 
    1042   _write_fpga_reg(FR_ATR_RXVAL_0, 0); 
    1043   _write_fpga_reg(FR_ATR_MASK_2, 0); 
    1044   _write_fpga_reg(FR_ATR_TXVAL_2, 0); 
    1045   _write_fpga_reg(FR_ATR_RXVAL_2, 0); 
     1149  write_atr_mask(0, 0);                // zero Tx A Auto Transmit/Receive regs 
     1150  write_atr_txval(0, 0); 
     1151  write_atr_rxval(0, 0); 
     1152  write_atr_mask(1, 0);                // zero Tx B Auto Transmit/Receive regs 
     1153  write_atr_txval(1, 0); 
     1154  write_atr_rxval(1, 0); 
    10461155} 
    10471156 
     
    12971406 
    12981407bool 
     1408usrp_basic_tx::write_refclk(int which_side, int value) 
     1409{ 
     1410  return common_write_refclk(C_TX, which_side, value); 
     1411} 
     1412 
     1413bool 
     1414usrp_basic_tx::write_atr_mask(int which_side, int value) 
     1415{ 
     1416  return common_write_atr_mask(C_TX, which_side, value); 
     1417} 
     1418 
     1419bool 
     1420usrp_basic_tx::write_atr_txval(int which_side, int value) 
     1421{ 
     1422  return common_write_atr_txval(C_TX, which_side, value); 
     1423} 
     1424 
     1425bool 
     1426usrp_basic_tx::write_atr_rxval(int which_side, int value) 
     1427{ 
     1428  return common_write_atr_rxval(C_TX, which_side, value); 
     1429} 
     1430 
     1431bool 
    12991432usrp_basic_tx::write_aux_dac (int which_side, int which_dac, int value) 
    13001433{ 
  • gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_basic.h

    r9748 r9761  
    240240  virtual int daughterboard_id (int which_side) const = 0; 
    241241 
     242  /*! 
     243   * \brief Clock ticks to delay rising of T/R signal 
     244   * \sa write_atr_mask, write_atr_txval, write_atr_rxval 
     245   */ 
     246  bool write_atr_tx_delay(int value); 
     247 
     248  /*! 
     249   * \brief Clock ticks to delay falling edge of T/R signal 
     250   * \sa write_atr_mask, write_atr_txval, write_atr_rxval 
     251   */ 
     252  bool write_atr_rx_delay(int value); 
     253 
     254 
    242255   // ================================================================ 
    243256  // Routines to access and control daughterboard specific i/o 
     
    341354 
    342355  /*! 
     356   * \brief Write daughterboard refclk config register 
     357   * 
     358   * \param txrx        Tx or Rx? 
     359   * \param which_side  [0,1] which d'board 
     360   * \param value       value to write into register, see below 
     361   * 
     362   * <pre> 
     363   * Control whether a reference clock is sent to the daughterboards, 
     364   * and what frequency.  The refclk is sent on d'board i/o pin 0. 
     365   *  
     366   *     3                   2                   1                        
     367   *   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 
     368   *  +-----------------------------------------------+-+------------+ 
     369   *  |             Reserved (Must be zero)           |E|   DIVISOR  | 
     370   *  +-----------------------------------------------+-+------------+ 
     371   *  
     372   *  Bit 7  -- 1 turns on refclk, 0 allows IO use 
     373   *  Bits 6:0 Divider value 
     374   * </pre> 
     375   */ 
     376  bool common_write_refclk(txrx_t txrx, int which_side, int value); 
     377 
     378  /*! 
     379   * \brief Automatic Transmit/Receive switching 
     380   * <pre> 
     381   * 
     382   * If automatic transmit/receive (ATR) switching is enabled in the 
     383   * FR_ATR_CTL register, the presence or absence of data in the FPGA 
     384   * transmit fifo selects between two sets of values for each of the 4 
     385   * banks of daughterboard i/o pins. 
     386   * 
     387   * Each daughterboard slot has 3 16-bit registers associated with it: 
     388   *   FR_ATR_MASK_*, FR_ATR_TXVAL_* and FR_ATR_RXVAL_* 
     389   * 
     390   * FR_ATR_MASK_{0,1,2,3}:  
     391   * 
     392   *   These registers determine which of the daugherboard i/o pins are 
     393   *   affected by ATR switching.  If a bit in the mask is set, the 
     394   *   corresponding i/o bit is controlled by ATR, else it's output 
     395   *   value comes from the normal i/o pin output register: 
     396   *   FR_IO_{0,1,2,3}. 
     397   * 
     398   * FR_ATR_TXVAL_{0,1,2,3}: 
     399   * FR_ATR_RXVAL_{0,1,2,3}: 
     400   * 
     401   *   If the Tx fifo contains data, then the bits from TXVAL that are 
     402   *   selected by MASK are output.  Otherwise, the bits from RXVAL that 
     403   *   are selected by MASK are output. 
     404   * </pre> 
     405   */ 
     406  bool common_write_atr_mask(txrx_t txrx, int which_side, int value); 
     407  bool common_write_atr_txval(txrx_t txrx, int which_side, int value); 
     408  bool common_write_atr_rxval(txrx_t txrx, int which_side, int value); 
     409 
     410  /*! 
    343411   * \brief Write auxiliary digital to analog converter. 
    344412   * 
     
    455523   */ 
    456524  virtual int read_io (int which_side) = 0; 
     525 
     526  /*! 
     527   * \brief Write daughterboard refclk config register 
     528   * 
     529   * \param which_side  [0,1] which d'board 
     530   * \param value       value to write into register, see below 
     531   * 
     532   * <pre> 
     533   * Control whether a reference clock is sent to the daughterboards, 
     534   * and what frequency.  The refclk is sent on d'board i/o pin 0. 
     535   *  
     536   *     3                   2                   1                        
     537   *   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 
     538   *  +-----------------------------------------------+-+------------+ 
     539   *  |             Reserved (Must be zero)           |E|   DIVISOR  | 
     540   *  +-----------------------------------------------+-+------------+ 
     541   *  
     542   *  Bit 7  -- 1 turns on refclk, 0 allows IO use 
     543   *  Bits 6:0 Divider value 
     544   * </pre> 
     545   */ 
     546  virtual bool write_refclk(int which_side, int value) = 0; 
     547 
     548  virtual bool write_atr_mask(int which_side, int value) = 0; 
     549  virtual bool write_atr_txval(int which_side, int value) = 0; 
     550  virtual bool write_atr_rxval(int which_side, int value) = 0; 
    457551 
    458552  /*! 
     
    703797  bool read_io (int which_side, int *value); 
    704798  int read_io (int which_side); 
     799  bool write_refclk(int which_side, int value); 
     800  bool write_atr_mask(int which_side, int value); 
     801  bool write_atr_txval(int which_side, int value); 
     802  bool write_atr_rxval(int which_side, int value); 
    705803 
    706804  bool write_aux_dac (int which_side, int which_dac, int value); 
     
    815913  bool read_io (int which_side, int *value); 
    816914  int read_io (int which_side); 
     915  bool write_refclk(int which_side, int value); 
     916  bool write_atr_mask(int which_side, int value); 
     917  bool write_atr_txval(int which_side, int value); 
     918  bool write_atr_rxval(int which_side, int value); 
    817919 
    818920  bool write_aux_dac (int which_side, int which_dac, int value);