ra6_eth_driver.c
Go to the documentation of this file.
1 /**
2  * @file ra6_eth_driver.c
3  * @brief Renesas RA6M2 / RA6M3 / RA6M4 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.4
29  **/
30 
31 //Switch to the appropriate trace level
32 #define TRACE_LEVEL NIC_TRACE_LEVEL
33 
34 //Dependencies
35 #include "bsp_api.h"
36 #include "core/net.h"
38 #include "debug.h"
39 
40 //Underlying network interface
41 static NetInterface *nicDriverInterface;
42 
43 //IAR EWARM compiler?
44 #if defined(__ICCARM__)
45 
46 //Transmit buffer
47 #pragma data_alignment = 32
48 #pragma location = RA6_ETH_RAM_SECTION
50 //Receive buffer
51 #pragma data_alignment = 32
52 #pragma location = RA6_ETH_RAM_SECTION
54 //Transmit DMA descriptors
55 #pragma data_alignment = 16
56 #pragma location = RA6_ETH_RAM_SECTION
58 //Receive DMA descriptors
59 #pragma data_alignment = 16
60 #pragma location = RA6_ETH_RAM_SECTION
62 
63 //ARM or GCC compiler?
64 #else
65 
66 //Transmit buffer
68  __attribute__((aligned(32), __section__(RA6_ETH_RAM_SECTION)));
69 //Receive buffer
71  __attribute__((aligned(32), __section__(RA6_ETH_RAM_SECTION)));
72 //Transmit DMA descriptors
74  __attribute__((aligned(16), __section__(RA6_ETH_RAM_SECTION)));
75 //Receive DMA descriptors
77  __attribute__((aligned(16), __section__(RA6_ETH_RAM_SECTION)));
78 
79 #endif
80 
81 //Current transmit descriptor
82 static uint_t txIndex;
83 //Current receive descriptor
84 static uint_t rxIndex;
85 
86 
87 /**
88  * @brief RA6 Ethernet MAC driver
89  **/
90 
92 {
94  ETH_MTU,
95  ra6EthInit,
96  ra6EthTick,
105  TRUE,
106  TRUE,
107  TRUE,
108  TRUE
109 };
110 
111 
112 /**
113  * @brief RA6 Ethernet MAC initialization
114  * @param[in] interface Underlying network interface
115  * @return Error code
116  **/
117 
119 {
120  error_t error;
121 
122  //Debug message
123  TRACE_INFO("Initializing RA6 Ethernet MAC...\r\n");
124 
125  //Save underlying network interface
126  nicDriverInterface = interface;
127 
128  //Disable protection
129  R_SYSTEM->PRCR = 0xA50B;
130  //Cancel EDMAC0 module stop state
131  R_MSTP->MSTPCRB &= ~R_MSTP_MSTPCRB_MSTPB15_Msk;
132  //Enable protection
133  R_SYSTEM->PRCR = 0xA500;
134 
135  //GPIO configuration
136  ra6EthInitGpio(interface);
137 
138  //Reset EDMAC0 module
139  R_ETHERC_EDMAC->EDMR |= R_ETHERC_EDMAC_EDMR_SWR_Msk;
140  //Wait for the reset to complete
141  sleep(10);
142 
143  //Valid Ethernet PHY or switch driver?
144  if(interface->phyDriver != NULL)
145  {
146  //Ethernet PHY initialization
147  error = interface->phyDriver->init(interface);
148  }
149  else if(interface->switchDriver != NULL)
150  {
151  //Ethernet switch initialization
152  error = interface->switchDriver->init(interface);
153  }
154  else
155  {
156  //The interface is not properly configured
157  error = ERROR_FAILURE;
158  }
159 
160  //Any error to report?
161  if(error)
162  {
163  return error;
164  }
165 
166  //Initialize DMA descriptor lists
167  ra6EthInitDmaDesc(interface);
168 
169  //Maximum frame length that can be accepted
170  R_ETHERC0->RFLR = RA6_ETH_RX_BUFFER_SIZE;
171  //Set default inter packet gap (96-bit time)
172  R_ETHERC0->IPGR = 0x14;
173 
174  //Set the upper 32 bits of the MAC address
175  R_ETHERC0->MAHR = (interface->macAddr.b[0] << 24) | (interface->macAddr.b[1] << 16) |
176  (interface->macAddr.b[2] << 8) | interface->macAddr.b[3];
177 
178  //Set the lower 16 bits of the MAC address
179  R_ETHERC0->MALR = (interface->macAddr.b[4] << 8) | interface->macAddr.b[5];
180 
181  //Select little endian mode and set descriptor length (16 bytes)
182  R_ETHERC_EDMAC->EDMR = R_ETHERC_EDMAC_EDMR_DE_Msk |
183  (0 << R_ETHERC_EDMAC_EDMR_DL_Pos);
184 
185  //Use store and forward mode
186  R_ETHERC_EDMAC->TFTR = 0;
187 
188  //Set transmit FIFO size (2048 bytes) and receive FIFO size (4096 bytes)
189  R_ETHERC_EDMAC->FDR = (7 << R_ETHERC_EDMAC_FDR_TFD_Pos) |
190  (15 << R_ETHERC_EDMAC_FDR_RFD_Pos);
191 
192  //Enable continuous reception of multiple frames
193  R_ETHERC_EDMAC->RMCR = R_ETHERC_EDMAC_RMCR_RNR_Msk;
194 
195  //Select write-back complete interrupt mode and enable transmit interrupts
196  R_ETHERC_EDMAC->TRIMD = R_ETHERC_EDMAC_TRIMD_TIM_Msk |
197  R_ETHERC_EDMAC_TRIMD_TIS_Msk;
198 
199  //Disable all ETHERC interrupts
200  R_ETHERC0->ECSIPR = 0;
201 
202  //Enable the desired EDMAC interrupts
203  R_ETHERC_EDMAC->EESIPR = R_ETHERC_EDMAC_EESIPR_TWBIP_Msk |
204  R_ETHERC_EDMAC_EESIPR_FRIP_Msk;
205 
206  //Set priority grouping (4 bits for pre-emption priority, no bits for subpriority)
207  NVIC_SetPriorityGrouping(RA6_ETH_IRQ_PRIORITY_GROUPING);
208 
209  //Configure EDMAC interrupt priority
210  NVIC_SetPriority(EDMAC0_EINT_IRQn, NVIC_EncodePriority(RA6_ETH_IRQ_PRIORITY_GROUPING,
212 
213  //Enable transmission and reception
214  R_ETHERC0->ECMR |= R_ETHERC0_ECMR_TE_Msk | R_ETHERC0_ECMR_RE_Msk;
215 
216  //Instruct the DMA to poll the receive descriptor list
217  R_ETHERC_EDMAC->EDRRR = R_ETHERC_EDMAC_EDRRR_RR_Msk;
218 
219  //Accept any packets from the upper layer
220  osSetEvent(&interface->nicTxEvent);
221 
222  //Successful initialization
223  return NO_ERROR;
224 }
225 
226 
227 /**
228  * @brief GPIO configuration
229  * @param[in] interface Underlying network interface
230  **/
231 
232 __weak_func void ra6EthInitGpio(NetInterface *interface)
233 {
234 //EK-RA6M3, EK-RA6M4 or EK-RA6M5 evaluation board?
235 #if defined(USE_EK_RA6M3) || defined(USE_EK_RA6M4) || defined(USE_EK_RA6M5)
236  //Disable protection
237  R_SYSTEM->PRCR = 0xA50B;
238  //Disable VBATT channel 0 input (P4_2)
239  R_SYSTEM->VBTICTLR &= ~R_SYSTEM_VBTICTLR_VCH0INEN_Msk;
240  //Enable protection
241  R_SYSTEM->PRCR = 0xA500;
242 
243  //Unlock PFS registers
244  R_PMISC->PWPR &= ~R_PMISC_PWPR_B0WI_Msk;
245  R_PMISC->PWPR |= R_PMISC_PWPR_PFSWE_Msk;
246 
247  //Select RMII interface mode
248  R_PMISC->PFENET &= ~R_PMISC_PFENET_PHYMODE0_Msk;
249 
250  //Configure ET0_MDC (P4_1)
251  R_PFS->PORT[4].PIN[1].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
252  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (1 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
253 
254  //Configure ET0_MDIO (P4_2)
255  R_PFS->PORT[4].PIN[2].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
256  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (1 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
257 
258  //Configure RMII0_TXD_EN_B (P4_5)
259  R_PFS->PORT[4].PIN[5].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
260  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
261 
262  //Configure RMII0_TXD1_B (P4_6)
263  R_PFS->PORT[4].PIN[6].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
264  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
265 
266  //Configure RMII0_TXD0_B (P7_0)
267  R_PFS->PORT[7].PIN[0].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
268  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
269 
270  //Configure REF50CK0_B (P7_1)
271  R_PFS->PORT[7].PIN[1].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
272  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
273 
274  //Configure RMII0_RXD0_B (P7_2)
275  R_PFS->PORT[7].PIN[2].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
276  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
277 
278  //Configure RMII0_RXD1_B (P7_3)
279  R_PFS->PORT[7].PIN[3].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
280  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
281 
282  //Configure RMII0_RX_ER_B (P7_4)
283  R_PFS->PORT[7].PIN[4].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
284  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
285 
286  //Configure RMII0_CRS_DV_B (P7_5)
287  R_PFS->PORT[7].PIN[5].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
288  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
289 
290  //Lock PFS registers
291  R_PMISC->PWPR &= ~R_PMISC_PWPR_PFSWE_Msk;
292  R_PMISC->PWPR |= R_PMISC_PWPR_B0WI_Msk;
293 
294 //AIK-RA6M3 evaluation board?
295 #elif defined(USE_AIK_RA6M3)
296  //Unlock PFS registers
297  R_PMISC->PWPR &= ~R_PMISC_PWPR_B0WI_Msk;
298  R_PMISC->PWPR |= R_PMISC_PWPR_PFSWE_Msk;
299 
300  //Select RMII interface mode
301  R_PMISC->PFENET &= ~R_PMISC_PFENET_PHYMODE0_Msk;
302 
303  //Configure ET0_MDC (P2_14)
304  R_PFS->PORT[2].PIN[14].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
305  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (1 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
306 
307  //Configure ET0_MDIO (P2_11)
308  R_PFS->PORT[2].PIN[11].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
309  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (1 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
310 
311  //Configure RMII0_TXD_EN_B (P4_5)
312  R_PFS->PORT[4].PIN[5].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
313  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
314 
315  //Configure RMII0_TXD1_B (P4_6)
316  R_PFS->PORT[4].PIN[6].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
317  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
318 
319  //Configure RMII0_TXD0_B (P7_0)
320  R_PFS->PORT[7].PIN[0].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
321  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
322 
323  //Configure REF50CK0_B (P7_1)
324  R_PFS->PORT[7].PIN[1].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
325  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
326 
327  //Configure RMII0_RXD0_B (P7_2)
328  R_PFS->PORT[7].PIN[2].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
329  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
330 
331  //Configure RMII0_RXD1_B (P7_3)
332  R_PFS->PORT[7].PIN[3].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
333  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
334 
335  //Configure RMII0_RX_ER_B (P7_4)
336  R_PFS->PORT[7].PIN[4].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
337  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
338 
339  //Configure RMII0_CRS_DV_B (P7_5)
340  R_PFS->PORT[7].PIN[5].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
341  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
342 
343  //Configure PHY reset pin (P0_10)
344  R_PFS->PORT[0].PIN[10].PmnPFS = R_PFS_PORT_PIN_PmnPFS_PDR_Msk;
345 
346  //Lock PFS registers
347  R_PMISC->PWPRS &= ~R_PMISC_PWPR_PFSWE_Msk;
348  R_PMISC->PWPRS |= R_PMISC_PWPR_B0WI_Msk;
349 
350  //Reset PHY transceiver
351  R_PORT0->PCNTR3 = (1 << 10) << R_PORTB_PCNTR3_PORR_Pos;
352  sleep(10);
353  R_PORT0->PCNTR3 = (1 << 10) << R_PORTB_PCNTR3_POSR_Pos;
354  sleep(10);
355 
356 //M13-RA6M2-EK, M13-RA6M4-EK or M13-RA6M5-EK evaluation board?
357 #elif defined(USE_M13_RA6M2_EK) || defined(USE_M13_RA6M4_EK) || \
358  defined(USE_M13_RA6M5_EK)
359  //Unlock PFS registers
360  R_PMISC->PWPR &= ~R_PMISC_PWPR_B0WI_Msk;
361  R_PMISC->PWPR |= R_PMISC_PWPR_PFSWE_Msk;
362 
363  //Select RMII interface mode
364  R_PMISC->PFENET &= ~R_PMISC_PFENET_PHYMODE0_Msk;
365 
366  //Configure RMII0_TXD_EN_B (P4_5)
367  R_PFS->PORT[4].PIN[5].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
368  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
369 
370  //Configure RMII0_TXD1_B (P4_6)
371  R_PFS->PORT[4].PIN[6].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
372  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
373 
374  //Configure RMII0_TXD0_B (P7_0)
375  R_PFS->PORT[7].PIN[0].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
376  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
377 
378  //Configure REF50CK0_B (P7_1)
379  R_PFS->PORT[7].PIN[1].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
380  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
381 
382  //Configure RMII0_RXD0_B (P7_2)
383  R_PFS->PORT[7].PIN[2].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
384  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
385 
386  //Configure RMII0_RXD1_B (P7_3)
387  R_PFS->PORT[7].PIN[3].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
388  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
389 
390  //Configure RMII0_RX_ER_B (P7_4)
391  R_PFS->PORT[7].PIN[4].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
392  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
393 
394  //Configure RMII0_CRS_DV_B (P7_5)
395  R_PFS->PORT[7].PIN[5].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
396  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
397 
398  //Configure PHY reset pin (P6_5)
399  R_PFS->PORT[6].PIN[5].PmnPFS = R_PFS_PORT_PIN_PmnPFS_PDR_Msk;
400 
401  //Lock PFS registers
402  R_PMISC->PWPR &= ~R_PMISC_PWPR_PFSWE_Msk;
403  R_PMISC->PWPR |= R_PMISC_PWPR_B0WI_Msk;
404 
405  //Reset PHY transceiver
406  R_PORT6->PCNTR3 = (1 << 5) << R_PORT0_PCNTR3_PORR_Pos;
407  sleep(10);
408  R_PORT6->PCNTR3 = (1 << 5) << R_PORT0_PCNTR3_POSR_Pos;
409  sleep(10);
410 
411 //M13-RA6M3-EK evaluation board?
412 #elif defined(USE_M13_RA6M3_EK)
413  //Disable protection
414  R_SYSTEM->PRCR = 0xA50B;
415  //Disable VBATT channel 0 input (P4_2)
416  R_SYSTEM->VBTICTLR &= ~R_SYSTEM_VBTICTLR_VCH0INEN_Msk;
417  //Enable protection
418  R_SYSTEM->PRCR = 0xA500;
419 
420  //Unlock PFS registers
421  R_PMISC->PWPR &= ~R_PMISC_PWPR_B0WI_Msk;
422  R_PMISC->PWPR |= R_PMISC_PWPR_PFSWE_Msk;
423 
424  //Select RMII interface mode
425  R_PMISC->PFENET &= ~R_PMISC_PFENET_PHYMODE0_Msk;
426 
427  //Configure ET0_MDC (P4_1)
428  R_PFS->PORT[4].PIN[1].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
429  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (1 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
430 
431  //Configure ET0_MDIO (P4_2)
432  R_PFS->PORT[4].PIN[2].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
433  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (1 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
434 
435  //Configure RMII0_CRS_DV_A (P4_8)
436  R_PFS->PORT[4].PIN[8].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
437  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
438 
439  //Configure RMII0_RXD1_A (P4_10)
440  R_PFS->PORT[4].PIN[10].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
441  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
442 
443  //Configure RMII0_RXD0_A (P4_11)
444  R_PFS->PORT[4].PIN[11].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
445  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
446 
447  //Configure REF50CK0_A (P4_12)
448  R_PFS->PORT[4].PIN[12].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
449  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
450 
451  //Configure RMII0_TXD0_A (P4_13)
452  R_PFS->PORT[4].PIN[13].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
453  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
454 
455  //Configure RMII0_TXD1_A (P4_14)
456  R_PFS->PORT[4].PIN[14].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
457  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
458 
459  //Configure RMII0_TXD_EN_A (P4_15)
460  R_PFS->PORT[4].PIN[15].PmnPFS = (23 << R_PFS_PORT_PIN_PmnPFS_PSEL_Pos) |
461  R_PFS_PORT_PIN_PmnPFS_PMR_Msk | (3 << R_PFS_PORT_PIN_PmnPFS_DSCR_Pos);
462 
463  //Lock PFS registers
464  R_PMISC->PWPR &= ~R_PMISC_PWPR_PFSWE_Msk;
465  R_PMISC->PWPR |= R_PMISC_PWPR_B0WI_Msk;
466 #endif
467 }
468 
469 
470 /**
471  * @brief Initialize DMA descriptor lists
472  * @param[in] interface Underlying network interface
473  **/
474 
476 {
477  uint_t i;
478 
479  //Initialize TX descriptors
480  for(i = 0; i < RA6_ETH_TX_BUFFER_COUNT; i++)
481  {
482  //The descriptor is initially owned by the application
483  txDmaDesc[i].td0 = 0;
484  //Transmit buffer length
485  txDmaDesc[i].td1 = 0;
486  //Transmit buffer address
487  txDmaDesc[i].td2 = (uint32_t) txBuffer[i];
488  //Clear padding field
489  txDmaDesc[i].padding = 0;
490  }
491 
492  //Mark the last descriptor entry with the TDLE flag
493  txDmaDesc[i - 1].td0 |= EDMAC_TD0_TDLE;
494  //Initialize TX descriptor index
495  txIndex = 0;
496 
497  //Initialize RX descriptors
498  for(i = 0; i < RA6_ETH_RX_BUFFER_COUNT; i++)
499  {
500  //The descriptor is initially owned by the DMA
501  rxDmaDesc[i].rd0 = EDMAC_RD0_RACT;
502  //Receive buffer length
504  //Receive buffer address
505  rxDmaDesc[i].rd2 = (uint32_t) rxBuffer[i];
506  //Clear padding field
507  rxDmaDesc[i].padding = 0;
508  }
509 
510  //Mark the last descriptor entry with the RDLE flag
511  rxDmaDesc[i - 1].rd0 |= EDMAC_RD0_RDLE;
512  //Initialize RX descriptor index
513  rxIndex = 0;
514 
515  //Start address of the TX descriptor list
516  R_ETHERC_EDMAC->TDLAR = (uint32_t) txDmaDesc;
517  //Start address of the RX descriptor list
518  R_ETHERC_EDMAC->RDLAR = (uint32_t) rxDmaDesc;
519 }
520 
521 
522 /**
523  * @brief RA6 Ethernet MAC timer handler
524  *
525  * This routine is periodically called by the TCP/IP stack to handle periodic
526  * operations such as polling the link state
527  *
528  * @param[in] interface Underlying network interface
529  **/
530 
531 void ra6EthTick(NetInterface *interface)
532 {
533  //Valid Ethernet PHY or switch driver?
534  if(interface->phyDriver != NULL)
535  {
536  //Handle periodic operations
537  interface->phyDriver->tick(interface);
538  }
539  else if(interface->switchDriver != NULL)
540  {
541  //Handle periodic operations
542  interface->switchDriver->tick(interface);
543  }
544  else
545  {
546  //Just for sanity
547  }
548 }
549 
550 
551 /**
552  * @brief Enable interrupts
553  * @param[in] interface Underlying network interface
554  **/
555 
557 {
558  //Enable Ethernet MAC interrupts
559  NVIC_EnableIRQ(EDMAC0_EINT_IRQn);
560 
561  //Valid Ethernet PHY or switch driver?
562  if(interface->phyDriver != NULL)
563  {
564  //Enable Ethernet PHY interrupts
565  interface->phyDriver->enableIrq(interface);
566  }
567  else if(interface->switchDriver != NULL)
568  {
569  //Enable Ethernet switch interrupts
570  interface->switchDriver->enableIrq(interface);
571  }
572  else
573  {
574  //Just for sanity
575  }
576 }
577 
578 
579 /**
580  * @brief Disable interrupts
581  * @param[in] interface Underlying network interface
582  **/
583 
585 {
586  //Disable Ethernet MAC interrupts
587  NVIC_DisableIRQ(EDMAC0_EINT_IRQn);
588 
589  //Valid Ethernet PHY or switch driver?
590  if(interface->phyDriver != NULL)
591  {
592  //Disable Ethernet PHY interrupts
593  interface->phyDriver->disableIrq(interface);
594  }
595  else if(interface->switchDriver != NULL)
596  {
597  //Disable Ethernet switch interrupts
598  interface->switchDriver->disableIrq(interface);
599  }
600  else
601  {
602  //Just for sanity
603  }
604 }
605 
606 
607 /**
608  * @brief RA6 Ethernet MAC interrupt service routine
609  **/
610 
612 {
613  bool_t flag;
614  uint32_t status;
615 
616  //Interrupt service routine prologue
617  osEnterIsr();
618 
619  //This flag will be set if a higher priority task must be woken
620  flag = FALSE;
621 
622  //Read interrupt status register
623  status = R_ETHERC_EDMAC->EESR;
624 
625  //Packet transmitted?
626  if((status & R_ETHERC_EDMAC_EESR_TWB_Msk) != 0)
627  {
628  //Clear TWB interrupt flag
629  R_ETHERC_EDMAC->EESR = R_ETHERC_EDMAC_EESR_TWB_Msk;
630 
631  //Check whether the TX buffer is available for writing
632  if((txDmaDesc[txIndex].td0 & EDMAC_TD0_TACT) == 0)
633  {
634  //Notify the TCP/IP stack that the transmitter is ready to send
635  flag |= osSetEventFromIsr(&nicDriverInterface->nicTxEvent);
636  }
637  }
638 
639  //Packet received?
640  if((status & R_ETHERC_EDMAC_EESR_FR_Msk) != 0)
641  {
642  //Clear FR interrupt flag
643  R_ETHERC_EDMAC->EESR = R_ETHERC_EDMAC_EESR_FR_Msk;
644 
645  //Set event flag
646  nicDriverInterface->nicEvent = TRUE;
647  //Notify the TCP/IP stack of the event
648  flag |= osSetEventFromIsr(&netEvent);
649  }
650 
651  //Clear IR flag
652  R_ICU->IELSR[EDMAC0_EINT_IRQn] &= ~R_ICU_IELSR_IR_Msk;
653 
654  //Interrupt service routine epilogue
655  osExitIsr(flag);
656 }
657 
658 
659 /**
660  * @brief RA6 Ethernet MAC event handler
661  * @param[in] interface Underlying network interface
662  **/
663 
665 {
666  error_t error;
667 
668  //Process all pending packets
669  do
670  {
671  //Read incoming packet
672  error = ra6EthReceivePacket(interface);
673 
674  //No more data in the receive buffer?
675  } while(error != ERROR_BUFFER_EMPTY);
676 }
677 
678 
679 /**
680  * @brief Send a packet
681  * @param[in] interface Underlying network interface
682  * @param[in] buffer Multi-part buffer containing the data to send
683  * @param[in] offset Offset to the first data byte
684  * @param[in] ancillary Additional options passed to the stack along with
685  * the packet
686  * @return Error code
687  **/
688 
690  const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
691 {
692  //Retrieve the length of the packet
693  size_t length = netBufferGetLength(buffer) - offset;
694 
695  //Check the frame length
697  {
698  //The transmitter can accept another packet
699  osSetEvent(&interface->nicTxEvent);
700  //Report an error
701  return ERROR_INVALID_LENGTH;
702  }
703 
704  //Make sure the current buffer is available for writing
705  if((txDmaDesc[txIndex].td0 & EDMAC_TD0_TACT) != 0)
706  {
707  return ERROR_FAILURE;
708  }
709 
710  //Copy user data to the transmit buffer
711  netBufferRead(txBuffer[txIndex], buffer, offset, length);
712 
713  //Write the number of bytes to send
714  txDmaDesc[txIndex].td1 = (length << 16) & EDMAC_TD1_TBL;
715 
716  //Check current index
717  if(txIndex < (RA6_ETH_TX_BUFFER_COUNT - 1))
718  {
719  //Give the ownership of the descriptor to the DMA engine
720  txDmaDesc[txIndex].td0 = EDMAC_TD0_TACT | EDMAC_TD0_TFP_SOF |
722 
723  //Point to the next descriptor
724  txIndex++;
725  }
726  else
727  {
728  //Give the ownership of the descriptor to the DMA engine
729  txDmaDesc[txIndex].td0 = EDMAC_TD0_TACT | EDMAC_TD0_TDLE |
731 
732  //Wrap around
733  txIndex = 0;
734  }
735 
736  //Instruct the DMA to poll the transmit descriptor list
737  R_ETHERC_EDMAC->EDTRR = R_ETHERC_EDMAC_EDTRR_TR_Msk;
738 
739  //Check whether the next buffer is available for writing
740  if((txDmaDesc[txIndex].td0 & EDMAC_TD0_TACT) == 0)
741  {
742  //The transmitter can accept another packet
743  osSetEvent(&interface->nicTxEvent);
744  }
745 
746  //Successful write operation
747  return NO_ERROR;
748 }
749 
750 
751 /**
752  * @brief Receive a packet
753  * @param[in] interface Underlying network interface
754  * @return Error code
755  **/
756 
758 {
759  error_t error;
760  size_t n;
761  NetRxAncillary ancillary;
762 
763  //Current buffer available for reading?
764  if((rxDmaDesc[rxIndex].rd0 & EDMAC_RD0_RACT) == 0)
765  {
766  //SOF and EOF flags should be set
767  if((rxDmaDesc[rxIndex].rd0 & EDMAC_RD0_RFP_SOF) != 0 &&
768  (rxDmaDesc[rxIndex].rd0 & EDMAC_RD0_RFP_EOF) != 0)
769  {
770  //Make sure no error occurred
771  if((rxDmaDesc[rxIndex].rd0 & (EDMAC_RD0_RFS_MASK & ~EDMAC_RD0_RFS_RMAF)) == 0)
772  {
773  //Retrieve the length of the frame
774  n = rxDmaDesc[rxIndex].rd1 & EDMAC_RD1_RFL;
775  //Limit the number of data to read
777 
778  //Additional options can be passed to the stack along with the packet
779  ancillary = NET_DEFAULT_RX_ANCILLARY;
780 
781  //Pass the packet to the upper layer
782  nicProcessPacket(interface, rxBuffer[rxIndex], n, &ancillary);
783 
784  //Valid packet received
785  error = NO_ERROR;
786  }
787  else
788  {
789  //The received packet contains an error
790  error = ERROR_INVALID_PACKET;
791  }
792  }
793  else
794  {
795  //The packet is not valid
796  error = ERROR_INVALID_PACKET;
797  }
798 
799  //Check current index
800  if(rxIndex < (RA6_ETH_RX_BUFFER_COUNT - 1))
801  {
802  //Give the ownership of the descriptor back to the DMA
803  rxDmaDesc[rxIndex].rd0 = EDMAC_RD0_RACT;
804  //Point to the next descriptor
805  rxIndex++;
806  }
807  else
808  {
809  //Give the ownership of the descriptor back to the DMA
810  rxDmaDesc[rxIndex].rd0 = EDMAC_RD0_RACT | EDMAC_RD0_RDLE;
811  //Wrap around
812  rxIndex = 0;
813  }
814 
815  //Instruct the DMA to poll the receive descriptor list
816  R_ETHERC_EDMAC->EDRRR = R_ETHERC_EDMAC_EDRRR_RR_Msk;
817  }
818  else
819  {
820  //No more data in the receive buffer
821  error = ERROR_BUFFER_EMPTY;
822  }
823 
824  //Return status code
825  return error;
826 }
827 
828 
829 /**
830  * @brief Configure MAC address filtering
831  * @param[in] interface Underlying network interface
832  * @return Error code
833  **/
834 
836 {
837  uint_t i;
838  bool_t acceptMulticast;
839 
840  //Debug message
841  TRACE_DEBUG("Updating MAC filter...\r\n");
842 
843  //Promiscuous mode?
844  if(interface->promiscuous)
845  {
846  //Accept all frames regardless of their destination address
847  R_ETHERC0->ECMR |= R_ETHERC0_ECMR_PRM_Msk;
848  }
849  else
850  {
851  //Disable promiscuous mode
852  R_ETHERC0->ECMR &= ~R_ETHERC0_ECMR_PRM_Msk;
853 
854  //Set the upper 32 bits of the MAC address
855  R_ETHERC0->MAHR = (interface->macAddr.b[0] << 24) | (interface->macAddr.b[1] << 16) |
856  (interface->macAddr.b[2] << 8) | interface->macAddr.b[3];
857 
858  //Set the lower 16 bits of the MAC address
859  R_ETHERC0->MALR = (interface->macAddr.b[4] << 8) | interface->macAddr.b[5];
860 
861  //This flag will be set if multicast addresses should be accepted
862  acceptMulticast = FALSE;
863 
864  //The MAC address filter contains the list of MAC addresses to accept
865  //when receiving an Ethernet frame
866  for(i = 0; i < MAC_ADDR_FILTER_SIZE; i++)
867  {
868  //Valid entry?
869  if(interface->macAddrFilter[i].refCount > 0)
870  {
871  //Accept multicast addresses
872  acceptMulticast = TRUE;
873  //We are done
874  break;
875  }
876  }
877 
878  //Enable or disable the reception of multicast frames
879  if(acceptMulticast || interface->acceptAllMulticast)
880  {
881  R_ETHERC_EDMAC->EESR |= R_ETHERC_EDMAC_EESR_RMAF_Msk;
882  }
883  else
884  {
885  R_ETHERC_EDMAC->EESR &= ~R_ETHERC_EDMAC_EESR_RMAF_Msk;
886  }
887  }
888 
889  //Successful processing
890  return NO_ERROR;
891 }
892 
893 
894 /**
895  * @brief Adjust MAC configuration parameters for proper operation
896  * @param[in] interface Underlying network interface
897  * @return Error code
898  **/
899 
901 {
902  uint32_t mode;
903 
904  //Read ETHERC mode register
905  mode = R_ETHERC0->ECMR;
906 
907  //10BASE-T or 100BASE-TX operation mode?
908  if(interface->linkSpeed == NIC_LINK_SPEED_100MBPS)
909  {
910  mode |= R_ETHERC0_ECMR_RTM_Msk;
911  }
912  else
913  {
914  mode &= ~R_ETHERC0_ECMR_RTM_Msk;
915  }
916 
917  //Half-duplex or full-duplex mode?
918  if(interface->duplexMode == NIC_FULL_DUPLEX_MODE)
919  {
920  mode |= R_ETHERC0_ECMR_DM_Msk;
921  }
922  else
923  {
924  mode &= ~R_ETHERC0_ECMR_DM_Msk;
925  }
926 
927  //Update ETHERC mode register
928  R_ETHERC0->ECMR = mode;
929 
930  //Successful processing
931  return NO_ERROR;
932 }
933 
934 
935 /**
936  * @brief Write PHY register
937  * @param[in] opcode Access type (2 bits)
938  * @param[in] phyAddr PHY address (5 bits)
939  * @param[in] regAddr Register address (5 bits)
940  * @param[in] data Register value
941  **/
942 
943 void ra6EthWritePhyReg(uint8_t opcode, uint8_t phyAddr,
944  uint8_t regAddr, uint16_t data)
945 {
946  //Synchronization pattern
948  //Start of frame
950  //Set up a write operation
952  //Write PHY address
953  ra6EthWriteSmi(phyAddr, 5);
954  //Write register address
956  //Turnaround
958  //Write register value
959  ra6EthWriteSmi(data, 16);
960  //Release MDIO
961  ra6EthReadSmi(1);
962 }
963 
964 
965 /**
966  * @brief Read PHY register
967  * @param[in] opcode Access type (2 bits)
968  * @param[in] phyAddr PHY address (5 bits)
969  * @param[in] regAddr Register address (5 bits)
970  * @return Register value
971  **/
972 
973 uint16_t ra6EthReadPhyReg(uint8_t opcode, uint8_t phyAddr,
974  uint8_t regAddr)
975 {
976  uint16_t data;
977 
978  //Synchronization pattern
980  //Start of frame
982  //Set up a read operation
984  //Write PHY address
985  ra6EthWriteSmi(phyAddr, 5);
986  //Write register address
988  //Turnaround to avoid contention
989  ra6EthReadSmi(1);
990  //Read register value
991  data = ra6EthReadSmi(16);
992  //Force the PHY to release the MDIO pin
993  ra6EthReadSmi(1);
994 
995  //Return PHY register contents
996  return data;
997 }
998 
999 
1000 /**
1001  * @brief SMI write operation
1002  * @param[in] data Raw data to be written
1003  * @param[in] length Number of bits to be written
1004  **/
1005 
1007 {
1008  //Skip the most significant bits since they are meaningless
1009  data <<= 32 - length;
1010 
1011  //Configure MDIO as an output
1012  R_ETHERC0->PIR |= R_ETHERC0_PIR_MMD_Msk;
1013 
1014  //Write the specified number of bits
1015  while(length--)
1016  {
1017  //Write MDIO
1018  if((data & 0x80000000) != 0)
1019  {
1020  R_ETHERC0->PIR |= R_ETHERC0_PIR_MDO_Msk;
1021  }
1022  else
1023  {
1024  R_ETHERC0->PIR &= ~R_ETHERC0_PIR_MDO_Msk;
1025  }
1026 
1027  //Assert MDC
1028  usleep(1);
1029  R_ETHERC0->PIR |= R_ETHERC0_PIR_MDC_Msk;
1030  //Deassert MDC
1031  usleep(1);
1032  R_ETHERC0->PIR &= ~R_ETHERC0_PIR_MDC_Msk;
1033 
1034  //Rotate data
1035  data <<= 1;
1036  }
1037 }
1038 
1039 
1040 /**
1041  * @brief SMI read operation
1042  * @param[in] length Number of bits to be read
1043  * @return Data resulting from the MDIO read operation
1044  **/
1045 
1047 {
1048  uint32_t data = 0;
1049 
1050  //Configure MDIO as an input
1051  R_ETHERC0->PIR &= ~R_ETHERC0_PIR_MMD_Msk;
1052 
1053  //Read the specified number of bits
1054  while(length--)
1055  {
1056  //Rotate data
1057  data <<= 1;
1058 
1059  //Assert MDC
1060  R_ETHERC0->PIR |= R_ETHERC0_PIR_MDC_Msk;
1061  usleep(1);
1062  //Deassert MDC
1063  R_ETHERC0->PIR &= ~R_ETHERC0_PIR_MDC_Msk;
1064  usleep(1);
1065 
1066  //Check MDIO state
1067  if((R_ETHERC0->PIR & R_ETHERC0_PIR_MDI_Msk) != 0)
1068  {
1069  data |= 0x01;
1070  }
1071  }
1072 
1073  //Return the received data
1074  return data;
1075 }
bool_t osSetEventFromIsr(OsEvent *event)
Set an event object to the signaled state from an interrupt service routine.
#define EDMAC_RD0_RFP_EOF
__weak_func void ra6EthInitGpio(NetInterface *interface)
GPIO configuration.
#define usleep(delay)
Definition: os_port.h:303
Renesas RA6M2 / RA6M3 / RA6M4 Ethernet MAC driver.
uint8_t opcode
Definition: dns_common.h:188
#define RA6_ETH_IRQ_SUB_PRIORITY
int bool_t
Definition: compiler_port.h:53
void ra6EthTick(NetInterface *interface)
RA6 Ethernet MAC timer handler.
#define netEvent
Definition: net_legacy.h:196
@ NIC_FULL_DUPLEX_MODE
Definition: nic.h:125
uint32_t ra6EthReadSmi(uint_t length)
SMI read operation.
void ra6EthDisableIrq(NetInterface *interface)
Disable interrupts.
size_t netBufferRead(void *dest, const NetBuffer *src, size_t srcOffset, size_t length)
Read data from a multi-part buffer.
Definition: net_mem.c:690
void ra6EthEnableIrq(NetInterface *interface)
Enable interrupts.
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:89
error_t ra6EthSendPacket(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a packet.
Receive DMA descriptor.
#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:307
#define EDMAC_RD0_RACT
#define RA6_ETH_RX_BUFFER_COUNT
#define R_MSTP_MSTPCRB_MSTPB15_Msk
#define SMI_TA
Definition: nic.h:68
void ra6EthWritePhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr, uint16_t data)
Write PHY register.
#define SMI_START
Definition: nic.h:64
error_t ra6EthInit(NetInterface *interface)
RA6 Ethernet MAC initialization.
void nicProcessPacket(NetInterface *interface, uint8_t *packet, size_t length, NetRxAncillary *ancillary)
Handle a packet received by the network controller.
Definition: nic.c:392
void EDMAC0_EINT_IRQHandler(void)
RA6 Ethernet MAC interrupt service routine.
#define osExitIsr(flag)
#define EDMAC_TD0_TWBI
Transmit DMA descriptor.
#define EDMAC_RD1_RFL
#define EDMAC_RD0_RDLE
#define FALSE
Definition: os_port.h:46
#define RA6_ETH_TX_BUFFER_COUNT
#define EDMAC_RD0_RFP_SOF
error_t
Error codes.
Definition: error.h:43
#define EDMAC_RD1_RBL
#define R_ETHERC_EDMAC
error_t ra6EthUpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
const NetRxAncillary NET_DEFAULT_RX_ANCILLARY
Definition: net_misc.c:104
@ ERROR_FAILURE
Generic error code.
Definition: error.h:45
#define RA6_ETH_RAM_SECTION
void ra6EthWriteSmi(uint32_t data, uint_t length)
SMI write operation.
#define txBuffer
#define RA6_ETH_RX_BUFFER_SIZE
#define NetRxAncillary
Definition: net_misc.h:40
#define EDMAC_RD0_RFS_RMAF
@ ERROR_INVALID_PACKET
Definition: error.h:140
#define NetInterface
Definition: net.h:36
@ ERROR_INVALID_LENGTH
Definition: error.h:111
#define EDMAC_RD0_RFS_MASK
@ ERROR_BUFFER_EMPTY
Definition: error.h:141
#define NetTxAncillary
Definition: net_misc.h:36
#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
void ra6EthEventHandler(NetInterface *interface)
RA6 Ethernet MAC event handler.
error_t ra6EthUpdateMacConfig(NetInterface *interface)
Adjust MAC configuration parameters for proper operation.
#define EDMAC_TD1_TBL
#define TRACE_DEBUG(...)
Definition: debug.h:107
#define EDMAC_TD0_TFP_SOF
error_t ra6EthReceivePacket(NetInterface *interface)
Receive a packet.
#define EDMAC_TD0_TDLE
#define RA6_ETH_TX_BUFFER_SIZE
uint16_t regAddr
uint16_t ra6EthReadPhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr)
Read PHY register.
#define ETH_MTU
Definition: ethernet.h:116
uint8_t n
#define osEnterIsr()
#define rxDmaDesc
void osSetEvent(OsEvent *event)
Set the specified event object to the signaled state.
#define txDmaDesc
@ NIC_LINK_SPEED_100MBPS
Definition: nic.h:112
#define EDMAC_TD0_TACT
#define SMI_SYNC
Definition: nic.h:63
unsigned int uint_t
Definition: compiler_port.h:50
TCP/IP stack core.
NIC driver.
Definition: nic.h:286
void ra6EthInitDmaDesc(NetInterface *interface)
Initialize DMA descriptor lists.
const NicDriver ra6EthDriver
RA6 Ethernet MAC driver.
#define RA6_ETH_IRQ_PRIORITY_GROUPING
@ NO_ERROR
Success.
Definition: error.h:44
__attribute__((naked))
AVR32 Ethernet MAC interrupt wrapper.
Debugging facilities.
#define EDMAC_TD0_TFP_EOF
#define RA6_ETH_IRQ_GROUP_PRIORITY
@ NIC_TYPE_ETHERNET
Ethernet interface.
Definition: nic.h:83