After ETHERC, EDMAC and PHY-LSI are reset in software, an auto negotiation of PHY-LSI is begun. Afterwards, the link signal change interrupt is permitted. Implements ether_api_t::open. More...
The setting of ETHERC is changed from normal sending and receiving mode to magic packet detection mode. Implements ether_api_t::wakeOnLANEnable. More...
Receive Ethernet frame. Receives data to the location specified by the pointer to the receive buffer. In zero copy mode, the address of the receive buffer is returned. In non zero copy mode, the received data in the internal buffer is copied to the pointer passed by the argument. Implements ether_api_t::read. More...
Transmit Ethernet frame. Transmits data from the location specified by the pointer to the transmit buffer, with the data size equal to the specified frame length. In the non zero copy mode, transmits data after being copied to the internal buffer. Implements ether_api_t::write. More...
Driver for the Ethernet peripheral on RA MCUs. This module implements the Ethernet Interface.
Overview
This module performs Ethernet frame transmission and reception using an Ethernet controller and an Ethernet DMA controller.
Features
The Ethernet module supports the following features:
Transmit/receive processing
Optional zero-copy buffering
Callback function with returned event code
Magic packet detection mode support
Auto negotiation support
Flow control support
Multicast filtering support
Broadcast filtering support
Promiscuous mode support
Configuration
Build Time Configurations for r_ether
The following build time configurations are defined in fsp_cfg/r_ether_cfg.h:
Configuration
Options
Default
Description
Parameter Checking
Default (BSP)
Enabled
Disabled
Default (BSP)
If selected code for parameter checking is included in the build.
ET0_LINKSTA Pin Status Flag
Fall -> Rise
Rise -> Fall
Fall -> Rise
Specify the polarity of the link signal output by the PHY-LSI. When 0 is specified, link-up and link-down correspond respectively to the fall and rise of the LINKSTA signal. When 1 is specified, link-up and link-down correspond respectively to the rise and fall of the LINKSTA signal.
Link Signal Change Flag
Unused
Used
Unused
Use LINKSTA signal for detect link status changes 0 = unused (use PHY-LSI status register) 1 = use (use LINKSTA signal)
Interrupt event backward compatibility
Do not keep compatibility
Keep compatibility
Keep compatibility
Keep backword compatibility of interrupt events. 0 = Do not keep compatibility, use separate events for each cause of interrupt. 1 = Keep compatibility, use common events for all interrupts.
Configurations for Networking > Ethernet (r_ether)
This module can be added to the Stacks tab via New Stack > Networking > Ethernet (r_ether). Non-secure callable guard functions can be generated for this module by right clicking the module in the RA Configuration tool and checking the "Non-secure Callable" box.
Configuration
Options
Default
Description
General
Name
Name must be a valid C symbol
g_ether0
Module name.
Channel
0
0
Select the ether channel number.
MAC address
Must be a valid MAC address
00:11:22:33:44:55
MAC address of this channel.
Zero-copy Mode
Disable
Enable
Disable
Enable or disable zero-copy mode.
Flow control functionality
Disable
Enable
Disable
Enable or disable flow control.
Filters
Multicast Mode
Disable
Enable
Enable
Enable or disable multicast frame reception.
Promiscuous Mode
Disable
Enable
Disable
Enable this option to receive packets addressed to other NICs.
Broadcast filter
Must be a valid non-negative integer with maximum configurable value of 65535.
0
Limit of the number of broadcast frames received continuously
Buffers
Number of TX buffer
Must be an integer from 1 to 8
1
Number of transmit buffers
Number of RX buffer
Must be an integer from 1 to 8
1
Number of receive buffers
Allocate RX buffer
Disable
Enable
Enable
Allocates the RX buffer when generating the configuration structure
Buffer size
Must be at least 1514 which is the maximum Ethernet frame size.
1514
Size of Ethernet buffer
Padding size
Disable
1 Byte
2 Bytes
3 Bytes
Disable
The padding size that is automatically inserted into the received packets
Padding offset
Must be less than 64 bytes.
0
The offset into a receive buffer to insert padding bytes.
Interrupts
EESR event
Refer to the RA Configuration tool for available options.
RFOF
RDE
FR
TFUF
TDE
TC
Select event list for each bit of EESR.
ECSR event
ICD
MPD
LCHNG
PSRTO
BFR
Select event list for each bit of ECSR.
Interrupt priority
MCU Specific Options
Select the EDMAC interrupt priority.
Callback
Name must be a valid C symbol
NULL
Callback provided when an ISR occurs
Interrupt Configuration
The first R_ETHER_Open function call sets EINT interrupts. The user could provide callback function which would be invoked when EINT interrupt handler has been completed. The callback arguments will contain information about a channel number, the ETHERC and EDMAC status, the event code, and a pointer to the user defined context.
Callback Configuration
The user could provide callback function which would be invoked when either a magic packet or a link signal change is detected. When the callback function is called, a variable in which the channel number for which the detection occurred and a constant shown in Table 2.4 are stored is passed as an argument. If the value of this argument is to be used outside the callback function, its value should be copied into, for example, a global variable.
Clock Configuration
The clock for this module is derived from the following peripheral clock for each MCU group:
MCU Group
Peripheral Clock
RA4E2
PCLKA
RA4T1
PCLKA
RA6E1
PCLKA
RA6E2
PCLKA
RA6M2
PCLKA
RA6M3
PCLKA
RA6M4
PCLKA
RA6M5
PCLKA
RA6T3
PCLKA
Note
1. When using ETHERC, the PCLKA frequency is in the range 12.5 MHz <= PCLKA <= 120 MHz.
2. When using ETHERC, PCLKA = ICLK.
Pin Configuration
To use the Ethernet module, input/output signals of the peripheral function have to be allocated to pins with the multi-function pin controller (MPC). Please perform the pin setting before calling the R_ETHER_Open function.
Usage Notes
Ethernet Frame Format
The Ethernet module supports the Ethernet II/IEEE 802.3 frame format.
Frame Format for Data Transmission and Reception
Frame Format Image
The preamble and SFD signal the start of an Ethernet frame. The FCS contains the CRC of the Ethernet frame and is calculated on the transmitting side. When data is received the CRC value of the frame is calculated in hardware, and the Ethernet frame is discarded if the values do not match. When the hardware determines that the data is normal, the valid range of receive data is: (transmission destination address) + (transmission source address) + (length/type) + (data).
PAUSE Frame Format
Pause Frame Format Image
The transmission destination address is specified as 01:80:C2:00:00:01 (a multicast address reserved for PAUSE frames). At the start of the payload the length/type is specified as 0x8808 and the operation code as 0x0001. The pause duration in the payload is specified by the value of the automatic PAUSE (AP) bits in the automatic PAUSE frame setting register (APR), or the manual PAUSE time setting (MP) bits in the manual PAUSE frame setting register (MPR).
Magic Packet Frame Format
Magic Packet Frame Format Image
In a Magic Packet, the value FF:FF:FF:FF:FF:FF followed by the transmission destination address repeated 16 times is inserted somewhere in the Ethernet frame data.
Limitations
Memory alignment limitation for Ethernet buffer
The Ethernet Driver has several alignment constraints:
The example demonstrates using send and receive function in zero copy mode. Transmit buffers must be 32-byte aligned and the receive buffer must be released once its contents have been used.
After ETHERC, EDMAC and PHY-LSI are reset in software, an auto negotiation of PHY-LSI is begun. Afterwards, the link signal change interrupt is permitted. Implements ether_api_t::open.
Return values
FSP_SUCCESS
Channel opened successfully.
FSP_ERR_ASSERTION
Pointer to ETHER control block or configuration structure is NULL.
FSP_ERR_ALREADY_OPEN
Control block has already been opened or channel is being used by another instance. Call close() then open() to reconfigure.
FSP_ERR_ETHER_ERROR_PHY_COMMUNICATION
Initialization of PHY-LSI failed.
FSP_ERR_INVALID_CHANNEL
Invalid channel number is given.
FSP_ERR_INVALID_POINTER
Pointer to extend config structure or MAC address is NULL.
Receive Ethernet frame. Receives data to the location specified by the pointer to the receive buffer. In zero copy mode, the address of the receive buffer is returned. In non zero copy mode, the received data in the internal buffer is copied to the pointer passed by the argument. Implements ether_api_t::read.
Return values
FSP_SUCCESS
Processing completed successfully.
FSP_ERR_ASSERTION
Pointer to ETHER control block is NULL.
FSP_ERR_NOT_OPEN
The control block has not been opened.
FSP_ERR_ETHER_ERROR_NO_DATA
There is no data in receive buffer.
FSP_ERR_ETHER_ERROR_LINK
Auto-negotiation is not completed, and reception is not enabled.
FSP_ERR_ETHER_ERROR_MAGIC_PACKET_MODE
As a Magic Packet is being detected, transmission and reception is not enabled.
FSP_ERR_ETHER_ERROR_FILTERING
Multicast Frame filter is enable, and Multicast Address Frame is received.
Transmit Ethernet frame. Transmits data from the location specified by the pointer to the transmit buffer, with the data size equal to the specified frame length. In the non zero copy mode, transmits data after being copied to the internal buffer. Implements ether_api_t::write.
Return values
FSP_SUCCESS
Processing completed successfully.
FSP_ERR_ASSERTION
Pointer to ETHER control block is NULL.
FSP_ERR_NOT_OPEN
The control block has not been opened.
FSP_ERR_ETHER_ERROR_LINK
Auto-negotiation is not completed, and reception is not enabled.
FSP_ERR_ETHER_ERROR_MAGIC_PACKET_MODE
As a Magic Packet is being detected, transmission and reception is not enabled.