1
10
11
12
13
14
15
16
17
18
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
/* ... */
#pragma once
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/* ... */
#define CH390_NCR 0x00
#define NCR_WAKEEN (1<<6)
#define NCR_FDX (1<<3)
#define NCR_LBK_MAC (1<<1)
#define NCR_RST (1<<0)
#define CH390_NSR 0x01
#define NSR_SPEED (1<<7)
#define NSR_LINKST (1<<6)
#define NSR_WAKEST (1<<5)
#define NSR_TX2END (1<<3)
#define NSR_TX1END (1<<2)
#define NSR_RXOV (1<<1)
#define NSR_RXRDY (1<<0)
#define CH390_TCR 0x02
#define TCR_TJDIS (1<<6)
#define TCR_PAD_DIS2 (1<<4)
#define TCR_CRC_DIS2 (1<<3)
#define TCR_PAD_DIS1 (1<<2)
#define TCR_CRC_DIS1 (1<<1)
#define TCR_TXREQ (1<<0)
#define CH390_TSRA 0x03
#define CH390_TSRB 0x04
#define TSR_TJTO (1<<7)
#define TSR_LC (1<<6)
#define TSR_NC (1<<5)
#define TSR_LCOL (1<<4)
#define TSR_COL (1<<3)
#define TSR_EC (1<<2)
#define CH390_RCR 0x05
#define RCR_DEFAULT 0x00
#define RCR_WTDIS (1<<6)
#define RCR_DIS_CRC (1<<4)
#define RCR_ALL (1<<3)
#define RCR_RUNT (1<<2)
#define RCR_PRMSC (1<<1)
#define RCR_RXEN (1<<0)
#define CH390_RSR 0x06
#define RSR_RF (1<<7)
#define RSR_MF (1<<6)
#define RSR_LCS (1<<5)
#define RSR_RWTO (1<<4)
#define RSR_PLE (1<<3)
#define RSR_AE (1<<2)
#define RSR_CE (1<<1)
#define RSR_FOE (1<<0)
#define RSR_ERR_MASK (RSR_RF | RSR_LCS | RSR_RWTO | RSR_PLE | \
RSR_AE | RSR_CE | RSR_FOE)...
#define CH390_ROCR 0x07
#define CH390_BPTR 0x08
#define CH390_FCTR 0x09
#define FCTR_HWOT(ot) (( ot & 0xf ) << 4)
#define FCTR_LWOT(ot) ( ot & 0xf )
#define CH390_FCR 0x0A
#define FCR_FLOW_ENABLE (0x39)
#define CH390_EPCR 0x0B
#define EPCR_REEP (1<<5)
#define EPCR_WEP (1<<4)
#define EPCR_EPOS (1<<3)
#define EPCR_ERPRR (1<<2)
#define EPCR_ERPRW (1<<1)
#define EPCR_ERRE (1<<0)
#define CH390_EPAR 0x0C
#define CH390_EPDRL 0x0D
#define CH390_EPDRH 0x0E
#define CH390_WCR 0x0F
#define WCR_LINKEN (1<<5)
#define WCR_SAMPLEEN (1<<4)
#define WCR_MAGICEN (1<<3)
#define WCR_LINKST (1<<2)
#define WCR_SAMPLEST (1<<1)
#define WCR_MAGICST (1<<0)
#define CH390_PAR 0x10
#define CH390_MAR 0x16
#define CH390_GPCR 0x1E
#define CH390_GPR 0x1F
#define CH390_TRPAL 0x22
#define CH390_TRPAH 0x23
#define CH390_RWPAL 0x24
#define CH390_RWPAH 0x25
#define CH390_VIDL 0x28
#define CH390_VIDH 0x29
#define CH390_PIDL 0x2A
#define CH390_PIDH 0x2B
#define CH390_CHIPR 0x2C
#define CH390_TCR2 0x2D
#define TCR2_RLCP (1<<6)
#define CH390_ATCR 0x30
#define ATCR_AUTO_TX (1<<7)
#define CH390_TCSCR 0x31
#define TCSCR_ALL 0x1F
#define TCSCR_IPv6TCPCSE (1<<4)
#define TCSCR_IPv6UDPCSE (1<<3)
#define TCSCR_UDPCSE (1<<2)
#define TCSCR_TCPCSE (1<<1)
#define TCSCR_IPCSE (1<<0)
#define CH390_RCSCSR 0x32
#define RCSCSR_UDPS (1<<7)
#define RCSCSR_TCPS (1<<6)
#define RCSCSR_IPS (1<<5)
#define RCSCSR_UDPP (1<<4)
#define RCSCSR_TCPP (1<<3)
#define RCSCSR_IPP (1<<2)
#define RCSCSR_RCSEN (1<<1)
#define RCSCSR_DCSE (1<<0)
#define CH390_MPAR 0x33
#define CH390_SBCR 0x38
#define CH390_INTCR 0x39
#define INCR_TYPE_OD 0x02
#define INCR_TYPE_PP 0x00
#define INCR_POL_L 0x01
#define INCR_POL_H 0x00
#define CH390_ALNCR 0x4A
#define CH390_SCCR 0x50
#define CH390_RSCCR 0x51
#define CH390_RLENCR 0x52
#define RLENCR_RXLEN_EN 0x80
#define RLENCR_RXLEN_DEFAULT 0x18
#define CH390_BCASTCR 0x53
#define CH390_INTCKCR 0x54
#define CH390_MPTRCR 0x55
#define MPTRCR_RST_TX (1<<1)
#define MPTRCR_RST_RX (1<<0)
#define CH390_MLEDCR 0x57
#define CH390_MRCMDX 0x70
#define CH390_MRCMDX1 0x71
#define CH390_MRCMD 0x72
#define CH390_MRRL 0x74
#define CH390_MRRH 0x75
#define CH390_MWCMDX 0x76
#define CH390_MWCMD 0x78
#define CH390_MWRL 0x7A
#define CH390_MWRH 0x7B
#define CH390_TXPLL 0x7C
#define CH390_TXPLH 0x7D
#define CH390_ISR 0x7E
#define ISR_LNKCHG (1<<5)
#define ISR_ROO (1<<3)
#define ISR_ROS (1<<2)
#define ISR_PT (1<<1)
#define ISR_PR (1<<0)
#define ISR_CLR_STATUS (ISR_LNKCHG | ISR_ROO | ISR_ROS | ISR_PT | ISR_PR)
#define CH390_IMR 0x7F
#define IMR_NONE 0x00
#define IMR_ALL 0xFF
#define IMR_PAR (1<<7)
#define IMR_LNKCHGI (1<<5)
#define IMR_UDRUNI (1<<4)
#define IMR_ROOI (1<<3)
#define IMR_ROI (1<<2)
#define IMR_PTI (1<<1)
#define IMR_PRI (1<<0)
#define OPC_REG_W 0x80
#define OPC_REG_R 0x00
#define OPC_MEM_DMY_R 0x70
#define OPC_MEM_WRITE 0xF8
#define OPC_MEM_READ 0x72
#define CH390_SPI_RD 0
#define CH390_SPI_WR 1
#define CH390_GPIO1 0x02
#define CH390_GPIO2 0x04
#define CH390_GPIO3 0x08
#define CH390_PHY 0x40
#define CH390_PHY_BMCR 0x00
#define CH390_PHY_BMSR 0x01
#define CH390_PHY_PHYID1 0x02
#define CH390_PHY_PHYID2 0x03
#define CH390_PHY_ANAR 0x04
#define CH390_PHY_ANLPAR 0x05
#define CH390_PHY_ANER 0x06
#define CH390_PHY_PAGE_SEL 0x1F
#define CH390_PKT_NONE 0x00
#define CH390_PKT_RDY 0x01
#define CH390_PKT_ERR 0xFE
#define CH390_PKT_ERR_WITH_RCSEN 0xE2 173 defines
#ifdef __cplusplus
}{...}
#endif