efm32gg11_eth_driver.h
Go to the documentation of this file.
1 /**
2  * @file efm32gg11_eth_driver.h
3  * @brief EFM32 Giant Gecko 11 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.4
29  **/
30 
31 #ifndef _EFM32GG11_ETH_DRIVER_H
32 #define _EFM32GG11_ETH_DRIVER_H
33 
34 //Dependencies
35 #include "core/nic.h"
36 
37 //Number of TX buffers
38 #ifndef EFM32GG11_ETH_TX_BUFFER_COUNT
39  #define EFM32GG11_ETH_TX_BUFFER_COUNT 2
40 #elif (EFM32GG11_ETH_TX_BUFFER_COUNT < 1)
41  #error EFM32GG11_ETH_TX_BUFFER_COUNT parameter is not valid
42 #endif
43 
44 //TX buffer size
45 #ifndef EFM32GG11_ETH_TX_BUFFER_SIZE
46  #define EFM32GG11_ETH_TX_BUFFER_SIZE 1536
47 #elif (EFM32GG11_ETH_TX_BUFFER_SIZE != 1536)
48  #error EFM32GG11_ETH_TX_BUFFER_SIZE parameter is not valid
49 #endif
50 
51 //Number of RX buffers
52 #ifndef EFM32GG11_ETH_RX_BUFFER_COUNT
53  #define EFM32GG11_ETH_RX_BUFFER_COUNT 48
54 #elif (EFM32GG11_ETH_RX_BUFFER_COUNT < 12)
55  #error EFM32GG11_ETH_RX_BUFFER_COUNT parameter is not valid
56 #endif
57 
58 //RX buffer size
59 #ifndef EFM32GG11_ETH_RX_BUFFER_SIZE
60  #define EFM32GG11_ETH_RX_BUFFER_SIZE 128
61 #elif (EFM32GG11_ETH_RX_BUFFER_SIZE != 128)
62  #error EFM32GG11_ETH_RX_BUFFER_SIZE parameter is not valid
63 #endif
64 
65 //Interrupt priority grouping
66 #ifndef EFM32GG11_ETH_IRQ_PRIORITY_GROUPING
67  #define EFM32GG11_ETH_IRQ_PRIORITY_GROUPING 4
68 #elif (EFM32GG11_ETH_IRQ_PRIORITY_GROUPING < 0)
69  #error EFM32GG11_ETH_IRQ_PRIORITY_GROUPING parameter is not valid
70 #endif
71 
72 //Ethernet interrupt group priority
73 #ifndef EFM32GG11_ETH_IRQ_GROUP_PRIORITY
74  #define EFM32GG11_ETH_IRQ_GROUP_PRIORITY 6
75 #elif (EFM32GG11_ETH_IRQ_GROUP_PRIORITY < 0)
76  #error EFM32GG11_ETH_IRQ_GROUP_PRIORITY parameter is not valid
77 #endif
78 
79 //Ethernet interrupt subpriority
80 #ifndef EFM32GG11_ETH_IRQ_SUB_PRIORITY
81  #define EFM32GG11_ETH_IRQ_SUB_PRIORITY 0
82 #elif (EFM32GG11_ETH_IRQ_SUB_PRIORITY < 0)
83  #error EFM32GG11_ETH_IRQ_SUB_PRIORITY parameter is not valid
84 #endif
85 
86 //TX buffer descriptor flags
87 #define ETH_TX_USED 0x80000000
88 #define ETH_TX_WRAP 0x40000000
89 #define ETH_TX_ERROR 0x20000000
90 #define ETH_TX_UNDERRUN 0x10000000
91 #define ETH_TX_EXHAUSTED 0x08000000
92 #define ETH_TX_NO_CRC 0x00010000
93 #define ETH_TX_LAST 0x00008000
94 #define ETH_TX_LENGTH 0x000007FF
95 
96 //RX buffer descriptor flags
97 #define ETH_RX_ADDRESS 0xFFFFFFFC
98 #define ETH_RX_WRAP 0x00000002
99 #define ETH_RX_OWNERSHIP 0x00000001
100 #define ETH_RX_BROADCAST 0x80000000
101 #define ETH_RX_MULTICAST_HASH 0x40000000
102 #define ETH_RX_UNICAST_HASH 0x20000000
103 #define ETH_RX_EXT_ADDR 0x10000000
104 #define ETH_RX_SAR1 0x04000000
105 #define ETH_RX_SAR2 0x02000000
106 #define ETH_RX_SAR3 0x01000000
107 #define ETH_RX_SAR4 0x00800000
108 #define ETH_RX_TYPE_ID 0x00400000
109 #define ETH_RX_VLAN_TAG 0x00200000
110 #define ETH_RX_PRIORITY_TAG 0x00100000
111 #define ETH_RX_VLAN_PRIORITY 0x000E0000
112 #define ETH_RX_CFI 0x00010000
113 #define ETH_RX_EOF 0x00008000
114 #define ETH_RX_SOF 0x00004000
115 #define ETH_RX_OFFSET 0x00003000
116 #define ETH_RX_LENGTH 0x00000FFF
117 
118 //C++ guard
119 #ifdef __cplusplus
120 extern "C" {
121 #endif
122 
123 
124 /**
125  * @brief Transmit buffer descriptor
126  **/
127 
128 typedef struct
129 {
130  uint32_t address;
131  uint32_t status;
133 
134 
135 /**
136  * @brief Receive buffer descriptor
137  **/
138 
139 typedef struct
140 {
141  uint32_t address;
142  uint32_t status;
144 
145 
146 //EFM32GG11 Ethernet MAC driver
147 extern const NicDriver efm32gg11EthDriver;
148 
149 //EFM32GG11 Ethernet MAC related functions
151 void efm32gg11EthInitGpio(NetInterface *interface);
153 
154 void efm32gg11EthTick(NetInterface *interface);
155 
156 void efm32gg11EthEnableIrq(NetInterface *interface);
157 void efm32gg11EthDisableIrq(NetInterface *interface);
158 void efm32gg11EthEventHandler(NetInterface *interface);
159 
161  const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary);
162 
164 
167 
168 void efm32gg11EthWritePhyReg(uint8_t opcode, uint8_t phyAddr,
169  uint8_t regAddr, uint16_t data);
170 
171 uint16_t efm32gg11EthReadPhyReg(uint8_t opcode, uint8_t phyAddr,
172  uint8_t regAddr);
173 
174 //C++ guard
175 #ifdef __cplusplus
176 }
177 #endif
178 
179 #endif
void efm32gg11EthTick(NetInterface *interface)
EFM32GG11 Ethernet MAC timer handler.
uint8_t opcode
Definition: dns_common.h:191
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:89
uint8_t data[]
Definition: ethernet.h:224
error_t efm32gg11EthUpdateMacConfig(NetInterface *interface)
Adjust MAC configuration parameters for proper operation.
void efm32gg11EthEventHandler(NetInterface *interface)
EFM32GG11 Ethernet MAC event handler.
error_t
Error codes.
Definition: error.h:43
void efm32gg11EthWritePhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr, uint16_t data)
Write PHY register.
#define NetInterface
Definition: net.h:36
error_t efm32gg11EthReceivePacket(NetInterface *interface)
Receive a packet.
#define NetTxAncillary
Definition: net_misc.h:36
error_t efm32gg11EthInit(NetInterface *interface)
EFM32GG11 Ethernet MAC initialization.
error_t efm32gg11EthUpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
Receive buffer descriptor.
uint16_t regAddr
void efm32gg11EthInitBufferDesc(NetInterface *interface)
Initialize buffer descriptors.
void efm32gg11EthEnableIrq(NetInterface *interface)
Enable interrupts.
Network interface controller abstraction layer.
error_t efm32gg11EthSendPacket(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a packet.
void efm32gg11EthInitGpio(NetInterface *interface)
GPIO configuration.
void efm32gg11EthDisableIrq(NetInterface *interface)
Disable interrupts.
NIC driver.
Definition: nic.h:286
uint16_t efm32gg11EthReadPhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr)
Read PHY register.
Transmit buffer descriptor.
const NicDriver efm32gg11EthDriver
EFM32GG11 Ethernet MAC driver.