mimxrt1160_eth1_driver.c
Go to the documentation of this file.
1 /**
2  * @file mimxrt1160_eth1_driver.c
3  * @brief NXP i.MX RT1160 Ethernet MAC driver (ENET 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 //TX buffer
49 #pragma data_alignment = 64
50 #pragma location = MIMXRT1160_ETH1_RAM_SECTION
52 //RX buffer
53 #pragma data_alignment = 64
54 #pragma location = MIMXRT1160_ETH1_RAM_SECTION
56 //TX buffer descriptors
57 #pragma data_alignment = 64
58 #pragma location = MIMXRT1160_ETH1_RAM_SECTION
59 static uint32_t txBufferDesc[MIMXRT1160_ETH1_TX_BUFFER_COUNT][8];
60 //RX buffer descriptors
61 #pragma data_alignment = 64
62 #pragma location = MIMXRT1160_ETH1_RAM_SECTION
63 static uint32_t rxBufferDesc[MIMXRT1160_ETH1_RX_BUFFER_COUNT][8];
64 
65 //ARM or GCC compiler?
66 #else
67 
68 //TX buffer
70  __attribute__((aligned(64), __section__(MIMXRT1160_ETH1_RAM_SECTION)));
71 //RX buffer
73  __attribute__((aligned(64), __section__(MIMXRT1160_ETH1_RAM_SECTION)));
74 //TX buffer descriptors
75 static uint32_t txBufferDesc[MIMXRT1160_ETH1_TX_BUFFER_COUNT][8]
76  __attribute__((aligned(64), __section__(MIMXRT1160_ETH1_RAM_SECTION)));
77 //RX buffer descriptors
78 static uint32_t rxBufferDesc[MIMXRT1160_ETH1_RX_BUFFER_COUNT][8]
79  __attribute__((aligned(64), __section__(MIMXRT1160_ETH1_RAM_SECTION)));
80 
81 #endif
82 
83 //TX buffer index
84 static uint_t txBufferIndex;
85 //RX buffer index
86 static uint_t rxBufferIndex;
87 
88 
89 /**
90  * @brief i.MX RT1160 Ethernet MAC driver (ENET instance)
91  **/
92 
94 {
96  ETH_MTU,
107  TRUE,
108  TRUE,
109  TRUE,
110  FALSE
111 };
112 
113 
114 /**
115  * @brief i.MX RT1160 Ethernet MAC initialization
116  * @param[in] interface Underlying network interface
117  * @return Error code
118  **/
119 
121 {
122  error_t error;
123  uint32_t value;
124 
125  //Debug message
126  TRACE_INFO("Initializing i.MX RT1160 Ethernet MAC (ENET)...\r\n");
127 
128  //Save underlying network interface
129  nicDriverInterface = interface;
130 
131  //Enable ENET peripheral clock
132  CLOCK_EnableClock(kCLOCK_Enet);
133 
134  //GPIO configuration
135  mimxrt1160Eth1InitGpio(interface);
136 
137  //Reset ENET module
138  ENET->ECR = ENET_ECR_RESET_MASK;
139  //Wait for the reset to complete
140  while((ENET->ECR & ENET_ECR_RESET_MASK) != 0)
141  {
142  }
143 
144  //Receive control register
145  ENET->RCR = ENET_RCR_MAX_FL(MIMXRT1160_ETH1_RX_BUFFER_SIZE) |
146  ENET_RCR_RMII_MODE_MASK | ENET_RCR_MII_MODE_MASK;
147 
148  //Transmit control register
149  ENET->TCR = 0;
150  //Configure MDC clock frequency
151  ENET->MSCR = ENET_MSCR_HOLDTIME(10) | ENET_MSCR_MII_SPEED(120);
152 
153  //Valid Ethernet PHY or switch driver?
154  if(interface->phyDriver != NULL)
155  {
156  //Ethernet PHY initialization
157  error = interface->phyDriver->init(interface);
158  }
159  else if(interface->switchDriver != NULL)
160  {
161  //Ethernet switch initialization
162  error = interface->switchDriver->init(interface);
163  }
164  else
165  {
166  //The interface is not properly configured
167  error = ERROR_FAILURE;
168  }
169 
170  //Any error to report?
171  if(error)
172  {
173  return error;
174  }
175 
176  //Set the MAC address of the station (upper 16 bits)
177  value = interface->macAddr.b[5];
178  value |= (interface->macAddr.b[4] << 8);
179  ENET->PAUR = ENET_PAUR_PADDR2(value) | ENET_PAUR_TYPE(0x8808);
180 
181  //Set the MAC address of the station (lower 32 bits)
182  value = interface->macAddr.b[3];
183  value |= (interface->macAddr.b[2] << 8);
184  value |= (interface->macAddr.b[1] << 16);
185  value |= (interface->macAddr.b[0] << 24);
186  ENET->PALR = ENET_PALR_PADDR1(value);
187 
188  //Hash table for unicast address filtering
189  ENET->IALR = 0;
190  ENET->IAUR = 0;
191  //Hash table for multicast address filtering
192  ENET->GALR = 0;
193  ENET->GAUR = 0;
194 
195  //Disable transmit accelerator functions
196  ENET->TACC = 0;
197  //Disable receive accelerator functions
198  ENET->RACC = 0;
199 
200  //Use enhanced buffer descriptors
201  ENET->ECR = ENET_ECR_DBSWP_MASK | ENET_ECR_EN1588_MASK;
202 
203  //Reset statistics counters
204  ENET->MIBC = ENET_MIBC_MIB_CLEAR_MASK;
205  ENET->MIBC = 0;
206 
207  //Initialize buffer descriptors
208  mimxrt1160Eth1InitBufferDesc(interface);
209 
210  //Clear any pending interrupts
211  ENET->EIR = 0xFFFFFFFF;
212  //Enable desired interrupts
213  ENET->EIMR = ENET_EIMR_TXF_MASK | ENET_EIMR_RXF_MASK | ENET_EIMR_EBERR_MASK;
214 
215  //Set priority grouping (4 bits for pre-emption priority, no bits for subpriority)
216  NVIC_SetPriorityGrouping(MIMXRT1160_ETH1_IRQ_PRIORITY_GROUPING);
217 
218  //Configure ENET interrupt priority
219  NVIC_SetPriority(ENET_IRQn, NVIC_EncodePriority(MIMXRT1160_ETH1_IRQ_PRIORITY_GROUPING,
221 
222  //Enable Ethernet MAC
223  ENET->ECR |= ENET_ECR_ETHEREN_MASK;
224  //Instruct the DMA to poll the receive descriptor list
225  ENET->RDAR = ENET_RDAR_RDAR_MASK;
226 
227  //Accept any packets from the upper layer
228  osSetEvent(&interface->nicTxEvent);
229 
230  //Successful initialization
231  return NO_ERROR;
232 }
233 
234 
235 /**
236  * @brief GPIO configuration
237  * @param[in] interface Underlying network interface
238  **/
239 
240 __weak_func void mimxrt1160Eth1InitGpio(NetInterface *interface)
241 {
242 //MIMXRT1160-EVK evaluation board?
243 #if defined(USE_MIMXRT1160_EVK)
244  gpio_pin_config_t pinConfig;
245  clock_root_config_t rootConfig = {0};
246  clock_sys_pll1_config_t sysPll1Config = {0};
247 
248  //Initialize system PLL1
249  sysPll1Config.pllDiv2En = true;
250  CLOCK_InitSysPll1(&sysPll1Config);
251 
252  //Generate 50MHz root clock
253  rootConfig.clockOff = false;
254  rootConfig.mux = kCLOCK_ENET1_ClockRoot_MuxSysPll1Div2;
255  rootConfig.div = 10;
256  CLOCK_SetRootClock(kCLOCK_Root_Enet1, &rootConfig);
257 
258 #if 0
259  //Initialize PLL PFD3 (528*18/24 = 396MHz)
260  CLOCK_InitPfd(kCLOCK_PllSys2, kCLOCK_Pfd3, 24);
261 
262  //Generate 198MHz bus clock
263  rootConfig.clockOff = false;
264  rootConfig.mux = kCLOCK_BUS_ClockRoot_MuxSysPll2Pfd3;
265  rootConfig.div = 2;
266  CLOCK_SetRootClock(kCLOCK_Root_Bus, &rootConfig);
267 #endif
268 
269  //ENET_REF_CLK is output driven by ENET1_CLK_ROOT
270  IOMUXC_GPR->GPR4 |= IOMUXC_GPR_GPR4_ENET_REF_CLK_DIR_MASK |
271  IOMUXC_GPR_GPR4_ENET_TX_CLK_SEL_MASK;
272 
273  //Enable IOMUXC clock
274  CLOCK_EnableClock(kCLOCK_Iomuxc);
275 
276  //Configure GPIO_DISP_B2_02 pin as ENET_TX_DATA00
277  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B2_02_ENET_TX_DATA00, 0);
278 
279  //Set GPIO_DISP_B2_02 pad properties
280  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B2_02_ENET_TX_DATA00,
281  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
282  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
283  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
284  IOMUXC_SW_PAD_CTL_PAD_PUS(0) |
285  IOMUXC_SW_PAD_CTL_PAD_PUE(0) |
286  IOMUXC_SW_PAD_CTL_PAD_DSE(1) |
287  IOMUXC_SW_PAD_CTL_PAD_SRE(1));
288 
289  //Configure GPIO_DISP_B2_03 pin as ENET_TX_DATA01
290  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B2_03_ENET_TX_DATA01, 0);
291 
292  //Set GPIO_DISP_B2_03 pad properties
293  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B2_03_ENET_TX_DATA01,
294  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
295  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
296  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
297  IOMUXC_SW_PAD_CTL_PAD_PUS(0) |
298  IOMUXC_SW_PAD_CTL_PAD_PUE(0) |
299  IOMUXC_SW_PAD_CTL_PAD_DSE(1) |
300  IOMUXC_SW_PAD_CTL_PAD_SRE(1));
301 
302  //Configure GPIO_DISP_B2_04 pin as ENET_TX_EN
303  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B2_04_ENET_TX_EN, 0);
304 
305  //Set GPIO_DISP_B2_04 pad properties
306  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B2_04_ENET_TX_EN,
307  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
308  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
309  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
310  IOMUXC_SW_PAD_CTL_PAD_PUS(0) |
311  IOMUXC_SW_PAD_CTL_PAD_PUE(0) |
312  IOMUXC_SW_PAD_CTL_PAD_DSE(1) |
313  IOMUXC_SW_PAD_CTL_PAD_SRE(1));
314 
315  //Configure GPIO_DISP_B2_05 pin as ENET_REF_CLK
316  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B2_05_ENET_REF_CLK, 1);
317 
318  //Set GPIO_DISP_B2_05 pad properties
319  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B2_05_ENET_REF_CLK,
320  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
321  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
322  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
323  IOMUXC_SW_PAD_CTL_PAD_PUS(0) |
324  IOMUXC_SW_PAD_CTL_PAD_PUE(0) |
325  IOMUXC_SW_PAD_CTL_PAD_DSE(1) |
326  IOMUXC_SW_PAD_CTL_PAD_SRE(1));
327 
328  //Configure GPIO_DISP_B2_06 pin as ENET_RX_DATA00
329  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B2_06_ENET_RX_DATA00, 0);
330 
331  //Set GPIO_DISP_B2_06 pad properties
332  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B2_06_ENET_RX_DATA00,
333  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
334  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
335  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
336  IOMUXC_SW_PAD_CTL_PAD_PUS(0) |
337  IOMUXC_SW_PAD_CTL_PAD_PUE(0) |
338  IOMUXC_SW_PAD_CTL_PAD_DSE(1) |
339  IOMUXC_SW_PAD_CTL_PAD_SRE(1));
340 
341  //Configure GPIO_DISP_B2_07 pin as ENET_RX_DATA01
342  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B2_07_ENET_RX_DATA01, 0);
343 
344  //Set GPIO_DISP_B2_07 pad properties
345  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B2_07_ENET_RX_DATA01,
346  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
347  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
348  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
349  IOMUXC_SW_PAD_CTL_PAD_PUS(0) |
350  IOMUXC_SW_PAD_CTL_PAD_PUE(0) |
351  IOMUXC_SW_PAD_CTL_PAD_DSE(1) |
352  IOMUXC_SW_PAD_CTL_PAD_SRE(1));
353 
354  //Configure GPIO_DISP_B2_08 pin as ENET_RX_EN
355  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B2_08_ENET_RX_EN, 0);
356 
357  //Set GPIO_DISP_B2_08 pad properties
358  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B2_08_ENET_RX_EN,
359  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
360  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
361  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
362  IOMUXC_SW_PAD_CTL_PAD_PUS(0) |
363  IOMUXC_SW_PAD_CTL_PAD_PUE(0) |
364  IOMUXC_SW_PAD_CTL_PAD_DSE(1) |
365  IOMUXC_SW_PAD_CTL_PAD_SRE(1));
366 
367  //Configure GPIO_DISP_B2_09 pin as ENET_RX_ER
368  IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B2_09_ENET_RX_ER, 0);
369 
370  //Set GPIO_DISP_B2_09 pad properties
371  IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B2_09_ENET_RX_ER,
372  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
373  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
374  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
375  IOMUXC_SW_PAD_CTL_PAD_PUS(0) |
376  IOMUXC_SW_PAD_CTL_PAD_PUE(0) |
377  IOMUXC_SW_PAD_CTL_PAD_DSE(1) |
378  IOMUXC_SW_PAD_CTL_PAD_SRE(1));
379 
380  //Configure GPIO_AD_32 pin as ENET_MDC
381  IOMUXC_SetPinMux(IOMUXC_GPIO_AD_32_ENET_MDC, 0);
382 
383  //Set GPIO_AD_32 pad properties
384  IOMUXC_SetPinConfig(IOMUXC_GPIO_AD_32_ENET_MDC,
385  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
386  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
387  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
388  IOMUXC_SW_PAD_CTL_PAD_PUS(0) |
389  IOMUXC_SW_PAD_CTL_PAD_PUE(0) |
390  IOMUXC_SW_PAD_CTL_PAD_DSE(1) |
391  IOMUXC_SW_PAD_CTL_PAD_SRE(0));
392 
393  //Configure GPIO_AD_33 pin as ENET_MDIO
394  IOMUXC_SetPinMux(IOMUXC_GPIO_AD_33_ENET_MDIO, 0);
395 
396  //Set GPIO_AD_33 pad properties
397  IOMUXC_SetPinConfig(IOMUXC_GPIO_AD_33_ENET_MDIO,
398  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
399  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
400  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
401  IOMUXC_SW_PAD_CTL_PAD_PUS(0) |
402  IOMUXC_SW_PAD_CTL_PAD_PUE(0) |
403  IOMUXC_SW_PAD_CTL_PAD_DSE(1) |
404  IOMUXC_SW_PAD_CTL_PAD_SRE(0));
405 
406  //Configure GPIO_LPSR_12 pin as GPIO12_IO12
407  IOMUXC_SetPinMux(IOMUXC_GPIO_LPSR_12_GPIO12_IO12, 0);
408 
409  //Set GPIO_LPSR_12 pad properties
410  IOMUXC_SetPinConfig(IOMUXC_GPIO_LPSR_12_GPIO12_IO12,
411  IOMUXC_SW_PAD_CTL_PAD_DWP_LOCK(0) |
412  IOMUXC_SW_PAD_CTL_PAD_DWP(0) |
413  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
414  IOMUXC_SW_PAD_CTL_PAD_PUS(0) |
415  IOMUXC_SW_PAD_CTL_PAD_PUE(0) |
416  IOMUXC_SW_PAD_CTL_PAD_DSE(1) |
417  IOMUXC_SW_PAD_CTL_PAD_SRE(0));
418 
419  //Configure GPIO_AD_12 pin as GPIO9_IO11
420  IOMUXC_SetPinMux(IOMUXC_GPIO_AD_12_GPIO9_IO11, 0);
421 
422  //Set GPIO_AD_12 pad properties
423  IOMUXC_SetPinConfig(IOMUXC_GPIO_AD_12_GPIO9_IO11,
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_PUS(0) |
428  IOMUXC_SW_PAD_CTL_PAD_PUE(0) |
429  IOMUXC_SW_PAD_CTL_PAD_DSE(1) |
430  IOMUXC_SW_PAD_CTL_PAD_SRE(0));
431 
432  //Configure ENET_RST as an output
433  pinConfig.direction = kGPIO_DigitalOutput;
434  pinConfig.outputLogic = 0;
435  pinConfig.interruptMode = kGPIO_NoIntmode;
436  GPIO_PinInit(GPIO12, 12, &pinConfig);
437 
438  //Configure ENET_INT as an input
439  pinConfig.direction = kGPIO_DigitalInput;
440  pinConfig.outputLogic = 0;
441  pinConfig.interruptMode = kGPIO_NoIntmode;
442  GPIO_PinInit(GPIO9, 11, &pinConfig);
443 
444  //Reset PHY transceiver (hard reset)
445  GPIO_PinWrite(GPIO12, 12, 0);
446  sleep(10);
447  GPIO_PinWrite(GPIO12, 12, 1);
448  sleep(10);
449 #endif
450 }
451 
452 
453 /**
454  * @brief Initialize buffer descriptors
455  * @param[in] interface Underlying network interface
456  **/
457 
459 {
460  uint_t i;
461  uint32_t address;
462 
463  //Clear TX and RX buffer descriptors
464  osMemset(txBufferDesc, 0, sizeof(txBufferDesc));
465  osMemset(rxBufferDesc, 0, sizeof(rxBufferDesc));
466 
467  //Initialize TX buffer descriptors
468  for(i = 0; i < MIMXRT1160_ETH1_TX_BUFFER_COUNT; i++)
469  {
470  //Calculate the address of the current TX buffer
471  address = (uint32_t) txBuffer[i];
472  //Transmit buffer address
473  txBufferDesc[i][1] = address;
474  //Generate interrupts
475  txBufferDesc[i][2] = ENET_TBD2_INT;
476  }
477 
478  //Mark the last descriptor entry with the wrap flag
479  txBufferDesc[i - 1][0] |= ENET_TBD0_W;
480  //Initialize TX buffer index
481  txBufferIndex = 0;
482 
483  //Initialize RX buffer descriptors
484  for(i = 0; i < MIMXRT1160_ETH1_RX_BUFFER_COUNT; i++)
485  {
486  //Calculate the address of the current RX buffer
487  address = (uint32_t) rxBuffer[i];
488  //The descriptor is initially owned by the DMA
489  rxBufferDesc[i][0] = ENET_RBD0_E;
490  //Receive buffer address
491  rxBufferDesc[i][1] = address;
492  //Generate interrupts
493  rxBufferDesc[i][2] = ENET_RBD2_INT;
494  }
495 
496  //Mark the last descriptor entry with the wrap flag
497  rxBufferDesc[i - 1][0] |= ENET_RBD0_W;
498  //Initialize RX buffer index
499  rxBufferIndex = 0;
500 
501  //Start location of the TX descriptor list
502  ENET->TDSR = (uint32_t) txBufferDesc;
503  //Start location of the RX descriptor list
504  ENET->RDSR = (uint32_t) rxBufferDesc;
505  //Maximum receive buffer size
506  ENET->MRBR = MIMXRT1160_ETH1_RX_BUFFER_SIZE;
507 }
508 
509 
510 /**
511  * @brief i.MX RT1160 Ethernet MAC timer handler
512  *
513  * This routine is periodically called by the TCP/IP stack to handle periodic
514  * operations such as polling the link state
515  *
516  * @param[in] interface Underlying network interface
517  **/
518 
520 {
521  //Valid Ethernet PHY or switch driver?
522  if(interface->phyDriver != NULL)
523  {
524  //Handle periodic operations
525  interface->phyDriver->tick(interface);
526  }
527  else if(interface->switchDriver != NULL)
528  {
529  //Handle periodic operations
530  interface->switchDriver->tick(interface);
531  }
532  else
533  {
534  //Just for sanity
535  }
536 }
537 
538 
539 /**
540  * @brief Enable interrupts
541  * @param[in] interface Underlying network interface
542  **/
543 
545 {
546  //Enable Ethernet MAC interrupts
547  NVIC_EnableIRQ(ENET_IRQn);
548 
549  //Valid Ethernet PHY or switch driver?
550  if(interface->phyDriver != NULL)
551  {
552  //Enable Ethernet PHY interrupts
553  interface->phyDriver->enableIrq(interface);
554  }
555  else if(interface->switchDriver != NULL)
556  {
557  //Enable Ethernet switch interrupts
558  interface->switchDriver->enableIrq(interface);
559  }
560  else
561  {
562  //Just for sanity
563  }
564 }
565 
566 
567 /**
568  * @brief Disable interrupts
569  * @param[in] interface Underlying network interface
570  **/
571 
573 {
574  //Disable Ethernet MAC interrupts
575  NVIC_DisableIRQ(ENET_IRQn);
576 
577  //Valid Ethernet PHY or switch driver?
578  if(interface->phyDriver != NULL)
579  {
580  //Disable Ethernet PHY interrupts
581  interface->phyDriver->disableIrq(interface);
582  }
583  else if(interface->switchDriver != NULL)
584  {
585  //Disable Ethernet switch interrupts
586  interface->switchDriver->disableIrq(interface);
587  }
588  else
589  {
590  //Just for sanity
591  }
592 }
593 
594 
595 /**
596  * @brief Ethernet MAC interrupt
597  **/
598 
599 void ENET_IRQHandler(void)
600 {
601  bool_t flag;
602  uint32_t events;
603 
604  //Interrupt service routine prologue
605  osEnterIsr();
606 
607  //This flag will be set if a higher priority task must be woken
608  flag = FALSE;
609  //Read interrupt event register
610  events = ENET->EIR;
611 
612  //Packet transmitted?
613  if((events & ENET_EIR_TXF_MASK) != 0)
614  {
615  //Clear TXF interrupt flag
616  ENET->EIR = ENET_EIR_TXF_MASK;
617 
618  //Check whether the TX buffer is available for writing
619  if((txBufferDesc[txBufferIndex][0] & ENET_TBD0_R) == 0)
620  {
621  //Notify the TCP/IP stack that the transmitter is ready to send
622  flag = osSetEventFromIsr(&nicDriverInterface->nicTxEvent);
623  }
624 
625  //Instruct the DMA to poll the transmit descriptor list
626  ENET->TDAR = ENET_TDAR_TDAR_MASK;
627  }
628 
629  //Packet received?
630  if((events & ENET_EIR_RXF_MASK) != 0)
631  {
632  //Disable RXF interrupt
633  ENET->EIMR &= ~ENET_EIMR_RXF_MASK;
634 
635  //Set event flag
636  nicDriverInterface->nicEvent = TRUE;
637  //Notify the TCP/IP stack of the event
638  flag = osSetEventFromIsr(&netEvent);
639  }
640 
641  //System bus error?
642  if((events & ENET_EIR_EBERR_MASK) != 0)
643  {
644  //Disable EBERR interrupt
645  ENET->EIMR &= ~ENET_EIMR_EBERR_MASK;
646 
647  //Set event flag
648  nicDriverInterface->nicEvent = TRUE;
649  //Notify the TCP/IP stack of the event
650  flag |= osSetEventFromIsr(&netEvent);
651  }
652 
653  //Interrupt service routine epilogue
654  osExitIsr(flag);
655 }
656 
657 
658 /**
659  * @brief i.MX RT1160 Ethernet MAC event handler
660  * @param[in] interface Underlying network interface
661  **/
662 
664 {
665  error_t error;
666  uint32_t status;
667 
668  //Read interrupt event register
669  status = ENET->EIR;
670 
671  //Packet received?
672  if((status & ENET_EIR_RXF_MASK) != 0)
673  {
674  //Clear RXF interrupt flag
675  ENET->EIR = ENET_EIR_RXF_MASK;
676 
677  //Process all pending packets
678  do
679  {
680  //Read incoming packet
681  error = mimxrt1160Eth1ReceivePacket(interface);
682 
683  //No more data in the receive buffer?
684  } while(error != ERROR_BUFFER_EMPTY);
685  }
686 
687  //System bus error?
688  if((status & ENET_EIR_EBERR_MASK) != 0)
689  {
690  //Clear EBERR interrupt flag
691  ENET->EIR = ENET_EIR_EBERR_MASK;
692 
693  //Disable Ethernet MAC
694  ENET->ECR &= ~ENET_ECR_ETHEREN_MASK;
695  //Reset buffer descriptors
696  mimxrt1160Eth1InitBufferDesc(interface);
697  //Resume normal operation
698  ENET->ECR |= ENET_ECR_ETHEREN_MASK;
699  //Instruct the DMA to poll the receive descriptor list
700  ENET->RDAR = ENET_RDAR_RDAR_MASK;
701  }
702 
703  //Re-enable Ethernet MAC interrupts
704  ENET->EIMR = ENET_EIMR_TXF_MASK | ENET_EIMR_RXF_MASK | ENET_EIMR_EBERR_MASK;
705 }
706 
707 
708 /**
709  * @brief Send a packet
710  * @param[in] interface Underlying network interface
711  * @param[in] buffer Multi-part buffer containing the data to send
712  * @param[in] offset Offset to the first data byte
713  * @param[in] ancillary Additional options passed to the stack along with
714  * the packet
715  * @return Error code
716  **/
717 
719  const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
720 {
721  size_t length;
722 
723  //Retrieve the length of the packet
724  length = netBufferGetLength(buffer) - offset;
725 
726  //Check the frame length
728  {
729  //The transmitter can accept another packet
730  osSetEvent(&interface->nicTxEvent);
731  //Report an error
732  return ERROR_INVALID_LENGTH;
733  }
734 
735  //Make sure the current buffer is available for writing
736  if((txBufferDesc[txBufferIndex][0] & ENET_TBD0_R) != 0)
737  {
738  return ERROR_FAILURE;
739  }
740 
741  //Copy user data to the transmit buffer
742  netBufferRead(txBuffer[txBufferIndex], buffer, offset, length);
743 
744  //Clear BDU flag
745  txBufferDesc[txBufferIndex][4] = 0;
746 
747  //Check current index
748  if(txBufferIndex < (MIMXRT1160_ETH1_TX_BUFFER_COUNT - 1))
749  {
750  //Give the ownership of the descriptor to the DMA engine
751  txBufferDesc[txBufferIndex][0] = ENET_TBD0_R | ENET_TBD0_L |
753 
754  //Point to the next buffer
755  txBufferIndex++;
756  }
757  else
758  {
759  //Give the ownership of the descriptor to the DMA engine
760  txBufferDesc[txBufferIndex][0] = ENET_TBD0_R | ENET_TBD0_W |
762 
763  //Wrap around
764  txBufferIndex = 0;
765  }
766 
767  //Data synchronization barrier
768  __DSB();
769 
770  //Instruct the DMA to poll the transmit descriptor list
771  ENET->TDAR = ENET_TDAR_TDAR_MASK;
772 
773  //Check whether the next buffer is available for writing
774  if((txBufferDesc[txBufferIndex][0] & ENET_TBD0_R) == 0)
775  {
776  //The transmitter can accept another packet
777  osSetEvent(&interface->nicTxEvent);
778  }
779 
780  //Successful processing
781  return NO_ERROR;
782 }
783 
784 
785 /**
786  * @brief Receive a packet
787  * @param[in] interface Underlying network interface
788  * @return Error code
789  **/
790 
792 {
793  error_t error;
794  size_t n;
795  NetRxAncillary ancillary;
796 
797  //Current buffer available for reading?
798  if((rxBufferDesc[rxBufferIndex][0] & ENET_RBD0_E) == 0)
799  {
800  //The frame should not span multiple buffers
801  if((rxBufferDesc[rxBufferIndex][0] & ENET_RBD0_L) != 0)
802  {
803  //Check whether an error occurred
804  if((rxBufferDesc[rxBufferIndex][0] & (ENET_RBD0_LG | ENET_RBD0_NO |
806  {
807  //Retrieve the length of the frame
808  n = rxBufferDesc[rxBufferIndex][0] & ENET_RBD0_DATA_LENGTH;
809  //Limit the number of data to read
811 
812  //Additional options can be passed to the stack along with the packet
813  ancillary = NET_DEFAULT_RX_ANCILLARY;
814 
815  //Pass the packet to the upper layer
816  nicProcessPacket(interface, rxBuffer[rxBufferIndex], n, &ancillary);
817 
818  //Valid packet received
819  error = NO_ERROR;
820  }
821  else
822  {
823  //The received packet contains an error
824  error = ERROR_INVALID_PACKET;
825  }
826  }
827  else
828  {
829  //The packet is not valid
830  error = ERROR_INVALID_PACKET;
831  }
832 
833  //Clear BDU flag
834  rxBufferDesc[rxBufferIndex][4] = 0;
835 
836  //Check current index
837  if(rxBufferIndex < (MIMXRT1160_ETH1_RX_BUFFER_COUNT - 1))
838  {
839  //Give the ownership of the descriptor back to the DMA engine
840  rxBufferDesc[rxBufferIndex][0] = ENET_RBD0_E;
841  //Point to the next buffer
842  rxBufferIndex++;
843  }
844  else
845  {
846  //Give the ownership of the descriptor back to the DMA engine
847  rxBufferDesc[rxBufferIndex][0] = ENET_RBD0_E | ENET_RBD0_W;
848  //Wrap around
849  rxBufferIndex = 0;
850  }
851 
852  //Instruct the DMA to poll the receive descriptor list
853  ENET->RDAR = ENET_RDAR_RDAR_MASK;
854  }
855  else
856  {
857  //No more data in the receive buffer
858  error = ERROR_BUFFER_EMPTY;
859  }
860 
861  //Return status code
862  return error;
863 }
864 
865 
866 /**
867  * @brief Configure MAC address filtering
868  * @param[in] interface Underlying network interface
869  * @return Error code
870  **/
871 
873 {
874  uint_t i;
875  uint_t k;
876  uint32_t crc;
877  uint32_t value;
878  uint32_t unicastHashTable[2];
879  uint32_t multicastHashTable[2];
880  MacFilterEntry *entry;
881 
882  //Debug message
883  TRACE_DEBUG("Updating MAC filter...\r\n");
884 
885  //Set the MAC address of the station (upper 16 bits)
886  value = interface->macAddr.b[5];
887  value |= (interface->macAddr.b[4] << 8);
888  ENET->PAUR = ENET_PAUR_PADDR2(value) | ENET_PAUR_TYPE(0x8808);
889 
890  //Set the MAC address of the station (lower 32 bits)
891  value = interface->macAddr.b[3];
892  value |= (interface->macAddr.b[2] << 8);
893  value |= (interface->macAddr.b[1] << 16);
894  value |= (interface->macAddr.b[0] << 24);
895  ENET->PALR = ENET_PALR_PADDR1(value);
896 
897  //Clear hash table (unicast address filtering)
898  unicastHashTable[0] = 0;
899  unicastHashTable[1] = 0;
900 
901  //Clear hash table (multicast address filtering)
902  multicastHashTable[0] = 0;
903  multicastHashTable[1] = 0;
904 
905  //The MAC address filter contains the list of MAC addresses to accept
906  //when receiving an Ethernet frame
907  for(i = 0; i < MAC_ADDR_FILTER_SIZE; i++)
908  {
909  //Point to the current entry
910  entry = &interface->macAddrFilter[i];
911 
912  //Valid entry?
913  if(entry->refCount > 0)
914  {
915  //Compute CRC over the current MAC address
916  crc = mimxrt1160Eth1CalcCrc(&entry->addr, sizeof(MacAddr));
917 
918  //The upper 6 bits in the CRC register are used to index the
919  //contents of the hash table
920  k = (crc >> 26) & 0x3F;
921 
922  //Multicast address?
923  if(macIsMulticastAddr(&entry->addr))
924  {
925  //Update the multicast hash table
926  multicastHashTable[k / 32] |= (1 << (k % 32));
927  }
928  else
929  {
930  //Update the unicast hash table
931  unicastHashTable[k / 32] |= (1 << (k % 32));
932  }
933  }
934  }
935 
936  //Write the hash table (unicast address filtering)
937  ENET->IALR = unicastHashTable[0];
938  ENET->IAUR = unicastHashTable[1];
939 
940  //Write the hash table (multicast address filtering)
941  ENET->GALR = multicastHashTable[0];
942  ENET->GAUR = multicastHashTable[1];
943 
944  //Debug message
945  TRACE_DEBUG(" IALR = %08" PRIX32 "\r\n", ENET->IALR);
946  TRACE_DEBUG(" IAUR = %08" PRIX32 "\r\n", ENET->IAUR);
947  TRACE_DEBUG(" GALR = %08" PRIX32 "\r\n", ENET->GALR);
948  TRACE_DEBUG(" GAUR = %08" PRIX32 "\r\n", ENET->GAUR);
949 
950  //Successful processing
951  return NO_ERROR;
952 }
953 
954 
955 /**
956  * @brief Adjust MAC configuration parameters for proper operation
957  * @param[in] interface Underlying network interface
958  * @return Error code
959  **/
960 
962 {
963  //Disable Ethernet MAC while modifying configuration registers
964  ENET->ECR &= ~ENET_ECR_ETHEREN_MASK;
965 
966  //10BASE-T or 100BASE-TX operation mode?
967  if(interface->linkSpeed == NIC_LINK_SPEED_100MBPS)
968  {
969  //100 Mbps operation
970  ENET->RCR &= ~ENET_RCR_RMII_10T_MASK;
971  }
972  else
973  {
974  //10 Mbps operation
975  ENET->RCR |= ENET_RCR_RMII_10T_MASK;
976  }
977 
978  //Half-duplex or full-duplex mode?
979  if(interface->duplexMode == NIC_FULL_DUPLEX_MODE)
980  {
981  //Full-duplex mode
982  ENET->TCR |= ENET_TCR_FDEN_MASK;
983  //Receive path operates independently of transmit
984  ENET->RCR &= ~ENET_RCR_DRT_MASK;
985  }
986  else
987  {
988  //Half-duplex mode
989  ENET->TCR &= ~ENET_TCR_FDEN_MASK;
990  //Disable reception of frames while transmitting
991  ENET->RCR |= ENET_RCR_DRT_MASK;
992  }
993 
994  //Reset buffer descriptors
995  mimxrt1160Eth1InitBufferDesc(interface);
996 
997  //Re-enable Ethernet MAC
998  ENET->ECR |= ENET_ECR_ETHEREN_MASK;
999  //Instruct the DMA to poll the receive descriptor list
1000  ENET->RDAR = ENET_RDAR_RDAR_MASK;
1001 
1002  //Successful processing
1003  return NO_ERROR;
1004 }
1005 
1006 
1007 /**
1008  * @brief Write PHY register
1009  * @param[in] opcode Access type (2 bits)
1010  * @param[in] phyAddr PHY address (5 bits)
1011  * @param[in] regAddr Register address (5 bits)
1012  * @param[in] data Register value
1013  **/
1014 
1015 void mimxrt1160Eth1WritePhyReg(uint8_t opcode, uint8_t phyAddr,
1016  uint8_t regAddr, uint16_t data)
1017 {
1018  uint32_t temp;
1019 
1020  //Valid opcode?
1021  if(opcode == SMI_OPCODE_WRITE)
1022  {
1023  //Set up a write operation
1024  temp = ENET_MMFR_ST(1) | ENET_MMFR_OP(1) | ENET_MMFR_TA(2);
1025  //PHY address
1026  temp |= ENET_MMFR_PA(phyAddr);
1027  //Register address
1028  temp |= ENET_MMFR_RA(regAddr);
1029  //Register value
1030  temp |= ENET_MMFR_DATA(data);
1031 
1032  //Clear MII interrupt flag
1033  ENET->EIR = ENET_EIR_MII_MASK;
1034  //Start a write operation
1035  ENET->MMFR = temp;
1036 
1037  //Wait for the write to complete
1038  while((ENET->EIR & ENET_EIR_MII_MASK) == 0)
1039  {
1040  }
1041  }
1042  else
1043  {
1044  //The MAC peripheral only supports standard Clause 22 opcodes
1045  }
1046 }
1047 
1048 
1049 /**
1050  * @brief Read PHY register
1051  * @param[in] opcode Access type (2 bits)
1052  * @param[in] phyAddr PHY address (5 bits)
1053  * @param[in] regAddr Register address (5 bits)
1054  * @return Register value
1055  **/
1056 
1057 uint16_t mimxrt1160Eth1ReadPhyReg(uint8_t opcode, uint8_t phyAddr,
1058  uint8_t regAddr)
1059 {
1060  uint16_t data;
1061  uint32_t temp;
1062 
1063  //Valid opcode?
1064  if(opcode == SMI_OPCODE_READ)
1065  {
1066  //Set up a read operation
1067  temp = ENET_MMFR_ST(1) | ENET_MMFR_OP(2) | ENET_MMFR_TA(2);
1068  //PHY address
1069  temp |= ENET_MMFR_PA(phyAddr);
1070  //Register address
1071  temp |= ENET_MMFR_RA(regAddr);
1072 
1073  //Clear MII interrupt flag
1074  ENET->EIR = ENET_EIR_MII_MASK;
1075  //Start a read operation
1076  ENET->MMFR = temp;
1077 
1078  //Wait for the read to complete
1079  while((ENET->EIR & ENET_EIR_MII_MASK) == 0)
1080  {
1081  }
1082 
1083  //Get register value
1084  data = ENET->MMFR & ENET_MMFR_DATA_MASK;
1085  }
1086  else
1087  {
1088  //The MAC peripheral only supports standard Clause 22 opcodes
1089  data = 0;
1090  }
1091 
1092  //Return the value of the PHY register
1093  return data;
1094 }
1095 
1096 
1097 /**
1098  * @brief CRC calculation
1099  * @param[in] data Pointer to the data over which to calculate the CRC
1100  * @param[in] length Number of bytes to process
1101  * @return Resulting CRC value
1102  **/
1103 
1104 uint32_t mimxrt1160Eth1CalcCrc(const void *data, size_t length)
1105 {
1106  uint_t i;
1107  uint_t j;
1108  uint32_t crc;
1109  const uint8_t *p;
1110 
1111  //Point to the data over which to calculate the CRC
1112  p = (uint8_t *) data;
1113  //CRC preset value
1114  crc = 0xFFFFFFFF;
1115 
1116  //Loop through data
1117  for(i = 0; i < length; i++)
1118  {
1119  //Update CRC value
1120  crc ^= p[i];
1121 
1122  //The message is processed bit by bit
1123  for(j = 0; j < 8; j++)
1124  {
1125  if((crc & 0x01) != 0)
1126  {
1127  crc = (crc >> 1) ^ 0xEDB88320;
1128  }
1129  else
1130  {
1131  crc = crc >> 1;
1132  }
1133  }
1134  }
1135 
1136  //Return CRC value
1137  return crc;
1138 }
bool_t osSetEventFromIsr(OsEvent *event)
Set an event object to the signaled state from an interrupt service routine.
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
#define ENET_TBD0_L
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_RBD0_DATA_LENGTH
uint8_t p
Definition: ndp.h:300
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
uint8_t data[]
Definition: ethernet.h:222
error_t mimxrt1160Eth1UpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
#define sleep(delay)
Definition: os_port.h:307
uint_t refCount
Reference count for the current entry.
Definition: ethernet.h:264
#define ENET_TBD0_DATA_LENGTH
#define ENET_TBD0_W
#define ENET_TBD0_TC
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 macIsMulticastAddr(macAddr)
Definition: ethernet.h:133
void mimxrt1160Eth1DisableIrq(NetInterface *interface)
Disable interrupts.
#define osExitIsr(flag)
#define SMI_OPCODE_WRITE
Definition: nic.h:66
#define ENET_RBD0_L
#define FALSE
Definition: os_port.h:46
#define MIMXRT1160_ETH1_IRQ_GROUP_PRIORITY
#define MIMXRT1160_ETH1_RAM_SECTION
error_t
Error codes.
Definition: error.h:43
void mimxrt1160Eth1WritePhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr, uint16_t data)
Write PHY register.
NXP i.MX RT1160 Ethernet MAC driver (ENET instance)
error_t mimxrt1160Eth1UpdateMacConfig(NetInterface *interface)
Adjust MAC configuration parameters for proper operation.
error_t mimxrt1160Eth1Init(NetInterface *interface)
i.MX RT1160 Ethernet MAC initialization
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 MIMXRT1160_ETH1_IRQ_SUB_PRIORITY
#define NetInterface
Definition: net.h:36
MacAddr addr
MAC address.
Definition: ethernet.h:263
const NicDriver mimxrt1160Eth1Driver
i.MX RT1160 Ethernet MAC driver (ENET instance)
@ ERROR_INVALID_LENGTH
Definition: error.h:111
#define ENET_RBD0_W
@ ERROR_BUFFER_EMPTY
Definition: error.h:141
#define ENET_RBD0_TR
__weak_func void mimxrt1160Eth1InitGpio(NetInterface *interface)
GPIO configuration.
#define NetTxAncillary
Definition: net_misc.h:36
#define SMI_OPCODE_READ
Definition: nic.h:67
#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
#define MIN(a, b)
Definition: os_port.h:63
#define rxBuffer
MacAddr
Definition: ethernet.h:195
#define ENET_RBD0_LG
#define TRACE_DEBUG(...)
Definition: debug.h:107
#define MIMXRT1160_ETH1_IRQ_PRIORITY_GROUPING
uint16_t mimxrt1160Eth1ReadPhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr)
Read PHY register.
uint16_t regAddr
#define ENET_RBD0_CR
#define ENET_RBD0_OV
#define ETH_MTU
Definition: ethernet.h:116
uint8_t n
#define MIMXRT1160_ETH1_RX_BUFFER_COUNT
MAC filter table entry.
Definition: ethernet.h:262
Ipv6Addr address[]
Definition: ipv6.h:325
#define osEnterIsr()
#define ENET_TBD0_R
void mimxrt1160Eth1InitBufferDesc(NetInterface *interface)
Initialize buffer descriptors.
uint8_t value[]
Definition: tcp.h:369
#define ENET_TBD2_INT
#define ENET_RBD0_E
void mimxrt1160Eth1EnableIrq(NetInterface *interface)
Enable interrupts.
uint32_t mimxrt1160Eth1CalcCrc(const void *data, size_t length)
CRC calculation.
void mimxrt1160Eth1Tick(NetInterface *interface)
i.MX RT1160 Ethernet MAC timer handler
void osSetEvent(OsEvent *event)
Set the specified event object to the signaled state.
@ NIC_LINK_SPEED_100MBPS
Definition: nic.h:112
unsigned int uint_t
Definition: compiler_port.h:50
#define MIMXRT1160_ETH1_TX_BUFFER_SIZE
#define osMemset(p, value, length)
Definition: os_port.h:135
TCP/IP stack core.
error_t mimxrt1160Eth1ReceivePacket(NetInterface *interface)
Receive a packet.
void ENET_IRQHandler(void)
Ethernet MAC interrupt.
void mimxrt1160Eth1EventHandler(NetInterface *interface)
i.MX RT1160 Ethernet MAC event handler
NIC driver.
Definition: nic.h:286
#define MIMXRT1160_ETH1_TX_BUFFER_COUNT
#define ENET_RBD0_NO
#define ENET_RBD2_INT
#define MIMXRT1160_ETH1_RX_BUFFER_SIZE
error_t mimxrt1160Eth1SendPacket(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a packet.
@ 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