mpc5777_eth_driver.h
Go to the documentation of this file.
1 /**
2  * @file mpc5777_eth_driver.h
3  * @brief NXP MPC5777 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 _MPC5777_ETH_DRIVER_H
32 #define _MPC5777_ETH_DRIVER_H
33 
34 //Dependencies
35 #include "core/nic.h"
36 
37 //Number of TX buffers
38 #ifndef MPC5777_ETH_TX_BUFFER_COUNT
39  #define MPC5777_ETH_TX_BUFFER_COUNT 3
40 #elif (MPC5777_ETH_TX_BUFFER_COUNT < 1)
41  #error MPC5777_ETH_TX_BUFFER_COUNT parameter is not valid
42 #endif
43 
44 //TX buffer size
45 #ifndef MPC5777_ETH_TX_BUFFER_SIZE
46  #define MPC5777_ETH_TX_BUFFER_SIZE 1536
47 #elif (MPC5777_ETH_TX_BUFFER_SIZE != 1536)
48  #error MPC5777_ETH_TX_BUFFER_SIZE parameter is not valid
49 #endif
50 
51 //Number of RX buffers
52 #ifndef MPC5777_ETH_RX_BUFFER_COUNT
53  #define MPC5777_ETH_RX_BUFFER_COUNT 6
54 #elif (MPC5777_ETH_RX_BUFFER_COUNT < 1)
55  #error MPC5777_ETH_RX_BUFFER_COUNT parameter is not valid
56 #endif
57 
58 //RX buffer size
59 #ifndef MPC5777_ETH_RX_BUFFER_SIZE
60  #define MPC5777_ETH_RX_BUFFER_SIZE 1536
61 #elif (MPC5777_ETH_RX_BUFFER_SIZE != 1536)
62  #error MPC5777_ETH_RX_BUFFER_SIZE parameter is not valid
63 #endif
64 
65 //Ethernet interrupt priority
66 #ifndef MPC5777_ETH_IRQ_PRIORITY
67  #define MPC5777_ETH_IRQ_PRIORITY 10
68 #elif (MPC5777_ETH_IRQ_PRIORITY < 0)
69  #error MPC5777_ETH_IRQ_PRIORITY parameter is not valid
70 #endif
71 
72 //Enhanced transmit buffer descriptor
73 #define FEC_TBD0_R 0x80000000
74 #define FEC_TBD0_TO1 0x40000000
75 #define FEC_TBD0_W 0x20000000
76 #define FEC_TBD0_TO2 0x10000000
77 #define FEC_TBD0_L 0x08000000
78 #define FEC_TBD0_TC 0x04000000
79 #define FEC_TBD0_DATA_LENGTH 0x0000FFFF
80 #define FEC_TBD1_DATA_POINTER 0xFFFFFFFF
81 
82 //Enhanced receive buffer descriptor
83 #define FEC_RBD0_E 0x80000000
84 #define FEC_RBD0_RO1 0x40000000
85 #define FEC_RBD0_W 0x20000000
86 #define FEC_RBD0_RO2 0x10000000
87 #define FEC_RBD0_L 0x08000000
88 #define FEC_RBD0_M 0x01000000
89 #define FEC_RBD0_BC 0x00800000
90 #define FEC_RBD0_MC 0x00400000
91 #define FEC_RBD0_LG 0x00200000
92 #define FEC_RBD0_NO 0x00100000
93 #define FEC_RBD0_CR 0x00040000
94 #define FEC_RBD0_OV 0x00020000
95 #define FEC_RBD0_TR 0x00010000
96 #define FEC_RBD0_DATA_LENGTH 0x0000FFFF
97 #define FEC_RBD1_DATA_POINTER 0xFFFFFFFF
98 
99 //C++ guard
100 #ifdef __cplusplus
101 extern "C" {
102 #endif
103 
104 //MPC5777 Ethernet MAC driver
105 extern const NicDriver mpc5777EthDriver;
106 
107 //MPC5777 Ethernet MAC related functions
109 void mpc5777EthInitGpio(NetInterface *interface);
110 void mpc5777EthInitBufferDesc(NetInterface *interface);
111 
112 void mpc5777EthTick(NetInterface *interface);
113 
114 void mpc5777EthEnableIrq(NetInterface *interface);
115 void mpc5777EthDisableIrq(NetInterface *interface);
116 void mpc5777EthEventHandler(NetInterface *interface);
117 
119  const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary);
120 
122 
125 
126 void mpc5777EthWritePhyReg(uint8_t opcode, uint8_t phyAddr,
127  uint8_t regAddr, uint16_t data);
128 
129 uint16_t mpc5777EthReadPhyReg(uint8_t opcode, uint8_t phyAddr,
130  uint8_t regAddr);
131 
132 uint32_t mpc5777EthCalcCrc(const void *data, size_t length);
133 
134 //C++ guard
135 #ifdef __cplusplus
136 }
137 #endif
138 
139 #endif
uint8_t opcode
Definition: dns_common.h:191
void mpc5777EthEnableIrq(NetInterface *interface)
Enable interrupts.
error_t mpc5777EthUpdateMacConfig(NetInterface *interface)
Adjust MAC configuration parameters for proper operation.
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:89
uint8_t data[]
Definition: ethernet.h:224
void mpc5777EthEventHandler(NetInterface *interface)
MPC5777 Ethernet MAC event handler.
void mpc5777EthDisableIrq(NetInterface *interface)
Disable interrupts.
const NicDriver mpc5777EthDriver
MPC5777 Ethernet MAC driver.
error_t
Error codes.
Definition: error.h:43
#define NetInterface
Definition: net.h:36
uint32_t mpc5777EthCalcCrc(const void *data, size_t length)
CRC calculation.
error_t mpc5777EthSendPacket(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a packet.
#define NetTxAncillary
Definition: net_misc.h:36
uint8_t length
Definition: tcp.h:375
void mpc5777EthInitBufferDesc(NetInterface *interface)
Initialize buffer descriptors.
uint16_t mpc5777EthReadPhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr)
Read PHY register.
error_t mpc5777EthReceivePacket(NetInterface *interface)
Receive a packet.
void mpc5777EthWritePhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr, uint16_t data)
Write PHY register.
uint16_t regAddr
Network interface controller abstraction layer.
error_t mpc5777EthInit(NetInterface *interface)
MPC5777 Ethernet MAC initialization.
void mpc5777EthInitGpio(NetInterface *interface)
GPIO configuration.
error_t mpc5777EthUpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
NIC driver.
Definition: nic.h:286
void mpc5777EthTick(NetInterface *interface)
MPC5777 Ethernet MAC timer handler.