| Line No. | Rev | Author | Line |
|---|---|---|---|
| 1 | 6 | kaklik | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| 2 | <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> |
||
| 3 | <title>Procyon AVRlib: net/cs8900.c Source File</title> |
||
| 4 | <link href="dox.css" rel="stylesheet" type="text/css"> |
||
| 5 | </head><body> |
||
| 6 | <!-- Generated by Doxygen 1.4.2 --> |
||
| 7 | <div class="qindex"><a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a></div> |
||
| 8 | <div class="nav"> |
||
| 9 | <a class="el" href="dir_000001.html">net</a></div> |
||
| 10 | <h1>cs8900.c</h1><a href="cs8900_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="comment">/*! \file cs8900.c \brief Crystal CS8900 Ethernet Interface Driver. */</span> |
||
| 11 | 00002 <span class="comment">//*****************************************************************************</span> |
||
| 12 | 00003 <span class="comment">//</span> |
||
| 13 | 00004 <span class="comment">// File Name : 'cs8900.c'</span> |
||
| 14 | 00005 <span class="comment">// Title : Crystal CS8900 Ethernet Interface Driver</span> |
||
| 15 | 00006 <span class="comment">// Author : Pascal Stang</span> |
||
| 16 | 00007 <span class="comment">// Created : 11/7/2004</span> |
||
| 17 | 00008 <span class="comment">// Revised : 11/7/2004</span> |
||
| 18 | 00009 <span class="comment">// Version : 0.1</span> |
||
| 19 | 00010 <span class="comment">// Target MCU : Atmel AVR series</span> |
||
| 20 | 00011 <span class="comment">// Editor Tabs : 4</span> |
||
| 21 | 00012 <span class="comment">//</span> |
||
| 22 | 00013 <span class="comment">//*****************************************************************************</span> |
||
| 23 | 00014 |
||
| 24 | 00015 <span class="preprocessor">#include "<a class="code" href="global_8h.html">global.h</a>"</span> |
||
| 25 | 00016 <span class="preprocessor">#include "<a class="code" href="timer_8h.html">timer.h</a>"</span> |
||
| 26 | 00017 <span class="preprocessor">#include "<a class="code" href="rprintf_8h.html">rprintf.h</a>"</span> |
||
| 27 | 00018 |
||
| 28 | 00019 <span class="preprocessor">#include "<a class="code" href="cs8900_8h.html">cs8900.h</a>"</span> |
||
| 29 | 00020 |
||
| 30 | 00021 <span class="comment">// include configuration</span> |
||
| 31 | 00022 <span class="preprocessor">#include "<a class="code" href="cs8900conf_8h.html">cs8900conf.h</a>"</span> |
||
| 32 | 00023 |
||
| 33 | <a name="l00024"></a><a class="code" href="group__nic.html#ga0">00024</a> <span class="keywordtype">void</span> <a class="code" href="group__nic.html#ga0">nicInit</a>(<span class="keywordtype">void</span>) |
||
| 34 | 00025 { |
||
| 35 | 00026 cs8900Init(); |
||
| 36 | 00027 } |
||
| 37 | 00028 |
||
| 38 | <a name="l00029"></a><a class="code" href="group__nic.html#ga1">00029</a> <span class="keywordtype">void</span> <a class="code" href="group__nic.html#ga1">nicSend</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> len, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>* packet) |
||
| 39 | 00030 { |
||
| 40 | 00031 u08 timeout = 15; |
||
| 41 | 00032 |
||
| 42 | 00033 <span class="comment">// request space in CS8900's on-chip memory for storing an outgoing frame</span> |
||
| 43 | 00034 cs8900Write16(CS8900_IO_TXCMD, TX_START_ALL_BYTES); |
||
| 44 | 00035 cs8900Write16(CS8900_IO_TXLENGTH, len); |
||
| 45 | 00036 <span class="comment">// check if CS8900 is ready to accept the frame we want to send</span> |
||
| 46 | 00037 <span class="comment">// (timeout after 1.5ms since it should only take 1.25ms to</span> |
||
| 47 | 00038 <span class="comment">// finish sending previous frame. If we timeout, it's probably</span> |
||
| 48 | 00039 <span class="comment">// because there's no link, no ethernet cable.)</span> |
||
| 49 | 00040 <span class="keywordflow">while</span>(!(cs8900ReadReg(PP_BusST) & READY_FOR_TX_NOW) && timeout) |
||
| 50 | 00041 { |
||
| 51 | 00042 <span class="comment">// wait 100us</span> |
||
| 52 | 00043 delay_us(100); |
||
| 53 | 00044 timeout--; |
||
| 54 | 00045 } |
||
| 55 | 00046 <span class="comment">// write packet data bytes</span> |
||
| 56 | 00047 cs8900CopyToFrame(packet, len); |
||
| 57 | 00048 |
||
| 58 | 00049 <span class="comment">// packet is automatically sent upon completion of above write</span> |
||
| 59 | 00050 } |
||
| 60 | 00051 |
||
| 61 | <a name="l00052"></a><a class="code" href="group__nic.html#ga2">00052</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="group__nic.html#ga2">nicPoll</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> maxlen, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>* packet) |
||
| 62 | 00053 { |
||
| 63 | 00054 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> packetLength; |
||
| 64 | 00055 |
||
| 65 | 00056 packetLength = cs8900BeginPacketRetreive(); |
||
| 66 | 00057 |
||
| 67 | 00058 <span class="comment">// if there's no packet or an error - exit without ending the operation</span> |
||
| 68 | 00059 <span class="keywordflow">if</span>( !packetLength ) |
||
| 69 | 00060 <span class="keywordflow">return</span> 0; |
||
| 70 | 00061 |
||
| 71 | 00062 <span class="comment">// drop anything too big for the buffer</span> |
||
| 72 | 00063 <span class="keywordflow">if</span>( packetLength > maxlen ) |
||
| 73 | 00064 { |
||
| 74 | 00065 cs8900EndPacketRetreive(); |
||
| 75 | 00066 <span class="keywordflow">return</span> 0; |
||
| 76 | 00067 } |
||
| 77 | 00068 |
||
| 78 | 00069 <span class="comment">// copy the packet data into the packet buffer</span> |
||
| 79 | 00070 cs8900RetreivePacketData( packet, packetLength ); |
||
| 80 | 00071 cs8900EndPacketRetreive(); |
||
| 81 | 00072 |
||
| 82 | 00073 <span class="keywordflow">return</span> packetLength; |
||
| 83 | 00074 } |
||
| 84 | 00075 |
||
| 85 | 00076 <span class="keywordtype">void</span> nicGetMacAddress(u08* macaddr) |
||
| 86 | 00077 { |
||
| 87 | 00078 <span class="comment">// read MAC address registers</span> |
||
| 88 | 00079 <span class="comment">// TODO: check byte order here!</span> |
||
| 89 | 00080 *((<span class="keywordtype">unsigned</span> <span class="keywordtype">short</span>*)(macaddr+0)) = cs8900ReadReg(PP_IA+0); |
||
| 90 | 00081 *((<span class="keywordtype">unsigned</span> <span class="keywordtype">short</span>*)(macaddr+2)) = cs8900ReadReg(PP_IA+2); |
||
| 91 | 00082 *((<span class="keywordtype">unsigned</span> <span class="keywordtype">short</span>*)(macaddr+4)) = cs8900ReadReg(PP_IA+4); |
||
| 92 | 00083 } |
||
| 93 | 00084 |
||
| 94 | 00085 <span class="keywordtype">void</span> nicSetMacAddress(u08* macaddr) |
||
| 95 | 00086 { |
||
| 96 | 00087 <span class="comment">// write MAC address registers</span> |
||
| 97 | 00088 cs8900WriteReg(PP_IA+0, (macaddr[1]<<8) + macaddr[0] ); |
||
| 98 | 00089 cs8900WriteReg(PP_IA+2, (macaddr[3]<<8) + macaddr[2] ); |
||
| 99 | 00090 cs8900WriteReg(PP_IA+4, (macaddr[5]<<8) + macaddr[4] ); |
||
| 100 | 00091 } |
||
| 101 | 00092 |
||
| 102 | 00093 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> cs8900BeginPacketRetreive(<span class="keywordtype">void</span>) |
||
| 103 | 00094 { |
||
| 104 | 00095 <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> status; |
||
| 105 | 00096 |
||
| 106 | 00097 <span class="comment">// check RxEvent</span> |
||
| 107 | 00098 status = cs8900ReadReg(PP_RxEvent); |
||
| 108 | 00099 |
||
| 109 | 00100 <span class="keywordflow">if</span>( !((status&RX_OK)||(status&RX_IA)||(status&RX_BROADCAST)) ) |
||
| 110 | 00101 { |
||
| 111 | 00102 <span class="keywordflow">return</span> 0; |
||
| 112 | 00103 } |
||
| 113 | 00104 |
||
| 114 | 00105 <span class="comment">// return cs8900ReadReg(PP_RxFrameByteCnt);</span> |
||
| 115 | 00106 <span class="comment">// read RxStatus high-byte first</span> |
||
| 116 | 00107 status = cs8900Read(CS8900_IO_RXTX_DATA_PORT0+1)<<8; |
||
| 117 | 00108 status |= cs8900Read(CS8900_IO_RXTX_DATA_PORT0+0); |
||
| 118 | 00109 <span class="comment">// read packet length high-byte first</span> |
||
| 119 | 00110 status = cs8900Read(CS8900_IO_RXTX_DATA_PORT0+1)<<8; |
||
| 120 | 00111 status |= cs8900Read(CS8900_IO_RXTX_DATA_PORT0+0); |
||
| 121 | 00112 |
||
| 122 | 00113 <span class="keywordflow">return</span> status; |
||
| 123 | 00114 } |
||
| 124 | 00115 |
||
| 125 | 00116 <span class="keywordtype">void</span> cs8900RetreivePacketData(u08* packet, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> packetLength ) |
||
| 126 | 00117 { |
||
| 127 | 00118 cs8900CopyFromFrame(packet, packetLength); |
||
| 128 | 00119 } |
||
| 129 | 00120 |
||
| 130 | 00121 <span class="keywordtype">void</span> cs8900EndPacketRetreive(<span class="keywordtype">void</span>) |
||
| 131 | 00122 { |
||
| 132 | 00123 <span class="comment">// dummy read first four bytes</span> |
||
| 133 | 00124 <span class="comment">//cs8900CopyFromFrame(packet, 4);</span> |
||
| 134 | 00125 } |
||
| 135 | 00126 |
||
| 136 | 00127 |
||
| 137 | 00128 |
||
| 138 | 00129 <span class="keywordtype">void</span> cs8900InitPorts(<span class="keywordtype">void</span>) |
||
| 139 | 00130 { |
||
| 140 | 00131 <span class="preprocessor">#if MEMORY_MAPPED_NIC == 1</span> |
||
| 141 | 00132 <span class="preprocessor"></span> <span class="comment">// enable external SRAM interface - no wait states</span> |
||
| 142 | 00133 sbi(MCUSR, SRE); |
||
| 143 | 00134 <span class="preprocessor">#else</span> |
||
| 144 | 00135 <span class="preprocessor"></span> <span class="comment">// set address port to output</span> |
||
| 145 | 00136 outb(CS8900_ADDRESS_DDR, CS8900_ADDRESS_MASK); |
||
| 146 | 00137 |
||
| 147 | 00138 <span class="comment">// set data port to input with pull-ups</span> |
||
| 148 | 00139 outb(CS8900_DATA_DDR, 0x00); |
||
| 149 | 00140 outb(CS8900_DATA_PORT, 0xFF); |
||
| 150 | 00141 |
||
| 151 | 00142 <span class="comment">// initialize the control port read and write pins to de-asserted</span> |
||
| 152 | 00143 sbi( CS8900_CONTROL_PORT, CS8900_CONTROL_READPIN ); |
||
| 153 | 00144 sbi( CS8900_CONTROL_PORT, CS8900_CONTROL_WRITEPIN ); |
||
| 154 | 00145 <span class="comment">// set the read and write pins to output</span> |
||
| 155 | 00146 sbi( CS8900_CONTROL_DDR, CS8900_CONTROL_READPIN ); |
||
| 156 | 00147 sbi( CS8900_CONTROL_DDR, CS8900_CONTROL_WRITEPIN ); |
||
| 157 | 00148 <span class="preprocessor">#endif</span> |
||
| 158 | 00149 <span class="preprocessor"></span> <span class="comment">// set reset pin to output</span> |
||
| 159 | 00150 sbi( CS8900_RESET_DDR, CS8900_RESET_PIN ); |
||
| 160 | 00151 } |
||
| 161 | 00152 |
||
| 162 | 00153 <span class="keywordtype">void</span> cs8900Init(<span class="keywordtype">void</span>) |
||
| 163 | 00154 { |
||
| 164 | 00155 cs8900InitPorts(); |
||
| 165 | 00156 |
||
| 166 | 00157 <span class="comment">// assert hardware reset</span> |
||
| 167 | 00158 sbi( CS8900_RESET_PORT, CS8900_RESET_PIN ); |
||
| 168 | 00159 <span class="comment">// wait</span> |
||
| 169 | 00160 delay_ms(10); |
||
| 170 | 00161 <span class="comment">// release hardware reset</span> |
||
| 171 | 00162 cbi( CS8900_RESET_PORT, CS8900_RESET_PIN ); |
||
| 172 | 00163 delay_ms(10); |
||
| 173 | 00164 |
||
| 174 | 00165 <span class="comment">// Reset the Ethernet-Controller</span> |
||
| 175 | 00166 cs8900Write16(CS8900_IO_PP_PTR, PP_SelfCTL); |
||
| 176 | 00167 cs8900Write16(CS8900_IO_PP_DATA_PORT0, POWER_ON_RESET); |
||
| 177 | 00168 <span class="comment">// wait until chip-reset is done</span> |
||
| 178 | 00169 cs8900Write16(CS8900_IO_PP_PTR, PP_SelfST); |
||
| 179 | 00170 <span class="keywordflow">while</span>(!(cs8900Read16(CS8900_IO_PP_DATA_PORT0) & INIT_DONE)); |
||
| 180 | 00171 |
||
| 181 | 00172 <span class="comment">// set our MAC as Individual Address</span> |
||
| 182 | 00173 cs8900WriteReg(PP_IA+0, (CS8900_MAC1<<8) + CS8900_MAC0 ); |
||
| 183 | 00174 cs8900WriteReg(PP_IA+2, (CS8900_MAC3<<8) + CS8900_MAC2 ); |
||
| 184 | 00175 cs8900WriteReg(PP_IA+4, (CS8900_MAC5<<8) + CS8900_MAC4 ); |
||
| 185 | 00176 <span class="comment">// configure the Physical Interface</span> |
||
| 186 | 00177 cs8900WriteReg(PP_LineCTL, SERIAL_RX_ON | SERIAL_TX_ON); |
||
| 187 | 00178 cs8900WriteReg(PP_RxCTL, RX_OK_ACCEPT | RX_IA_ACCEPT | RX_BROADCAST_ACCEPT ); |
||
| 188 | 00179 } |
||
| 189 | 00180 |
||
| 190 | 00181 <span class="keywordtype">void</span> cs8900Write(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> address, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> data) |
||
| 191 | 00182 { |
||
| 192 | 00183 <span class="comment">// assert the address</span> |
||
| 193 | 00184 outb(CS8900_ADDRESS_PORT, address | (inb(CS8900_ADDRESS_PORT)&~CS8900_ADDRESS_MASK)); |
||
| 194 | 00185 <span class="comment">// set data bus as output</span> |
||
| 195 | 00186 outb(CS8900_DATA_DDR, 0xFF); |
||
| 196 | 00187 <span class="comment">// place data on bus</span> |
||
| 197 | 00188 outb(CS8900_DATA_PORT, data); |
||
| 198 | 00189 <span class="comment">// clock write pin</span> |
||
| 199 | 00190 cbi(CS8900_CONTROL_PORT, CS8900_CONTROL_WRITEPIN); |
||
| 200 | 00191 nop(); |
||
| 201 | 00192 nop(); |
||
| 202 | 00193 nop(); |
||
| 203 | 00194 nop(); |
||
| 204 | 00195 sbi(CS8900_CONTROL_PORT, CS8900_CONTROL_WRITEPIN); |
||
| 205 | 00196 <span class="comment">// set data bus back to input with pullups enabled</span> |
||
| 206 | 00197 outb(CS8900_DATA_DDR, 0x00); |
||
| 207 | 00198 outb(CS8900_DATA_PORT, 0xFF); |
||
| 208 | 00199 } |
||
| 209 | 00200 |
||
| 210 | 00201 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> cs8900Read(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> address) |
||
| 211 | 00202 { |
||
| 212 | 00203 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> data; |
||
| 213 | 00204 <span class="comment">// assert the address</span> |
||
| 214 | 00205 outb(CS8900_ADDRESS_PORT, address | (inb(CS8900_ADDRESS_PORT)&~CS8900_ADDRESS_MASK)); |
||
| 215 | 00206 <span class="comment">// set data bus to input with pullups enabled</span> |
||
| 216 | 00207 outb(CS8900_DATA_DDR, 0x00); |
||
| 217 | 00208 outb(CS8900_DATA_PORT, 0xFF); |
||
| 218 | 00209 <span class="comment">// assert read</span> |
||
| 219 | 00210 cbi(CS8900_CONTROL_PORT, CS8900_CONTROL_READPIN); |
||
| 220 | 00211 nop(); |
||
| 221 | 00212 nop(); |
||
| 222 | 00213 nop(); |
||
| 223 | 00214 nop(); |
||
| 224 | 00215 <span class="comment">// read in the data</span> |
||
| 225 | 00216 data = inb( CS8900_DATA_PIN ); |
||
| 226 | 00217 <span class="comment">// negate read</span> |
||
| 227 | 00218 sbi(CS8900_CONTROL_PORT, CS8900_CONTROL_READPIN); |
||
| 228 | 00219 <span class="comment">// return data</span> |
||
| 229 | 00220 <span class="keywordflow">return</span> data; |
||
| 230 | 00221 } |
||
| 231 | 00222 |
||
| 232 | 00223 <span class="keywordtype">void</span> cs8900Write16(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> address, <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> data) |
||
| 233 | 00224 { |
||
| 234 | 00225 cs8900Write(address+0, data); |
||
| 235 | 00226 cs8900Write(address+1, data>>8); |
||
| 236 | 00227 } |
||
| 237 | 00228 |
||
| 238 | 00229 <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> cs8900Read16(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> address) |
||
| 239 | 00230 { |
||
| 240 | 00231 <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> data; |
||
| 241 | 00232 data = cs8900Read(address+0); |
||
| 242 | 00233 data |= cs8900Read(address+1)<<8; |
||
| 243 | 00234 <span class="keywordflow">return</span> data; |
||
| 244 | 00235 } |
||
| 245 | 00236 |
||
| 246 | 00237 <span class="comment">// writes a word in little-endian byte order to a specified PacketPage address</span> |
||
| 247 | 00238 <span class="keywordtype">void</span> cs8900WriteReg(<span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> address, <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> data) |
||
| 248 | 00239 { |
||
| 249 | 00240 cs8900Write16(CS8900_IO_PP_PTR, address); |
||
| 250 | 00241 cs8900Write16(CS8900_IO_PP_DATA_PORT0, data); |
||
| 251 | 00242 } |
||
| 252 | 00243 |
||
| 253 | 00244 <span class="comment">// reads a word in little-endian byte order from a specified PacketPage address</span> |
||
| 254 | 00245 <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> cs8900ReadReg(<span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> address) |
||
| 255 | 00246 { |
||
| 256 | 00247 cs8900Write16(CS8900_IO_PP_PTR, address); |
||
| 257 | 00248 <span class="keywordflow">return</span> cs8900Read16(CS8900_IO_PP_DATA_PORT0); |
||
| 258 | 00249 } |
||
| 259 | 00250 |
||
| 260 | 00251 <span class="comment">// copies bytes from MCU-memory to frame port</span> |
||
| 261 | 00252 <span class="comment">// NOTES: * an odd number of byte may only be transfered</span> |
||
| 262 | 00253 <span class="comment">// if the frame is written to the end!</span> |
||
| 263 | 00254 <span class="comment">// * MCU-memory MUST start at word-boundary</span> |
||
| 264 | 00255 |
||
| 265 | 00256 <span class="keywordtype">void</span> cs8900CopyToFrame(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *source, <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> size) |
||
| 266 | 00257 { |
||
| 267 | 00258 <span class="keywordflow">while</span>(size>1) |
||
| 268 | 00259 { |
||
| 269 | 00260 cs8900Write16(CS8900_IO_RXTX_DATA_PORT0, *((<span class="keywordtype">unsigned</span> <span class="keywordtype">short</span>*)source)); |
||
| 270 | 00261 source += 2; |
||
| 271 | 00262 size -= 2; |
||
| 272 | 00263 } |
||
| 273 | 00264 <span class="comment">// if odd num. of bytes...</span> |
||
| 274 | 00265 <span class="comment">// write leftover byte (the LAN-controller ignores the highbyte)</span> |
||
| 275 | 00266 <span class="keywordflow">if</span>(size) |
||
| 276 | 00267 cs8900Write16(CS8900_IO_RXTX_DATA_PORT0, *(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>*)source); |
||
| 277 | 00268 } |
||
| 278 | 00269 |
||
| 279 | 00270 <span class="comment">// copies bytes from frame port to MCU-memory</span> |
||
| 280 | 00271 <span class="comment">// NOTES: * an odd number of byte may only be transfered</span> |
||
| 281 | 00272 <span class="comment">// if the frame is read to the end!</span> |
||
| 282 | 00273 <span class="comment">// * MCU-memory MUST start at word-boundary</span> |
||
| 283 | 00274 |
||
| 284 | 00275 <span class="keywordtype">void</span> cs8900CopyFromFrame(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *dest, <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> size) |
||
| 285 | 00276 { |
||
| 286 | 00277 <span class="keywordflow">while</span>(size>1) |
||
| 287 | 00278 { |
||
| 288 | 00279 *((<span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> *)dest) = cs8900Read16(CS8900_IO_RXTX_DATA_PORT0); |
||
| 289 | 00280 dest += 2; |
||
| 290 | 00281 size -= 2; |
||
| 291 | 00282 } |
||
| 292 | 00283 |
||
| 293 | 00284 <span class="comment">// check for leftover byte...</span> |
||
| 294 | 00285 <span class="comment">// the LAN-Controller will return 0 for the highbyte</span> |
||
| 295 | 00286 <span class="keywordflow">if</span>(size) |
||
| 296 | 00287 *(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *)dest = cs8900Read16(CS8900_IO_RXTX_DATA_PORT0); |
||
| 297 | 00288 } |
||
| 298 | 00289 |
||
| 299 | 00290 <span class="keywordtype">void</span> cs8900IORegDump(<span class="keywordtype">void</span>) |
||
| 300 | 00291 { |
||
| 301 | 00292 <a class="code" href="group__rprintf.html#ga15">rprintfProgStrM</a>(<span class="stringliteral">"CS8900 I/O Registers\r\n"</span>); |
||
| 302 | 00293 <a class="code" href="group__rprintf.html#ga15">rprintfProgStrM</a>(<span class="stringliteral">" FRAME ISQ ADDR DATA0 DATA1\r\n"</span>); |
||
| 303 | 00294 <a class="code" href="group__rprintf.html#ga15">rprintfProgStrM</a>(<span class="stringliteral">"-------------------------------\r\n"</span>); |
||
| 304 | 00295 <a class="code" href="group__rprintf.html#ga15">rprintfProgStrM</a>(<span class="stringliteral">" "</span>); |
||
| 305 | 00296 <a class="code" href="group__rprintf.html#ga8">rprintfu16</a>(cs8900Read16(CS8900_IO_RXTX_DATA_PORT0)); |
||
| 306 | 00297 <a class="code" href="group__rprintf.html#ga15">rprintfProgStrM</a>(<span class="stringliteral">" "</span>); |
||
| 307 | 00298 <a class="code" href="group__rprintf.html#ga8">rprintfu16</a>(cs8900Read16(CS8900_IO_ISQ)); |
||
| 308 | 00299 <a class="code" href="group__rprintf.html#ga15">rprintfProgStrM</a>(<span class="stringliteral">" "</span>); |
||
| 309 | 00300 <a class="code" href="group__rprintf.html#ga8">rprintfu16</a>(cs8900Read16(CS8900_IO_PP_PTR)); |
||
| 310 | 00301 <a class="code" href="group__rprintf.html#ga15">rprintfProgStrM</a>(<span class="stringliteral">" "</span>); |
||
| 311 | 00302 <a class="code" href="group__rprintf.html#ga8">rprintfu16</a>(cs8900Read16(CS8900_IO_PP_DATA_PORT0)); |
||
| 312 | 00303 <a class="code" href="group__rprintf.html#ga15">rprintfProgStrM</a>(<span class="stringliteral">" "</span>); |
||
| 313 | 00304 <a class="code" href="group__rprintf.html#ga8">rprintfu16</a>(cs8900Read16(CS8900_IO_PP_DATA_PORT1)); |
||
| 314 | 00305 <a class="code" href="group__rprintf.html#ga5">rprintfCRLF</a>(); |
||
| 315 | 00306 } |
||
| 316 | 00307 |
||
| 317 | 00308 <span class="keywordtype">void</span> cs8900RegDump(<span class="keywordtype">void</span>) |
||
| 318 | 00309 { |
||
| 319 | 00310 <a class="code" href="group__rprintf.html#ga15">rprintfProgStrM</a>(<span class="stringliteral">"CS8900 PacketPage Registers\r\n"</span>); |
||
| 320 | 00311 <a class="code" href="group__rprintf.html#ga15">rprintfProgStrM</a>(<span class="stringliteral">"CHIP ID: "</span>); |
||
| 321 | 00312 <a class="code" href="group__rprintf.html#ga8">rprintfu16</a>(cs8900ReadReg(PP_ChipID)); |
||
| 322 | 00313 <a class="code" href="group__rprintf.html#ga5">rprintfCRLF</a>(); |
||
| 323 | 00314 |
||
| 324 | 00315 <a class="code" href="group__rprintf.html#ga15">rprintfProgStrM</a>(<span class="stringliteral">"PP_ISAIOB: "</span>); |
||
| 325 | 00316 <a class="code" href="group__rprintf.html#ga8">rprintfu16</a>(cs8900ReadReg(PP_ISAIOB)); |
||
| 326 | 00317 <a class="code" href="group__rprintf.html#ga5">rprintfCRLF</a>(); |
||
| 327 | 00318 |
||
| 328 | 00319 <a class="code" href="group__rprintf.html#ga15">rprintfProgStrM</a>(<span class="stringliteral">"MAC addr: "</span>); |
||
| 329 | 00320 <a class="code" href="group__rprintf.html#ga8">rprintfu16</a>(cs8900ReadReg(PP_IA+0)); |
||
| 330 | 00321 <a class="code" href="group__rprintf.html#ga8">rprintfu16</a>(cs8900ReadReg(PP_IA+2)); |
||
| 331 | 00322 <a class="code" href="group__rprintf.html#ga8">rprintfu16</a>(cs8900ReadReg(PP_IA+4)); |
||
| 332 | 00323 <a class="code" href="group__rprintf.html#ga5">rprintfCRLF</a>(); |
||
| 333 | 00324 } |
||
| 334 | 00325 |
||
| 335 | <a name="l00326"></a><a class="code" href="group__nic.html#ga5">00326</a> <span class="keywordtype">void</span> <a class="code" href="group__nic.html#ga5">nicRegDump</a>(<span class="keywordtype">void</span>) |
||
| 336 | 00327 { |
||
| 337 | 00328 cs8900IORegDump(); |
||
| 338 | 00329 cs8900RegDump(); |
||
| 339 | 00330 } |
||
| 340 | 00331 |
||
| 341 | 00332 |
||
| 342 | 00333 u08 cs8900LinkStatus(<span class="keywordtype">void</span>) |
||
| 343 | 00334 { |
||
| 344 | 00335 <span class="keywordflow">if</span>(cs8900ReadReg(PP_LineST) & LINK_OK) |
||
| 345 | 00336 <span class="keywordflow">return</span> 1; |
||
| 346 | 00337 <span class="keywordflow">else</span> |
||
| 347 | 00338 <span class="keywordflow">return</span> 0; |
||
| 348 | 00339 } |
||
| 349 | </pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Oct 29 03:41:07 2006 for Procyon AVRlib by |
||
| 350 | <a href="http://www.doxygen.org/index.html"> |
||
| 351 | <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.2 </small></address> |
||
| 352 | </body> |
||
| 353 | </html> |
Powered by WebSVN v2.8.3