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-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 #ifndef _MPC5777_ETH_DRIVER_H
32 #define _MPC5777_ETH_DRIVER_H
33 
34 //Number of TX buffers
35 #ifndef MPC5777_ETH_TX_BUFFER_COUNT
36  #define MPC5777_ETH_TX_BUFFER_COUNT 3
37 #elif (MPC5777_ETH_TX_BUFFER_COUNT < 1)
38  #error MPC5777_ETH_TX_BUFFER_COUNT parameter is not valid
39 #endif
40 
41 //TX buffer size
42 #ifndef MPC5777_ETH_TX_BUFFER_SIZE
43  #define MPC5777_ETH_TX_BUFFER_SIZE 1536
44 #elif (MPC5777_ETH_TX_BUFFER_SIZE != 1536)
45  #error MPC5777_ETH_TX_BUFFER_SIZE parameter is not valid
46 #endif
47 
48 //Number of RX buffers
49 #ifndef MPC5777_ETH_RX_BUFFER_COUNT
50  #define MPC5777_ETH_RX_BUFFER_COUNT 6
51 #elif (MPC5777_ETH_RX_BUFFER_COUNT < 1)
52  #error MPC5777_ETH_RX_BUFFER_COUNT parameter is not valid
53 #endif
54 
55 //RX buffer size
56 #ifndef MPC5777_ETH_RX_BUFFER_SIZE
57  #define MPC5777_ETH_RX_BUFFER_SIZE 1536
58 #elif (MPC5777_ETH_RX_BUFFER_SIZE != 1536)
59  #error MPC5777_ETH_RX_BUFFER_SIZE parameter is not valid
60 #endif
61 
62 //Ethernet interrupt priority
63 #ifndef MPC5777_ETH_IRQ_PRIORITY
64  #define MPC5777_ETH_IRQ_PRIORITY 10
65 #elif (MPC5777_ETH_IRQ_PRIORITY < 0)
66  #error MPC5777_ETH_IRQ_PRIORITY parameter is not valid
67 #endif
68 
69 //Enhanced transmit buffer descriptor
70 #define FEC_TBD0_R 0x80000000
71 #define FEC_TBD0_TO1 0x40000000
72 #define FEC_TBD0_W 0x20000000
73 #define FEC_TBD0_TO2 0x10000000
74 #define FEC_TBD0_L 0x08000000
75 #define FEC_TBD0_TC 0x04000000
76 #define FEC_TBD0_DATA_LENGTH 0x0000FFFF
77 #define FEC_TBD1_DATA_POINTER 0xFFFFFFFF
78 
79 //Enhanced receive buffer descriptor
80 #define FEC_RBD0_E 0x80000000
81 #define FEC_RBD0_RO1 0x40000000
82 #define FEC_RBD0_W 0x20000000
83 #define FEC_RBD0_RO2 0x10000000
84 #define FEC_RBD0_L 0x08000000
85 #define FEC_RBD0_M 0x01000000
86 #define FEC_RBD0_BC 0x00800000
87 #define FEC_RBD0_MC 0x00400000
88 #define FEC_RBD0_LG 0x00200000
89 #define FEC_RBD0_NO 0x00100000
90 #define FEC_RBD0_CR 0x00040000
91 #define FEC_RBD0_OV 0x00020000
92 #define FEC_RBD0_TR 0x00010000
93 #define FEC_RBD0_DATA_LENGTH 0x0000FFFF
94 #define FEC_RBD1_DATA_POINTER 0xFFFFFFFF
95 
96 //C++ guard
97 #ifdef __cplusplus
98 extern "C" {
99 #endif
100 
101 //MPC5777 Ethernet MAC driver
102 extern const NicDriver mpc5777EthDriver;
103 
104 //MPC5777 Ethernet MAC related functions
106 void mpc5777EthInitGpio(NetInterface *interface);
107 void mpc5777EthInitBufferDesc(NetInterface *interface);
108 
109 void mpc5777EthTick(NetInterface *interface);
110 
111 void mpc5777EthEnableIrq(NetInterface *interface);
112 void mpc5777EthDisableIrq(NetInterface *interface);
113 void mpc5777EthEventHandler(NetInterface *interface);
114 
116  const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary);
117 
119 
122 
123 void mpc5777EthWritePhyReg(uint8_t opcode, uint8_t phyAddr,
124  uint8_t regAddr, uint16_t data);
125 
126 uint16_t mpc5777EthReadPhyReg(uint8_t opcode, uint8_t phyAddr,
127  uint8_t regAddr);
128 
129 uint32_t mpc5777EthCalcCrc(const void *data, size_t length);
130 
131 //C++ guard
132 #ifdef __cplusplus
133 }
134 #endif
135 
136 #endif
uint8_t opcode
Definition: dns_common.h:188
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:222
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:368
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
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.