OpenCores
URL https://opencores.org/ocsvn/tv80/tv80/trunk

Subversion Repositories tv80

[/] [tv80/] [trunk/] [tests/] [nwtest.c] - Blame information for rev 84

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 54 ghutchis
//
2
// Copyright (c) 2004 Guy Hutchison (ghutchis@opencores.org)
3
//
4
// Permission is hereby granted, free of charge, to any person obtaining a 
5
// copy of this software and associated documentation files (the "Software"), 
6
// to deal in the Software without restriction, including without limitation 
7
// the rights to use, copy, modify, merge, publish, distribute, sublicense, 
8
// and/or sell copies of the Software, and to permit persons to whom the 
9
// Software is furnished to do so, subject to the following conditions:
10
//
11
// The above copyright notice and this permission notice shall be included 
12
// in all copies or substantial portions of the Software.
13
//
14
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
15
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
16
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
17
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 
18
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
19
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 
20
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
//
22
//
23
//  IO-interface:
24
//    R0  --  Status register
25
//    R1  --  Control register
26
//    R2  --  RX Length (low)
27
//    R3  --  RX Length (high)
28
//    R4  --  RX Data
29
//    R5  --  TX Data
30
//    R6  --  Configuration
31
//
32
sfr at 0x08 nw_status;
33 68 ghutchis
sfr at 0x09 nw_status_msk;
34
sfr at 0x0A nw_control;
35
sfr at 0x0B nw_rx_cnt_low;
36
sfr at 0x0C nw_rx_cnt_high;
37
sfr at 0x0D nw_rx_data;
38
sfr at 0x0E nw_tx_data;
39
sfr at 0x0F nw_config;
40 54 ghutchis
 
41
sfr at 0x80 sim_ctl_port;
42
sfr at 0x81 msg_port;
43
sfr at 0x82 timeout_port;
44
 
45
void print (char *string)
46
{
47
  char *iter;
48
 
49
  iter = string;
50
  while (*iter != 0) {
51
    msg_port = *iter++;
52
  }
53
}
54
 
55
char rxbuf[128];
56
 
57
int main ()
58
{
59
  //print ("Hello, world!\n");
60
 
61
  int i, rx_count;
62
 
63 68 ghutchis
  // configure nwintf to use preambles
64
  nw_config = 1;
65
 
66 54 ghutchis
  // send packet to buffer and trigger transmit
67
  for (i=0; i<64; i++)
68
    nw_tx_data = i;
69
 
70
  nw_control = 1;
71
 
72 68 ghutchis
  // wait for packet to be sent
73
  while ((nw_status & 0x02) != 2) ;
74
 
75
  // check and clear the TX status bit
76
  //if ((nw_status & 0x02) != 2)
77
  //sim_ctl_port = 0x02;
78
    //else
79
  nw_status = 0x02;
80
 
81 54 ghutchis
  // wait for packet to arrive on loopback
82
  while ((nw_status & 0x01) != 1)
83
    ;
84
 
85
  rx_count = nw_rx_cnt_low | (nw_rx_cnt_high << 8);
86
 
87
  if (rx_count != 64)
88
    sim_ctl_port = 0x02;
89
 
90
  // pull all the data from the interface into a buffer
91 57 ghutchis
  //for (i=0; i<rx_count; i++)
92
  //  rxbuf[i] = nw_rx_data;
93
  _asm
94
    in    a, (_nw_rx_cnt_low)
95
    ld    b, a
96
    ld    hl, #_rxbuf
97
    ld    c, #_nw_rx_data
98
    inir
99
  _endasm;
100 54 ghutchis
 
101 68 ghutchis
  // clear the RX status bit
102
  nw_status = 0x01;
103
 
104 54 ghutchis
  // check the status bit
105 68 ghutchis
  if (nw_status != 0)
106 54 ghutchis
    sim_ctl_port = 0x02;
107
 
108
  // maybe do a checksum here
109
  sim_ctl_port = 0x01;
110
 
111
  return 0;
112
}
113
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.