mimxrt1170_eth3_driver.c
Go to the documentation of this file.
1 /**
2  * @file mimxrt1170_eth3_driver.c
3  * @brief NXP i.MX RT1170 Gigabit Ethernet MAC driver (ENET_QOS instance)
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2026 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.6.0
29  **/
30 
31 //Switch to the appropriate trace level
32 #define TRACE_LEVEL NIC_TRACE_LEVEL
33 
34 //Dependencies
35 #include "fsl_device_registers.h"
36 #include "fsl_gpio.h"
37 #include "fsl_iomuxc.h"
38 #include "core/net.h"
40 #include "debug.h"
41 
42 //Underlying network interface
43 static NetInterface *nicDriverInterface;
44 
45 //IAR EWARM compiler?
46 #if defined(__ICCARM__)
47 
48 //Transmit buffer
49 #pragma data_alignment = 4
50 #pragma location = MIMXRT1170_ETH3_RAM_SECTION
52 //Receive buffer
53 #pragma data_alignment = 4
54 #pragma location = MIMXRT1170_ETH3_RAM_SECTION
56 //Transmit DMA descriptors
57 #pragma data_alignment = 8
58 #pragma location = MIMXRT1170_ETH3_RAM_SECTION
60 //Receive DMA descriptors
61 #pragma data_alignment = 8
62 #pragma location = MIMXRT1170_ETH3_RAM_SECTION
64 
65 //Keil MDK-ARM or GCC compiler?
66 #else
67 
68 //Transmit buffer
70  __attribute__((aligned(4), __section__(MIMXRT1170_ETH3_RAM_SECTION)));
71 //Receive buffer
73  __attribute__((aligned(4), __section__(MIMXRT1170_ETH3_RAM_SECTION)));
74 //Transmit DMA descriptors
76  __attribute__((aligned(8), __section__(MIMXRT1170_ETH3_RAM_SECTION)));
77 //Receive DMA descriptors
79  __attribute__((aligned(8), __section__(MIMXRT1170_ETH3_RAM_SECTION)));
80 
81 #endif
82 
83 //Current transmit descriptor
84 static uint_t txIndex;
85 //Current receive descriptor
86 static uint_t rxIndex;
87 
88 
89 /**
90  * @brief i.MX RT1170 Ethernet MAC driver (ENET_QOS instance)
91  **/
92 
94 {
96  ETH_MTU,
107  TRUE,
108  TRUE,
109  TRUE,
110  FALSE
111 };
112 
113 
114 /**
115  * @brief i.MX RT1170 Ethernet MAC initialization
116  * @param[in] interface Underlying network interface
117  * @return Error code
118  **/
119 
121 {
122  error_t error;
123  uint32_t temp;
124 
125  //Debug message
126  TRACE_INFO("Initializing i.MX RT1170 Ethernet MAC (ENET_QOS)...\r\n");
127 
128  //Save underlying network interface
129  nicDriverInterface = interface;
130 
131  //Enable ENET_QOS peripheral clock
132  CLOCK_EnableClock(kCLOCK_Enet_Qos);
133 
134  //GPIO configuration
135  mimxrt1170Eth3InitGpio(interface);
136 
137  //Perform a software reset
138  ENET_QOS->DMA_MODE |= ENET_QOS_DMA_MODE_SWR_MASK;
139  //Wait for the reset to complete
140  while((ENET_QOS->DMA_MODE & ENET_QOS_DMA_MODE_SWR_MASK) != 0)
141  {
142  }
143 
144  //Adjust MDC clock range depending on CSR frequency
145  ENET_QOS->MAC_MDIO_ADDRESS = ENET_QOS_MAC_MDIO_ADDRESS_CR(7);
146 
147  //Valid Ethernet PHY or switch driver?
148  if(interface->phyDriver != NULL)
149  {
150  //Ethernet PHY initialization
151  error = interface->phyDriver->init(interface);
152  }
153  else if(interface->switchDriver != NULL)
154  {
155  //Ethernet switch initialization
156  error = interface->switchDriver->init(interface);
157  }
158  else
159  {
160  //The interface is not properly configured
161  error = ERROR_FAILURE;
162  }
163 
164  //Any error to report?
165  if(error)
166  {
167  return error;
168  }
169 
170  //Use default MAC configuration
171  ENET_QOS->MAC_CONFIGURATION = ENET_QOS_MAC_CONFIGURATION_GPSLCE_MASK |
172  ENET_QOS_MAC_CONFIGURATION_DO_MASK;
173 
174  //Set the maximum packet size that can be accepted
175  temp = ENET_QOS->MAC_EXT_CONFIGURATION & ~ENET_QOS_MAC_EXT_CONFIGURATION_GPSL_MASK;
176  ENET_QOS->MAC_EXT_CONFIGURATION = temp | MIMXRT1170_ETH3_RX_BUFFER_SIZE;
177 
178  //Configure MAC address filtering
180 
181  //Disable flow control
182  ENET_QOS->MAC_TX_FLOW_CTRL_Q[0] = 0;
183  ENET_QOS->MAC_RX_FLOW_CTRL = 0;
184 
185  //Enable the first RX queue
186  ENET_QOS->MAC_RXQ_CTRL[0] = ENET_QOS_MAC_RXQ_CTRL_RXQ0EN(2);
187 
188  //Configure DMA operating mode
189  ENET_QOS->DMA_MODE = ENET_QOS_DMA_MODE_INTM(0) | ENET_QOS_DMA_MODE_DSPW(0);
190  //Configure system bus mode
191  ENET_QOS->DMA_SYSBUS_MODE |= ENET_QOS_DMA_SYSBUS_MODE_AAL_MASK;
192 
193  //The DMA takes the descriptor table as contiguous
194  ENET_QOS->DMA_CH[0].DMA_CHX_CTRL = ENET_QOS_DMA_CHX_CTRL_DSL(0);
195  //Configure TX features
196  ENET_QOS->DMA_CH[0].DMA_CHX_TX_CTRL = ENET_QOS_DMA_CHX_TX_CTRL_TxPBL(32);
197 
198  //Configure RX features
199  ENET_QOS->DMA_CH[0].DMA_CHX_RX_CTRL = ENET_QOS_DMA_CHX_RX_CTRL_RxPBL(32) |
200  ENET_QOS_DMA_CHX_RX_CTRL_RBSZ_13_y(MIMXRT1170_ETH3_RX_BUFFER_SIZE / 8);
201 
202  //Enable store and forward mode for transmission
203  ENET_QOS->MTL_QUEUE[0].MTL_TXQX_OP_MODE |= ENET_QOS_MTL_TXQX_OP_MODE_TQS(7) |
204  ENET_QOS_MTL_TXQX_OP_MODE_TXQEN(2) | ENET_QOS_MTL_TXQX_OP_MODE_TSF_MASK;
205 
206  //Enable store and forward mode for reception
207  ENET_QOS->MTL_QUEUE[0].MTL_RXQX_OP_MODE |= ENET_QOS_MTL_RXQX_OP_MODE_RQS(7) |
208  ENET_QOS_MTL_RXQX_OP_MODE_RSF_MASK;
209 
210  //Initialize DMA descriptor lists
211  mimxrt1170Eth3InitDmaDesc(interface);
212 
213  //Prevent interrupts from being generated when statistic counters reach
214  //half their maximum value
215  ENET_QOS->MAC_MMC_TX_INTERRUPT_MASK = 0xFFFFFFFF;
216  ENET_QOS->MAC_MMC_RX_INTERRUPT_MASK = 0xFFFFFFFF;
217  ENET_QOS->MAC_MMC_IPC_RX_INTERRUPT_MASK = 0xFFFFFFFF;
218  ENET_QOS->MAC_MMC_FPE_TX_INTERRUPT_MASK = 0xFFFFFFFF;
219  ENET_QOS->MAC_MMC_FPE_RX_INTERRUPT_MASK = 0xFFFFFFFF;
220 
221  //Disable MAC interrupts
222  ENET_QOS->MAC_INTERRUPT_ENABLE = 0;
223 
224  //Enable the desired DMA interrupts
225  ENET_QOS->DMA_CH[0].DMA_CHX_INT_EN = ENET_QOS_DMA_CHX_INT_EN_NIE_MASK |
226  ENET_QOS_DMA_CHX_INT_EN_RIE_MASK | ENET_QOS_DMA_CHX_INT_EN_TIE_MASK;
227 
228  //Set priority grouping (3 bits for pre-emption priority, no bits for subpriority)
229  NVIC_SetPriorityGrouping(MIMXRT1170_ETH3_IRQ_PRIORITY_GROUPING);
230 
231  //Configure ENET_QOS interrupt priority
232  NVIC_SetPriority(ENET_QOS_IRQn, NVIC_EncodePriority(MIMXRT1170_ETH3_IRQ_PRIORITY_GROUPING,
234 
235  //Enable MAC transmission and reception
236  ENET_QOS->MAC_CONFIGURATION |= ENET_QOS_MAC_CONFIGURATION_TE_MASK |
237  ENET_QOS_MAC_CONFIGURATION_RE_MASK;
238 
239  //Enable DMA transmission and reception
240  ENET_QOS->DMA_CH[0].DMA_CHX_TX_CTRL |= ENET_QOS_DMA_CHX_TX_CTRL_ST_MASK;
241  ENET_QOS->DMA_CH[0].DMA_CHX_RX_CTRL |= ENET_QOS_DMA_CHX_RX_CTRL_SR_MASK;
242 
243  //Accept any packets from the upper layer
244  osSetEvent(&interface->nicTxEvent);
245 
246  //Successful initialization
247  return NO_ERROR;
248 }
249 
250 
251 /**
252  * @brief GPIO configuration
253  * @param[in] interface Underlying network interface
254  **/
255 
256 __weak_func void mimxrt1170Eth3InitGpio(NetInterface *interface)
257 {
258 //MIMXRT1170-EVK evaluation board?
259 #if defined(USE_MIMXRT1170_EVK)
260  uint32_t temp;
261  gpio_pin_config_t pinConfig;
262  clock_root_config_t rootConfig = {0};
263 #if 0
264  clock_sys_pll1_config_t sysPll1Config = {0};
265 
266  //Initialize system PLL1
267  sysPll1Config.pllDiv2En = true;
268  CLOCK_InitSysPll1(&sysPll1Config);
269 #endif
270 
271  //Generate 125MHz root clock
272  rootConfig.clockOff = false;
273  rootConfig.mux = kCLOCK_ENET_QOS_ClockRoot_MuxSysPll1Div2;
274  rootConfig.div = 4;
275  CLOCK_SetRootClock(kCLOCK_Root_Enet_Qos, &rootConfig);
276 
277 #if 0
278  //Initialize PLL PFD3 (528*18/24 = 396MHz)
279  CLOCK_InitPfd(kCLOCK_PllSys2, kCLOCK_Pfd3, 24);
280 
281  //Generate 198MHz bus clock
282  rootConfig.clockOff = false;
283  rootConfig.mux = kCLOCK_BUS_ClockRoot_MuxSysPll2Pfd3;
284  rootConfig.div = 2;
285  CLOCK_SetRootClock(kCLOCK_Root_Bus, &rootConfig);
286 #endif
287 
288  //Select RGMII interface mode
289  temp = IOMUXC_GPR->GPR6 & ~IOMUXC_GPR_GPR6_ENET_QOS_INTF_SEL_MASK;
290  IOMUXC_GPR->GPR6 = temp | IOMUXC_GPR_GPR6_ENET_QOS_INTF_SEL(1);
291 
292  //ENET_QOS_TX_CLK is driven by ENET_QOS_CLK_ROOT
293  IOMUXC_GPR->GPR6 |= IOMUXC_GPR_GPR6_ENET_QOS_CLKGEN_EN_MASK;
294  //Enable ENET_QOS_TX_CLK output
295  IOMUXC_GPR->GPR6 |= IOMUXC_GPR_GPR6_ENET_QOS_RGMII_EN_MASK;
296 
297  //Enable IOMUXC clock
298  CLOCK_EnableClock(kCLOCK_Iomuxc);
299 
300  //Configure GPIO_DISP_B1_00 pin as ENET_QOS_RX_EN
301  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B1_00_ENET_QOS_RX_EN, 0);
302 
303  //Set GPIO_DISP_B1_00 pad properties
304  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B1_00_ENET_QOS_RX_EN,
305  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
306  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
307  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
308  IOMUXC_SW_PAD_CTL_PAD_PULL(2) |
309  IOMUXC_SW_PAD_CTL_PAD_PDRV(0));
310 
311  //Configure GPIO_DISP_B1_01 pin as ENET_QOS_RX_CLK
312  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B1_01_ENET_QOS_RX_CLK, 0);
313 
314  //Set GPIO_DISP_B1_01 pad properties
315  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B1_01_ENET_QOS_RX_CLK,
316  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
317  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
318  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
319  IOMUXC_SW_PAD_CTL_PAD_PULL(2) |
320  IOMUXC_SW_PAD_CTL_PAD_PDRV(0));
321 
322  //Configure GPIO_DISP_B1_02 pin as ENET_QOS_RX_DATA00
323  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B1_02_ENET_QOS_RX_DATA00, 0);
324 
325  //Set GPIO_DISP_B1_02 pad properties
326  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B1_02_ENET_QOS_RX_DATA00,
327  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
328  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
329  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
330  IOMUXC_SW_PAD_CTL_PAD_PULL(2) |
331  IOMUXC_SW_PAD_CTL_PAD_PDRV(0));
332 
333  //Configure GPIO_DISP_B1_03 pin as ENET_QOS_RX_DATA01
334  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B1_03_ENET_QOS_RX_DATA01, 0);
335 
336  //Set GPIO_DISP_B1_03 pad properties
337  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B1_03_ENET_QOS_RX_DATA01,
338  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
339  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
340  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
341  IOMUXC_SW_PAD_CTL_PAD_PULL(2) |
342  IOMUXC_SW_PAD_CTL_PAD_PDRV(0));
343 
344  //Configure GPIO_DISP_B1_04 pin as ENET_QOS_RX_DATA02
345  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B1_04_ENET_QOS_RX_DATA02, 0);
346 
347  //Set GPIO_DISP_B1_04 pad properties
348  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B1_04_ENET_QOS_RX_DATA02,
349  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
350  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
351  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
352  IOMUXC_SW_PAD_CTL_PAD_PULL(2) |
353  IOMUXC_SW_PAD_CTL_PAD_PDRV(0));
354 
355  //Configure GPIO_DISP_B1_05 pin as ENET_QOS_RX_DATA03
356  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B1_05_ENET_QOS_RX_DATA03, 0);
357 
358  //Set GPIO_DISP_B1_05 pad properties
359  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B1_05_ENET_QOS_RX_DATA03,
360  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
361  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
362  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
363  IOMUXC_SW_PAD_CTL_PAD_PULL(2) |
364  IOMUXC_SW_PAD_CTL_PAD_PDRV(0));
365 
366  //Configure GPIO_DISP_B1_06 pin as ENET_QOS_TX_DATA03
367  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B1_06_ENET_QOS_TX_DATA03, 0);
368 
369  //Set GPIO_DISP_B1_06 pad properties
370  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B1_06_ENET_QOS_TX_DATA03,
371  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
372  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
373  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
374  IOMUXC_SW_PAD_CTL_PAD_PULL(3) |
375  IOMUXC_SW_PAD_CTL_PAD_PDRV(0));
376 
377  //Configure GPIO_DISP_B1_07 pin as ENET_QOS_TX_DATA02
378  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B1_07_ENET_QOS_TX_DATA02, 0);
379 
380  //Set GPIO_DISP_B1_07 pad properties
381  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B1_07_ENET_QOS_TX_DATA02,
382  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
383  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
384  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
385  IOMUXC_SW_PAD_CTL_PAD_PULL(3) |
386  IOMUXC_SW_PAD_CTL_PAD_PDRV(0));
387 
388  //Configure GPIO_DISP_B1_08 pin as ENET_QOS_TX_DATA01
389  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B1_08_ENET_QOS_TX_DATA01, 0);
390 
391  //Set GPIO_DISP_B1_08 pad properties
392  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B1_08_ENET_QOS_TX_DATA01,
393  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
394  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
395  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
396  IOMUXC_SW_PAD_CTL_PAD_PULL(3) |
397  IOMUXC_SW_PAD_CTL_PAD_PDRV(0));
398 
399  //Configure GPIO_DISP_B1_09 pin as ENET_QOS_TX_DATA00
400  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B1_09_ENET_QOS_TX_DATA00, 0);
401 
402  //Set GPIO_DISP_B1_09 pad properties
403  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B1_09_ENET_QOS_TX_DATA00,
404  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
405  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
406  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
407  IOMUXC_SW_PAD_CTL_PAD_PULL(3) |
408  IOMUXC_SW_PAD_CTL_PAD_PDRV(0));
409 
410  //Configure GPIO_DISP_B1_10 pin as ENET_QOS_TX_EN
411  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B1_10_ENET_QOS_TX_EN, 0);
412 
413  //Set GPIO_DISP_B1_10 pad properties
414  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B1_10_ENET_QOS_TX_EN,
415  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
416  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
417  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
418  IOMUXC_SW_PAD_CTL_PAD_PULL(3) |
419  IOMUXC_SW_PAD_CTL_PAD_PDRV(0));
420 
421  //Configure GPIO_DISP_B1_11 pin as ENET_QOS_TX_CLK
422  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B1_11_ENET_QOS_TX_CLK, 0);
423 
424  //Set GPIO_DISP_B1_11 pad properties
425  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B1_11_ENET_QOS_TX_CLK,
426  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
427  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
428  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
429  IOMUXC_SW_PAD_CTL_PAD_PULL(3) |
430  IOMUXC_SW_PAD_CTL_PAD_PDRV(0));
431 
432  //Configure GPIO_EMC_B2_19 pin as ENET_QOS_MDC
433  IOMUXC_SetPinMux(IOMUXC_GPIO_EMC_B2_19_ENET_QOS_MDC, 0);
434 
435  //Set GPIO_EMC_B2_19 pad properties
436  IOMUXC_SetPinConfig(IOMUXC_GPIO_EMC_B2_19_ENET_QOS_MDC,
437  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
438  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
439  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
440  IOMUXC_SW_PAD_CTL_PAD_PULL(3) |
441  IOMUXC_SW_PAD_CTL_PAD_PDRV(0));
442 
443  //Configure GPIO_EMC_B2_20 pin as ENET_QOS_MDIO
444  IOMUXC_SetPinMux(IOMUXC_GPIO_EMC_B2_20_ENET_QOS_MDIO, 0);
445 
446  //Set GPIO_EMC_B2_20 pad properties
447  IOMUXC_SetPinConfig(IOMUXC_GPIO_EMC_B2_20_ENET_QOS_MDIO,
448  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
449  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
450  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
451  IOMUXC_SW_PAD_CTL_PAD_PULL(1) |
452  IOMUXC_SW_PAD_CTL_PAD_PDRV(0));
453 
454  //Configure GPIO_DISP_B2_13 pin as GPIO11_IO14
455  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B2_13_GPIO11_IO14, 0);
456 
457  //Set GPIO_DISP_B2_13 pad properties
458  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B2_13_GPIO11_IO14,
459  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
460  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
461  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
462  IOMUXC_SW_PAD_CTL_PAD_PUS(0) |
463  IOMUXC_SW_PAD_CTL_PAD_PUE(0) |
464  IOMUXC_SW_PAD_CTL_PAD_DSE(1) |
465  IOMUXC_SW_PAD_CTL_PAD_SRE(0));
466 
467  //Configure GPIO_DISP_B2_12 pin as GPIO11_IO13
468  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B2_12_GPIO11_IO13, 0);
469 
470  //Set GPIO_DISP_B2_12 pad properties
471  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B2_12_GPIO11_IO13,
472  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
473  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
474  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
475  IOMUXC_SW_PAD_CTL_PAD_PUS(0) |
476  IOMUXC_SW_PAD_CTL_PAD_PUE(0) |
477  IOMUXC_SW_PAD_CTL_PAD_DSE(1) |
478  IOMUXC_SW_PAD_CTL_PAD_SRE(0));
479 
480  //Configure ENET_QOS_RST as an output
481  pinConfig.direction = kGPIO_DigitalOutput;
482  pinConfig.outputLogic = 0;
483  pinConfig.interruptMode = kGPIO_NoIntmode;
484  GPIO_PinInit(GPIO11, 14, &pinConfig);
485 
486  //Configure ENET_QOS_INT as an input
487  pinConfig.direction = kGPIO_DigitalInput;
488  pinConfig.outputLogic = 0;
489  pinConfig.interruptMode = kGPIO_NoIntmode;
490  GPIO_PinInit(GPIO11, 13, &pinConfig);
491 
492  //Reset PHY transceiver (hard reset)
493  GPIO_PinWrite(GPIO11, 14, 0);
494  sleep(10);
495  GPIO_PinWrite(GPIO11, 14, 1);
496  sleep(10);
497 #endif
498 }
499 
500 
501 /**
502  * @brief Initialize buffer descriptors
503  * @param[in] interface Underlying network interface
504  **/
505 
507 {
508  uint_t i;
509 
510  //Initialize TX DMA descriptor list
511  for(i = 0; i < MIMXRT1170_ETH3_TX_BUFFER_COUNT; i++)
512  {
513  //The descriptor is initially owned by the application
514  txDmaDesc[i].tdes0 = 0;
515  txDmaDesc[i].tdes1 = 0;
516  txDmaDesc[i].tdes2 = 0;
517  txDmaDesc[i].tdes3 = 0;
518  }
519 
520  //Initialize TX descriptor index
521  txIndex = 0;
522 
523  //Initialize RX DMA descriptor list
524  for(i = 0; i < MIMXRT1170_ETH3_RX_BUFFER_COUNT; i++)
525  {
526  //The descriptor is initially owned by the DMA
527  rxDmaDesc[i].rdes0 = (uint32_t) rxBuffer[i];
528  rxDmaDesc[i].rdes1 = 0;
529  rxDmaDesc[i].rdes2 = 0;
531  }
532 
533  //Initialize RX descriptor index
534  rxIndex = 0;
535 
536  //Start location of the TX descriptor list
537  ENET_QOS->DMA_CH[0].DMA_CHX_TXDESC_LIST_ADDR = (uint32_t) &txDmaDesc[0];
538  //Length of the transmit descriptor ring
539  ENET_QOS->DMA_CH[0].DMA_CHX_TXDESC_RING_LENGTH = MIMXRT1170_ETH3_TX_BUFFER_COUNT - 1;
540 
541  //Start location of the RX descriptor list
542  ENET_QOS->DMA_CH[0].DMA_CHX_RXDESC_LIST_ADDR = (uint32_t) &rxDmaDesc[0];
543  //Length of the receive descriptor ring
544  ENET_QOS->DMA_CH[0].DMA_CHX_RXDESC_RING_LENGTH = MIMXRT1170_ETH3_RX_BUFFER_COUNT - 1;
545 }
546 
547 
548 /**
549  * @brief i.MX RT1170 Ethernet MAC timer handler
550  *
551  * This routine is periodically called by the TCP/IP stack to handle periodic
552  * operations such as polling the link state
553  *
554  * @param[in] interface Underlying network interface
555  **/
556 
558 {
559  //Valid Ethernet PHY or switch driver?
560  if(interface->phyDriver != NULL)
561  {
562  //Handle periodic operations
563  interface->phyDriver->tick(interface);
564  }
565  else if(interface->switchDriver != NULL)
566  {
567  //Handle periodic operations
568  interface->switchDriver->tick(interface);
569  }
570  else
571  {
572  //Just for sanity
573  }
574 }
575 
576 
577 /**
578  * @brief Enable interrupts
579  * @param[in] interface Underlying network interface
580  **/
581 
583 {
584  //Enable Ethernet MAC interrupts
585  NVIC_EnableIRQ(ENET_QOS_IRQn);
586 
587  //Valid Ethernet PHY or switch driver?
588  if(interface->phyDriver != NULL)
589  {
590  //Enable Ethernet PHY interrupts
591  interface->phyDriver->enableIrq(interface);
592  }
593  else if(interface->switchDriver != NULL)
594  {
595  //Enable Ethernet switch interrupts
596  interface->switchDriver->enableIrq(interface);
597  }
598  else
599  {
600  //Just for sanity
601  }
602 }
603 
604 
605 /**
606  * @brief Disable interrupts
607  * @param[in] interface Underlying network interface
608  **/
609 
611 {
612  //Disable Ethernet MAC interrupts
613  NVIC_DisableIRQ(ENET_QOS_IRQn);
614 
615  //Valid Ethernet PHY or switch driver?
616  if(interface->phyDriver != NULL)
617  {
618  //Disable Ethernet PHY interrupts
619  interface->phyDriver->disableIrq(interface);
620  }
621  else if(interface->switchDriver != NULL)
622  {
623  //Disable Ethernet switch interrupts
624  interface->switchDriver->disableIrq(interface);
625  }
626  else
627  {
628  //Just for sanity
629  }
630 }
631 
632 
633 /**
634  * @brief Ethernet MAC interrupt
635  **/
636 
638 {
639  bool_t flag;
640  uint32_t status;
641 
642  //Interrupt service routine prologue
643  osEnterIsr();
644 
645  //This flag will be set if a higher priority task must be woken
646  flag = FALSE;
647 
648  //Read DMA status register
649  status = ENET_QOS->DMA_CH[0].DMA_CHX_STAT;
650 
651  //Packet transmitted?
652  if((status & ENET_QOS_DMA_CHX_STAT_TI_MASK) != 0)
653  {
654  //Clear TI interrupt flag
655  ENET_QOS->DMA_CH[0].DMA_CHX_STAT = ENET_QOS_DMA_CHX_STAT_TI_MASK;
656 
657  //Check whether the TX buffer is available for writing
658  if((txDmaDesc[txIndex].tdes3 & ENET_TDES3_OWN) == 0)
659  {
660  //Notify the TCP/IP stack that the transmitter is ready to send
661  flag |= osSetEventFromIsr(&nicDriverInterface->nicTxEvent);
662  }
663  }
664 
665  //Packet received?
666  if((status & ENET_QOS_DMA_CHX_STAT_RI_MASK) != 0)
667  {
668  //Clear RI interrupt flag
669  ENET_QOS->DMA_CH[0].DMA_CHX_STAT = ENET_QOS_DMA_CHX_STAT_RI_MASK;
670 
671  //Set event flag
672  nicDriverInterface->nicEvent = TRUE;
673  //Notify the TCP/IP stack of the event
674  flag |= osSetEventFromIsr(&nicDriverInterface->netContext->event);
675  }
676 
677  //Clear NIS interrupt flag
678  ENET_QOS->DMA_CH[0].DMA_CHX_STAT = ENET_QOS_DMA_CHX_STAT_NIS_MASK;
679 
680  //Interrupt service routine epilogue
681  osExitIsr(flag);
682 }
683 
684 
685 /**
686  * @brief i.MX RT1170 Ethernet MAC event handler
687  * @param[in] interface Underlying network interface
688  **/
689 
691 {
692  error_t error;
693 
694  //Process all pending packets
695  do
696  {
697  //Read incoming packet
698  error = mimxrt1170Eth3ReceivePacket(interface);
699 
700  //No more data in the receive buffer?
701  } while(error != ERROR_BUFFER_EMPTY);
702 }
703 
704 
705 /**
706  * @brief Send a packet
707  * @param[in] interface Underlying network interface
708  * @param[in] buffer Multi-part buffer containing the data to send
709  * @param[in] offset Offset to the first data byte
710  * @param[in] ancillary Additional options passed to the stack along with
711  * the packet
712  * @return Error code
713  **/
714 
716  const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
717 {
718  size_t length;
719 
720  //Retrieve the length of the packet
721  length = netBufferGetLength(buffer) - offset;
722 
723  //Check the frame length
725  {
726  //The transmitter can accept another packet
727  osSetEvent(&interface->nicTxEvent);
728  //Report an error
729  return ERROR_INVALID_LENGTH;
730  }
731 
732  //Make sure the current buffer is available for writing
733  if((txDmaDesc[txIndex].tdes3 & ENET_TDES3_OWN) != 0)
734  {
735  return ERROR_FAILURE;
736  }
737 
738  //Copy user data to the transmit buffer
739  netBufferRead(txBuffer[txIndex], buffer, offset, length);
740 
741  //Set the start address of the buffer
742  txDmaDesc[txIndex].tdes0 = (uint32_t) txBuffer[txIndex];
743  //Write the number of bytes to send
744  txDmaDesc[txIndex].tdes2 = ENET_TDES2_IOC | (length & ENET_TDES2_B1L);
745  //Give the ownership of the descriptor to the DMA
747 
748  //Data synchronization barrier
749  __DSB();
750 
751  //Clear TBU flag to resume processing
752  ENET_QOS->DMA_CH[0].DMA_CHX_STAT = ENET_QOS_DMA_CHX_STAT_TBU_MASK;
753  //Instruct the DMA to poll the transmit descriptor list
754  ENET_QOS->DMA_CH[0].DMA_CHX_TXDESC_TAIL_PTR = 0;
755 
756  //Increment index and wrap around if necessary
757  if(++txIndex >= MIMXRT1170_ETH3_TX_BUFFER_COUNT)
758  {
759  txIndex = 0;
760  }
761 
762  //Check whether the next buffer is available for writing
763  if((txDmaDesc[txIndex].tdes3 & ENET_TDES3_OWN) == 0)
764  {
765  //The transmitter can accept another packet
766  osSetEvent(&interface->nicTxEvent);
767  }
768 
769  //Data successfully written
770  return NO_ERROR;
771 }
772 
773 
774 /**
775  * @brief Receive a packet
776  * @param[in] interface Underlying network interface
777  * @return Error code
778  **/
779 
781 {
782  error_t error;
783  size_t n;
784  NetRxAncillary ancillary;
785 
786  //Current buffer available for reading?
787  if((rxDmaDesc[rxIndex].rdes3 & ENET_RDES3_OWN) == 0)
788  {
789  //FD and LD flags should be set
790  if((rxDmaDesc[rxIndex].rdes3 & ENET_RDES3_FD) != 0 &&
791  (rxDmaDesc[rxIndex].rdes3 & ENET_RDES3_LD) != 0)
792  {
793  //Make sure no error occurred
794  if((rxDmaDesc[rxIndex].rdes3 & ENET_RDES3_ES) == 0)
795  {
796  //Retrieve the length of the frame
797  n = rxDmaDesc[rxIndex].rdes3 & ENET_RDES3_PL;
798  //Limit the number of data to read
800 
801  //Additional options can be passed to the stack along with the packet
802  ancillary = NET_DEFAULT_RX_ANCILLARY;
803 
804  //Pass the packet to the upper layer
805  nicProcessPacket(interface, rxBuffer[rxIndex], n, &ancillary);
806 
807  //Valid packet received
808  error = NO_ERROR;
809  }
810  else
811  {
812  //The received packet contains an error
813  error = ERROR_INVALID_PACKET;
814  }
815  }
816  else
817  {
818  //The packet is not valid
819  error = ERROR_INVALID_PACKET;
820  }
821 
822  //Set the start address of the buffer
823  rxDmaDesc[rxIndex].rdes0 = (uint32_t) rxBuffer[rxIndex];
824  //Give the ownership of the descriptor back to the DMA
826 
827  //Increment index and wrap around if necessary
828  if(++rxIndex >= MIMXRT1170_ETH3_RX_BUFFER_COUNT)
829  {
830  rxIndex = 0;
831  }
832  }
833  else
834  {
835  //No more data in the receive buffer
836  error = ERROR_BUFFER_EMPTY;
837  }
838 
839  //Clear RBU flag to resume processing
840  ENET_QOS->DMA_CH[0].DMA_CHX_STAT = ENET_QOS_DMA_CHX_STAT_RBU_MASK;
841  //Instruct the DMA to poll the receive descriptor list
842  ENET_QOS->DMA_CH[0].DMA_CHX_RXDESC_TAIL_PTR = 0;
843 
844  //Return status code
845  return error;
846 }
847 
848 
849 /**
850  * @brief Configure MAC address filtering
851  * @param[in] interface Underlying network interface
852  * @return Error code
853  **/
854 
856 {
857  uint_t i;
858  uint_t j;
859  MacFilterEntry *entry;
860 
861  //Debug message
862  TRACE_DEBUG("Updating MAC filter...\r\n");
863 
864  //Configure the receive filter
865  ENET_QOS->MAC_PACKET_FILTER = 0;
866 
867  //Set the MAC address of the station
868  ENET_QOS->MAC_ADDRESS[0].LOW = interface->macAddr.w[0] | (interface->macAddr.w[1] << 16);
869  ENET_QOS->MAC_ADDRESS[0].HIGH = interface->macAddr.w[2];
870 
871  //The MAC address filter contains the list of MAC addresses to accept
872  //when receiving an Ethernet frame
873  for(i = 0, j = 1; i < MAC_ADDR_FILTER_SIZE && j < 64; i++)
874  {
875  //Point to the current entry
876  entry = &interface->macAddrFilter[i];
877 
878  //Valid entry?
879  if(entry->refCount > 0)
880  {
881  //When the AE bit is set, the entry is used for perfect filtering
882  ENET_QOS->MAC_ADDRESS[j].LOW = entry->addr.w[0] | (entry->addr.w[1] << 16);
883  ENET_QOS->MAC_ADDRESS[j].HIGH = entry->addr.w[2] | ENET_QOS_HIGH_AE_MASK;
884 
885  //Next entry
886  j++;
887  }
888  }
889 
890  //Clear unused entries
891  while(j < 64)
892  {
893  //When the AE bit is cleared, the entry is ignored
894  ENET_QOS->MAC_ADDRESS[j].LOW = 0;
895  ENET_QOS->MAC_ADDRESS[j].HIGH = 0;
896 
897  //Next entry
898  j++;
899  }
900 
901  //Successful processing
902  return NO_ERROR;
903 }
904 
905 
906 /**
907  * @brief Adjust MAC configuration parameters for proper operation
908  * @param[in] interface Underlying network interface
909  * @return Error code
910  **/
911 
913 {
914  uint32_t config;
915 
916  //Read current MAC configuration
917  config = ENET_QOS->MAC_CONFIGURATION;
918 
919  //1000BASE-T operation mode?
920  if(interface->linkSpeed == NIC_LINK_SPEED_1GBPS)
921  {
922  config &= ~ENET_QOS_MAC_CONFIGURATION_PS_MASK;
923  config &= ~ENET_QOS_MAC_CONFIGURATION_FES_MASK;
924  }
925  //100BASE-TX operation mode?
926  else if(interface->linkSpeed == NIC_LINK_SPEED_100MBPS)
927  {
928  config |= ENET_QOS_MAC_CONFIGURATION_PS_MASK;
929  config |= ENET_QOS_MAC_CONFIGURATION_FES_MASK;
930  }
931  //10BASE-T operation mode?
932  else
933  {
934  config |= ENET_QOS_MAC_CONFIGURATION_PS_MASK;
935  config &= ~ENET_QOS_MAC_CONFIGURATION_FES_MASK;
936  }
937 
938  //Half-duplex or full-duplex mode?
939  if(interface->duplexMode == NIC_FULL_DUPLEX_MODE)
940  {
941  config |= ENET_QOS_MAC_CONFIGURATION_DM_MASK;
942  }
943  else
944  {
945  config &= ~ENET_QOS_MAC_CONFIGURATION_DM_MASK;
946  }
947 
948  //Update MAC configuration register
949  ENET_QOS->MAC_CONFIGURATION = config;
950 
951  //Successful processing
952  return NO_ERROR;
953 }
954 
955 
956 /**
957  * @brief Write PHY register
958  * @param[in] opcode Access type (2 bits)
959  * @param[in] phyAddr PHY address (5 bits)
960  * @param[in] regAddr Register address (5 bits)
961  * @param[in] data Register value
962  **/
963 
964 void mimxrt1170Eth3WritePhyReg(uint8_t opcode, uint8_t phyAddr,
965  uint8_t regAddr, uint16_t data)
966 {
967  uint32_t temp;
968 
969  //Valid opcode?
970  if(opcode == SMI_OPCODE_WRITE)
971  {
972  //Take care not to alter MDC clock configuration
973  temp = ENET_QOS->MAC_MDIO_ADDRESS & ENET_QOS_MAC_MDIO_ADDRESS_CR_MASK;
974 
975  //Set up a write operation
976  temp |= ENET_QOS_MAC_MDIO_ADDRESS_GOC_0_MASK |
977  ENET_QOS_MAC_MDIO_ADDRESS_GB_MASK;
978 
979  //PHY address
980  temp |= ENET_QOS_MAC_MDIO_ADDRESS_PA(phyAddr);
981  //Register address
982  temp |= ENET_QOS_MAC_MDIO_ADDRESS_RDA(regAddr);
983 
984  //Data to be written in the PHY register
985  ENET_QOS->MAC_MDIO_DATA = data & ENET_QOS_MAC_MDIO_DATA_GD_MASK;
986 
987  //Start a write operation
988  ENET_QOS->MAC_MDIO_ADDRESS = temp;
989  //Wait for the write to complete
990  while((ENET_QOS->MAC_MDIO_ADDRESS & ENET_QOS_MAC_MDIO_ADDRESS_GB_MASK) != 0)
991  {
992  }
993  }
994  else
995  {
996  //The MAC peripheral only supports standard Clause 22 opcodes
997  }
998 }
999 
1000 
1001 /**
1002  * @brief Read PHY register
1003  * @param[in] opcode Access type (2 bits)
1004  * @param[in] phyAddr PHY address (5 bits)
1005  * @param[in] regAddr Register address (5 bits)
1006  * @return Register value
1007  **/
1008 
1009 uint16_t mimxrt1170Eth3ReadPhyReg(uint8_t opcode, uint8_t phyAddr,
1010  uint8_t regAddr)
1011 {
1012  uint16_t data;
1013  uint32_t temp;
1014 
1015  //Valid opcode?
1016  if(opcode == SMI_OPCODE_READ)
1017  {
1018  //Take care not to alter MDC clock configuration
1019  temp = ENET_QOS->MAC_MDIO_ADDRESS & ENET_QOS_MAC_MDIO_ADDRESS_CR_MASK;
1020 
1021  //Set up a read operation
1022  temp |= ENET_QOS_MAC_MDIO_ADDRESS_GOC_1_MASK |
1023  ENET_QOS_MAC_MDIO_ADDRESS_GOC_0_MASK | ENET_QOS_MAC_MDIO_ADDRESS_GB_MASK;
1024 
1025  //PHY address
1026  temp |= ENET_QOS_MAC_MDIO_ADDRESS_PA(phyAddr);
1027  //Register address
1028  temp |= ENET_QOS_MAC_MDIO_ADDRESS_RDA(regAddr);
1029 
1030  //Start a read operation
1031  ENET_QOS->MAC_MDIO_ADDRESS = temp;
1032  //Wait for the read to complete
1033  while((ENET_QOS->MAC_MDIO_ADDRESS & ENET_QOS_MAC_MDIO_ADDRESS_GB_MASK) != 0)
1034  {
1035  }
1036 
1037  //Get register value
1038  data = ENET_QOS->MAC_MDIO_DATA & ENET_QOS_MAC_MDIO_DATA_GD_MASK;
1039  }
1040  else
1041  {
1042  //The MAC peripheral only supports standard Clause 22 opcodes
1043  data = 0;
1044  }
1045 
1046  //Return the value of the PHY register
1047  return data;
1048 }
bool_t osSetEventFromIsr(OsEvent *event)
Set an event object to the signaled state from an interrupt service routine.
@ NIC_LINK_SPEED_1GBPS
Definition: nic.h:113
uint8_t opcode
Definition: dns_common.h:191
int bool_t
Definition: compiler_port.h:63
@ NIC_FULL_DUPLEX_MODE
Definition: nic.h:125
void mimxrt1170Eth3DisableIrq(NetInterface *interface)
Disable interrupts.
size_t netBufferRead(void *dest, const NetBuffer *src, size_t srcOffset, size_t length)
Read data from a multi-part buffer.
Definition: net_mem.c:690
#define ENET_RDES3_OWN
#define ENET_RDES3_IOC
#define ENET_RDES3_ES
#define ENET_TDES2_IOC
#define ENET_RDES3_PL
error_t mimxrt1170Eth3ReceivePacket(NetInterface *interface)
Receive a packet.
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:89
#define MAC_ADDR_FILTER_SIZE
Definition: ethernet.h:95
#define TRUE
Definition: os_port.h:50
#define ENET_RDES3_LD
uint8_t data[]
Definition: ethernet.h:224
#define sleep(delay)
Definition: os_port.h:310
void mimxrt1170Eth3Tick(NetInterface *interface)
i.MX RT1170 Ethernet MAC timer handler
#define MIMXRT1170_ETH3_RAM_SECTION
uint_t refCount
Reference count for the current entry.
Definition: ethernet.h:266
#define MIMXRT1170_ETH3_RX_BUFFER_SIZE
void ENET_QOS_IRQHandler(void)
Ethernet MAC interrupt.
void nicProcessPacket(NetInterface *interface, uint8_t *packet, size_t length, NetRxAncillary *ancillary)
Handle a packet received by the network controller.
Definition: nic.c:418
#define osExitIsr(flag)
#define ENET_RDES3_BUF1V
#define SMI_OPCODE_WRITE
Definition: nic.h:66
#define MIMXRT1170_ETH3_IRQ_PRIORITY_GROUPING
#define MIMXRT1170_ETH3_TX_BUFFER_COUNT
#define ENET_TDES2_B1L
const NicDriver mimxrt1170Eth3Driver
i.MX RT1170 Ethernet MAC driver (ENET_QOS instance)
NXP i.MX RT1170 Gigabit Ethernet MAC driver (ENET_QOS instance)
#define FALSE
Definition: os_port.h:46
#define MIMXRT1170_ETH3_TX_BUFFER_SIZE
error_t
Error codes.
Definition: error.h:43
void mimxrt1170Eth3InitDmaDesc(NetInterface *interface)
Initialize buffer descriptors.
const NetRxAncillary NET_DEFAULT_RX_ANCILLARY
Definition: net_misc.c:103
@ ERROR_FAILURE
Generic error code.
Definition: error.h:45
#define txBuffer
#define NetRxAncillary
Definition: net_misc.h:40
@ ERROR_INVALID_PACKET
Definition: error.h:141
#define NetInterface
Definition: net.h:40
MacAddr addr
MAC address.
Definition: ethernet.h:265
@ ERROR_INVALID_LENGTH
Definition: error.h:111
@ ERROR_BUFFER_EMPTY
Definition: error.h:142
#define NetTxAncillary
Definition: net_misc.h:36
#define SMI_OPCODE_READ
Definition: nic.h:67
#define MIMXRT1170_ETH3_IRQ_GROUP_PRIORITY
#define TRACE_INFO(...)
Definition: debug.h:105
uint8_t length
Definition: tcp.h:375
size_t netBufferGetLength(const NetBuffer *buffer)
Get the actual length of a multi-part buffer.
Definition: net_mem.c:297
error_t mimxrt1170Eth3SendPacket(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a packet.
#define MIMXRT1170_ETH3_RX_BUFFER_COUNT
#define MIN(a, b)
Definition: os_port.h:63
void mimxrt1170Eth3WritePhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr, uint16_t data)
Write PHY register.
#define rxBuffer
#define MIMXRT1170_ETH3_IRQ_SUB_PRIORITY
uint16_t mimxrt1170Eth3ReadPhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr)
Read PHY register.
#define TRACE_DEBUG(...)
Definition: debug.h:119
error_t mimxrt1170Eth3UpdateMacConfig(NetInterface *interface)
Adjust MAC configuration parameters for proper operation.
uint16_t regAddr
#define ENET_RDES3_FD
#define ETH_MTU
Definition: ethernet.h:116
uint8_t n
MAC filter table entry.
Definition: ethernet.h:264
#define ENET_TDES3_OWN
error_t mimxrt1170Eth3UpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
#define ENET_TDES3_LD
#define osEnterIsr()
error_t mimxrt1170Eth3Init(NetInterface *interface)
i.MX RT1170 Ethernet MAC initialization
#define ENET_TDES3_FD
void mimxrt1170Eth3EnableIrq(NetInterface *interface)
Enable interrupts.
__weak_func void mimxrt1170Eth3InitGpio(NetInterface *interface)
GPIO configuration.
#define rxDmaDesc
void osSetEvent(OsEvent *event)
Set the specified event object to the signaled state.
#define txDmaDesc
@ NIC_LINK_SPEED_100MBPS
Definition: nic.h:112
unsigned int uint_t
Definition: compiler_port.h:57
TCP/IP stack core.
NIC driver.
Definition: nic.h:286
void mimxrt1170Eth3EventHandler(NetInterface *interface)
i.MX RT1170 Ethernet MAC event handler
@ NO_ERROR
Success.
Definition: error.h:44
__attribute__((naked))
AVR32 Ethernet MAC interrupt wrapper.
Debugging facilities.
@ NIC_TYPE_ETHERNET
Ethernet interface.
Definition: nic.h:83