Subversion Repositories ngs

Rev

Blame | Last modification | View Log | Download | RSS feed | ?url?

  1. /*
  2.  *  INFO:
  3.  *     tap.cpp (C) 2004  Dr. Yuri Klimets (www.jtag.tk, jtagtools.sf.net)  
  4.  *     E-mail: klimets@jtag.tk
  5.  *     Rev. 1.2 - 04.01.2004
  6.  *  
  7.  *  
  8.  *  DESCRIPTION:
  9.  *     Contains implementation of TAP class methods.
  10.  *     For more detailed info - see "tap.h"
  11.  *
  12.  *
  13.  *  DISCLAIMER:
  14.  *     This program is free software; you can redistribute it and/or modify
  15.  *     it under the terms of the GNU General Public License as published by
  16.  *     the Free Software Foundation; either version 2 of the License, or
  17.  *     (at your option) any later version.
  18.  *
  19.  *     This program is distributed in the hope that it will be useful,
  20.  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
  21.  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  22.  *     GNU General Public License for more details.
  23.  *
  24.  *     You should have received a copy of the GNU General Public License
  25.  *     along with this program; if not, write to the Free Software
  26.  *     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  27. */  
  28.  
  29. #include "tap.h"
  30.  
  31. int DP=0x378;           // data port
  32. int SP=0x379;           // status port
  33. int CP=0x37a;           // control port
  34.  
  35. TAP::TAP(int port, int g_size) {
  36.  status=0;
  37.  DP=port;SP=port+1;CP=port+2;
  38.  oldv=0;
  39.  FD=0;
  40.  g_pos=0;
  41. // SET_CTRL();
  42.  _outp(CP,(1<<_BBMV_ON_));
  43.  g_buf=NULL;
  44.  g_buf=new BYTE[g_size+1];
  45.  if (g_buf==NULL) status=TAP_MEMERR;
  46. }
  47.  
  48.  
  49. TAP::~TAP() {
  50.  if (g_buf!=NULL) {delete[] g_buf; g_buf=NULL;}
  51.  _outp(CP,0x00);
  52. }
  53.  
  54.  
  55. void TAP::update() {g_buf[g_pos++]=oldv;}
  56.  
  57. void TAP::realize() {
  58.  DWORD i=0;
  59.  for (i=0;i<g_pos;i++) _outp(DP,g_buf[i]);
  60.  g_pos=0;
  61. }
  62.  
  63. void TAP::set_bit(int bit, int val) {
  64.  BYTE mask=0x01;
  65.  mask<<=bit;
  66.  oldv=(BYTE)(val)?(oldv|mask):(oldv&(0xff^mask));
  67. }
  68.  
  69. BYTE TAP::get_bit(int bit) {
  70.  BYTE s=_inp(SP);
  71.  BYTE mask=0x01;
  72.  mask<<=bit;
  73.  return (BYTE)((s&mask)?0:1);
  74. }
  75.  
  76. void TAP::TCK_CLOCK(int NUM) {
  77.  if (NUM==1) {TCK(1);update();TCK(0);return;}
  78.  for (int i=0;i<(NUM-1);i++) {
  79.      TCK(1);update();TCK(0);update();
  80.  }
  81.  TCK(1);update();TCK(0);    
  82. }
  83.  
  84.