47 #if (_WIZCHIP_ == 5100)
50 #define _WIZCHIP_SN_BASE_ (0x0400)
51 #define _WIZCHIP_SN_SIZE_ (0x0100)
52 #define _WIZCHIP_IO_TXBUF_ (0x4000)
53 #define _WIZCHIP_IO_RXBUF_ (0x6000)
56 #define WIZCHIP_CREG_BLOCK 0x00
57 #define WIZCHIP_SREG_BLOCK(N) (_WIZCHIP_SN_BASE_+ _WIZCHIP_SN_SIZE_*N)
59 #define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + N)
61 #if (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_DIR_)
62 #define _W5100_IO_BASE_ _WIZCHIP_IO_BASE_
63 #elif (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_)
64 #define IDM_OR ((_WIZCHIP_IO_BASE + 0x0000))
65 #define IDM_AR0 ((_WIZCHIP_IO_BASE_ + 0x0001))
66 #define IDM_AR1 ((_WIZCHIP_IO_BASE_ + 0x0002))
67 #define IDM_DR ((_WIZCHIP_IO_BASE_ + 0x0003))
68 #define _W5100_IO_BASE_ 0x0000
69 #elif (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_)
70 #define _W5100_IO_BASE_ 0x0000
76 #define IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR)
77 #define IINCHIP_WRITE(ADDR,VAL) WIZCHIP_WRITE(ADDR,VAL)
78 #define IINCHIP_READ_BUF(ADDR,BUF,LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN)
79 #define IINCHIP_WRITE_BUF(ADDR,BUF,LEN) WIZCHIP_WRITE(ADDR,BUF,LEN)
201 #if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_
202 #define MR (_WIZCHIP_IO_BASE_ + (0x0000)) // Mode
204 #define MR (_W5100_IO_BASE_ + (0x0000)) // Mode
212 #define GAR (_W5100_IO_BASE_ + (0x0001)) // GW Address
219 #define SUBR (_W5100_IO_BASE_ + (0x0005)) // SN Mask Address
226 #define SHAR (_W5100_IO_BASE_ + (0x0009)) // Source Hardware Address
233 #define SIPR (_W5100_IO_BASE_ + (0x000F)) // Source IP Address
256 #define IR (_W5100_IO_BASE_ + (0x0015)) // Interrupt
264 #define _IMR_ (_W5100_IO_BASE_ + (0x0016)) // Socket Interrupt Mask
274 #define _RTR_ (_W5100_IO_BASE_ + (0x0017)) // Retry Time
282 #define _RCR_ (_W5100_IO_BASE_ + (0x0019)) // Retry Count
283 #define RMSR (_W5100_IO_BASE_ + (0x001A)) // Receicve Memory Size
284 #define TMSR (_W5100_IO_BASE_ + (0x001B)) // Trnasmit Memory Size
293 #define PATR (_W5100_IO_BASE_ + (0x001C))
301 #define PTIMER (_W5100_IO_BASE_ + (0x0028)) // PPP LCP RequestTimer
308 #define PMAGIC (_W5100_IO_BASE_ + (0x0029)) // PPP LCP Magic number
310 #define UIPR0 (_W5100_IO_BASE_ + (0x002A))
311 #define UPORT0 (_W5100_IO_BASE + (0x002E))
352 #define Sn_MR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0000)) // socket Mode register
380 #define Sn_CR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0001)) // channel Sn_CR register
401 #define Sn_IR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0002)) // channel interrupt register
424 #define Sn_SR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0003)) // channel status register
432 #define Sn_PORT(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0004)) // source port register
440 #define Sn_DHAR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0006)) // Peer MAC register address
450 #define Sn_DIPR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x000C)) // Peer IP register address
460 #define Sn_DPORT(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0010)) // Peer port register address
467 #define Sn_MSSR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0012)) // Maximum Segment Size(Sn_MSSR0) register address
475 #define Sn_PROTO(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0014)) // Protocol of IP Header field register in IP raw mode
483 #define Sn_TOS(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + 0x0015) // IP Type of Service(TOS) Register
491 #define Sn_TTL(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0016)) // IP Time to live(TTL) Register
510 #define Sn_TX_FSR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0020)) // Transmit free memory size register
522 #define Sn_TX_RD(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0022)) // Transmit memory read pointer register address
536 #define Sn_TX_WR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0024)) // Transmit memory write pointer register address
545 #define Sn_RX_RSR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0026)) // Received data size register
558 #define Sn_RX_RD(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0028)) // Read point of Receive memory
567 #define Sn_RX_WR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002A)) // Write point of Receive memory
594 #define MR_PPPOE 0x08
618 #define IR_CONFLICT 0x80
625 #define IR_UNREACH 0x40
631 #define IR_PPPoE 0x20
633 #define IR_SOCK(sn) (0x01 << sn)
642 #define Sn_MR_CLOSE 0x00
648 #define Sn_MR_TCP 0x01
654 #define Sn_MR_UDP 0x02
655 #define Sn_MR_IPRAW 0x03
662 #define Sn_MR_MACRAW 0x04
669 #define Sn_MR_PPPoE 0x05
679 #define Sn_MR_ND 0x20
688 #define Sn_MR_MC Sn_MR_ND
700 #define Sn_MR_MF 0x40
701 #define Sn_MR_MFEN Sn_MR_MF
713 #define Sn_MR_MULTI 0x80
730 #define Sn_CR_OPEN 0x01
741 #define Sn_CR_LISTEN 0x02
753 #define Sn_CR_CONNECT 0x04
766 #define Sn_CR_DISCON 0x08
772 #define Sn_CR_CLOSE 0x10
780 #define Sn_CR_SEND 0x20
790 #define Sn_CR_SEND_MAC 0x21
798 #define Sn_CR_SEND_KEEP 0x22
806 #define Sn_CR_RECV 0x40
812 #define Sn_CR_PCON 0x23
818 #define Sn_CR_PDISCON 0x24
824 #define Sn_CR_PCR 0x25
830 #define Sn_CR_PCN 0x26
836 #define Sn_CR_PCJ 0x27
843 #define Sn_IR_PRECV 0x80
849 #define Sn_IR_PFAIL 0x40
855 #define Sn_IR_PNEXT 0x20
861 #define Sn_IR_SENDOK 0x10
867 #define Sn_IR_TIMEOUT 0x08
873 #define Sn_IR_RECV 0x04
879 #define Sn_IR_DISCON 0x02
885 #define Sn_IR_CON 0x01
893 #define SOCK_CLOSED 0x00
901 #define SOCK_INIT 0x13
909 #define SOCK_LISTEN 0x14
918 #define SOCK_SYNSENT 0x15
926 #define SOCK_SYNRECV 0x16
935 #define SOCK_ESTABLISHED 0x17
943 #define SOCK_FIN_WAIT 0x18
951 #define SOCK_CLOSING 0x1A
959 #define SOCK_TIME_WAIT 0x1B
967 #define SOCK_CLOSE_WAIT 0x1C
974 #define SOCK_LAST_ACK 0x1D
982 #define SOCK_UDP 0x22
990 #define SOCK_IPRAW 0x32
998 #define SOCK_MACRAW 0x42
1007 #define SOCK_PPPOE 0x5F
1010 #define IPPROTO_IP 0
1011 #define IPPROTO_ICMP 1
1012 #define IPPROTO_IGMP 2
1013 #define IPPROTO_GGP 3
1014 #define IPPROTO_TCP 6
1015 #define IPPROTO_PUP 12
1016 #define IPPROTO_UDP 17
1017 #define IPPROTO_IDP 22
1018 #define IPPROTO_ND 77
1019 #define IPPROTO_RAW 255
1032 #define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter()
1049 #define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit()
1105 #if (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_)
1106 #define setMR(mr) WIZCHIP_WRITE(MR,mr)
1108 #define setMR(mr) (*((uint8_t*)MR) = mr)
1117 #if (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_)
1118 #define getMR() WIZCHIP_READ(MR)
1120 #define getMR() (*(uint8_t*)MR)
1129 #define setGAR(gar) \
1130 WIZCHIP_WRITE_BUF(GAR,gar,4)
1138 #define getGAR(gar) \
1139 WIZCHIP_READ_BUF(GAR,gar,4)
1150 #define setSUBR(subr) \
1151 WIZCHIP_WRITE_BUF(SUBR,subr,4)
1159 #define getSUBR(subr) \
1160 WIZCHIP_READ_BUF(SUBR, subr, 4)
1168 #define setSHAR(shar) \
1169 WIZCHIP_WRITE_BUF(SHAR, shar, 6)
1177 #define getSHAR(shar) \
1178 WIZCHIP_READ_BUF(SHAR, shar, 6)
1186 #define setSIPR(sipr) \
1187 WIZCHIP_WRITE_BUF(SIPR, sipr, 4)
1195 #define getSIPR(sipr) \
1196 WIZCHIP_READ_BUF(SIPR, sipr, 4)
1205 WIZCHIP_WRITE(IR, (ir & 0xA0))
1213 (WIZCHIP_READ(IR) & 0xA0)
1221 #define setIMR(imr) \
1222 WIZCHIP_WRITE(_IMR_, imr)
1239 #define setRTR(rtr) {\
1240 WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \
1241 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \
1251 (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1)))
1259 #define setRCR(rcr) \
1260 WIZCHIP_WRITE(_RCR_, rcr)
1276 #define setRMSR(rmsr) \
1277 WIZCHIP_WRITE(RMSR) // Receicve Memory Size
1286 WIZCHIP_READ() // Receicve Memory Size
1293 #define setTMSR(rmsr) \
1294 WIZCHIP_WRITE(TMSR) // Receicve Memory Size
1310 (((uint16_t)WIZCHIP_READ(PATR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PATR,1)))
1317 #define getPPPALGO() \
1318 WIZCHIP_READ(PPPALGO)
1327 #define setPTIMER(ptimer) \
1328 WIZCHIP_WRITE(PTIMER, ptimer)
1336 #define getPTIMER() \
1337 WIZCHIP_READ(PTIMER)
1345 #define setPMAGIC(pmagic) \
1346 WIZCHIP_WRITE(PMAGIC, pmagic)
1354 #define getPMAGIC() \
1355 WIZCHIP_READ(PMAGIC)
1367 #define setSn_MR(sn, mr) \
1368 WIZCHIP_WRITE(Sn_MR(sn),mr)
1377 #define getSn_MR(sn) \
1378 WIZCHIP_READ(Sn_MR(sn))
1387 #define setSn_CR(sn, cr) \
1388 WIZCHIP_WRITE(Sn_CR(sn), cr)
1397 #define getSn_CR(sn) \
1398 WIZCHIP_READ(Sn_CR(sn))
1407 #define setSn_IR(sn, ir) \
1408 WIZCHIP_WRITE(Sn_IR(sn), ir)
1417 #define getSn_IR(sn) \
1418 WIZCHIP_READ(Sn_IR(sn))
1426 #define getSn_SR(sn) \
1427 WIZCHIP_READ(Sn_SR(sn))
1436 #define setSn_PORT(sn, port) { \
1437 WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \
1438 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \
1448 #define getSn_PORT(sn) \
1449 (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1)))
1458 #define setSn_DHAR(sn, dhar) \
1459 WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6)
1468 #define getSn_DHAR(sn, dhar) \
1469 WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6)
1478 #define setSn_DIPR(sn, dipr) \
1479 WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4)
1488 #define getSn_DIPR(sn, dipr) \
1489 WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4)
1498 #define setSn_DPORT(sn, dport) { \
1499 WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \
1500 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \
1510 #define getSn_DPORT(sn) \
1511 (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1)))
1520 #define setSn_MSSR(sn, mss) { \
1521 WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \
1522 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \
1532 #define getSn_MSSR(sn) \
1533 (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1)))
1542 #define setSn_PROTO(sn, proto) \
1543 WIZCHIP_WRITE(Sn_TOS(sn), tos)
1552 #define getSn_PROTO(sn) \
1553 WIZCHIP_READ(Sn_TOS(sn))
1562 #define setSn_TOS(sn, tos) \
1563 WIZCHIP_WRITE(Sn_TOS(sn), tos)
1572 #define getSn_TOS(sn) \
1573 WIZCHIP_READ(Sn_TOS(sn))
1582 #define setSn_TTL(sn, ttl) \
1583 WIZCHIP_WRITE(Sn_TTL(sn), ttl)
1592 #define getSn_TTL(sn) \
1593 WIZCHIP_READ(Sn_TTL(sn))
1602 #define setSn_RXMEM_SIZE(sn, rxmemsize) \
1603 WIZCHIP_WRITE(RMSR, (WIZCHIP_READ(RMSR) & ~(0x03 << (2*sn))) | (rxmemsize << (2*sn)))
1604 #define setSn_RXBUF_SIZE(sn,rxmemsize) setSn_RXMEM_SIZE(sn,rxmemsize)
1613 #define getSn_RXMEM_SIZE(sn) \
1614 ((WIZCHIP_READ(RMSR) & (0x03 << (2*sn))) >> (2*sn))
1615 #define getSn_RXBUF_SIZE(sn) getSn_RXMEM_SIZE(sn)
1624 #define setSn_TXMEM_SIZE(sn, txmemsize) \
1625 WIZCHIP_WRITE(TMSR, (WIZCHIP_READ(TMSR) & ~(0x03 << (2*sn))) | (txmemsize << (2*sn)))
1626 #define setSn_TXBUF_SIZE(sn, txmemsize) setSn_TXMEM_SIZE(sn,txmemsize)
1635 #define getSn_TXMEM_SIZE(sn) \
1636 ((WIZCHIP_READ(TMSR) & (0x03 << (2*sn))) >> (2*sn))
1637 #define getSn_TXBUF_SIZE(sn) getSn_TXMEM_SIZE(sn)
1653 #define getSn_TX_RD(sn) \
1654 (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1)))
1663 #define setSn_TX_WR(sn, txwr) { \
1664 WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \
1665 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \
1675 #define getSn_TX_WR(sn) \
1676 (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1)))
1693 #define setSn_RX_RD(sn, rxrd) { \
1694 WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \
1695 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \
1705 #define getSn_RX_RD(sn) \
1706 (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1)))
1715 #define setSn_RX_WR(sn, rxwr) { \
1716 WIZCHIP_WRITE(Sn_RX_WR(sn), (uint8_t)(rxwr>>8)); \
1717 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1), (uint8_t) rxwr); \
1727 #define getSn_RX_WR(sn) \
1728 (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1)))
1737 #define setSn_FRAG(sn, frag) { \
1738 WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \
1739 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \
1749 #define getSn_FRAG(sn) \
1750 (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1)))
1758 #define getSn_RxMAX(sn) \
1759 ((uint16_t)(1 << getSn_RXMEM_SIZE(sn)) << 10)
1768 #define getSn_TxMAX(sn) \
1769 ((uint16_t)(1 << getSn_TXMEM_SIZE(sn)) << 10)
1777 #define getSn_RxMASK(sn) \
1778 (getSn_RxMAX(sn) - 1)
1786 #define getSn_TxMASK(sn) \
1787 (getSn_TxMAX(sn) - 1)
1822 void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len);
1838 void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len);
uint32_t getSn_TxBASE(uint8_t sn)
Get the base address of socket sn TX buffer.
void wiz_recv_ignore(uint8_t sn, uint16_t len)
It discard the received data in RX memory.
uint16_t getSn_RX_RSR(uint8_t sn)
Get Sn_RX_RSR register.
void WIZCHIP_READ_BUF(uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It reads sequence data from registers.
void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to your buffer from internal RX memory.
uint8_t WIZCHIP_READ(uint32_t AddrSel)
It reads 1 byte value from a register.
void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to internal TX memory.
uint16_t getSn_TX_FSR(uint8_t sn)
Get Sn_TX_FSR register.
uint32_t getSn_RxBASE(uint8_t sn)
Get the base address of socket sn RX buffer.
void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It writes sequence data to registers.
void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb)
It writes 1 byte value to a register.
WIZCHIP Config Header File.