friendev EtherDune TCP/IP library
/home/jander/temp/etherdune/enc28j60constants.h
Go to the documentation of this file.
1 // ENC28J60 constants
2 // Author: Javier Peletier <jm@friendev.com>
3 // Credits: Based off EtherCard's enc28j60.cpp file, taken only the constants
4 // Credits: Jean-Claude Wippler, Guido Socher and Pascal Stang
5 // Summary: ENC28J60 hardcoded Constants
6 //
7 // Copyright (c) 2015 All Rights Reserved, http://friendev.com
8 //
9 // This source is subject to the GPLv2 license.
10 // Please see the License.txt file for more information.
11 // All other rights reserved.
12 //
13 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
14 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
15 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
16 // PARTICULAR PURPOSE.
17 
18 #ifndef _enc28j60constants_h_
19 #define _enc28j60constants_h_
20 
21 // ENC28J60 Control Registers
22 // Control register definitions are a combination of address,
23 // bank number, and Ethernet/MAC/PHY indicator bits.
24 // - Register address (bits 0-4)
25 // - Bank number (bits 5-6)
26 // - MAC/PHY indicator (bit 7)
27 
28 
29 #define ADDR_MASK 0x1F
30 #define BANK_MASK 0x60
31 #define SPRD_MASK 0x80
32 // All-bank registers
33 #define EIE 0x1B
34 #define EIR 0x1C
35 #define ESTAT 0x1D
36 #define ECON2 0x1E
37 #define ECON1 0x1F
38 // Bank 0 registers
39 #define ERDPT (0x00|0x00)
40 #define EWRPT (0x02|0x00)
41 #define ETXST (0x04|0x00)
42 #define ETXND (0x06|0x00)
43 #define ERXST (0x08|0x00)
44 #define ERXND (0x0A|0x00)
45 #define ERXRDPT (0x0C|0x00)
46 // #define ERXWRPT (0x0E|0x00)
47 #define EDMAST (0x10|0x00)
48 #define EDMAND (0x12|0x00)
49 // #define EDMADST (0x14|0x00)
50 #define EDMACS (0x16|0x00)
51 // Bank 1 registers
52 #define EHT0 (0x00|0x20)
53 #define EHT1 (0x01|0x20)
54 #define EHT2 (0x02|0x20)
55 #define EHT3 (0x03|0x20)
56 #define EHT4 (0x04|0x20)
57 #define EHT5 (0x05|0x20)
58 #define EHT6 (0x06|0x20)
59 #define EHT7 (0x07|0x20)
60 #define EPMM0 (0x08|0x20)
61 #define EPMM1 (0x09|0x20)
62 #define EPMM2 (0x0A|0x20)
63 #define EPMM3 (0x0B|0x20)
64 #define EPMM4 (0x0C|0x20)
65 #define EPMM5 (0x0D|0x20)
66 #define EPMM6 (0x0E|0x20)
67 #define EPMM7 (0x0F|0x20)
68 #define EPMCS (0x10|0x20)
69 // #define EPMO (0x14|0x20)
70 #define EWOLIE (0x16|0x20)
71 #define EWOLIR (0x17|0x20)
72 #define ERXFCON (0x18|0x20)
73 #define EPKTCNT (0x19|0x20)
74 // Bank 2 registers
75 #define MACON1 (0x00|0x40|0x80)
76 #define MACON2 (0x01|0x40|0x80)
77 #define MACON3 (0x02|0x40|0x80)
78 #define MACON4 (0x03|0x40|0x80)
79 #define MABBIPG (0x04|0x40|0x80)
80 #define MAIPG (0x06|0x40|0x80)
81 #define MACLCON1 (0x08|0x40|0x80)
82 #define MACLCON2 (0x09|0x40|0x80)
83 #define MAMXFL (0x0A|0x40|0x80)
84 #define MAPHSUP (0x0D|0x40|0x80)
85 #define MICON (0x11|0x40|0x80)
86 #define MICMD (0x12|0x40|0x80)
87 #define MIREGADR (0x14|0x40|0x80)
88 #define MIWR (0x16|0x40|0x80)
89 #define MIRD (0x18|0x40|0x80)
90 // Bank 3 registers
91 #define MAADR1 (0x00|0x60|0x80)
92 #define MAADR0 (0x01|0x60|0x80)
93 #define MAADR3 (0x02|0x60|0x80)
94 #define MAADR2 (0x03|0x60|0x80)
95 #define MAADR5 (0x04|0x60|0x80)
96 #define MAADR4 (0x05|0x60|0x80)
97 #define EBSTSD (0x06|0x60)
98 #define EBSTCON (0x07|0x60)
99 #define EBSTCS (0x08|0x60)
100 #define MISTAT (0x0A|0x60|0x80)
101 #define EREVID (0x12|0x60)
102 #define ECOCON (0x15|0x60)
103 #define EFLOCON (0x17|0x60)
104 #define EPAUS (0x18|0x60)
105 
106 // ENC28J60 ERXFCON Register Bit Definitions
107 #define ERXFCON_UCEN 0x80
108 #define ERXFCON_ANDOR 0x40
109 #define ERXFCON_CRCEN 0x20
110 #define ERXFCON_PMEN 0x10
111 #define ERXFCON_MPEN 0x08
112 #define ERXFCON_HTEN 0x04
113 #define ERXFCON_MCEN 0x02
114 #define ERXFCON_BCEN 0x01
115 // ENC28J60 EIE Register Bit Definitions
116 #define EIE_INTIE 0x80
117 #define EIE_PKTIE 0x40
118 #define EIE_DMAIE 0x20
119 #define EIE_LINKIE 0x10
120 #define EIE_TXIE 0x08
121 #define EIE_WOLIE 0x04
122 #define EIE_TXERIE 0x02
123 #define EIE_RXERIE 0x01
124 // ENC28J60 EIR Register Bit Definitions
125 #define EIR_PKTIF 0x40
126 #define EIR_DMAIF 0x20
127 #define EIR_LINKIF 0x10
128 #define EIR_TXIF 0x08
129 #define EIR_WOLIF 0x04
130 #define EIR_TXERIF 0x02
131 #define EIR_RXERIF 0x01
132 // ENC28J60 ESTAT Register Bit Definitions
133 #define ESTAT_INT 0x80
134 #define ESTAT_LATECOL 0x10
135 #define ESTAT_RXBUSY 0x04
136 #define ESTAT_TXABRT 0x02
137 #define ESTAT_CLKRDY 0x01
138 // ENC28J60 ECON2 Register Bit Definitions
139 #define ECON2_AUTOINC 0x80
140 #define ECON2_PKTDEC 0x40
141 #define ECON2_PWRSV 0x20
142 #define ECON2_VRPS 0x08
143 // ENC28J60 ECON1 Register Bit Definitions
144 #define ECON1_TXRST 0x80
145 #define ECON1_RXRST 0x40
146 #define ECON1_DMAST 0x20
147 #define ECON1_CSUMEN 0x10
148 #define ECON1_TXRTS 0x08
149 #define ECON1_RXEN 0x04
150 #define ECON1_BSEL1 0x02
151 #define ECON1_BSEL0 0x01
152 // ENC28J60 MACON1 Register Bit Definitions
153 #define MACON1_LOOPBK 0x10
154 #define MACON1_TXPAUS 0x08
155 #define MACON1_RXPAUS 0x04
156 #define MACON1_PASSALL 0x02
157 #define MACON1_MARXEN 0x01
158 // ENC28J60 MACON2 Register Bit Definitions
159 #define MACON2_MARST 0x80
160 #define MACON2_RNDRST 0x40
161 #define MACON2_MARXRST 0x08
162 #define MACON2_RFUNRST 0x04
163 #define MACON2_MATXRST 0x02
164 #define MACON2_TFUNRST 0x01
165 // ENC28J60 MACON3 Register Bit Definitions
166 #define MACON3_PADCFG2 0x80
167 #define MACON3_PADCFG1 0x40
168 #define MACON3_PADCFG0 0x20
169 #define MACON3_TXCRCEN 0x10
170 #define MACON3_PHDRLEN 0x08
171 #define MACON3_HFRMLEN 0x04
172 #define MACON3_FRMLNEN 0x02
173 #define MACON3_FULDPX 0x01
174 // ENC28J60 MICMD Register Bit Definitions
175 #define MICMD_MIISCAN 0x02
176 #define MICMD_MIIRD 0x01
177 // ENC28J60 MISTAT Register Bit Definitions
178 #define MISTAT_NVALID 0x04
179 #define MISTAT_SCAN 0x02
180 #define MISTAT_BUSY 0x01
181 
182 // ENC28J60 EBSTCON Register Bit Definitions
183 #define EBSTCON_PSV2 0x80
184 #define EBSTCON_PSV1 0x40
185 #define EBSTCON_PSV0 0x20
186 #define EBSTCON_PSEL 0x10
187 #define EBSTCON_TMSEL1 0x08
188 #define EBSTCON_TMSEL0 0x04
189 #define EBSTCON_TME 0x02
190 #define EBSTCON_BISTST 0x01
191 
192 // PHY registers
193 #define PHCON1 0x00
194 #define PHSTAT1 0x01
195 #define PHHID1 0x02
196 #define PHHID2 0x03
197 #define PHCON2 0x10
198 #define PHSTAT2 0x11
199 #define PHIE 0x12
200 #define PHIR 0x13
201 #define PHLCON 0x14
202 
203 // ENC28J60 PHY PHCON1 Register Bit Definitions
204 #define PHCON1_PRST 0x8000
205 #define PHCON1_PLOOPBK 0x4000
206 #define PHCON1_PPWRSV 0x0800
207 #define PHCON1_PDPXMD 0x0100
208 // ENC28J60 PHY PHSTAT1 Register Bit Definitions
209 #define PHSTAT1_PFDPX 0x1000
210 #define PHSTAT1_PHDPX 0x0800
211 #define PHSTAT1_LLSTAT 0x0004
212 #define PHSTAT1_JBSTAT 0x0002
213 // ENC28J60 PHY PHCON2 Register Bit Definitions
214 #define PHCON2_FRCLINK 0x4000
215 #define PHCON2_TXDIS 0x2000
216 #define PHCON2_JABBER 0x0400
217 #define PHCON2_HDLDIS 0x0100
218 
219 // ENC28J60 Packet Control Byte Bit Definitions
220 #define PKTCTRL_PHUGEEN 0x08
221 #define PKTCTRL_PPADEN 0x04
222 #define PKTCTRL_PCRCEN 0x02
223 #define PKTCTRL_POVERRIDE 0x01
224 
225 // SPI operation codes
226 #define ENC28J60_READ_CTRL_REG 0x00
227 #define ENC28J60_READ_BUF_MEM 0x3A
228 #define ENC28J60_WRITE_CTRL_REG 0x40
229 #define ENC28J60_WRITE_BUF_MEM 0x7A
230 #define ENC28J60_BIT_FIELD_SET 0x80
231 #define ENC28J60_BIT_FIELD_CLR 0xA0
232 #define ENC28J60_SOFT_RESET 0xFF
233 
234 
235 // DMA mode constants
236 #define EDMASTL (0x10|0x00)
237 #define EDMADSTL (0x14|0x00)
238 #define EDMANDL (0x12|0x00)
239 #endif