27 uint8 incr_windowfull_retry_cnt(uint8 s)
29 return ++windowfull_retry_cnt[s];
32 void init_windowfull_retry_cnt(uint8 s)
34 windowfull_retry_cnt[s] = 0;
45 uint16 getIINCHIP_RxMAX(uint8 s)
49 uint16 getIINCHIP_TxMAX(uint8 s)
53 uint16 getIINCHIP_RxMASK(uint8 s)
57 uint16 getIINCHIP_TxMASK(uint8 s)
61 uint16 getIINCHIP_RxBASE(uint8 s)
63 return RBUFBASEADDRESS[s];
65 uint16 getIINCHIP_TxBASE(uint8 s)
67 return SBUFBASEADDRESS[s];
69 void IINCHIP_CSoff(
void)
73 void IINCHIP_CSon(
void)
77 uint8 IINCHIP_SpiSendData(uint8 dat)
86 uint8 IINCHIP_WRITE(uint16 addr,uint8 data)
88 IINCHIP_ISR_DISABLE();
93 IINCHIP_SpiSendData((addr & 0xFF00) >> 8);
94 IINCHIP_SpiSendData(addr & 0x00FF);
95 IINCHIP_SpiSendData(0x80);
96 IINCHIP_SpiSendData(0x01);
97 IINCHIP_SpiSendData(data);
101 IINCHIP_ISR_ENABLE();
108 uint8 IINCHIP_READ(uint16 addr)
112 IINCHIP_ISR_DISABLE();
116 IINCHIP_SpiSendData((addr & 0xFF00) >> 8);
117 IINCHIP_SpiSendData(addr & 0x00FF);
118 IINCHIP_SpiSendData(0x00);
119 IINCHIP_SpiSendData(0x01);
120 data = IINCHIP_SpiSendData(0x00);
124 IINCHIP_ISR_ENABLE();
131 uint16 IINCHIP_WRITE_BLOCK(uint16 addr,uint8* buf,uint16 len)
138 IINCHIP_ISR_DISABLE();
143 IINCHIP_SpiSendData(((addr+idx) & 0xFF00) >> 8);
144 IINCHIP_SpiSendData((addr+idx) & 0x00FF);
145 IINCHIP_SpiSendData((0x80 | ((len & 0x7F00) >> 8)));
146 IINCHIP_SpiSendData((len & 0x00FF));
147 for(idx = 0; idx < len; idx++)
149 IINCHIP_SpiSendData(buf[idx]);
154 IINCHIP_ISR_ENABLE();
161 uint16 IINCHIP_READ_BLOCK(uint16 addr, uint8* buf,uint16 len)
165 IINCHIP_ISR_DISABLE();
169 IINCHIP_SpiSendData(((addr+idx) & 0xFF00) >> 8);
170 IINCHIP_SpiSendData((addr+idx) & 0x00FF);
171 IINCHIP_SpiSendData((0x00 | ((len & 0x7F00) >> 8)));
172 IINCHIP_SpiSendData((len & 0x00FF));
174 for(idx = 0; idx < len; idx++)
176 buf[idx] = IINCHIP_SpiSendData(0x00);
182 IINCHIP_ISR_ENABLE();
190 void setGAR(uint8 *addr)
192 IINCHIP_WRITE((WIZC_GAR0),addr[0]);
193 IINCHIP_WRITE((WIZC_GAR1),addr[1]);
194 IINCHIP_WRITE((WIZC_GAR2),addr[2]);
195 IINCHIP_WRITE((WIZC_GAR3),addr[3]);
212 void setSUBR(uint8 *addr)
214 IINCHIP_WRITE((WIZC_SUBR0),addr[0]);
215 IINCHIP_WRITE((WIZC_SUBR1),addr[1]);
216 IINCHIP_WRITE((WIZC_SUBR2),addr[2]);
217 IINCHIP_WRITE((WIZC_SUBR3),addr[3]);
224 void setSHAR(uint8 *addr)
226 IINCHIP_WRITE((WIZC_SHAR0),addr[0]);
227 IINCHIP_WRITE((WIZC_SHAR1),addr[1]);
228 IINCHIP_WRITE((WIZC_SHAR2),addr[2]);
229 IINCHIP_WRITE((WIZC_SHAR3),addr[3]);
230 IINCHIP_WRITE((WIZC_SHAR4),addr[4]);
231 IINCHIP_WRITE((WIZC_SHAR5),addr[5]);
238 void setSIPR(uint8 *addr)
240 IINCHIP_WRITE((WIZC_SIPR0),addr[0]);
241 IINCHIP_WRITE((WIZC_SIPR1),addr[1]);
242 IINCHIP_WRITE((WIZC_SIPR2),addr[2]);
243 IINCHIP_WRITE((WIZC_SIPR3),addr[3]);
249 void getGAR(uint8 *addr)
251 addr[0] = IINCHIP_READ(WIZC_GAR0);
252 addr[1] = IINCHIP_READ(WIZC_GAR1);
253 addr[2] = IINCHIP_READ(WIZC_GAR2);
254 addr[3] = IINCHIP_READ(WIZC_GAR3);
256 void getSUBR(uint8 *addr)
258 addr[0] = IINCHIP_READ(WIZC_SUBR0);
259 addr[1] = IINCHIP_READ(WIZC_SUBR1);
260 addr[2] = IINCHIP_READ(WIZC_SUBR2);
261 addr[3] = IINCHIP_READ(WIZC_SUBR3);
263 void getSHAR(uint8 *addr)
265 addr[0] = IINCHIP_READ(WIZC_SHAR0);
266 addr[1] = IINCHIP_READ(WIZC_SHAR1);
267 addr[2] = IINCHIP_READ(WIZC_SHAR2);
268 addr[3] = IINCHIP_READ(WIZC_SHAR3);
269 addr[4] = IINCHIP_READ(WIZC_SHAR4);
270 addr[5] = IINCHIP_READ(WIZC_SHAR5);
272 void getSIPR(uint8 *addr)
274 addr[0] = IINCHIP_READ(WIZC_SIPR0);
275 addr[1] = IINCHIP_READ(WIZC_SIPR1);
276 addr[2] = IINCHIP_READ(WIZC_SIPR2);
277 addr[3] = IINCHIP_READ(WIZC_SIPR3);
279 void getDIPR(uint8 s, uint8 *addr)
281 addr[0] = IINCHIP_READ(WIZ_SOCK_REG(s, WIZS_DIPR0));
282 addr[1] = IINCHIP_READ(WIZ_SOCK_REG(s, WIZS_DIPR1));
283 addr[2] = IINCHIP_READ(WIZ_SOCK_REG(s, WIZS_DIPR2));
284 addr[3] = IINCHIP_READ(WIZ_SOCK_REG(s, WIZS_DIPR3));
286 void getDPORT(uint8 s, uint16 *port)
288 *port = IINCHIP_READ(WIZ_SOCK_REG(s, WIZS_DPORT0)) << 8;
289 *port += IINCHIP_READ(WIZ_SOCK_REG(s, WIZS_DPORT1));
292 void setMR(uint8 val)
294 IINCHIP_WRITE(WIZC_MR,val);
302 return IINCHIP_READ(WIZC_IR);
316 void setRTR(uint16 timeout)
318 IINCHIP_WRITE(WIZC_RTR0, (uint8)((timeout & 0xff00) >> 8));
319 IINCHIP_WRITE(WIZC_RTR1, (uint8)(timeout & 0x00ff));
328 void setRCR(uint8 retry)
330 IINCHIP_WRITE(WIZC_RCR,retry);
342 void setIMR(uint8 mask)
344 IINCHIP_WRITE(WIZC_IMR,mask);
350 void setSn_MSS(uint8 s, uint16 Sn_MSSR0)
352 IINCHIP_WRITE(Sn_MSSR0(s),(uint8)((Sn_MSSR0 & 0xff00) >> 8));
353 IINCHIP_WRITE((Sn_MSSR0(s) + 1),(uint8)(Sn_MSSR0 & 0x00ff));
356 void setSn_TTL(uint8 s, uint8 ttl)
358 IINCHIP_WRITE(Sn_TTL(s), ttl);
366 void setSn_PROTO(uint8 s, uint8 proto)
368 IINCHIP_WRITE(Sn_PROTO(s),proto);
377 uint8 getSn_IR(uint8 s)
379 return IINCHIP_READ(Sn_IR(s));
386 uint8 getSn_SR(uint8 s)
388 return IINCHIP_READ(Sn_SR(s));
398 uint16 getSn_TX_FSR(uint8 s)
403 val1 = IINCHIP_READ(Sn_TX_FSR0(s));
404 val1 = (val1 << 8) + IINCHIP_READ(Sn_TX_FSR0(s) + 1);
407 val = IINCHIP_READ(Sn_TX_FSR0(s));
408 val = (val << 8) + IINCHIP_READ(Sn_TX_FSR0(s) + 1);
410 }
while (val != val1);
420 uint16 getSn_RX_RSR(uint8 s)
425 val1 = IINCHIP_READ(Sn_RX_RSR0(s));
426 val1 = (val1 << 8) + IINCHIP_READ(Sn_RX_RSR0(s) + 1);
429 val = IINCHIP_READ(Sn_RX_RSR0(s));
430 val = (val << 8) + IINCHIP_READ(Sn_RX_RSR0(s) + 1);
432 }
while (val != val1);
448 void send_data_processing(uint8 s, uint8 *data, uint16 len)
456 ptr = IINCHIP_READ(Sn_TX_WR0(s));
457 ptr = (ptr << 8) + IINCHIP_READ(Sn_TX_WR0(s) + 1);
459 dst_mask = (uint32)ptr & getIINCHIP_TxMASK(s);
460 dst_ptr = (uint8 *)(getIINCHIP_TxBASE(s) + dst_mask);
462 if (dst_mask + len > getIINCHIP_TxMAX(s))
464 size = getIINCHIP_TxMAX(s) - dst_mask;
465 IINCHIP_WRITE_BLOCK((uint32)dst_ptr, (uint8*)data, size);
468 dst_ptr = (uint8 *)(getIINCHIP_TxBASE(s));
469 IINCHIP_WRITE_BLOCK((uint32)dst_ptr, (uint8*)data, size);
473 IINCHIP_WRITE_BLOCK((uint32)dst_ptr, (uint8*)data, len);
478 IINCHIP_WRITE(Sn_TX_WR0(s),(uint8)((ptr & 0xff00) >> 8));
479 IINCHIP_WRITE((Sn_TX_WR0(s) + 1),(uint8)(ptr & 0x00ff));
494 void recv_data_processing(uint8 s, uint8 *data, uint16 len)
501 ptr = IINCHIP_READ(Sn_RX_RD0(s));
502 ptr = ((ptr & 0x00ff) << 8) + IINCHIP_READ(Sn_RX_RD0(s) + 1);
504 DBGA(
"ISR_RX: rd_ptr : %.4x", ptr);
506 src_mask = (uint32)ptr & getIINCHIP_RxMASK(s);
507 src_ptr = (uint8 *)(getIINCHIP_RxBASE(s) + src_mask);
509 if( (src_mask + len) > getIINCHIP_RxMAX(s) )
511 size = getIINCHIP_RxMAX(s) - src_mask;
512 IINCHIP_READ_BLOCK((uint32)src_ptr, (uint8*)data,size);
515 src_ptr = (uint8 *)(getIINCHIP_RxBASE(s));
516 IINCHIP_READ_BLOCK((uint32)src_ptr, (uint8*) data,size);
520 IINCHIP_READ_BLOCK((uint32)src_ptr, (uint8*) data,len);
524 IINCHIP_WRITE(Sn_RX_RD0(s),(uint8)((ptr & 0xff00) >> 8));
525 IINCHIP_WRITE((Sn_RX_RD0(s) + 1),(uint8)(ptr & 0x00ff));
528 void recv_data_ignore(uint8 s, uint16 len)
532 ptr = IINCHIP_READ(Sn_RX_RD0(s));
533 ptr = ((ptr & 0x00ff) << 8) + IINCHIP_READ(Sn_RX_RD0(s) + 1);
535 IINCHIP_WRITE(Sn_RX_RD0(s),(uint8)((ptr & 0xff00) >> 8));
536 IINCHIP_WRITE((Sn_RX_RD0(s) + 1),(uint8)(ptr & 0x00ff));
557 addr += IINCHIP_READ(Sn_DIPR0(s)+i);
571 port = ((uint16) IINCHIP_READ(Sn_DPORT0(s))) & 0x00FF;
573 port += ((uint16) IINCHIP_READ(Sn_DPORT0(s)+1)) & 0x00FF;
577 uint8 CheckDestInLocal(uint32 destip)
580 uint8 * pdestip = (uint8*)&destip;
581 for(i =0; i < 4; i++)
583 if((pdestip[i] & IINCHIP_READ(WIZC_SUBR0+i)) != (IINCHIP_READ(WIZC_SIPR0+i) & IINCHIP_READ(WIZC_SUBR0+i)))
599 if(start > 3) start = 0;
601 for(i = start; i <
TOTAL_SOCK_NUM ; i++)
if( getSn_SR(i)==status )
return i;