mikroSDK Reference Manual
tc3xx_eth_driver.h
Go to the documentation of this file.
1
31#ifndef _TC3XX_ETH_DRIVER_H
32#define _TC3XX_ETH_DRIVER_H
33
34//Dependencies
35#include "core/nic.h"
36
37//Number of TX buffers
38#ifndef TC3XX_ETH_TX_BUFFER_COUNT
39 #define TC3XX_ETH_TX_BUFFER_COUNT 3
40#elif (TC3XX_ETH_TX_BUFFER_COUNT < 1)
41 #error TC3XX_ETH_TX_BUFFER_COUNT parameter is not valid
42#endif
43
44//TX buffer size
45#ifndef TC3XX_ETH_TX_BUFFER_SIZE
46 #define TC3XX_ETH_TX_BUFFER_SIZE 1536
47#elif (TC3XX_ETH_TX_BUFFER_SIZE != 1536)
48 #error TC3XX_ETH_TX_BUFFER_SIZE parameter is not valid
49#endif
50
51//Number of RX buffers
52#ifndef TC3XX_ETH_RX_BUFFER_COUNT
53 #define TC3XX_ETH_RX_BUFFER_COUNT 6
54#elif (TC3XX_ETH_RX_BUFFER_COUNT < 1)
55 #error TC3XX_ETH_RX_BUFFER_COUNT parameter is not valid
56#endif
57
58//RX buffer size
59#ifndef TC3XX_ETH_RX_BUFFER_SIZE
60 #define TC3XX_ETH_RX_BUFFER_SIZE 1536
61#elif (TC3XX_ETH_RX_BUFFER_SIZE != 1536)
62 #error TC3XX_ETH_RX_BUFFER_SIZE parameter is not valid
63#endif
64
65//Ethernet interrupt priority
66#ifndef TC3XX_ETH_IRQ_PRIORITY
67 #define TC3XX_ETH_IRQ_PRIORITY 10
68#elif (TC3XX_ETH_IRQ_PRIORITY < 0)
69 #error TC3XX_ETH_IRQ_PRIORITY parameter is not valid
70#endif
71
72//DMA_CH_STATUS register
73#define ETH_DMA_CH_STATUS_REB 0x00380000
74#define ETH_DMA_CH_STATUS_TEB 0x00070000
75#define ETH_DMA_CH_STATUS_NIS 0x00008000
76#define ETH_DMA_CH_STATUS_AIS 0x00004000
77#define ETH_DMA_CH_STATUS_CDE 0x00002000
78#define ETH_DMA_CH_STATUS_FBE 0x00001000
79#define ETH_DMA_CH_STATUS_ERI 0x00000800
80#define ETH_DMA_CH_STATUS_ETI 0x00000400
81#define ETH_DMA_CH_STATUS_RWT 0x00000200
82#define ETH_DMA_CH_STATUS_RPS 0x00000100
83#define ETH_DMA_CH_STATUS_RBU 0x00000080
84#define ETH_DMA_CH_STATUS_RI 0x00000040
85#define ETH_DMA_CH_STATUS_TBU 0x00000004
86#define ETH_DMA_CH_STATUS_TPS 0x00000002
87#define ETH_DMA_CH_STATUS_TI 0x00000001
88
89//DMA_CH_INTERRUPT_ENABLE register
90#define ETH_DMA_CH_INTERRUPT_ENABLE_NIE 0x00008000
91#define ETH_DMA_CH_INTERRUPT_ENABLE_AIE 0x00004000
92#define ETH_DMA_CH_INTERRUPT_ENABLE_CDEE 0x00002000
93#define ETH_DMA_CH_INTERRUPT_ENABLE_FBEE 0x00001000
94#define ETH_DMA_CH_INTERRUPT_ENABLE_ERIE 0x00000800
95#define ETH_DMA_CH_INTERRUPT_ENABLE_ETIE 0x00000400
96#define ETH_DMA_CH_INTERRUPT_ENABLE_RWTE 0x00000200
97#define ETH_DMA_CH_INTERRUPT_ENABLE_RSE 0x00000100
98#define ETH_DMA_CH_INTERRUPT_ENABLE_RBUE 0x00000080
99#define ETH_DMA_CH_INTERRUPT_ENABLE_RIE 0x00000040
100#define ETH_DMA_CH_INTERRUPT_ENABLE_TBUE 0x00000004
101#define ETH_DMA_CH_INTERRUPT_ENABLE_TXSE 0x00000002
102#define ETH_DMA_CH_INTERRUPT_ENABLE_TIE 0x00000001
103
104//Transmit normal descriptor (read format)
105#define ETH_TDES0_BUF1AP 0xFFFFFFFF
106#define ETH_TDES1_BUF2AP 0xFFFFFFFF
107#define ETH_TDES2_IOC 0x80000000
108#define ETH_TDES2_TTSE 0x40000000
109#define ETH_TDES2_B2L 0x3FFF0000
110#define ETH_TDES2_B1L 0x00003FFF
111#define ETH_TDES3_OWN 0x80000000
112#define ETH_TDES3_CTXT 0x40000000
113#define ETH_TDES3_FD 0x20000000
114#define ETH_TDES3_LD 0x10000000
115#define ETH_TDES3_CPC 0x0C000000
116#define ETH_TDES3_SLOTNUM 0x00780000
117#define ETH_TDES3_CIC 0x00030000
118#define ETH_TDES3_FL 0x00007FFF
119
120//Transmit normal descriptor (write-back format)
121#define ETH_TDES0_TTSL 0xFFFFFFFF
122#define ETH_TDES1_TTSH 0xFFFFFFFF
123#define ETH_TDES3_OWN 0x80000000
124#define ETH_TDES3_CTXT 0x40000000
125#define ETH_TDES3_FD 0x20000000
126#define ETH_TDES3_LD 0x10000000
127#define ETH_TDES3_TTSS 0x00020000
128#define ETH_TDES3_ES 0x00008000
129#define ETH_TDES3_JT 0x00004000
130#define ETH_TDES3_FF 0x00002000
131#define ETH_TDES3_PCE 0x00001000
132#define ETH_TDES3_LOC 0x00000800
133#define ETH_TDES3_NC 0x00000400
134#define ETH_TDES3_LC 0x00000200
135#define ETH_TDES3_EC 0x00000100
136#define ETH_TDES3_CC 0x000000F0
137#define ETH_TDES3_ED 0x00000008
138#define ETH_TDES3_UF 0x00000004
139#define ETH_TDES3_DB 0x00000002
140#define ETH_TDES3_IHE 0x00000001
141
142//Receive normal descriptor (read format)
143#define ETH_RDES0_BUF1AP 0xFFFFFFFF
144#define ETH_RDES2_BUF2AP 0xFFFFFFFF
145#define ETH_RDES3_OWN 0x80000000
146#define ETH_RDES3_IOC 0x40000000
147#define ETH_RDES3_BUF2V 0x02000000
148#define ETH_RDES3_BUF1V 0x01000000
149
150//Receive normal descriptor (write-back format)
151#define ETH_RDES1_OPC 0xFFFF0000
152#define ETH_RDES1_TD 0x00008000
153#define ETH_RDES1_TSA 0x00004000
154#define ETH_RDES1_PV 0x00002000
155#define ETH_RDES1_PFT 0x00001000
156#define ETH_RDES1_PMT 0x00000F00
157#define ETH_RDES1_IPCE 0x00000080
158#define ETH_RDES1_IPCB 0x00000040
159#define ETH_RDES1_IPV6 0x00000020
160#define ETH_RDES1_IPV4 0x00000010
161#define ETH_RDES1_IPHE 0x00000008
162#define ETH_RDES1_PT 0x00000007
163#define ETH_RDES2_MADRM 0x07F80000
164#define ETH_RDES2_DAF 0x00020000
165#define ETH_RDES2_SAF 0x00010000
166#define ETH_RDES3_OWN 0x80000000
167#define ETH_RDES3_CTXT 0x40000000
168#define ETH_RDES3_FD 0x20000000
169#define ETH_RDES3_LD 0x10000000
170#define ETH_RDES3_RS2V 0x08000000
171#define ETH_RDES3_RS1V 0x04000000
172#define ETH_RDES3_RS0V 0x02000000
173#define ETH_RDES3_CE 0x01000000
174#define ETH_RDES3_GP 0x00800000
175#define ETH_RDES3_RWT 0x00400000
176#define ETH_RDES3_OE 0x00200000
177#define ETH_RDES3_RE 0x00100000
178#define ETH_RDES3_DE 0x00080000
179#define ETH_RDES3_LT 0x00070000
180#define ETH_RDES3_ES 0x00008000
181#define ETH_RDES3_PL 0x00007FFF
182
183//Get CPU core identifier
184#define ETH_CPU_ID() (_mfcr(CPU_CORE_ID) & IFX_CPU_CORE_ID_CORE_ID_MSK)
185
186//Convert a local DSPR address to a global DSPR address
187#define ETH_GLOBAL_DSPR_ADDR(address) \
188 ((((uint32_t) (address) & 0xF0000000) == 0xD0000000) ? \
189 ((((uint32_t) (address) & 0x000FFFFF) | 0x70000000) - (ETH_CPU_ID() * 0x10000000)) : \
190 (uint32_t) (address))
191
192//C++ guard
193#ifdef __cplusplus
194extern "C" {
195#endif
196
197
202typedef struct
203{
204 uint32_t tdes0;
205 uint32_t tdes1;
206 uint32_t tdes2;
207 uint32_t tdes3;
209
210
215typedef struct
216{
217 uint32_t rdes0;
218 uint32_t rdes1;
219 uint32_t rdes2;
220 uint32_t rdes3;
222
223
224//TC3xx Ethernet MAC driver
225extern const NicDriver tc3xxEthDriver;
226
227//TC3xx Ethernet MAC related functions
228error_t tc3xxEthInit(NetInterface *interface);
229void tc3xxEthInitGpio(NetInterface *interface);
230void tc3xxEthInitDmaDesc(NetInterface *interface);
231
232void tc3xxEthTick(NetInterface *interface);
233
234void tc3xxEthEnableIrq(NetInterface *interface);
235void tc3xxEthDisableIrq(NetInterface *interface);
236void tc3xxEthIrqHandler(int_t arg);
237void tc3xxEthEventHandler(NetInterface *interface);
238
239error_t tc3xxEthSendPacket(NetInterface *interface,
240 const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary);
241
242error_t tc3xxEthReceivePacket(NetInterface *interface);
243
244error_t tc3xxEthUpdateMacAddrFilter(NetInterface *interface);
245error_t tc3xxEthUpdateMacConfig(NetInterface *interface);
246
247void tc3xxEthWritePhyReg(uint8_t opcode, uint8_t phyAddr,
248 uint8_t regAddr, uint16_t data);
249
250uint16_t tc3xxEthReadPhyReg(uint8_t opcode, uint8_t phyAddr,
251 uint8_t regAddr);
252
253//C++ guard
254#ifdef __cplusplus
255}
256#endif
257
258#endif
error_t
Error codes.
Definition error.h:43
Network interface controller abstraction layer.
Structure describing a buffer that spans multiple chunks.
Definition net_mem.h:89
NIC driver.
Definition nic.h:283
Receive DMA descriptor.
Definition tc3xx_eth_driver.h:216
Transmit DMA descriptor.
Definition tc3xx_eth_driver.h:203