Changeset 9761
- Timestamp:
- 10/08/08 22:22:38
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_basic.cc
r9748 r9761 29 29 #include "usrp_interfaces.h" 30 30 #include "fpga_regs_common.h" 31 #include "fpga_regs_standard.h" 31 32 #include "fusb.h" 32 33 #include <usb.h> … … 426 427 } 427 428 429 bool 430 usrp_basic::write_atr_tx_delay(int value) 431 { 432 return _write_fpga_reg(FR_ATR_TX_DELAY, value); 433 } 434 435 bool 436 usrp_basic::write_atr_rx_delay(int value) 437 { 438 return _write_fpga_reg(FR_ATR_RX_DELAY, value); 439 } 440 428 441 /* 429 442 * ---------------------------------------------------------------- … … 448 461 449 462 static int 463 slot_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 470 static int 471 slot_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 478 static int 479 slot_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 486 static int 487 slot_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 494 static int 450 495 to_slot(txrx_t txrx, int which_side) 451 496 { … … 588 633 return READ_FAILED; 589 634 return value; 635 } 636 637 bool 638 usrp_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 647 bool 648 usrp_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 657 bool 658 usrp_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 667 bool 668 usrp_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); 590 675 } 591 676 … … 676 761 fusb_block_size, fusb_nblocks); 677 762 678 _write_fpga_reg(FR_ATR_MASK_1, 0); // zero Rx sideAuto Transmit/Receive regs679 _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); 684 769 } 685 770 … … 932 1017 933 1018 bool 1019 usrp_basic_rx::write_refclk(int which_side, int value) 1020 { 1021 return common_write_refclk(C_RX, which_side, value); 1022 } 1023 1024 bool 1025 usrp_basic_rx::write_atr_mask(int which_side, int value) 1026 { 1027 return common_write_atr_mask(C_RX, which_side, value); 1028 } 1029 1030 bool 1031 usrp_basic_rx::write_atr_txval(int which_side, int value) 1032 { 1033 return common_write_atr_txval(C_RX, which_side, value); 1034 } 1035 1036 bool 1037 usrp_basic_rx::write_atr_rxval(int which_side, int value) 1038 { 1039 return common_write_atr_rxval(C_RX, which_side, value); 1040 } 1041 1042 bool 934 1043 usrp_basic_rx::write_aux_dac (int which_side, int which_dac, int value) 935 1044 { … … 1038 1147 fusb_block_size, fusb_nblocks); 1039 1148 1040 _write_fpga_reg(FR_ATR_MASK_0, 0); // zero Tx sideAuto Transmit/Receive regs1041 _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); 1046 1155 } 1047 1156 … … 1297 1406 1298 1407 bool 1408 usrp_basic_tx::write_refclk(int which_side, int value) 1409 { 1410 return common_write_refclk(C_TX, which_side, value); 1411 } 1412 1413 bool 1414 usrp_basic_tx::write_atr_mask(int which_side, int value) 1415 { 1416 return common_write_atr_mask(C_TX, which_side, value); 1417 } 1418 1419 bool 1420 usrp_basic_tx::write_atr_txval(int which_side, int value) 1421 { 1422 return common_write_atr_txval(C_TX, which_side, value); 1423 } 1424 1425 bool 1426 usrp_basic_tx::write_atr_rxval(int which_side, int value) 1427 { 1428 return common_write_atr_rxval(C_TX, which_side, value); 1429 } 1430 1431 bool 1299 1432 usrp_basic_tx::write_aux_dac (int which_side, int which_dac, int value) 1300 1433 { gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_basic.h
r9748 r9761 240 240 virtual int daughterboard_id (int which_side) const = 0; 241 241 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 242 255 // ================================================================ 243 256 // Routines to access and control daughterboard specific i/o … … 341 354 342 355 /*! 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 /*! 343 411 * \brief Write auxiliary digital to analog converter. 344 412 * … … 455 523 */ 456 524 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; 457 551 458 552 /*! … … 703 797 bool read_io (int which_side, int *value); 704 798 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); 705 803 706 804 bool write_aux_dac (int which_side, int which_dac, int value); … … 815 913 bool read_io (int which_side, int *value); 816 914 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); 817 919 818 920 bool write_aux_dac (int which_side, int which_dac, int value);
