mikroSDK Reference Manual
upd60611_driver.h
Go to the documentation of this file.
1
31#ifndef _UPD60611_DRIVER_H
32#define _UPD60611_DRIVER_H
33
34//Dependencies
35#include "core/nic.h"
36
37//PHY address
38#ifndef UPD60611_PHY_ADDR
39 #define UPD60611_PHY_ADDR 0
40#elif (UPD60611_PHY_ADDR < 0 || UPD60611_PHY_ADDR > 31)
41 #error UPD60611_PHY_ADDR parameter is not valid
42#endif
43
44//uPD60611 PHY registers
45#define UPD60611_BMCR 0x00
46#define UPD60611_BMSR 0x01
47#define UPD60611_PHYID1 0x02
48#define UPD60611_PHYID2 0x03
49#define UPD60611_ANAR 0x04
50#define UPD60611_ANLPAR 0x05
51#define UPD60611_ANER 0x06
52#define UPD60611_ANNPR 0x07
53#define UPD60611_SRR 0x10
54#define UPD60611_MCSR 0x11
55#define UPD60611_SMR 0x12
56#define UPD60611_EBSR 0x13
57#define UPD60611_BER 0x17
58#define UPD60611_FEQMR 0x18
59#define UPD60611_DCSR 0x19
60#define UPD60611_DCR 0x1A
61#define UPD60611_SCSIR 0x1B
62#define UPD60611_ISR 0x1D
63#define UPD60611_IER 0x1E
64#define UPD60611_PSCSR 0x1F
65
66//Basic Control register
67#define UPD60611_BMCR_RESET 0x8000
68#define UPD60611_BMCR_LOOPBACK 0x4000
69#define UPD60611_BMCR_SPEED_SEL 0x2000
70#define UPD60611_BMCR_AN_EN 0x1000
71#define UPD60611_BMCR_POWER_DOWN 0x0800
72#define UPD60611_BMCR_ISOLATE 0x0400
73#define UPD60611_BMCR_RESTART_AN 0x0200
74#define UPD60611_BMCR_DUPLEX_MODE 0x0100
75#define UPD60611_BMCR_COL_TEST 0x0080
76
77//Basic Status register
78#define UPD60611_BMSR_100BT4 0x8000
79#define UPD60611_BMSR_100BTX_FD 0x4000
80#define UPD60611_BMSR_100BTX_HD 0x2000
81#define UPD60611_BMSR_10BT_FD 0x1000
82#define UPD60611_BMSR_10BT_HD 0x0800
83#define UPD60611_BMSR_AN_COMPLETE 0x0020
84#define UPD60611_BMSR_REMOTE_FAULT 0x0010
85#define UPD60611_BMSR_AN_CAPABLE 0x0008
86#define UPD60611_BMSR_LINK_STATUS 0x0004
87#define UPD60611_BMSR_JABBER_DETECT 0x0002
88#define UPD60611_BMSR_EXTENDED_CAPABLE 0x0001
89
90//PHY Identifier 1 register
91#define UPD60611_PHYID1_PHY_ID_NUM_MSB 0xFFFF
92#define UPD60611_PHYID1_PHY_ID_NUM_MSB_DEFAULT 0xB824
93
94//PHY Identifier 2 register
95#define UPD60611_PHYID2_PHY_ID_NUM_LSB 0xFC00
96#define UPD60611_PHYID2_PHY_ID_NUM_LSB_DEFAULT 0x2800
97#define UPD60611_PHYID2_MODEL_NUM 0x03F0
98#define UPD60611_PHYID2_MODEL_NUM_DEFAULT 0x0010
99#define UPD60611_PHYID2_REVISION_NUM 0x000F
100
101//Auto-Negotiation Advertisement register
102#define UPD60611_ANAR_NEXT_PAGE 0x8000
103#define UPD60611_ANAR_REMOTE_FAULT 0x2000
104#define UPD60611_ANAR_PAUSE 0x0C00
105#define UPD60611_ANAR_100BT4 0x0200
106#define UPD60611_ANAR_100BTX_FD 0x0100
107#define UPD60611_ANAR_100BTX_HD 0x0080
108#define UPD60611_ANAR_10BT_FD 0x0040
109#define UPD60611_ANAR_10BT_HD 0x0020
110#define UPD60611_ANAR_SELECTOR 0x001F
111#define UPD60611_ANAR_SELECTOR_DEFAULT 0x0001
112
113//Auto-Negotiation Link Partner Ability register
114#define UPD60611_ANLPAR_NEXT_PAGE 0x8000
115#define UPD60611_ANLPAR_ACK 0x4000
116#define UPD60611_ANLPAR_REMOTE_FAULT 0x2000
117#define UPD60611_ANLPAR_PAUSE 0x0400
118#define UPD60611_ANLPAR_100BT4 0x0200
119#define UPD60611_ANLPAR_100BTX_FD 0x0100
120#define UPD60611_ANLPAR_100BTX_HD 0x0080
121#define UPD60611_ANLPAR_10BT_FD 0x0040
122#define UPD60611_ANLPAR_10BT_HD 0x0020
123#define UPD60611_ANLPAR_SELECTOR 0x001F
124#define UPD60611_ANLPAR_SELECTOR_DEFAULT 0x0001
125
126//Auto-Negotiation Expansion register
127#define UPD60611_ANER_PAR_DETECT_FAULT 0x0010
128#define UPD60611_ANER_LP_NEXT_PAGE_ABLE 0x0008
129#define UPD60611_ANER_NEXT_PAGE_ABLE 0x0004
130#define UPD60611_ANER_PAGE_RECEIVED 0x0002
131#define UPD60611_ANER_LP_AN_ABLE 0x0001
132
133//Auto-Negotiation Next Page Transmit register
134#define UPD60611_ANNPR_NEXT_PAGE 0x8000
135#define UPD60611_ANNPR_MSG_PAGE 0x2000
136#define UPD60611_ANNPR_ACK2 0x1000
137#define UPD60611_ANNPR_TOGGLE 0x0800
138#define UPD60611_ANNPR_MESSAGE 0x07FF
139
140//Silicon Revision register
141#define UPD60611_SRR_SILICON_REV 0x03C0
142
143//Mode Control/Status register
144#define UPD60611_MCSR_EDPWRDOWN 0x2000
145#define UPD60611_MCSR_FARLOOPBACK 0x0200
146#define UPD60611_MCSR_FASTEST 0x0100
147#define UPD60611_MCSR_AUTOMDIX_EN 0x0080
148#define UPD60611_MCSR_MDI_MODE 0x0040
149#define UPD60611_MCSR_FORCE_GOOD_LINK 0x0004
150#define UPD60611_MCSR_ENERGYON 0x0002
151
152//Special Modes register
153#define UPD60611_SMR_FX_MODE 0x0400
154#define UPD60611_SMR_PHY_MODE 0x01E0
155#define UPD60611_SMR_PHY_ADD_DEV 0x0018
156#define UPD60611_SMR_PHY_ADD_MOD 0x0007
157
158//Elastic Buffer Status register
159#define UPD60611_EBSR_T_EL_BUF_OVF 0x0080
160#define UPD60611_EBSR_T_EL_BUF_UDF 0x0040
161#define UPD60611_EBSR_R_EL_BUF_OVF 0x0020
162#define UPD60611_EBSR_R_EL_BUF_UDF 0x0010
163
164//BER Counter register
165#define UPD60611_BER_LNK_OK 0x8000
166#define UPD60611_BER_CNT_LNK_EN 0x4000
167#define UPD60611_BER_CNT_TRIG 0x3800
168#define UPD60611_BER_WINDOW 0x0780
169#define UPD60611_BER_COUNT 0x007F
170
171//Diagnosis Control/Status register
172#define UPD60611_DCSR_DIAG_INIT 0x4000
173#define UPD60611_DCSR_ADC_MAX_VALUE 0x3F00
174#define UPD60611_DCSR_DIAG_DONE 0x0080
175#define UPD60611_DCSR_DIAG_POL 0x0040
176#define UPD60611_DCSR_DIAG_SEL_LINE 0x0020
177#define UPD60611_DCSR_PW_DIAG 0x001F
178
179//Diagnosis Counter register
180#define UPD60611_DCR_CNT_WINDOW 0xFF00
181#define UPD60611_DCR_DIAGCNT 0x00FF
182
183//Special Control/Status Indications register
184#define UPD60611_SCSIR_SWRST_FAST 0x1000
185#define UPD60611_SCSIR_SQEOFF 0x0800
186#define UPD60611_SCSIR_FEFIEN 0x0020
187#define UPD60611_SCSIR_XPOL 0x0010
188
189//Interrupt Source Flags register
190#define UPD60611_ISR_BER 0x0400
191#define UPD60611_ISR_FEQ 0x0200
192#define UPD60611_ISR_ENERGYON 0x0080
193#define UPD60611_ISR_AN_COMPLETE 0x0040
194#define UPD60611_ISR_REMOTE_FAULT 0x0020
195#define UPD60611_ISR_LINK_DOWN 0x0010
196#define UPD60611_ISR_AN_LP_ACK 0x0008
197#define UPD60611_ISR_PAR_DETECT_FAULT 0x0004
198#define UPD60611_ISR_AN_PAGE_RECEIVED 0x0002
199
200//Interrupt Enable register
201#define UPD60611_IER_BER 0x0400
202#define UPD60611_IER_FEQ 0x0200
203#define UPD60611_IER_ENERGYON 0x0080
204#define UPD60611_IER_AN_COMPLETE 0x0040
205#define UPD60611_IER_REMOTE_FAULT 0x0020
206#define UPD60611_IER_LINK_DOWN 0x0010
207#define UPD60611_IER_AN_LP_ACK 0x0008
208#define UPD60611_IER_PAR_DETECT_FAULT 0x0004
209#define UPD60611_IER_AN_PAGE_RECEIVED 0x0002
210
211//PHY Special Control/Status register
212#define UPD60611_PSCSR_AUTODONE 0x1000
213#define UPD60611_PSCSR_4B5B_EN 0x0040
214#define UPD60611_PSCSR_HCDSPEED 0x001C
215#define UPD60611_PSCSR_HCDSPEED_10BT_HD 0x0004
216#define UPD60611_PSCSR_HCDSPEED_100BTX_HD 0x0008
217#define UPD60611_PSCSR_HCDSPEED_10BT_FD 0x0014
218#define UPD60611_PSCSR_HCDSPEED_100BTX_FD 0x0018
219#define UPD60611_PSCSR_RX_DV_J2T 0x0002
220#define UPD60611_PSCSR_SCRAMBLE_DIS 0x0001
221
222//C++ guard
223#ifdef __cplusplus
224extern "C" {
225#endif
226
227//uPD60611 Ethernet PHY driver
228extern const PhyDriver upd60611PhyDriver;
229
230//uPD60611 related functions
231error_t upd60611Init(NetInterface *interface);
232void upd60611InitHook(NetInterface *interface);
233
234void upd60611Tick(NetInterface *interface);
235
236void upd60611EnableIrq(NetInterface *interface);
237void upd60611DisableIrq(NetInterface *interface);
238
239void upd60611EventHandler(NetInterface *interface);
240
241void upd60611WritePhyReg(NetInterface *interface, uint8_t address,
242 uint16_t data);
243
244uint16_t upd60611ReadPhyReg(NetInterface *interface, uint8_t address);
245
246void upd60611DumpPhyReg(NetInterface *interface);
247
248//C++ guard
249#ifdef __cplusplus
250}
251#endif
252
253#endif
error_t
Error codes.
Definition error.h:43
Network interface controller abstraction layer.
Ethernet PHY driver.
Definition nic.h:308