Dependents:   Nucleo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mcf5225x_eth.h Source File

mcf5225x_eth.h

Go to the documentation of this file.
00001 /**
00002  * @file mcf5225x_eth.h
00003  * @brief Coldfire V2 MCF5225x Ethernet MAC controller
00004  *
00005  * @section License
00006  *
00007  * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved.
00008  *
00009  * This file is part of CycloneTCP Open.
00010  *
00011  * This program is free software; you can redistribute it and/or
00012  * modify it under the terms of the GNU General Public License
00013  * as published by the Free Software Foundation; either version 2
00014  * of the License, or (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software Foundation,
00023  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00024  *
00025  * @author Oryx Embedded SARL (www.oryx-embedded.com)
00026  * @version 1.7.6
00027  **/
00028 
00029 #ifndef _MCF5225X_ETH_H
00030 #define _MCF5225X_ETH_H
00031 
00032 //Number of TX buffers
00033 #ifndef MCF5225X_ETH_TX_BUFFER_COUNT
00034    #define MCF5225X_ETH_TX_BUFFER_COUNT 2
00035 #elif (MCF5225X_ETH_TX_BUFFER_COUNT < 1)
00036    #error MCF5225X_ETH_TX_BUFFER_COUNT parameter is not valid
00037 #endif
00038 
00039 //TX buffer size
00040 #ifndef MCF5225X_ETH_TX_BUFFER_SIZE
00041    #define MCF5225X_ETH_TX_BUFFER_SIZE 1536
00042 #elif (MCF5225X_ETH_TX_BUFFER_SIZE != 1536)
00043    #error MCF5225X_ETH_TX_BUFFER_SIZE parameter is not valid
00044 #endif
00045 
00046 //Number of RX buffers
00047 #ifndef MCF5225X_ETH_RX_BUFFER_COUNT
00048    #define MCF5225X_ETH_RX_BUFFER_COUNT 4
00049 #elif (MCF5225X_ETH_RX_BUFFER_COUNT < 1)
00050    #error MCF5225X_ETH_RX_BUFFER_COUNT parameter is not valid
00051 #endif
00052 
00053 //RX buffer size
00054 #ifndef MCF5225X_ETH_RX_BUFFER_SIZE
00055    #define MCF5225X_ETH_RX_BUFFER_SIZE 1536
00056 #elif (MCF5225X_ETH_RX_BUFFER_SIZE != 1536)
00057    #error MCF5225X_ETH_RX_BUFFER_SIZE parameter is not valid
00058 #endif
00059 
00060 //Ethernet interrupt level
00061 #ifndef MCF5225X_ETH_IRQ_LEVEL
00062    #define MCF5225X_ETH_IRQ_LEVEL 4
00063 #elif (MCF5225X_ETH_IRQ_LEVEL < 0)
00064    #error MCF5225X_ETH_IRQ_LEVEL parameter is not valid
00065 #endif
00066 
00067 //Ethernet interrupt priority
00068 #ifndef MCF5225X_ETH_IRQ_PRIORITY
00069    #define MCF5225X_ETH_IRQ_PRIORITY 1
00070 #elif (MCF5225X_ETH_IRQ_PRIORITY < 0)
00071    #error MCF5225X_ETH_IRQ_PRIORITY parameter is not valid
00072 #endif
00073 
00074 //Align to 16-byte boundary
00075 #define FEC_ALIGN16(p) ((void *) ((((uint32_t) (p)) + 15) & 0xFFFFFFF0))
00076 
00077 //Transmit buffer descriptor
00078 #define FEC_TX_BD_R   0x8000
00079 #define FEC_TX_BD_TO1 0x4000
00080 #define FEC_TX_BD_W   0x2000
00081 #define FEC_TX_BD_TO2 0x1000
00082 #define FEC_TX_BD_L   0x0800
00083 #define FEC_TX_BD_TC  0x0400
00084 #define FEC_TX_BD_ABC 0x0200
00085 
00086 //Receive buffer descriptor
00087 #define FEC_RX_BD_E   0x8000
00088 #define FEC_RX_BD_RO1 0x4000
00089 #define FEC_RX_BD_W   0x2000
00090 #define FEC_RX_BD_RO2 0x1000
00091 #define FEC_RX_BD_L   0x0800
00092 #define FEC_RX_BD_M   0x0100
00093 #define FEC_RX_BD_BC  0x0080
00094 #define FEC_RX_BD_MC  0x0040
00095 #define FEC_RX_BD_LG  0x0020
00096 #define FEC_RX_BD_NO  0x0010
00097 #define FEC_RX_BD_CR  0x0004
00098 #define FEC_RX_BD_OV  0x0002
00099 #define FEC_RX_BD_TR  0x0001
00100 
00101 
00102 /**
00103  * @brief Transmit buffer descriptor
00104  **/
00105 
00106 typedef struct
00107 {
00108    uint16_t status;
00109    uint16_t length;
00110    uint32_t address;
00111 } Mcf5225xTxBufferDesc;
00112 
00113 
00114 /**
00115  * @brief Receive buffer descriptor
00116  **/
00117 
00118 typedef struct
00119 {
00120    uint16_t status;
00121    uint16_t length;
00122    uint32_t address;
00123 } Mcf5225xRxBufferDesc;
00124 
00125 
00126 //MCF5225x Ethernet MAC driver
00127 extern const NicDriver mcf5225xEthDriver;
00128 
00129 //MCF5225x Ethernet MAC related functions
00130 error_t mcf5225xEthInit(NetInterface *interface);
00131 void mcf5225xEthInitGpio(NetInterface *interface);
00132 void mcf5225xEthInitBufferDesc(NetInterface *interface);
00133 
00134 void mcf5225xEthTick(NetInterface *interface);
00135 
00136 void mcf5225xEthEnableIrq(NetInterface *interface);
00137 void mcf5225xEthDisableIrq(NetInterface *interface);
00138 void mcf5225xEthEventHandler(NetInterface *interface);
00139 
00140 error_t mcf5225xEthSendPacket(NetInterface *interface,
00141    const NetBuffer *buffer, size_t offset);
00142 
00143 error_t mcf5225xEthReceivePacket(NetInterface *interface);
00144 
00145 error_t mcf5225xEthSetMulticastFilter(NetInterface *interface);
00146 error_t mcf5225xEthUpdateMacConfig(NetInterface *interface);
00147 
00148 void mcf5225xEthWritePhyReg(uint8_t phyAddr, uint8_t regAddr, uint16_t data);
00149 uint16_t mcf5225xEthReadPhyReg(uint8_t phyAddr, uint8_t regAddr);
00150 
00151 uint32_t mcf5225xEthCalcCrc(const void *data, size_t length);
00152 
00153 #endif
00154