mimxrt1040_eth_driver.c
Go to the documentation of this file.
1 /**
2  * @file mimxrt1040_eth_driver.c
3  * @brief NXP i.MX RT1040 Ethernet MAC driver
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.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 //TX buffer
49 #pragma data_alignment = 64
50 #pragma location = MIMXRT1040_ETH_RAM_SECTION
52 //RX buffer
53 #pragma data_alignment = 64
54 #pragma location = MIMXRT1040_ETH_RAM_SECTION
56 //TX buffer descriptors
57 #pragma data_alignment = 64
58 #pragma location = MIMXRT1040_ETH_RAM_SECTION
59 static uint32_t txBufferDesc[MIMXRT1040_ETH_TX_BUFFER_COUNT][8];
60 //RX buffer descriptors
61 #pragma data_alignment = 64
62 #pragma location = MIMXRT1040_ETH_RAM_SECTION
63 static uint32_t rxBufferDesc[MIMXRT1040_ETH_RX_BUFFER_COUNT][8];
64 
65 //ARM or GCC compiler?
66 #else
67 
68 //TX buffer
70  __attribute__((aligned(64), __section__(MIMXRT1040_ETH_RAM_SECTION)));
71 //RX buffer
73  __attribute__((aligned(64), __section__(MIMXRT1040_ETH_RAM_SECTION)));
74 //TX buffer descriptors
75 static uint32_t txBufferDesc[MIMXRT1040_ETH_TX_BUFFER_COUNT][8]
76  __attribute__((aligned(64), __section__(MIMXRT1040_ETH_RAM_SECTION)));
77 //RX buffer descriptors
78 static uint32_t rxBufferDesc[MIMXRT1040_ETH_RX_BUFFER_COUNT][8]
79  __attribute__((aligned(64), __section__(MIMXRT1040_ETH_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 RT1040 Ethernet MAC driver
91  **/
92 
94 {
96  ETH_MTU,
107  TRUE,
108  TRUE,
109  TRUE,
110  FALSE
111 };
112 
113 
114 /**
115  * @brief i.MX RT1040 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 RT1040 Ethernet MAC...\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  mimxrt1040EthInitGpio(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(MIMXRT1040_ETH_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  mimxrt1040EthInitBufferDesc(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(MIMXRT1040_ETH_IRQ_PRIORITY_GROUPING);
217 
218  //Configure ENET interrupt priority
219  NVIC_SetPriority(ENET_IRQn, NVIC_EncodePriority(MIMXRT1040_ETH_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 mimxrt1040EthInitGpio(NetInterface *interface)
241 {
242 //MIMXRT1040-EVKA evaluation board?
243 #if defined(USE_MIMXRT1040_EVK)
244  gpio_pin_config_t pinConfig;
245  clock_enet_pll_config_t pllConfig;
246 
247  //Configure ENET PLL (50MHz)
248  pllConfig.enableClkOutput = true;
249  pllConfig.enableClkOutput25M = false;
250  pllConfig.loopDivider = 1;
251  pllConfig.src = 0;
252  CLOCK_InitEnetPll(&pllConfig);
253 
254  //Enable ENET1_TX_CLK output driver
255  IOMUXC_EnableMode(IOMUXC_GPR, kIOMUXC_GPR_ENET1TxClkOutputDir, true);
256 
257  //Enable IOMUXC clock
258  CLOCK_EnableClock(kCLOCK_Iomuxc);
259 
260  //Configure GPIO_B1_04 pin as ENET_RX_DATA00
261  IOMUXC_SetPinMux(IOMUXC_GPIO_B1_04_ENET_RX_DATA00, 0);
262 
263  //Set GPIO_B1_04 pad properties
264  IOMUXC_SetPinConfig(IOMUXC_GPIO_B1_04_ENET_RX_DATA00,
265  IOMUXC_SW_PAD_CTL_PAD_HYS(0) |
266  IOMUXC_SW_PAD_CTL_PAD_PUS(0) |
267  IOMUXC_SW_PAD_CTL_PAD_PUE(0) |
268  IOMUXC_SW_PAD_CTL_PAD_PKE(0) |
269  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
270  IOMUXC_SW_PAD_CTL_PAD_SPEED(3) |
271  IOMUXC_SW_PAD_CTL_PAD_DSE(0) |
272  IOMUXC_SW_PAD_CTL_PAD_SRE(1));
273 
274  //Configure GPIO_B1_05 pin as ENET_RX_DATA01
275  IOMUXC_SetPinMux(IOMUXC_GPIO_B1_05_ENET_RX_DATA01, 0);
276 
277  //Set GPIO_B1_05 pad properties
278  IOMUXC_SetPinConfig(IOMUXC_GPIO_B1_05_ENET_RX_DATA01,
279  IOMUXC_SW_PAD_CTL_PAD_HYS(0) |
280  IOMUXC_SW_PAD_CTL_PAD_PUS(0) |
281  IOMUXC_SW_PAD_CTL_PAD_PUE(0) |
282  IOMUXC_SW_PAD_CTL_PAD_PKE(0) |
283  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
284  IOMUXC_SW_PAD_CTL_PAD_SPEED(3) |
285  IOMUXC_SW_PAD_CTL_PAD_DSE(0) |
286  IOMUXC_SW_PAD_CTL_PAD_SRE(1));
287 
288  //Configure GPIO_B1_06 pin as ENET_RX_EN
289  IOMUXC_SetPinMux(IOMUXC_GPIO_B1_06_ENET_RX_EN, 0);
290 
291  //Set GPIO_B1_06 pad properties
292  IOMUXC_SetPinConfig(IOMUXC_GPIO_B1_06_ENET_RX_EN,
293  IOMUXC_SW_PAD_CTL_PAD_HYS(0) |
294  IOMUXC_SW_PAD_CTL_PAD_PUS(0) |
295  IOMUXC_SW_PAD_CTL_PAD_PUE(0) |
296  IOMUXC_SW_PAD_CTL_PAD_PKE(0) |
297  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
298  IOMUXC_SW_PAD_CTL_PAD_SPEED(3) |
299  IOMUXC_SW_PAD_CTL_PAD_DSE(0) |
300  IOMUXC_SW_PAD_CTL_PAD_SRE(1));
301 
302  //Configure GPIO_B1_07 pin as ENET_TX_DATA00
303  IOMUXC_SetPinMux(IOMUXC_GPIO_B1_07_ENET_TX_DATA00, 0);
304 
305  //Set GPIO_B1_07 pad properties
306  IOMUXC_SetPinConfig(IOMUXC_GPIO_B1_07_ENET_TX_DATA00,
307  IOMUXC_SW_PAD_CTL_PAD_HYS(0) |
308  IOMUXC_SW_PAD_CTL_PAD_PUS(0) |
309  IOMUXC_SW_PAD_CTL_PAD_PUE(0) |
310  IOMUXC_SW_PAD_CTL_PAD_PKE(0) |
311  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
312  IOMUXC_SW_PAD_CTL_PAD_SPEED(3) |
313  IOMUXC_SW_PAD_CTL_PAD_DSE(5) |
314  IOMUXC_SW_PAD_CTL_PAD_SRE(1));
315 
316  //Configure GPIO_B1_08 pin as ENET_TX_DATA01
317  IOMUXC_SetPinMux(IOMUXC_GPIO_B1_08_ENET_TX_DATA01, 0);
318 
319  //Set GPIO_B1_08 pad properties
320  IOMUXC_SetPinConfig(IOMUXC_GPIO_B1_08_ENET_TX_DATA01,
321  IOMUXC_SW_PAD_CTL_PAD_HYS(0) |
322  IOMUXC_SW_PAD_CTL_PAD_PUS(0) |
323  IOMUXC_SW_PAD_CTL_PAD_PUE(0) |
324  IOMUXC_SW_PAD_CTL_PAD_PKE(0) |
325  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
326  IOMUXC_SW_PAD_CTL_PAD_SPEED(3) |
327  IOMUXC_SW_PAD_CTL_PAD_DSE(5) |
328  IOMUXC_SW_PAD_CTL_PAD_SRE(1));
329 
330  //Configure GPIO_B1_09 pin as ENET_TX_EN
331  IOMUXC_SetPinMux(IOMUXC_GPIO_B1_09_ENET_TX_EN, 0);
332 
333  //Set GPIO_B1_09 pad properties
334  IOMUXC_SetPinConfig(IOMUXC_GPIO_B1_09_ENET_TX_EN,
335  IOMUXC_SW_PAD_CTL_PAD_HYS(0) |
336  IOMUXC_SW_PAD_CTL_PAD_PUS(0) |
337  IOMUXC_SW_PAD_CTL_PAD_PUE(0) |
338  IOMUXC_SW_PAD_CTL_PAD_PKE(0) |
339  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
340  IOMUXC_SW_PAD_CTL_PAD_SPEED(3) |
341  IOMUXC_SW_PAD_CTL_PAD_DSE(5) |
342  IOMUXC_SW_PAD_CTL_PAD_SRE(1));
343 
344  //Configure GPIO_B1_10 pin as ENET_REF_CLK
345  IOMUXC_SetPinMux(IOMUXC_GPIO_B1_10_ENET_REF_CLK, 1);
346 
347  //Set GPIO_B1_10 pad properties
348  IOMUXC_SetPinConfig(IOMUXC_GPIO_B1_10_ENET_REF_CLK,
349  IOMUXC_SW_PAD_CTL_PAD_HYS(0) |
350  IOMUXC_SW_PAD_CTL_PAD_PUS(0) |
351  IOMUXC_SW_PAD_CTL_PAD_PUE(0) |
352  IOMUXC_SW_PAD_CTL_PAD_PKE(0) |
353  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
354  IOMUXC_SW_PAD_CTL_PAD_SPEED(3) |
355  IOMUXC_SW_PAD_CTL_PAD_DSE(5) |
356  IOMUXC_SW_PAD_CTL_PAD_SRE(1));
357 
358  //Configure GPIO_B1_11 pin as ENET_RX_ER
359  IOMUXC_SetPinMux(IOMUXC_GPIO_B1_11_ENET_RX_ER, 0);
360 
361  //Set GPIO_B1_11 pad properties
362  IOMUXC_SetPinConfig(IOMUXC_GPIO_B1_11_ENET_RX_ER,
363  IOMUXC_SW_PAD_CTL_PAD_HYS(0) |
364  IOMUXC_SW_PAD_CTL_PAD_PUS(0) |
365  IOMUXC_SW_PAD_CTL_PAD_PUE(0) |
366  IOMUXC_SW_PAD_CTL_PAD_PKE(0) |
367  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
368  IOMUXC_SW_PAD_CTL_PAD_SPEED(3) |
369  IOMUXC_SW_PAD_CTL_PAD_DSE(0) |
370  IOMUXC_SW_PAD_CTL_PAD_SRE(1));
371 
372  //Configure GPIO_EMC_40 pin as ENET_MDC
373  IOMUXC_SetPinMux(IOMUXC_GPIO_EMC_40_ENET_MDC, 0);
374 
375  //Set GPIO_EMC_40 pad properties
376  IOMUXC_SetPinConfig(IOMUXC_GPIO_EMC_40_ENET_MDC,
377  IOMUXC_SW_PAD_CTL_PAD_HYS(0) |
378  IOMUXC_SW_PAD_CTL_PAD_PUS(0) |
379  IOMUXC_SW_PAD_CTL_PAD_PUE(0) |
380  IOMUXC_SW_PAD_CTL_PAD_PKE(0) |
381  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
382  IOMUXC_SW_PAD_CTL_PAD_SPEED(0) |
383  IOMUXC_SW_PAD_CTL_PAD_DSE(5) |
384  IOMUXC_SW_PAD_CTL_PAD_SRE(1));
385 
386  //Configure GPIO_EMC_41 pin as ENET_MDIO
387  IOMUXC_SetPinMux(IOMUXC_GPIO_EMC_41_ENET_MDIO, 0);
388 
389  //Set GPIO_EMC_41 pad properties
390  IOMUXC_SetPinConfig(IOMUXC_GPIO_EMC_41_ENET_MDIO,
391  IOMUXC_SW_PAD_CTL_PAD_HYS(0) |
392  IOMUXC_SW_PAD_CTL_PAD_PUS(2) |
393  IOMUXC_SW_PAD_CTL_PAD_PUE(1) |
394  IOMUXC_SW_PAD_CTL_PAD_PKE(1) |
395  IOMUXC_SW_PAD_CTL_PAD_ODE(1) |
396  IOMUXC_SW_PAD_CTL_PAD_SPEED(0) |
397  IOMUXC_SW_PAD_CTL_PAD_DSE(5) |
398  IOMUXC_SW_PAD_CTL_PAD_SRE(1));
399 
400  //Configure GPIO_SD_B1_04 pin as GPIO3_IO04
401  IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B1_04_GPIO3_IO04, 0);
402 
403  //Set GPIO_SD_B1_04 pad properties
404  IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B1_04_GPIO3_IO04,
405  IOMUXC_SW_PAD_CTL_PAD_HYS(0) |
406  IOMUXC_SW_PAD_CTL_PAD_PUS(0) |
407  IOMUXC_SW_PAD_CTL_PAD_PUE(0) |
408  IOMUXC_SW_PAD_CTL_PAD_PKE(0) |
409  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
410  IOMUXC_SW_PAD_CTL_PAD_SPEED(0) |
411  IOMUXC_SW_PAD_CTL_PAD_DSE(5) |
412  IOMUXC_SW_PAD_CTL_PAD_SRE(0));
413 
414  //Configure GPIO_AD_B0_10 pin as GPIO1_IO10
415  IOMUXC_SetPinMux(IOMUXC_GPIO_AD_B0_10_GPIO1_IO10, 0);
416 
417  //Set GPIO_AD_B0_10 pad properties
418  IOMUXC_SetPinConfig(IOMUXC_GPIO_AD_B0_10_GPIO1_IO10,
419  IOMUXC_SW_PAD_CTL_PAD_HYS(0) |
420  IOMUXC_SW_PAD_CTL_PAD_PUS(2) |
421  IOMUXC_SW_PAD_CTL_PAD_PUE(1) |
422  IOMUXC_SW_PAD_CTL_PAD_PKE(1) |
423  IOMUXC_SW_PAD_CTL_PAD_ODE(0) |
424  IOMUXC_SW_PAD_CTL_PAD_SPEED(0) |
425  IOMUXC_SW_PAD_CTL_PAD_DSE(0) |
426  IOMUXC_SW_PAD_CTL_PAD_SRE(0));
427 
428  //Configure ENET_RST as an output
429  pinConfig.direction = kGPIO_DigitalOutput;
430  pinConfig.outputLogic = 0;
431  pinConfig.interruptMode = kGPIO_NoIntmode;
432  GPIO_PinInit(GPIO3, 4, &pinConfig);
433 
434  //Configure ENET_INT as an input
435  pinConfig.direction = kGPIO_DigitalInput;
436  pinConfig.outputLogic = 0;
437  pinConfig.interruptMode = kGPIO_NoIntmode;
438  GPIO_PinInit(GPIO1, 10, &pinConfig);
439 
440  //Reset PHY transceiver (hard reset)
441  GPIO_PinWrite(GPIO3, 4, 0);
442  sleep(10);
443  GPIO_PinWrite(GPIO3, 4, 1);
444  sleep(10);
445 #endif
446 }
447 
448 
449 /**
450  * @brief Initialize buffer descriptors
451  * @param[in] interface Underlying network interface
452  **/
453 
455 {
456  uint_t i;
457  uint32_t address;
458 
459  //Clear TX and RX buffer descriptors
460  osMemset(txBufferDesc, 0, sizeof(txBufferDesc));
461  osMemset(rxBufferDesc, 0, sizeof(rxBufferDesc));
462 
463  //Initialize TX buffer descriptors
464  for(i = 0; i < MIMXRT1040_ETH_TX_BUFFER_COUNT; i++)
465  {
466  //Calculate the address of the current TX buffer
467  address = (uint32_t) txBuffer[i];
468  //Transmit buffer address
469  txBufferDesc[i][1] = address;
470  //Generate interrupts
471  txBufferDesc[i][2] = ENET_TBD2_INT;
472  }
473 
474  //Mark the last descriptor entry with the wrap flag
475  txBufferDesc[i - 1][0] |= ENET_TBD0_W;
476  //Initialize TX buffer index
477  txBufferIndex = 0;
478 
479  //Initialize RX buffer descriptors
480  for(i = 0; i < MIMXRT1040_ETH_RX_BUFFER_COUNT; i++)
481  {
482  //Calculate the address of the current RX buffer
483  address = (uint32_t) rxBuffer[i];
484  //The descriptor is initially owned by the DMA
485  rxBufferDesc[i][0] = ENET_RBD0_E;
486  //Receive buffer address
487  rxBufferDesc[i][1] = address;
488  //Generate interrupts
489  rxBufferDesc[i][2] = ENET_RBD2_INT;
490  }
491 
492  //Mark the last descriptor entry with the wrap flag
493  rxBufferDesc[i - 1][0] |= ENET_RBD0_W;
494  //Initialize RX buffer index
495  rxBufferIndex = 0;
496 
497  //Start location of the TX descriptor list
498  ENET->TDSR = (uint32_t) txBufferDesc;
499  //Start location of the RX descriptor list
500  ENET->RDSR = (uint32_t) rxBufferDesc;
501  //Maximum receive buffer size
502  ENET->MRBR = MIMXRT1040_ETH_RX_BUFFER_SIZE;
503 }
504 
505 
506 /**
507  * @brief i.MX RT1040 Ethernet MAC timer handler
508  *
509  * This routine is periodically called by the TCP/IP stack to handle periodic
510  * operations such as polling the link state
511  *
512  * @param[in] interface Underlying network interface
513  **/
514 
516 {
517  //Valid Ethernet PHY or switch driver?
518  if(interface->phyDriver != NULL)
519  {
520  //Handle periodic operations
521  interface->phyDriver->tick(interface);
522  }
523  else if(interface->switchDriver != NULL)
524  {
525  //Handle periodic operations
526  interface->switchDriver->tick(interface);
527  }
528  else
529  {
530  //Just for sanity
531  }
532 }
533 
534 
535 /**
536  * @brief Enable interrupts
537  * @param[in] interface Underlying network interface
538  **/
539 
541 {
542  //Enable Ethernet MAC interrupts
543  NVIC_EnableIRQ(ENET_IRQn);
544 
545  //Valid Ethernet PHY or switch driver?
546  if(interface->phyDriver != NULL)
547  {
548  //Enable Ethernet PHY interrupts
549  interface->phyDriver->enableIrq(interface);
550  }
551  else if(interface->switchDriver != NULL)
552  {
553  //Enable Ethernet switch interrupts
554  interface->switchDriver->enableIrq(interface);
555  }
556  else
557  {
558  //Just for sanity
559  }
560 }
561 
562 
563 /**
564  * @brief Disable interrupts
565  * @param[in] interface Underlying network interface
566  **/
567 
569 {
570  //Disable Ethernet MAC interrupts
571  NVIC_DisableIRQ(ENET_IRQn);
572 
573  //Valid Ethernet PHY or switch driver?
574  if(interface->phyDriver != NULL)
575  {
576  //Disable Ethernet PHY interrupts
577  interface->phyDriver->disableIrq(interface);
578  }
579  else if(interface->switchDriver != NULL)
580  {
581  //Disable Ethernet switch interrupts
582  interface->switchDriver->disableIrq(interface);
583  }
584  else
585  {
586  //Just for sanity
587  }
588 }
589 
590 
591 /**
592  * @brief Ethernet MAC interrupt
593  **/
594 
595 void ENET_IRQHandler(void)
596 {
597  bool_t flag;
598  uint32_t events;
599 
600  //Interrupt service routine prologue
601  osEnterIsr();
602 
603  //This flag will be set if a higher priority task must be woken
604  flag = FALSE;
605  //Read interrupt event register
606  events = ENET->EIR;
607 
608  //Packet transmitted?
609  if((events & ENET_EIR_TXF_MASK) != 0)
610  {
611  //Clear TXF interrupt flag
612  ENET->EIR = ENET_EIR_TXF_MASK;
613 
614  //Check whether the TX buffer is available for writing
615  if((txBufferDesc[txBufferIndex][0] & ENET_TBD0_R) == 0)
616  {
617  //Notify the TCP/IP stack that the transmitter is ready to send
618  flag = osSetEventFromIsr(&nicDriverInterface->nicTxEvent);
619  }
620 
621  //Instruct the DMA to poll the transmit descriptor list
622  ENET->TDAR = ENET_TDAR_TDAR_MASK;
623  }
624 
625  //Packet received?
626  if((events & ENET_EIR_RXF_MASK) != 0)
627  {
628  //Disable RXF interrupt
629  ENET->EIMR &= ~ENET_EIMR_RXF_MASK;
630 
631  //Set event flag
632  nicDriverInterface->nicEvent = TRUE;
633  //Notify the TCP/IP stack of the event
634  flag = osSetEventFromIsr(&netEvent);
635  }
636 
637  //System bus error?
638  if((events & ENET_EIR_EBERR_MASK) != 0)
639  {
640  //Disable EBERR interrupt
641  ENET->EIMR &= ~ENET_EIMR_EBERR_MASK;
642 
643  //Set event flag
644  nicDriverInterface->nicEvent = TRUE;
645  //Notify the TCP/IP stack of the event
646  flag |= osSetEventFromIsr(&netEvent);
647  }
648 
649  //Interrupt service routine epilogue
650  osExitIsr(flag);
651 }
652 
653 
654 /**
655  * @brief i.MX RT1040 Ethernet MAC event handler
656  * @param[in] interface Underlying network interface
657  **/
658 
660 {
661  error_t error;
662  uint32_t status;
663 
664  //Read interrupt event register
665  status = ENET->EIR;
666 
667  //Packet received?
668  if((status & ENET_EIR_RXF_MASK) != 0)
669  {
670  //Clear RXF interrupt flag
671  ENET->EIR = ENET_EIR_RXF_MASK;
672 
673  //Process all pending packets
674  do
675  {
676  //Read incoming packet
677  error = mimxrt1040EthReceivePacket(interface);
678 
679  //No more data in the receive buffer?
680  } while(error != ERROR_BUFFER_EMPTY);
681  }
682 
683  //System bus error?
684  if((status & ENET_EIR_EBERR_MASK) != 0)
685  {
686  //Clear EBERR interrupt flag
687  ENET->EIR = ENET_EIR_EBERR_MASK;
688 
689  //Disable Ethernet MAC
690  ENET->ECR &= ~ENET_ECR_ETHEREN_MASK;
691  //Reset buffer descriptors
692  mimxrt1040EthInitBufferDesc(interface);
693  //Resume normal operation
694  ENET->ECR |= ENET_ECR_ETHEREN_MASK;
695  //Instruct the DMA to poll the receive descriptor list
696  ENET->RDAR = ENET_RDAR_RDAR_MASK;
697  }
698 
699  //Re-enable Ethernet MAC interrupts
700  ENET->EIMR = ENET_EIMR_TXF_MASK | ENET_EIMR_RXF_MASK | ENET_EIMR_EBERR_MASK;
701 }
702 
703 
704 /**
705  * @brief Send a packet
706  * @param[in] interface Underlying network interface
707  * @param[in] buffer Multi-part buffer containing the data to send
708  * @param[in] offset Offset to the first data byte
709  * @param[in] ancillary Additional options passed to the stack along with
710  * the packet
711  * @return Error code
712  **/
713 
715  const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
716 {
717  static uint32_t temp[MIMXRT1040_ETH_TX_BUFFER_SIZE / 4];
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((txBufferDesc[txBufferIndex][0] & ENET_TBD0_R) != 0)
734  {
735  return ERROR_FAILURE;
736  }
737 
738  //Copy user data to the transmit buffer
739  netBufferRead(temp, buffer, offset, length);
740  osMemcpy(txBuffer[txBufferIndex], temp, (length + 3) & ~3UL);
741 
742  //Clear BDU flag
743  txBufferDesc[txBufferIndex][4] = 0;
744 
745  //Check current index
746  if(txBufferIndex < (MIMXRT1040_ETH_TX_BUFFER_COUNT - 1))
747  {
748  //Give the ownership of the descriptor to the DMA engine
749  txBufferDesc[txBufferIndex][0] = ENET_TBD0_R | ENET_TBD0_L |
751 
752  //Point to the next buffer
753  txBufferIndex++;
754  }
755  else
756  {
757  //Give the ownership of the descriptor to the DMA engine
758  txBufferDesc[txBufferIndex][0] = ENET_TBD0_R | ENET_TBD0_W |
760 
761  //Wrap around
762  txBufferIndex = 0;
763  }
764 
765  //Data synchronization barrier
766  __DSB();
767 
768  //Instruct the DMA to poll the transmit descriptor list
769  ENET->TDAR = ENET_TDAR_TDAR_MASK;
770 
771  //Check whether the next buffer is available for writing
772  if((txBufferDesc[txBufferIndex][0] & ENET_TBD0_R) == 0)
773  {
774  //The transmitter can accept another packet
775  osSetEvent(&interface->nicTxEvent);
776  }
777 
778  //Successful processing
779  return NO_ERROR;
780 }
781 
782 
783 /**
784  * @brief Receive a packet
785  * @param[in] interface Underlying network interface
786  * @return Error code
787  **/
788 
790 {
791  static uint32_t temp[MIMXRT1040_ETH_RX_BUFFER_SIZE / 4];
792  error_t error;
793  size_t n;
794  NetRxAncillary ancillary;
795 
796  //Current buffer available for reading?
797  if((rxBufferDesc[rxBufferIndex][0] & ENET_RBD0_E) == 0)
798  {
799  //The frame should not span multiple buffers
800  if((rxBufferDesc[rxBufferIndex][0] & ENET_RBD0_L) != 0)
801  {
802  //Check whether an error occurred
803  if((rxBufferDesc[rxBufferIndex][0] & (ENET_RBD0_LG | ENET_RBD0_NO |
805  {
806  //Retrieve the length of the frame
807  n = rxBufferDesc[rxBufferIndex][0] & ENET_RBD0_DATA_LENGTH;
808  //Limit the number of data to read
810 
811  //Copy data from the receive buffer
812  osMemcpy(temp, rxBuffer[rxBufferIndex], (n + 3) & ~3UL);
813 
814  //Additional options can be passed to the stack along with the packet
815  ancillary = NET_DEFAULT_RX_ANCILLARY;
816 
817  //Pass the packet to the upper layer
818  nicProcessPacket(interface, (uint8_t *) temp, n, &ancillary);
819 
820  //Valid packet received
821  error = NO_ERROR;
822  }
823  else
824  {
825  //The received packet contains an error
826  error = ERROR_INVALID_PACKET;
827  }
828  }
829  else
830  {
831  //The packet is not valid
832  error = ERROR_INVALID_PACKET;
833  }
834 
835  //Clear BDU flag
836  rxBufferDesc[rxBufferIndex][4] = 0;
837 
838  //Check current index
839  if(rxBufferIndex < (MIMXRT1040_ETH_RX_BUFFER_COUNT - 1))
840  {
841  //Give the ownership of the descriptor back to the DMA engine
842  rxBufferDesc[rxBufferIndex][0] = ENET_RBD0_E;
843  //Point to the next buffer
844  rxBufferIndex++;
845  }
846  else
847  {
848  //Give the ownership of the descriptor back to the DMA engine
849  rxBufferDesc[rxBufferIndex][0] = ENET_RBD0_E | ENET_RBD0_W;
850  //Wrap around
851  rxBufferIndex = 0;
852  }
853 
854  //Instruct the DMA to poll the receive descriptor list
855  ENET->RDAR = ENET_RDAR_RDAR_MASK;
856  }
857  else
858  {
859  //No more data in the receive buffer
860  error = ERROR_BUFFER_EMPTY;
861  }
862 
863  //Return status code
864  return error;
865 }
866 
867 
868 /**
869  * @brief Configure MAC address filtering
870  * @param[in] interface Underlying network interface
871  * @return Error code
872  **/
873 
875 {
876  uint_t i;
877  uint_t k;
878  uint32_t crc;
879  uint32_t value;
880  uint32_t unicastHashTable[2];
881  uint32_t multicastHashTable[2];
882  MacFilterEntry *entry;
883 
884  //Debug message
885  TRACE_DEBUG("Updating MAC filter...\r\n");
886 
887  //Set the MAC address of the station (upper 16 bits)
888  value = interface->macAddr.b[5];
889  value |= (interface->macAddr.b[4] << 8);
890  ENET->PAUR = ENET_PAUR_PADDR2(value) | ENET_PAUR_TYPE(0x8808);
891 
892  //Set the MAC address of the station (lower 32 bits)
893  value = interface->macAddr.b[3];
894  value |= (interface->macAddr.b[2] << 8);
895  value |= (interface->macAddr.b[1] << 16);
896  value |= (interface->macAddr.b[0] << 24);
897  ENET->PALR = ENET_PALR_PADDR1(value);
898 
899  //Clear hash table (unicast address filtering)
900  unicastHashTable[0] = 0;
901  unicastHashTable[1] = 0;
902 
903  //Clear hash table (multicast address filtering)
904  multicastHashTable[0] = 0;
905  multicastHashTable[1] = 0;
906 
907  //The MAC address filter contains the list of MAC addresses to accept
908  //when receiving an Ethernet frame
909  for(i = 0; i < MAC_ADDR_FILTER_SIZE; i++)
910  {
911  //Point to the current entry
912  entry = &interface->macAddrFilter[i];
913 
914  //Valid entry?
915  if(entry->refCount > 0)
916  {
917  //Compute CRC over the current MAC address
918  crc = mimxrt1040EthCalcCrc(&entry->addr, sizeof(MacAddr));
919 
920  //The upper 6 bits in the CRC register are used to index the
921  //contents of the hash table
922  k = (crc >> 26) & 0x3F;
923 
924  //Multicast address?
925  if(macIsMulticastAddr(&entry->addr))
926  {
927  //Update the multicast hash table
928  multicastHashTable[k / 32] |= (1 << (k % 32));
929  }
930  else
931  {
932  //Update the unicast hash table
933  unicastHashTable[k / 32] |= (1 << (k % 32));
934  }
935  }
936  }
937 
938  //Write the hash table (unicast address filtering)
939  ENET->IALR = unicastHashTable[0];
940  ENET->IAUR = unicastHashTable[1];
941 
942  //Write the hash table (multicast address filtering)
943  ENET->GALR = multicastHashTable[0];
944  ENET->GAUR = multicastHashTable[1];
945 
946  //Debug message
947  TRACE_DEBUG(" IALR = %08" PRIX32 "\r\n", ENET->IALR);
948  TRACE_DEBUG(" IAUR = %08" PRIX32 "\r\n", ENET->IAUR);
949  TRACE_DEBUG(" GALR = %08" PRIX32 "\r\n", ENET->GALR);
950  TRACE_DEBUG(" GAUR = %08" PRIX32 "\r\n", ENET->GAUR);
951 
952  //Successful processing
953  return NO_ERROR;
954 }
955 
956 
957 /**
958  * @brief Adjust MAC configuration parameters for proper operation
959  * @param[in] interface Underlying network interface
960  * @return Error code
961  **/
962 
964 {
965  //Disable Ethernet MAC while modifying configuration registers
966  ENET->ECR &= ~ENET_ECR_ETHEREN_MASK;
967 
968  //10BASE-T or 100BASE-TX operation mode?
969  if(interface->linkSpeed == NIC_LINK_SPEED_100MBPS)
970  {
971  //100 Mbps operation
972  ENET->RCR &= ~ENET_RCR_RMII_10T_MASK;
973  }
974  else
975  {
976  //10 Mbps operation
977  ENET->RCR |= ENET_RCR_RMII_10T_MASK;
978  }
979 
980  //Half-duplex or full-duplex mode?
981  if(interface->duplexMode == NIC_FULL_DUPLEX_MODE)
982  {
983  //Full-duplex mode
984  ENET->TCR |= ENET_TCR_FDEN_MASK;
985  //Receive path operates independently of transmit
986  ENET->RCR &= ~ENET_RCR_DRT_MASK;
987  }
988  else
989  {
990  //Half-duplex mode
991  ENET->TCR &= ~ENET_TCR_FDEN_MASK;
992  //Disable reception of frames while transmitting
993  ENET->RCR |= ENET_RCR_DRT_MASK;
994  }
995 
996  //Reset buffer descriptors
997  mimxrt1040EthInitBufferDesc(interface);
998 
999  //Re-enable Ethernet MAC
1000  ENET->ECR |= ENET_ECR_ETHEREN_MASK;
1001  //Instruct the DMA to poll the receive descriptor list
1002  ENET->RDAR = ENET_RDAR_RDAR_MASK;
1003 
1004  //Successful processing
1005  return NO_ERROR;
1006 }
1007 
1008 
1009 /**
1010  * @brief Write PHY register
1011  * @param[in] opcode Access type (2 bits)
1012  * @param[in] phyAddr PHY address (5 bits)
1013  * @param[in] regAddr Register address (5 bits)
1014  * @param[in] data Register value
1015  **/
1016 
1017 void mimxrt1040EthWritePhyReg(uint8_t opcode, uint8_t phyAddr,
1018  uint8_t regAddr, uint16_t data)
1019 {
1020  uint32_t temp;
1021 
1022  //Valid opcode?
1023  if(opcode == SMI_OPCODE_WRITE)
1024  {
1025  //Set up a write operation
1026  temp = ENET_MMFR_ST(1) | ENET_MMFR_OP(1) | ENET_MMFR_TA(2);
1027  //PHY address
1028  temp |= ENET_MMFR_PA(phyAddr);
1029  //Register address
1030  temp |= ENET_MMFR_RA(regAddr);
1031  //Register value
1032  temp |= ENET_MMFR_DATA(data);
1033 
1034  //Clear MII interrupt flag
1035  ENET->EIR = ENET_EIR_MII_MASK;
1036  //Start a write operation
1037  ENET->MMFR = temp;
1038 
1039  //Wait for the write to complete
1040  while((ENET->EIR & ENET_EIR_MII_MASK) == 0)
1041  {
1042  }
1043  }
1044  else
1045  {
1046  //The MAC peripheral only supports standard Clause 22 opcodes
1047  }
1048 }
1049 
1050 
1051 /**
1052  * @brief Read PHY register
1053  * @param[in] opcode Access type (2 bits)
1054  * @param[in] phyAddr PHY address (5 bits)
1055  * @param[in] regAddr Register address (5 bits)
1056  * @return Register value
1057  **/
1058 
1059 uint16_t mimxrt1040EthReadPhyReg(uint8_t opcode, uint8_t phyAddr,
1060  uint8_t regAddr)
1061 {
1062  uint16_t data;
1063  uint32_t temp;
1064 
1065  //Valid opcode?
1066  if(opcode == SMI_OPCODE_READ)
1067  {
1068  //Set up a read operation
1069  temp = ENET_MMFR_ST(1) | ENET_MMFR_OP(2) | ENET_MMFR_TA(2);
1070  //PHY address
1071  temp |= ENET_MMFR_PA(phyAddr);
1072  //Register address
1073  temp |= ENET_MMFR_RA(regAddr);
1074 
1075  //Clear MII interrupt flag
1076  ENET->EIR = ENET_EIR_MII_MASK;
1077  //Start a read operation
1078  ENET->MMFR = temp;
1079 
1080  //Wait for the read to complete
1081  while((ENET->EIR & ENET_EIR_MII_MASK) == 0)
1082  {
1083  }
1084 
1085  //Get register value
1086  data = ENET->MMFR & ENET_MMFR_DATA_MASK;
1087  }
1088  else
1089  {
1090  //The MAC peripheral only supports standard Clause 22 opcodes
1091  data = 0;
1092  }
1093 
1094  //Return the value of the PHY register
1095  return data;
1096 }
1097 
1098 
1099 /**
1100  * @brief CRC calculation
1101  * @param[in] data Pointer to the data over which to calculate the CRC
1102  * @param[in] length Number of bytes to process
1103  * @return Resulting CRC value
1104  **/
1105 
1106 uint32_t mimxrt1040EthCalcCrc(const void *data, size_t length)
1107 {
1108  uint_t i;
1109  uint_t j;
1110  uint32_t crc;
1111  const uint8_t *p;
1112 
1113  //Point to the data over which to calculate the CRC
1114  p = (uint8_t *) data;
1115  //CRC preset value
1116  crc = 0xFFFFFFFF;
1117 
1118  //Loop through data
1119  for(i = 0; i < length; i++)
1120  {
1121  //Update CRC value
1122  crc ^= p[i];
1123 
1124  //The message is processed bit by bit
1125  for(j = 0; j < 8; j++)
1126  {
1127  if((crc & 0x01) != 0)
1128  {
1129  crc = (crc >> 1) ^ 0xEDB88320;
1130  }
1131  else
1132  {
1133  crc = crc >> 1;
1134  }
1135  }
1136  }
1137 
1138  //Return CRC value
1139  return crc;
1140 }
#define rxBuffer
#define txBuffer
__attribute__((naked))
AVR32 Ethernet MAC interrupt wrapper.
unsigned int uint_t
Definition: compiler_port.h:50
int bool_t
Definition: compiler_port.h:53
Debugging facilities.
#define TRACE_DEBUG(...)
Definition: debug.h:107
#define TRACE_INFO(...)
Definition: debug.h:95
uint8_t n
uint8_t opcode
Definition: dns_common.h:188
error_t
Error codes.
Definition: error.h:43
@ ERROR_BUFFER_EMPTY
Definition: error.h:141
@ NO_ERROR
Success.
Definition: error.h:44
@ ERROR_INVALID_PACKET
Definition: error.h:140
@ ERROR_INVALID_LENGTH
Definition: error.h:111
@ ERROR_FAILURE
Generic error code.
Definition: error.h:45
#define macIsMulticastAddr(macAddr)
Definition: ethernet.h:133
#define ETH_MTU
Definition: ethernet.h:116
uint8_t data[]
Definition: ethernet.h:222
MacAddr
Definition: ethernet.h:195
#define MAC_ADDR_FILTER_SIZE
Definition: ethernet.h:95
Ipv6Addr address[]
Definition: ipv6.h:316
#define ENET_RBD0_E
#define ENET_RBD0_DATA_LENGTH
#define ENET_TBD2_INT
#define ENET_TBD0_W
#define ENET_TBD0_R
#define ENET_RBD0_L
#define ENET_RBD0_NO
#define ENET_RBD0_W
#define ENET_RBD0_LG
#define ENET_TBD0_DATA_LENGTH
#define ENET_RBD2_INT
#define ENET_RBD0_OV
#define ENET_TBD0_TC
#define ENET_RBD0_CR
#define ENET_TBD0_L
#define ENET_RBD0_TR
error_t mimxrt1040EthReceivePacket(NetInterface *interface)
Receive a packet.
void mimxrt1040EthDisableIrq(NetInterface *interface)
Disable interrupts.
error_t mimxrt1040EthSendPacket(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a packet.
const NicDriver mimxrt1040EthDriver
i.MX RT1040 Ethernet MAC driver
void mimxrt1040EthEventHandler(NetInterface *interface)
i.MX RT1040 Ethernet MAC event handler
error_t mimxrt1040EthInit(NetInterface *interface)
i.MX RT1040 Ethernet MAC initialization
void ENET_IRQHandler(void)
Ethernet MAC interrupt.
error_t mimxrt1040EthUpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
error_t mimxrt1040EthUpdateMacConfig(NetInterface *interface)
Adjust MAC configuration parameters for proper operation.
void mimxrt1040EthWritePhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr, uint16_t data)
Write PHY register.
uint16_t mimxrt1040EthReadPhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr)
Read PHY register.
uint32_t mimxrt1040EthCalcCrc(const void *data, size_t length)
CRC calculation.
__weak_func void mimxrt1040EthInitGpio(NetInterface *interface)
GPIO configuration.
void mimxrt1040EthEnableIrq(NetInterface *interface)
Enable interrupts.
void mimxrt1040EthInitBufferDesc(NetInterface *interface)
Initialize buffer descriptors.
void mimxrt1040EthTick(NetInterface *interface)
i.MX RT1040 Ethernet MAC timer handler
NXP i.MX RT1040 Ethernet MAC driver.
#define MIMXRT1040_ETH_IRQ_SUB_PRIORITY
#define MIMXRT1040_ETH_RX_BUFFER_COUNT
#define MIMXRT1040_ETH_RX_BUFFER_SIZE
#define MIMXRT1040_ETH_IRQ_GROUP_PRIORITY
#define MIMXRT1040_ETH_TX_BUFFER_SIZE
#define MIMXRT1040_ETH_IRQ_PRIORITY_GROUPING
#define MIMXRT1040_ETH_TX_BUFFER_COUNT
#define MIMXRT1040_ETH_RAM_SECTION
uint16_t regAddr
uint8_t p
Definition: ndp.h:300
TCP/IP stack core.
#define NetInterface
Definition: net.h:36
#define netEvent
Definition: net_legacy.h:196
size_t netBufferGetLength(const NetBuffer *buffer)
Get the actual length of a multi-part buffer.
Definition: net_mem.c:297
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:674
const NetRxAncillary NET_DEFAULT_RX_ANCILLARY
Definition: net_misc.c:101
#define NetRxAncillary
Definition: net_misc.h:40
#define NetTxAncillary
Definition: net_misc.h:36
void nicProcessPacket(NetInterface *interface, uint8_t *packet, size_t length, NetRxAncillary *ancillary)
Handle a packet received by the network controller.
Definition: nic.c:391
#define SMI_OPCODE_WRITE
Definition: nic.h:66
@ NIC_TYPE_ETHERNET
Ethernet interface.
Definition: nic.h:83
#define SMI_OPCODE_READ
Definition: nic.h:67
@ NIC_FULL_DUPLEX_MODE
Definition: nic.h:125
@ NIC_LINK_SPEED_100MBPS
Definition: nic.h:112
#define osMemset(p, value, length)
Definition: os_port.h:135
#define osMemcpy(dest, src, length)
Definition: os_port.h:141
#define MIN(a, b)
Definition: os_port.h:63
#define TRUE
Definition: os_port.h:50
#define FALSE
Definition: os_port.h:46
#define sleep(delay)
Definition: os_port.h:301
bool_t osSetEventFromIsr(OsEvent *event)
Set an event object to the signaled state from an interrupt service routine.
void osSetEvent(OsEvent *event)
Set the specified event object to the signaled state.
#define osEnterIsr()
#define osExitIsr(flag)
MAC filter table entry.
Definition: ethernet.h:262
MacAddr addr
MAC address.
Definition: ethernet.h:263
uint_t refCount
Reference count for the current entry.
Definition: ethernet.h:264
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:89
NIC driver.
Definition: nic.h:283
uint8_t length
Definition: tcp.h:368
uint8_t value[]
Definition: tcp.h:369