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-2024 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.4.4
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 the 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 
219  //Disable MAC interrupts
220  ENET_QOS->MAC_INTERRUPT_ENABLE = 0;
221 
222  //Enable the desired DMA interrupts
223  ENET_QOS->DMA_CH[0].DMA_CHX_INT_EN = ENET_QOS_DMA_CHX_INT_EN_NIE_MASK |
224  ENET_QOS_DMA_CHX_INT_EN_RIE_MASK | ENET_QOS_DMA_CHX_INT_EN_TIE_MASK;
225 
226  //Set priority grouping (3 bits for pre-emption priority, no bits for subpriority)
227  NVIC_SetPriorityGrouping(MIMXRT1170_ETH3_IRQ_PRIORITY_GROUPING);
228 
229  //Configure ENET_QOS interrupt priority
230  NVIC_SetPriority(ENET_QOS_IRQn, NVIC_EncodePriority(MIMXRT1170_ETH3_IRQ_PRIORITY_GROUPING,
232 
233  //Enable MAC transmission and reception
234  ENET_QOS->MAC_CONFIGURATION |= ENET_QOS_MAC_CONFIGURATION_TE_MASK |
235  ENET_QOS_MAC_CONFIGURATION_RE_MASK;
236 
237  //Enable DMA transmission and reception
238  ENET_QOS->DMA_CH[0].DMA_CHX_TX_CTRL |= ENET_QOS_DMA_CHX_TX_CTRL_ST_MASK;
239  ENET_QOS->DMA_CH[0].DMA_CHX_RX_CTRL |= ENET_QOS_DMA_CHX_RX_CTRL_SR_MASK;
240 
241  //Accept any packets from the upper layer
242  osSetEvent(&interface->nicTxEvent);
243 
244  //Successful initialization
245  return NO_ERROR;
246 }
247 
248 
249 /**
250  * @brief GPIO configuration
251  * @param[in] interface Underlying network interface
252  **/
253 
254 __weak_func void mimxrt1170Eth3InitGpio(NetInterface *interface)
255 {
256 //MIMXRT1170-EVK evaluation board?
257 #if defined(USE_MIMXRT1170_EVK)
258  uint32_t temp;
259  gpio_pin_config_t pinConfig;
260  clock_root_config_t rootConfig = {0};
261 #if 0
262  clock_sys_pll1_config_t sysPll1Config = {0};
263 
264  //Initialize system PLL1
265  sysPll1Config.pllDiv2En = true;
266  CLOCK_InitSysPll1(&sysPll1Config);
267 #endif
268 
269  //Generate 125MHz root clock
270  rootConfig.clockOff = false;
271  rootConfig.mux = kCLOCK_ENET_QOS_ClockRoot_MuxSysPll1Div2;
272  rootConfig.div = 4;
273  CLOCK_SetRootClock(kCLOCK_Root_Enet_Qos, &rootConfig);
274 
275 #if 0
276  //Initialize PLL PFD3 (528*18/24 = 396MHz)
277  CLOCK_InitPfd(kCLOCK_PllSys2, kCLOCK_Pfd3, 24);
278 
279  //Generate 198MHz bus clock
280  rootConfig.clockOff = false;
281  rootConfig.mux = kCLOCK_BUS_ClockRoot_MuxSysPll2Pfd3;
282  rootConfig.div = 2;
283  CLOCK_SetRootClock(kCLOCK_Root_Bus, &rootConfig);
284 #endif
285 
286  //Select RGMII interface mode
287  temp = IOMUXC_GPR->GPR6 & ~IOMUXC_GPR_GPR6_ENET_QOS_INTF_SEL_MASK;
288  IOMUXC_GPR->GPR6 = temp | IOMUXC_GPR_GPR6_ENET_QOS_INTF_SEL(1);
289 
290  //ENET_QOS_TX_CLK is driven by ENET_QOS_CLK_ROOT
291  IOMUXC_GPR->GPR6 |= IOMUXC_GPR_GPR6_ENET_QOS_CLKGEN_EN_MASK;
292  //Enable ENET_QOS_TX_CLK output
293  IOMUXC_GPR->GPR6 |= IOMUXC_GPR_GPR6_ENET_QOS_RGMII_EN_MASK;
294 
295  //Enable IOMUXC clock
296  CLOCK_EnableClock(kCLOCK_Iomuxc);
297 
298  //Configure GPIO_DISP_B1_00 pin as ENET_QOS_RX_EN
299  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B1_00_ENET_QOS_RX_EN, 0);
300 
301  //Set GPIO_DISP_B1_00 pad properties
302  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B1_00_ENET_QOS_RX_EN,
303  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
304  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
305  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
306  IOMUXC_SW_PAD_CTL_PAD_PULL(2) |
307  IOMUXC_SW_PAD_CTL_PAD_PDRV(0));
308 
309  //Configure GPIO_DISP_B1_01 pin as ENET_QOS_RX_CLK
310  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B1_01_ENET_QOS_RX_CLK, 0);
311 
312  //Set GPIO_DISP_B1_01 pad properties
313  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B1_01_ENET_QOS_RX_CLK,
314  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
315  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
316  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
317  IOMUXC_SW_PAD_CTL_PAD_PULL(2) |
318  IOMUXC_SW_PAD_CTL_PAD_PDRV(0));
319 
320  //Configure GPIO_DISP_B1_02 pin as ENET_QOS_RX_DATA00
321  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B1_02_ENET_QOS_RX_DATA00, 0);
322 
323  //Set GPIO_DISP_B1_02 pad properties
324  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B1_02_ENET_QOS_RX_DATA00,
325  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
326  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
327  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
328  IOMUXC_SW_PAD_CTL_PAD_PULL(2) |
329  IOMUXC_SW_PAD_CTL_PAD_PDRV(0));
330 
331  //Configure GPIO_DISP_B1_03 pin as ENET_QOS_RX_DATA01
332  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B1_03_ENET_QOS_RX_DATA01, 0);
333 
334  //Set GPIO_DISP_B1_03 pad properties
335  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B1_03_ENET_QOS_RX_DATA01,
336  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
337  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
338  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
339  IOMUXC_SW_PAD_CTL_PAD_PULL(2) |
340  IOMUXC_SW_PAD_CTL_PAD_PDRV(0));
341 
342  //Configure GPIO_DISP_B1_04 pin as ENET_QOS_RX_DATA02
343  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B1_04_ENET_QOS_RX_DATA02, 0);
344 
345  //Set GPIO_DISP_B1_04 pad properties
346  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B1_04_ENET_QOS_RX_DATA02,
347  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
348  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
349  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
350  IOMUXC_SW_PAD_CTL_PAD_PULL(2) |
351  IOMUXC_SW_PAD_CTL_PAD_PDRV(0));
352 
353  //Configure GPIO_DISP_B1_05 pin as ENET_QOS_RX_DATA03
354  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B1_05_ENET_QOS_RX_DATA03, 0);
355 
356  //Set GPIO_DISP_B1_05 pad properties
357  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B1_05_ENET_QOS_RX_DATA03,
358  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
359  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
360  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
361  IOMUXC_SW_PAD_CTL_PAD_PULL(2) |
362  IOMUXC_SW_PAD_CTL_PAD_PDRV(0));
363 
364  //Configure GPIO_DISP_B1_06 pin as ENET_QOS_TX_DATA03
365  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B1_06_ENET_QOS_TX_DATA03, 0);
366 
367  //Set GPIO_DISP_B1_06 pad properties
368  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B1_06_ENET_QOS_TX_DATA03,
369  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
370  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
371  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
372  IOMUXC_SW_PAD_CTL_PAD_PULL(3) |
373  IOMUXC_SW_PAD_CTL_PAD_PDRV(0));
374 
375  //Configure GPIO_DISP_B1_07 pin as ENET_QOS_TX_DATA02
376  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B1_07_ENET_QOS_TX_DATA02, 0);
377 
378  //Set GPIO_DISP_B1_07 pad properties
379  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B1_07_ENET_QOS_TX_DATA02,
380  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
381  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
382  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
383  IOMUXC_SW_PAD_CTL_PAD_PULL(3) |
384  IOMUXC_SW_PAD_CTL_PAD_PDRV(0));
385 
386  //Configure GPIO_DISP_B1_08 pin as ENET_QOS_TX_DATA01
387  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B1_08_ENET_QOS_TX_DATA01, 0);
388 
389  //Set GPIO_DISP_B1_08 pad properties
390  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B1_08_ENET_QOS_TX_DATA01,
391  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
392  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
393  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
394  IOMUXC_SW_PAD_CTL_PAD_PULL(3) |
395  IOMUXC_SW_PAD_CTL_PAD_PDRV(0));
396 
397  //Configure GPIO_DISP_B1_09 pin as ENET_QOS_TX_DATA00
398  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B1_09_ENET_QOS_TX_DATA00, 0);
399 
400  //Set GPIO_DISP_B1_09 pad properties
401  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B1_09_ENET_QOS_TX_DATA00,
402  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
403  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
404  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
405  IOMUXC_SW_PAD_CTL_PAD_PULL(3) |
406  IOMUXC_SW_PAD_CTL_PAD_PDRV(0));
407 
408  //Configure GPIO_DISP_B1_10 pin as ENET_QOS_TX_EN
409  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B1_10_ENET_QOS_TX_EN, 0);
410 
411  //Set GPIO_DISP_B1_10 pad properties
412  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B1_10_ENET_QOS_TX_EN,
413  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
414  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
415  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
416  IOMUXC_SW_PAD_CTL_PAD_PULL(3) |
417  IOMUXC_SW_PAD_CTL_PAD_PDRV(0));
418 
419  //Configure GPIO_DISP_B1_11 pin as ENET_QOS_TX_CLK
420  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B1_11_ENET_QOS_TX_CLK, 0);
421 
422  //Set GPIO_DISP_B1_11 pad properties
423  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B1_11_ENET_QOS_TX_CLK,
424  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
425  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
426  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
427  IOMUXC_SW_PAD_CTL_PAD_PULL(3) |
428  IOMUXC_SW_PAD_CTL_PAD_PDRV(0));
429 
430  //Configure GPIO_EMC_B2_19 pin as ENET_QOS_MDC
431  IOMUXC_SetPinMux(IOMUXC_GPIO_EMC_B2_19_ENET_QOS_MDC, 0);
432 
433  //Set GPIO_EMC_B2_19 pad properties
434  IOMUXC_SetPinConfig(IOMUXC_GPIO_EMC_B2_19_ENET_QOS_MDC,
435  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
436  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
437  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
438  IOMUXC_SW_PAD_CTL_PAD_PULL(3) |
439  IOMUXC_SW_PAD_CTL_PAD_PDRV(0));
440 
441  //Configure GPIO_EMC_B2_20 pin as ENET_QOS_MDIO
442  IOMUXC_SetPinMux(IOMUXC_GPIO_EMC_B2_20_ENET_QOS_MDIO, 0);
443 
444  //Set GPIO_EMC_B2_20 pad properties
445  IOMUXC_SetPinConfig(IOMUXC_GPIO_EMC_B2_20_ENET_QOS_MDIO,
446  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
447  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
448  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
449  IOMUXC_SW_PAD_CTL_PAD_PULL(1) |
450  IOMUXC_SW_PAD_CTL_PAD_PDRV(0));
451 
452  //Configure GPIO_DISP_B2_13 pin as GPIO11_IO14
453  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B2_13_GPIO11_IO14, 0);
454 
455  //Set GPIO_DISP_B2_13 pad properties
456  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B2_13_GPIO11_IO14,
457  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
458  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
459  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
460  IOMUXC_SW_PAD_CTL_PAD_PUS(0) |
461  IOMUXC_SW_PAD_CTL_PAD_PUE(0) |
462  IOMUXC_SW_PAD_CTL_PAD_DSE(1) |
463  IOMUXC_SW_PAD_CTL_PAD_SRE(0));
464 
465  //Configure GPIO_DISP_B2_12 pin as GPIO11_IO13
466  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B2_12_GPIO11_IO13, 0);
467 
468  //Set GPIO_DISP_B2_12 pad properties
469  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B2_12_GPIO11_IO13,
470  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
471  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
472  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
473  IOMUXC_SW_PAD_CTL_PAD_PUS(0) |
474  IOMUXC_SW_PAD_CTL_PAD_PUE(0) |
475  IOMUXC_SW_PAD_CTL_PAD_DSE(1) |
476  IOMUXC_SW_PAD_CTL_PAD_SRE(0));
477 
478  //Configure ENET_QOS_RST as an output
479  pinConfig.direction = kGPIO_DigitalOutput;
480  pinConfig.outputLogic = 0;
481  pinConfig.interruptMode = kGPIO_NoIntmode;
482  GPIO_PinInit(GPIO11, 14, &pinConfig);
483 
484  //Configure ENET_QOS_INT as an input
485  pinConfig.direction = kGPIO_DigitalInput;
486  pinConfig.outputLogic = 0;
487  pinConfig.interruptMode = kGPIO_NoIntmode;
488  GPIO_PinInit(GPIO11, 13, &pinConfig);
489 
490  //Reset PHY transceiver (hard reset)
491  GPIO_PinWrite(GPIO11, 14, 0);
492  sleep(10);
493  GPIO_PinWrite(GPIO11, 14, 1);
494  sleep(10);
495 #endif
496 }
497 
498 
499 /**
500  * @brief Initialize buffer descriptors
501  * @param[in] interface Underlying network interface
502  **/
503 
505 {
506  uint_t i;
507 
508  //Initialize TX DMA descriptor list
509  for(i = 0; i < MIMXRT1170_ETH3_TX_BUFFER_COUNT; i++)
510  {
511  //The descriptor is initially owned by the application
512  txDmaDesc[i].tdes0 = 0;
513  txDmaDesc[i].tdes1 = 0;
514  txDmaDesc[i].tdes2 = 0;
515  txDmaDesc[i].tdes3 = 0;
516  }
517 
518  //Initialize TX descriptor index
519  txIndex = 0;
520 
521  //Initialize RX DMA descriptor list
522  for(i = 0; i < MIMXRT1170_ETH3_RX_BUFFER_COUNT; i++)
523  {
524  //The descriptor is initially owned by the DMA
525  rxDmaDesc[i].rdes0 = (uint32_t) rxBuffer[i];
526  rxDmaDesc[i].rdes1 = 0;
527  rxDmaDesc[i].rdes2 = 0;
529  }
530 
531  //Initialize RX descriptor index
532  rxIndex = 0;
533 
534  //Start location of the TX descriptor list
535  ENET_QOS->DMA_CH[0].DMA_CHX_TXDESC_LIST_ADDR = (uint32_t) &txDmaDesc[0];
536  //Length of the transmit descriptor ring
537  ENET_QOS->DMA_CH[0].DMA_CHX_TXDESC_RING_LENGTH = MIMXRT1170_ETH3_TX_BUFFER_COUNT - 1;
538 
539  //Start location of the RX descriptor list
540  ENET_QOS->DMA_CH[0].DMA_CHX_RXDESC_LIST_ADDR = (uint32_t) &rxDmaDesc[0];
541  //Length of the receive descriptor ring
542  ENET_QOS->DMA_CH[0].DMA_CHX_RXDESC_RING_LENGTH = MIMXRT1170_ETH3_RX_BUFFER_COUNT - 1;
543 }
544 
545 
546 /**
547  * @brief i.MX RT1170 Ethernet MAC timer handler
548  *
549  * This routine is periodically called by the TCP/IP stack to handle periodic
550  * operations such as polling the link state
551  *
552  * @param[in] interface Underlying network interface
553  **/
554 
556 {
557  //Valid Ethernet PHY or switch driver?
558  if(interface->phyDriver != NULL)
559  {
560  //Handle periodic operations
561  interface->phyDriver->tick(interface);
562  }
563  else if(interface->switchDriver != NULL)
564  {
565  //Handle periodic operations
566  interface->switchDriver->tick(interface);
567  }
568  else
569  {
570  //Just for sanity
571  }
572 }
573 
574 
575 /**
576  * @brief Enable interrupts
577  * @param[in] interface Underlying network interface
578  **/
579 
581 {
582  //Enable Ethernet MAC interrupts
583  NVIC_EnableIRQ(ENET_QOS_IRQn);
584 
585  //Valid Ethernet PHY or switch driver?
586  if(interface->phyDriver != NULL)
587  {
588  //Enable Ethernet PHY interrupts
589  interface->phyDriver->enableIrq(interface);
590  }
591  else if(interface->switchDriver != NULL)
592  {
593  //Enable Ethernet switch interrupts
594  interface->switchDriver->enableIrq(interface);
595  }
596  else
597  {
598  //Just for sanity
599  }
600 }
601 
602 
603 /**
604  * @brief Disable interrupts
605  * @param[in] interface Underlying network interface
606  **/
607 
609 {
610  //Disable Ethernet MAC interrupts
611  NVIC_DisableIRQ(ENET_QOS_IRQn);
612 
613  //Valid Ethernet PHY or switch driver?
614  if(interface->phyDriver != NULL)
615  {
616  //Disable Ethernet PHY interrupts
617  interface->phyDriver->disableIrq(interface);
618  }
619  else if(interface->switchDriver != NULL)
620  {
621  //Disable Ethernet switch interrupts
622  interface->switchDriver->disableIrq(interface);
623  }
624  else
625  {
626  //Just for sanity
627  }
628 }
629 
630 
631 /**
632  * @brief Ethernet MAC interrupt
633  **/
634 
636 {
637  bool_t flag;
638  uint32_t status;
639 
640  //Interrupt service routine prologue
641  osEnterIsr();
642 
643  //This flag will be set if a higher priority task must be woken
644  flag = FALSE;
645 
646  //Read DMA status register
647  status = ENET_QOS->DMA_CH[0].DMA_CHX_STAT;
648 
649  //Packet transmitted?
650  if((status & ENET_QOS_DMA_CHX_STAT_TI_MASK) != 0)
651  {
652  //Clear TI interrupt flag
653  ENET_QOS->DMA_CH[0].DMA_CHX_STAT = ENET_QOS_DMA_CHX_STAT_TI_MASK;
654 
655  //Check whether the TX buffer is available for writing
656  if((txDmaDesc[txIndex].tdes3 & ENET_TDES3_OWN) == 0)
657  {
658  //Notify the TCP/IP stack that the transmitter is ready to send
659  flag |= osSetEventFromIsr(&nicDriverInterface->nicTxEvent);
660  }
661  }
662 
663  //Packet received?
664  if((status & ENET_QOS_DMA_CHX_STAT_RI_MASK) != 0)
665  {
666  //Clear RI interrupt flag
667  ENET_QOS->DMA_CH[0].DMA_CHX_STAT = ENET_QOS_DMA_CHX_STAT_RI_MASK;
668 
669  //Set event flag
670  nicDriverInterface->nicEvent = TRUE;
671  //Notify the TCP/IP stack of the event
672  flag |= osSetEventFromIsr(&netEvent);
673  }
674 
675  //Clear NIS interrupt flag
676  ENET_QOS->DMA_CH[0].DMA_CHX_STAT = ENET_QOS_DMA_CHX_STAT_NIS_MASK;
677 
678  //Interrupt service routine epilogue
679  osExitIsr(flag);
680 }
681 
682 
683 /**
684  * @brief i.MX RT1170 Ethernet MAC event handler
685  * @param[in] interface Underlying network interface
686  **/
687 
689 {
690  error_t error;
691 
692  //Process all pending packets
693  do
694  {
695  //Read incoming packet
696  error = mimxrt1170Eth3ReceivePacket(interface);
697 
698  //No more data in the receive buffer?
699  } while(error != ERROR_BUFFER_EMPTY);
700 }
701 
702 
703 /**
704  * @brief Send a packet
705  * @param[in] interface Underlying network interface
706  * @param[in] buffer Multi-part buffer containing the data to send
707  * @param[in] offset Offset to the first data byte
708  * @param[in] ancillary Additional options passed to the stack along with
709  * the packet
710  * @return Error code
711  **/
712 
714  const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
715 {
716  size_t length;
717 
718  //Retrieve the length of the packet
719  length = netBufferGetLength(buffer) - offset;
720 
721  //Check the frame length
723  {
724  //The transmitter can accept another packet
725  osSetEvent(&interface->nicTxEvent);
726  //Report an error
727  return ERROR_INVALID_LENGTH;
728  }
729 
730  //Make sure the current buffer is available for writing
731  if((txDmaDesc[txIndex].tdes3 & ENET_TDES3_OWN) != 0)
732  {
733  return ERROR_FAILURE;
734  }
735 
736  //Copy user data to the transmit buffer
737  netBufferRead(txBuffer[txIndex], buffer, offset, length);
738 
739  //Set the start address of the buffer
740  txDmaDesc[txIndex].tdes0 = (uint32_t) txBuffer[txIndex];
741  //Write the number of bytes to send
742  txDmaDesc[txIndex].tdes2 = ENET_TDES2_IOC | (length & ENET_TDES2_B1L);
743  //Give the ownership of the descriptor to the DMA
745 
746  //Data synchronization barrier
747  __DSB();
748 
749  //Clear TBU flag to resume processing
750  ENET_QOS->DMA_CH[0].DMA_CHX_STAT = ENET_QOS_DMA_CHX_STAT_TBU_MASK;
751  //Instruct the DMA to poll the transmit descriptor list
752  ENET_QOS->DMA_CH[0].DMA_CHX_TXDESC_TAIL_PTR = 0;
753 
754  //Increment index and wrap around if necessary
755  if(++txIndex >= MIMXRT1170_ETH3_TX_BUFFER_COUNT)
756  {
757  txIndex = 0;
758  }
759 
760  //Check whether the next buffer is available for writing
761  if((txDmaDesc[txIndex].tdes3 & ENET_TDES3_OWN) == 0)
762  {
763  //The transmitter can accept another packet
764  osSetEvent(&interface->nicTxEvent);
765  }
766 
767  //Data successfully written
768  return NO_ERROR;
769 }
770 
771 
772 /**
773  * @brief Receive a packet
774  * @param[in] interface Underlying network interface
775  * @return Error code
776  **/
777 
779 {
780  error_t error;
781  size_t n;
782  NetRxAncillary ancillary;
783 
784  //Current buffer available for reading?
785  if((rxDmaDesc[rxIndex].rdes3 & ENET_RDES3_OWN) == 0)
786  {
787  //FD and LD flags should be set
788  if((rxDmaDesc[rxIndex].rdes3 & ENET_RDES3_FD) != 0 &&
789  (rxDmaDesc[rxIndex].rdes3 & ENET_RDES3_LD) != 0)
790  {
791  //Make sure no error occurred
792  if((rxDmaDesc[rxIndex].rdes3 & ENET_RDES3_ES) == 0)
793  {
794  //Retrieve the length of the frame
795  n = rxDmaDesc[rxIndex].rdes3 & ENET_RDES3_PL;
796  //Limit the number of data to read
798 
799  //Additional options can be passed to the stack along with the packet
800  ancillary = NET_DEFAULT_RX_ANCILLARY;
801 
802  //Pass the packet to the upper layer
803  nicProcessPacket(interface, rxBuffer[rxIndex], n, &ancillary);
804 
805  //Valid packet received
806  error = NO_ERROR;
807  }
808  else
809  {
810  //The received packet contains an error
811  error = ERROR_INVALID_PACKET;
812  }
813  }
814  else
815  {
816  //The packet is not valid
817  error = ERROR_INVALID_PACKET;
818  }
819 
820  //Set the start address of the buffer
821  rxDmaDesc[rxIndex].rdes0 = (uint32_t) rxBuffer[rxIndex];
822  //Give the ownership of the descriptor back to the DMA
824 
825  //Increment index and wrap around if necessary
826  if(++rxIndex >= MIMXRT1170_ETH3_RX_BUFFER_COUNT)
827  {
828  rxIndex = 0;
829  }
830  }
831  else
832  {
833  //No more data in the receive buffer
834  error = ERROR_BUFFER_EMPTY;
835  }
836 
837  //Clear RBU flag to resume processing
838  ENET_QOS->DMA_CH[0].DMA_CHX_STAT = ENET_QOS_DMA_CHX_STAT_RBU_MASK;
839  //Instruct the DMA to poll the receive descriptor list
840  ENET_QOS->DMA_CH[0].DMA_CHX_RXDESC_TAIL_PTR = 0;
841 
842  //Return status code
843  return error;
844 }
845 
846 
847 /**
848  * @brief Configure MAC address filtering
849  * @param[in] interface Underlying network interface
850  * @return Error code
851  **/
852 
854 {
855  uint_t i;
856  uint_t j;
857  MacFilterEntry *entry;
858 
859  //Debug message
860  TRACE_DEBUG("Updating MAC filter...\r\n");
861 
862  //Configure the receive filter
863  ENET_QOS->MAC_PACKET_FILTER = 0;
864 
865  //Set the MAC address of the station
866  ENET_QOS->MAC_ADDRESS[0].LOW = interface->macAddr.w[0] | (interface->macAddr.w[1] << 16);
867  ENET_QOS->MAC_ADDRESS[0].HIGH = interface->macAddr.w[2];
868 
869  //The MAC address filter contains the list of MAC addresses to accept
870  //when receiving an Ethernet frame
871  for(i = 0, j = 1; i < MAC_ADDR_FILTER_SIZE && j < 64; i++)
872  {
873  //Point to the current entry
874  entry = &interface->macAddrFilter[i];
875 
876  //Valid entry?
877  if(entry->refCount > 0)
878  {
879  //When the AE bit is set, the entry is used for perfect filtering
880  ENET_QOS->MAC_ADDRESS[j].LOW = entry->addr.w[0] | (entry->addr.w[1] << 16);
881  ENET_QOS->MAC_ADDRESS[j].HIGH = entry->addr.w[2] | ENET_QOS_HIGH_AE_MASK;
882 
883  //Next entry
884  j++;
885  }
886  }
887 
888  //Clear unused entries
889  while(j < 64)
890  {
891  //When the AE bit is cleared, the entry is ignored
892  ENET_QOS->MAC_ADDRESS[j].LOW = 0;
893  ENET_QOS->MAC_ADDRESS[j].HIGH = 0;
894 
895  //Next entry
896  j++;
897  }
898 
899  //Successful processing
900  return NO_ERROR;
901 }
902 
903 
904 /**
905  * @brief Adjust MAC configuration parameters for proper operation
906  * @param[in] interface Underlying network interface
907  * @return Error code
908  **/
909 
911 {
912  uint32_t config;
913 
914  //Read current MAC configuration
915  config = ENET_QOS->MAC_CONFIGURATION;
916 
917  //1000BASE-T operation mode?
918  if(interface->linkSpeed == NIC_LINK_SPEED_1GBPS)
919  {
920  config &= ~ENET_QOS_MAC_CONFIGURATION_PS_MASK;
921  config &= ~ENET_QOS_MAC_CONFIGURATION_FES_MASK;
922  }
923  //100BASE-TX operation mode?
924  else if(interface->linkSpeed == NIC_LINK_SPEED_100MBPS)
925  {
926  config |= ENET_QOS_MAC_CONFIGURATION_PS_MASK;
927  config |= ENET_QOS_MAC_CONFIGURATION_FES_MASK;
928  }
929  //10BASE-T operation mode?
930  else
931  {
932  config |= ENET_QOS_MAC_CONFIGURATION_PS_MASK;
933  config &= ~ENET_QOS_MAC_CONFIGURATION_FES_MASK;
934  }
935 
936  //Half-duplex or full-duplex mode?
937  if(interface->duplexMode == NIC_FULL_DUPLEX_MODE)
938  {
939  config |= ENET_QOS_MAC_CONFIGURATION_DM_MASK;
940  }
941  else
942  {
943  config &= ~ENET_QOS_MAC_CONFIGURATION_DM_MASK;
944  }
945 
946  //Update MAC configuration register
947  ENET_QOS->MAC_CONFIGURATION = config;
948 
949  //Successful processing
950  return NO_ERROR;
951 }
952 
953 
954 /**
955  * @brief Write PHY register
956  * @param[in] opcode Access type (2 bits)
957  * @param[in] phyAddr PHY address (5 bits)
958  * @param[in] regAddr Register address (5 bits)
959  * @param[in] data Register value
960  **/
961 
962 void mimxrt1170Eth3WritePhyReg(uint8_t opcode, uint8_t phyAddr,
963  uint8_t regAddr, uint16_t data)
964 {
965  uint32_t temp;
966 
967  //Valid opcode?
968  if(opcode == SMI_OPCODE_WRITE)
969  {
970  //Take care not to alter MDC clock configuration
971  temp = ENET_QOS->MAC_MDIO_ADDRESS & ENET_QOS_MAC_MDIO_ADDRESS_CR_MASK;
972 
973  //Set up a write operation
974  temp |= ENET_QOS_MAC_MDIO_ADDRESS_GOC_0_MASK |
975  ENET_QOS_MAC_MDIO_ADDRESS_GB_MASK;
976 
977  //PHY address
978  temp |= ENET_QOS_MAC_MDIO_ADDRESS_PA(phyAddr);
979  //Register address
980  temp |= ENET_QOS_MAC_MDIO_ADDRESS_RDA(regAddr);
981 
982  //Data to be written in the PHY register
983  ENET_QOS->MAC_MDIO_DATA = data & ENET_QOS_MAC_MDIO_DATA_GD_MASK;
984 
985  //Start a write operation
986  ENET_QOS->MAC_MDIO_ADDRESS = temp;
987  //Wait for the write to complete
988  while((ENET_QOS->MAC_MDIO_ADDRESS & ENET_QOS_MAC_MDIO_ADDRESS_GB_MASK) != 0)
989  {
990  }
991  }
992  else
993  {
994  //The MAC peripheral only supports standard Clause 22 opcodes
995  }
996 }
997 
998 
999 /**
1000  * @brief Read PHY register
1001  * @param[in] opcode Access type (2 bits)
1002  * @param[in] phyAddr PHY address (5 bits)
1003  * @param[in] regAddr Register address (5 bits)
1004  * @return Register value
1005  **/
1006 
1007 uint16_t mimxrt1170Eth3ReadPhyReg(uint8_t opcode, uint8_t phyAddr,
1008  uint8_t regAddr)
1009 {
1010  uint16_t data;
1011  uint32_t temp;
1012 
1013  //Valid opcode?
1014  if(opcode == SMI_OPCODE_READ)
1015  {
1016  //Take care not to alter MDC clock configuration
1017  temp = ENET_QOS->MAC_MDIO_ADDRESS & ENET_QOS_MAC_MDIO_ADDRESS_CR_MASK;
1018 
1019  //Set up a read operation
1020  temp |= ENET_QOS_MAC_MDIO_ADDRESS_GOC_1_MASK |
1021  ENET_QOS_MAC_MDIO_ADDRESS_GOC_0_MASK | ENET_QOS_MAC_MDIO_ADDRESS_GB_MASK;
1022 
1023  //PHY address
1024  temp |= ENET_QOS_MAC_MDIO_ADDRESS_PA(phyAddr);
1025  //Register address
1026  temp |= ENET_QOS_MAC_MDIO_ADDRESS_RDA(regAddr);
1027 
1028  //Start a read operation
1029  ENET_QOS->MAC_MDIO_ADDRESS = temp;
1030  //Wait for the read to complete
1031  while((ENET_QOS->MAC_MDIO_ADDRESS & ENET_QOS_MAC_MDIO_ADDRESS_GB_MASK) != 0)
1032  {
1033  }
1034 
1035  //Get register value
1036  data = ENET_QOS->MAC_MDIO_DATA & ENET_QOS_MAC_MDIO_DATA_GD_MASK;
1037  }
1038  else
1039  {
1040  //The MAC peripheral only supports standard Clause 22 opcodes
1041  data = 0;
1042  }
1043 
1044  //Return the value of the PHY register
1045  return data;
1046 }
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:188
int bool_t
Definition: compiler_port.h:53
#define netEvent
Definition: net_legacy.h:196
@ 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:222
#define sleep(delay)
Definition: os_port.h:307
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:264
#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:392
#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:104
@ ERROR_FAILURE
Generic error code.
Definition: error.h:45
#define txBuffer
#define NetRxAncillary
Definition: net_misc.h:40
@ ERROR_INVALID_PACKET
Definition: error.h:140
#define NetInterface
Definition: net.h:36
MacAddr addr
MAC address.
Definition: ethernet.h:263
@ ERROR_INVALID_LENGTH
Definition: error.h:111
@ ERROR_BUFFER_EMPTY
Definition: error.h:141
#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:95
uint8_t length
Definition: tcp.h:368
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:107
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:262
#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:50
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