rx62n_eth_driver.c
Go to the documentation of this file.
1 /**
2  * @file rx62n_eth_driver.c
3  * @brief Renesas RX62N Ethernet MAC driver
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2025 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.5.0
29  **/
30 
31 //Switch to the appropriate trace level
32 #define TRACE_LEVEL NIC_TRACE_LEVEL
33 
34 //Dependencies
35 #include <iorx62n.h>
36 #include <intrinsics.h>
37 #include "core/net.h"
39 #include "debug.h"
40 
41 //Underlying network interface
42 static NetInterface *nicDriverInterface;
43 
44 //IAR EWRX compiler?
45 #if defined(__ICCRX__)
46 
47 //Transmit buffer
48 #pragma data_alignment = 32
50 //Receive buffer
51 #pragma data_alignment = 32
53 //Transmit DMA descriptors
54 #pragma data_alignment = 32
56 //Receive DMA descriptors
57 #pragma data_alignment = 32
59 
60 //GCC compiler?
61 #else
62 
63 //Transmit buffer
65  __attribute__((aligned(32)));
66 //Receive buffer
68  __attribute__((aligned(32)));
69 //Transmit DMA descriptors
71  __attribute__((aligned(32)));
72 //Receive DMA descriptors
74  __attribute__((aligned(32)));
75 
76 #endif
77 
78 //Current transmit descriptor
79 static uint_t txIndex;
80 //Current receive descriptor
81 static uint_t rxIndex;
82 
83 
84 /**
85  * @brief RX62N Ethernet MAC driver
86  **/
87 
89 {
91  ETH_MTU,
102  TRUE,
103  TRUE,
104  TRUE,
105  TRUE
106 };
107 
108 
109 /**
110  * @brief RX62N Ethernet MAC initialization
111  * @param[in] interface Underlying network interface
112  * @return Error code
113  **/
114 
116 {
117  error_t error;
118 
119  //Debug message
120  TRACE_INFO("Initializing RX62N Ethernet MAC...\r\n");
121 
122  //Save underlying network interface
123  nicDriverInterface = interface;
124 
125  //Cancel EDMAC module stop state
126  MSTP(EDMAC) = 0;
127 
128  //GPIO configuration
129  rx62nEthInitGpio(interface);
130 
131  //Reset EDMAC module
132  EDMAC.EDMR.BIT.SWR = 1;
133  //Wait for the reset to complete
134  sleep(10);
135 
136  //Valid Ethernet PHY or switch driver?
137  if(interface->phyDriver != NULL)
138  {
139  //Ethernet PHY initialization
140  error = interface->phyDriver->init(interface);
141  }
142  else if(interface->switchDriver != NULL)
143  {
144  //Ethernet switch initialization
145  error = interface->switchDriver->init(interface);
146  }
147  else
148  {
149  //The interface is not properly configured
150  error = ERROR_FAILURE;
151  }
152 
153  //Any error to report?
154  if(error)
155  {
156  return error;
157  }
158 
159  //Initialize DMA descriptor lists
160  rx62nEthInitDmaDesc(interface);
161 
162  //Maximum frame length that can be accepted
163  ETHERC.RFLR.LONG = RX62N_ETH_RX_BUFFER_SIZE;
164  //Set default inter packet gap (96-bit time)
165  ETHERC.IPGR.LONG = 0x14;
166 
167  //Set the upper 32 bits of the MAC address
168  ETHERC.MAHR = (interface->macAddr.b[0] << 24) | (interface->macAddr.b[1] << 16) |
169  (interface->macAddr.b[2] << 8) | interface->macAddr.b[3];
170 
171  //Set the lower 16 bits of the MAC address
172  ETHERC.MALR.BIT.MA = (interface->macAddr.b[4] << 8) | interface->macAddr.b[5];
173 
174  //Set descriptor length (16 bytes)
175  EDMAC.EDMR.BIT.DL = 0;
176 
177 #ifdef _CPU_BIG_ENDIAN
178  //Select big endian mode
179  EDMAC.EDMR.BIT.DE = 0;
180 #else
181  //Select little endian mode
182  EDMAC.EDMR.BIT.DE = 1;
183 #endif
184 
185  //Use store and forward mode
186  EDMAC.TFTR.BIT.TFT = 0;
187 
188  //Set transmit FIFO size (2048 bytes)
189  EDMAC.FDR.BIT.TFD = 7;
190  //Set receive FIFO size (2048 bytes)
191  EDMAC.FDR.BIT.RFD = 7;
192 
193  //Enable continuous reception of multiple frames
194  EDMAC.RMCR.BIT.RNR = 1;
195 
196  //Accept transmit interrupt notifications
197  EDMAC.TRIMD.BIT.TIM = 0;
198  EDMAC.TRIMD.BIT.TIS = 1;
199 
200  //Disable all EDMAC interrupts
201  EDMAC.EESIPR.LONG = 0;
202  //Enable only the desired EDMAC interrupts
203  EDMAC.EESIPR.BIT.TWBIP = 1;
204  EDMAC.EESIPR.BIT.FRIP = 1;
205 
206  //Configure EDMAC interrupt priority
207  IPR(ETHER, EINT) = RX62N_ETH_IRQ_PRIORITY;
208 
209  //Enable transmission and reception
210  ETHERC.ECMR.BIT.TE = 1;
211  ETHERC.ECMR.BIT.RE = 1;
212 
213  //Instruct the DMA to poll the receive descriptor list
214  EDMAC.EDRRR.BIT.RR = 1;
215 
216  //Accept any packets from the upper layer
217  osSetEvent(&interface->nicTxEvent);
218 
219  //Successful initialization
220  return NO_ERROR;
221 }
222 
223 
224 /**
225  * @brief GPIO configuration
226  * @param[in] interface Underlying network interface
227  **/
228 
229 __weak_func void rx62nEthInitGpio(NetInterface *interface)
230 {
231 //RDK-RX62N evaluation board?
232 #if defined(USE_RDK_RX62N)
233  //Select RMII interface mode
234  IOPORT.PFENET.BIT.PHYMODE = 0;
235 
236  //Enable Ethernet pins
237  IOPORT.PFENET.BIT.EE = 1;
238  //Disable ET_WOL pin
239  IOPORT.PFENET.BIT.ENETE0 = 0;
240  //Enable ET_LINKSTA pin
241  IOPORT.PFENET.BIT.ENETE1 = 1;
242  //Disable ET_EXOUT pin
243  IOPORT.PFENET.BIT.ENETE2 = 0;
244  //Disable ET_TX_ER pin
245  IOPORT.PFENET.BIT.ENETE3 = 0;
246 
247  //Configure ET_MDIO (PA3)
248  PORTA.ICR.BIT.B3 = 1;
249  //Configure ET_LINKSTA (PA5)
250  PORTA.ICR.BIT.B5 = 1;
251  //Configure RMII_RXD1 (PB0)
252  PORTB.ICR.BIT.B0 = 1;
253  //Configure RMII_RXD0 (PB1)
254  PORTB.ICR.BIT.B1 = 1;
255  //Configure REF50CK (PB2)
256  PORTB.ICR.BIT.B2 = 1;
257  //Configure RMII_RX_ER (PB3)
258  PORTB.ICR.BIT.B3 = 1;
259  //Configure RMII_CRS_DV (PB7)
260  PORTB.ICR.BIT.B7 = 1;
261 #endif
262 }
263 
264 
265 /**
266  * @brief Initialize DMA descriptor lists
267  * @param[in] interface Underlying network interface
268  **/
269 
271 {
272  uint_t i;
273 
274  //Initialize TX descriptors
275  for(i = 0; i < RX62N_ETH_TX_BUFFER_COUNT; i++)
276  {
277  //The descriptor is initially owned by the application
278  txDmaDesc[i].td0 = 0;
279  //Transmit buffer length
280  txDmaDesc[i].td1 = 0;
281  //Transmit buffer address
282  txDmaDesc[i].td2 = (uint32_t) txBuffer[i];
283  //Clear padding field
284  txDmaDesc[i].padding = 0;
285  }
286 
287  //Mark the last descriptor entry with the TDLE flag
288  txDmaDesc[i - 1].td0 |= EDMAC_TD0_TDLE;
289  //Initialize TX descriptor index
290  txIndex = 0;
291 
292  //Initialize RX descriptors
293  for(i = 0; i < RX62N_ETH_RX_BUFFER_COUNT; i++)
294  {
295  //The descriptor is initially owned by the DMA
296  rxDmaDesc[i].rd0 = EDMAC_RD0_RACT;
297  //Receive buffer length
299  //Receive buffer address
300  rxDmaDesc[i].rd2 = (uint32_t) rxBuffer[i];
301  //Clear padding field
302  rxDmaDesc[i].padding = 0;
303  }
304 
305  //Mark the last descriptor entry with the RDLE flag
306  rxDmaDesc[i - 1].rd0 |= EDMAC_RD0_RDLE;
307  //Initialize RX descriptor index
308  rxIndex = 0;
309 
310  //Start address of the TX descriptor list
311  EDMAC.TDLAR = txDmaDesc;
312  //Start address of the RX descriptor list
313  EDMAC.RDLAR = rxDmaDesc;
314 }
315 
316 
317 /**
318  * @brief RX62N Ethernet MAC timer handler
319  *
320  * This routine is periodically called by the TCP/IP stack to handle periodic
321  * operations such as polling the link state
322  *
323  * @param[in] interface Underlying network interface
324  **/
325 
326 void rx62nEthTick(NetInterface *interface)
327 {
328  //Valid Ethernet PHY or switch driver?
329  if(interface->phyDriver != NULL)
330  {
331  //Handle periodic operations
332  interface->phyDriver->tick(interface);
333  }
334  else if(interface->switchDriver != NULL)
335  {
336  //Handle periodic operations
337  interface->switchDriver->tick(interface);
338  }
339  else
340  {
341  //Just for sanity
342  }
343 }
344 
345 
346 /**
347  * @brief Enable interrupts
348  * @param[in] interface Underlying network interface
349  **/
350 
352 {
353  //Enable Ethernet MAC interrupts
354  IEN(ETHER, EINT) = 1;
355 
356  //Valid Ethernet PHY or switch driver?
357  if(interface->phyDriver != NULL)
358  {
359  //Enable Ethernet PHY interrupts
360  interface->phyDriver->enableIrq(interface);
361  }
362  else if(interface->switchDriver != NULL)
363  {
364  //Enable Ethernet switch interrupts
365  interface->switchDriver->enableIrq(interface);
366  }
367  else
368  {
369  //Just for sanity
370  }
371 }
372 
373 
374 /**
375  * @brief Disable interrupts
376  * @param[in] interface Underlying network interface
377  **/
378 
380 {
381  //Disable Ethernet MAC interrupts
382  IEN(ETHER, EINT) = 0;
383 
384  //Valid Ethernet PHY or switch driver?
385  if(interface->phyDriver != NULL)
386  {
387  //Disable Ethernet PHY interrupts
388  interface->phyDriver->disableIrq(interface);
389  }
390  else if(interface->switchDriver != NULL)
391  {
392  //Disable Ethernet switch interrupts
393  interface->switchDriver->disableIrq(interface);
394  }
395  else
396  {
397  //Just for sanity
398  }
399 }
400 
401 
402 /**
403  * @brief RX62N Ethernet MAC interrupt service routine
404  **/
405 
406 #pragma vector = VECT_ETHER_EINT
407 __interrupt void rx62nEthIrqHandler(void)
408 {
409  bool_t flag;
410  uint32_t status;
411 
412  //Allow nested interrupts
413  __enable_interrupt();
414 
415  //This flag will be set if a higher priority task must be woken
416  flag = FALSE;
417 
418  //Read interrupt status register
419  status = EDMAC.EESR.LONG;
420 
421  //Packet transmitted?
422  if((status & EDMAC_EESR_TWB) != 0)
423  {
424  //Clear TWB interrupt flag
425  EDMAC.EESR.LONG = EDMAC_EESR_TWB;
426 
427  //Check whether the TX buffer is available for writing
428  if((txDmaDesc[txIndex].td0 & EDMAC_TD0_TACT) == 0)
429  {
430  //Notify the TCP/IP stack that the transmitter is ready to send
431  flag |= osSetEventFromIsr(&nicDriverInterface->nicTxEvent);
432  }
433  }
434 
435  //Packet received?
436  if((status & EDMAC_EESR_FR) != 0)
437  {
438  //Clear FR interrupt flag
439  EDMAC.EESR.LONG = EDMAC_EESR_FR;
440 
441  //Set event flag
442  nicDriverInterface->nicEvent = TRUE;
443  //Notify the TCP/IP stack of the event
444  flag |= osSetEventFromIsr(&netEvent);
445  }
446 
447  //Interrupt service routine epilogue
448  osExitIsr(flag);
449 }
450 
451 
452 /**
453  * @brief RX62N Ethernet MAC event handler
454  * @param[in] interface Underlying network interface
455  **/
456 
458 {
459  error_t error;
460 
461  //Process all pending packets
462  do
463  {
464  //Read incoming packet
465  error = rx62nEthReceivePacket(interface);
466 
467  //No more data in the receive buffer?
468  } while(error != ERROR_BUFFER_EMPTY);
469 }
470 
471 
472 /**
473  * @brief Send a packet
474  * @param[in] interface Underlying network interface
475  * @param[in] buffer Multi-part buffer containing the data to send
476  * @param[in] offset Offset to the first data byte
477  * @param[in] ancillary Additional options passed to the stack along with
478  * the packet
479  * @return Error code
480  **/
481 
483  const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
484 {
485  //Retrieve the length of the packet
486  size_t length = netBufferGetLength(buffer) - offset;
487 
488  //Check the frame length
490  {
491  //The transmitter can accept another packet
492  osSetEvent(&interface->nicTxEvent);
493  //Report an error
494  return ERROR_INVALID_LENGTH;
495  }
496 
497  //Make sure the current buffer is available for writing
498  if((txDmaDesc[txIndex].td0 & EDMAC_TD0_TACT) != 0)
499  {
500  return ERROR_FAILURE;
501  }
502 
503  //Copy user data to the transmit buffer
504  netBufferRead(txBuffer[txIndex], buffer, offset, length);
505 
506  //Write the number of bytes to send
507  txDmaDesc[txIndex].td1 = (length << 16) & EDMAC_TD1_TBL;
508 
509  //Check current index
510  if(txIndex < (RX62N_ETH_TX_BUFFER_COUNT - 1))
511  {
512  //Give the ownership of the descriptor to the DMA engine
513  txDmaDesc[txIndex].td0 = EDMAC_TD0_TACT | EDMAC_TD0_TFP_SOF |
515 
516  //Point to the next descriptor
517  txIndex++;
518  }
519  else
520  {
521  //Give the ownership of the descriptor to the DMA engine
522  txDmaDesc[txIndex].td0 = EDMAC_TD0_TACT | EDMAC_TD0_TDLE |
524 
525  //Wrap around
526  txIndex = 0;
527  }
528 
529  //Instruct the DMA to poll the transmit descriptor list
530  EDMAC.EDTRR.BIT.TR = 1;
531 
532  //Check whether the next buffer is available for writing
533  if((txDmaDesc[txIndex].td0 & EDMAC_TD0_TACT) == 0)
534  {
535  //The transmitter can accept another packet
536  osSetEvent(&interface->nicTxEvent);
537  }
538 
539  //Successful write operation
540  return NO_ERROR;
541 }
542 
543 
544 /**
545  * @brief Receive a packet
546  * @param[in] interface Underlying network interface
547  * @return Error code
548  **/
549 
551 {
552  error_t error;
553  size_t n;
554  NetRxAncillary ancillary;
555 
556  //Current buffer available for reading?
557  if((rxDmaDesc[rxIndex].rd0 & EDMAC_RD0_RACT) == 0)
558  {
559  //SOF and EOF flags should be set
560  if((rxDmaDesc[rxIndex].rd0 & EDMAC_RD0_RFP_SOF) != 0 &&
561  (rxDmaDesc[rxIndex].rd0 & EDMAC_RD0_RFP_EOF) != 0)
562  {
563  //Make sure no error occurred
564  if((rxDmaDesc[rxIndex].rd0 & (EDMAC_RD0_RFS_MASK & ~EDMAC_RD0_RFS_RMAF)) == 0)
565  {
566  //Retrieve the length of the frame
567  n = rxDmaDesc[rxIndex].rd1 & EDMAC_RD1_RFL;
568  //Limit the number of data to read
570 
571  //Additional options can be passed to the stack along with the packet
572  ancillary = NET_DEFAULT_RX_ANCILLARY;
573 
574  //Pass the packet to the upper layer
575  nicProcessPacket(interface, rxBuffer[rxIndex], n, &ancillary);
576 
577  //Valid packet received
578  error = NO_ERROR;
579  }
580  else
581  {
582  //The received packet contains an error
583  error = ERROR_INVALID_PACKET;
584  }
585  }
586  else
587  {
588  //The packet is not valid
589  error = ERROR_INVALID_PACKET;
590  }
591 
592  //Check current index
593  if(rxIndex < (RX62N_ETH_RX_BUFFER_COUNT - 1))
594  {
595  //Give the ownership of the descriptor back to the DMA
596  rxDmaDesc[rxIndex].rd0 = EDMAC_RD0_RACT;
597  //Point to the next descriptor
598  rxIndex++;
599  }
600  else
601  {
602  //Give the ownership of the descriptor back to the DMA
603  rxDmaDesc[rxIndex].rd0 = EDMAC_RD0_RACT | EDMAC_RD0_RDLE;
604  //Wrap around
605  rxIndex = 0;
606  }
607 
608  //Instruct the DMA to poll the receive descriptor list
609  EDMAC.EDRRR.BIT.RR = 1;
610  }
611  else
612  {
613  //No more data in the receive buffer
614  error = ERROR_BUFFER_EMPTY;
615  }
616 
617  //Return status code
618  return error;
619 }
620 
621 
622 /**
623  * @brief Configure MAC address filtering
624  * @param[in] interface Underlying network interface
625  * @return Error code
626  **/
627 
629 {
630  uint_t i;
631  bool_t acceptMulticast;
632 
633  //Debug message
634  TRACE_DEBUG("Updating MAC filter...\r\n");
635 
636  //Set the upper 32 bits of the MAC address
637  ETHERC.MAHR = (interface->macAddr.b[0] << 24) | (interface->macAddr.b[1] << 16) |
638  (interface->macAddr.b[2] << 8) | interface->macAddr.b[3];
639 
640  //Set the lower 16 bits of the MAC address
641  ETHERC.MALR.BIT.MA = (interface->macAddr.b[4] << 8) | interface->macAddr.b[5];
642 
643  //This flag will be set if multicast addresses should be accepted
644  acceptMulticast = FALSE;
645 
646  //The MAC address filter contains the list of MAC addresses to accept
647  //when receiving an Ethernet frame
648  for(i = 0; i < MAC_ADDR_FILTER_SIZE; i++)
649  {
650  //Valid entry?
651  if(interface->macAddrFilter[i].refCount > 0)
652  {
653  //Accept multicast addresses
654  acceptMulticast = TRUE;
655  //We are done
656  break;
657  }
658  }
659 
660  //Enable or disable the reception of multicast frames
661  if(acceptMulticast)
662  {
663  EDMAC.EESR.BIT.RMAF = 1;
664  }
665  else
666  {
667  EDMAC.EESR.BIT.RMAF = 0;
668  }
669 
670  //Successful processing
671  return NO_ERROR;
672 }
673 
674 
675 /**
676  * @brief Adjust MAC configuration parameters for proper operation
677  * @param[in] interface Underlying network interface
678  * @return Error code
679  **/
680 
682 {
683  //10BASE-T or 100BASE-TX operation mode?
684  if(interface->linkSpeed == NIC_LINK_SPEED_100MBPS)
685  {
686  ETHERC.ECMR.BIT.RTM = 1;
687  }
688  else
689  {
690  ETHERC.ECMR.BIT.RTM = 0;
691  }
692 
693  //Half-duplex or full-duplex mode?
694  if(interface->duplexMode == NIC_FULL_DUPLEX_MODE)
695  {
696  ETHERC.ECMR.BIT.DM = 1;
697  }
698  else
699  {
700  ETHERC.ECMR.BIT.DM = 0;
701  }
702 
703  //Successful processing
704  return NO_ERROR;
705 }
706 
707 
708 /**
709  * @brief Write PHY register
710  * @param[in] opcode Access type (2 bits)
711  * @param[in] phyAddr PHY address (5 bits)
712  * @param[in] regAddr Register address (5 bits)
713  * @param[in] data Register value
714  **/
715 
716 void rx62nEthWritePhyReg(uint8_t opcode, uint8_t phyAddr,
717  uint8_t regAddr, uint16_t data)
718 {
719  //Synchronization pattern
721  //Start of frame
723  //Set up a write operation
725  //Write PHY address
726  rx62nEthWriteSmi(phyAddr, 5);
727  //Write register address
729  //Turnaround
731  //Write register value
732  rx62nEthWriteSmi(data, 16);
733  //Release MDIO
734  rx62nEthReadSmi(1);
735 }
736 
737 
738 /**
739  * @brief Read PHY register
740  * @param[in] opcode Access type (2 bits)
741  * @param[in] phyAddr PHY address (5 bits)
742  * @param[in] regAddr Register address (5 bits)
743  * @return Register value
744  **/
745 
746 uint16_t rx62nEthReadPhyReg(uint8_t opcode, uint8_t phyAddr,
747  uint8_t regAddr)
748 {
749  uint16_t data;
750 
751  //Synchronization pattern
753  //Start of frame
755  //Set up a read operation
757  //Write PHY address
758  rx62nEthWriteSmi(phyAddr, 5);
759  //Write register address
761  //Turnaround to avoid contention
762  rx62nEthReadSmi(1);
763  //Read register value
764  data = rx62nEthReadSmi(16);
765  //Force the PHY to release the MDIO pin
766  rx62nEthReadSmi(1);
767 
768  //Return PHY register contents
769  return data;
770 }
771 
772 
773 /**
774  * @brief SMI write operation
775  * @param[in] data Raw data to be written
776  * @param[in] length Number of bits to be written
777  **/
778 
780 {
781  //Skip the most significant bits since they are meaningless
782  data <<= 32 - length;
783 
784  //Configure MDIO as an output
785  ETHERC.PIR.BIT.MMD = 1;
786 
787  //Write the specified number of bits
788  while(length--)
789  {
790  //Write MDIO
791  if((data & 0x80000000) != 0)
792  {
793  ETHERC.PIR.BIT.MDO = 1;
794  }
795  else
796  {
797  ETHERC.PIR.BIT.MDO = 0;
798  }
799 
800  //Assert MDC
801  usleep(1);
802  ETHERC.PIR.BIT.MDC = 1;
803  //Deassert MDC
804  usleep(1);
805  ETHERC.PIR.BIT.MDC = 0;
806 
807  //Rotate data
808  data <<= 1;
809  }
810 }
811 
812 
813 /**
814  * @brief SMI read operation
815  * @param[in] length Number of bits to be read
816  * @return Data resulting from the MDIO read operation
817  **/
818 
820 {
821  uint32_t data = 0;
822 
823  //Configure MDIO as an input
824  ETHERC.PIR.BIT.MMD = 0;
825 
826  //Read the specified number of bits
827  while(length--)
828  {
829  //Rotate data
830  data <<= 1;
831 
832  //Assert MDC
833  ETHERC.PIR.BIT.MDC = 1;
834  usleep(1);
835  //Deassert MDC
836  ETHERC.PIR.BIT.MDC = 0;
837  usleep(1);
838 
839  //Check MDIO state
840  if(ETHERC.PIR.BIT.MDI != 0)
841  {
842  data |= 0x01;
843  }
844  }
845 
846  //Return the received data
847  return data;
848 }
bool_t osSetEventFromIsr(OsEvent *event)
Set an event object to the signaled state from an interrupt service routine.
#define EDMAC_RD0_RFP_EOF
#define usleep(delay)
Definition: os_port.h:306
uint8_t opcode
Definition: dns_common.h:188
error_t rx62nEthUpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
int bool_t
Definition: compiler_port.h:61
#define RX62N_ETH_IRQ_PRIORITY
#define netEvent
Definition: net_legacy.h:196
#define EDMAC_EESR_TWB
@ NIC_FULL_DUPLEX_MODE
Definition: nic.h:125
error_t rx62nEthSendPacket(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a packet.
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
Renesas RX62N Ethernet MAC driver.
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
#define sleep(delay)
Definition: os_port.h:310
#define EDMAC_RD0_RACT
void rx62nEthInitDmaDesc(NetInterface *interface)
Initialize DMA descriptor lists.
#define RX62N_ETH_RX_BUFFER_COUNT
Transmit DMA descriptor.
#define SMI_TA
Definition: nic.h:68
#define SMI_START
Definition: nic.h:64
#define RX62N_ETH_TX_BUFFER_SIZE
uint16_t rx62nEthReadPhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr)
Read PHY register.
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 EDMAC_TD0_TWBI
#define EDMAC_RD1_RFL
#define EDMAC_RD0_RDLE
#define FALSE
Definition: os_port.h:46
#define EDMAC_RD0_RFP_SOF
#define RX62N_ETH_RX_BUFFER_SIZE
error_t
Error codes.
Definition: error.h:43
#define EDMAC_RD1_RBL
const NetRxAncillary NET_DEFAULT_RX_ANCILLARY
Definition: net_misc.c:105
@ ERROR_FAILURE
Generic error code.
Definition: error.h:45
#define txBuffer
#define NetRxAncillary
Definition: net_misc.h:40
#define EDMAC_RD0_RFS_RMAF
@ ERROR_INVALID_PACKET
Definition: error.h:141
#define NetInterface
Definition: net.h:36
void rx62nEthDisableIrq(NetInterface *interface)
Disable interrupts.
@ ERROR_INVALID_LENGTH
Definition: error.h:111
#define EDMAC_RD0_RFS_MASK
@ ERROR_BUFFER_EMPTY
Definition: error.h:142
#define NetTxAncillary
Definition: net_misc.h:36
#define TRACE_INFO(...)
Definition: debug.h:105
uint8_t length
Definition: tcp.h:375
size_t netBufferGetLength(const NetBuffer *buffer)
Get the actual length of a multi-part buffer.
Definition: net_mem.c:297
#define MIN(a, b)
Definition: os_port.h:63
uint32_t rx62nEthReadSmi(uint_t length)
SMI read operation.
#define rxBuffer
void rx62nEthWritePhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr, uint16_t data)
Write PHY register.
#define EDMAC_TD1_TBL
#define TRACE_DEBUG(...)
Definition: debug.h:119
#define EDMAC_TD0_TFP_SOF
Receive DMA descriptor.
#define EDMAC_TD0_TDLE
uint16_t regAddr
#define ETH_MTU
Definition: ethernet.h:116
__interrupt void rx62nEthIrqHandler(void)
RX62N Ethernet MAC interrupt service routine.
uint8_t n
const NicDriver rx62nEthDriver
RX62N Ethernet MAC driver.
void rx62nEthEnableIrq(NetInterface *interface)
Enable interrupts.
error_t rx62nEthReceivePacket(NetInterface *interface)
Receive a packet.
#define EDMAC_EESR_FR
#define rxDmaDesc
void rx62nEthEventHandler(NetInterface *interface)
RX62N Ethernet MAC event handler.
#define RX62N_ETH_TX_BUFFER_COUNT
void osSetEvent(OsEvent *event)
Set the specified event object to the signaled state.
#define txDmaDesc
@ NIC_LINK_SPEED_100MBPS
Definition: nic.h:112
#define EDMAC_TD0_TACT
error_t rx62nEthUpdateMacConfig(NetInterface *interface)
Adjust MAC configuration parameters for proper operation.
#define SMI_SYNC
Definition: nic.h:63
unsigned int uint_t
Definition: compiler_port.h:57
void rx62nEthTick(NetInterface *interface)
RX62N Ethernet MAC timer handler.
TCP/IP stack core.
NIC driver.
Definition: nic.h:286
error_t rx62nEthInit(NetInterface *interface)
RX62N Ethernet MAC initialization.
void rx62nEthWriteSmi(uint32_t data, uint_t length)
SMI write operation.
__weak_func void rx62nEthInitGpio(NetInterface *interface)
GPIO configuration.
@ NO_ERROR
Success.
Definition: error.h:44
__attribute__((naked))
AVR32 Ethernet MAC interrupt wrapper.
Debugging facilities.
#define EDMAC_TD0_TFP_EOF
@ NIC_TYPE_ETHERNET
Ethernet interface.
Definition: nic.h:83