Webserver+3d print
cyclone_tcp/drivers/rx63n_eth.h@0:8918a71cdbe9, 2017-02-04 (annotated)
- Committer:
- Sergunb
- Date:
- Sat Feb 04 18:15:49 2017 +0000
- Revision:
- 0:8918a71cdbe9
nothing else
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Sergunb | 0:8918a71cdbe9 | 1 | /** |
Sergunb | 0:8918a71cdbe9 | 2 | * @file rx63n_eth.h |
Sergunb | 0:8918a71cdbe9 | 3 | * @brief Renesas RX63N Ethernet MAC controller |
Sergunb | 0:8918a71cdbe9 | 4 | * |
Sergunb | 0:8918a71cdbe9 | 5 | * @section License |
Sergunb | 0:8918a71cdbe9 | 6 | * |
Sergunb | 0:8918a71cdbe9 | 7 | * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved. |
Sergunb | 0:8918a71cdbe9 | 8 | * |
Sergunb | 0:8918a71cdbe9 | 9 | * This file is part of CycloneTCP Open. |
Sergunb | 0:8918a71cdbe9 | 10 | * |
Sergunb | 0:8918a71cdbe9 | 11 | * This program is free software; you can redistribute it and/or |
Sergunb | 0:8918a71cdbe9 | 12 | * modify it under the terms of the GNU General Public License |
Sergunb | 0:8918a71cdbe9 | 13 | * as published by the Free Software Foundation; either version 2 |
Sergunb | 0:8918a71cdbe9 | 14 | * of the License, or (at your option) any later version. |
Sergunb | 0:8918a71cdbe9 | 15 | * |
Sergunb | 0:8918a71cdbe9 | 16 | * This program is distributed in the hope that it will be useful, |
Sergunb | 0:8918a71cdbe9 | 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
Sergunb | 0:8918a71cdbe9 | 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Sergunb | 0:8918a71cdbe9 | 19 | * GNU General Public License for more details. |
Sergunb | 0:8918a71cdbe9 | 20 | * |
Sergunb | 0:8918a71cdbe9 | 21 | * You should have received a copy of the GNU General Public License |
Sergunb | 0:8918a71cdbe9 | 22 | * along with this program; if not, write to the Free Software Foundation, |
Sergunb | 0:8918a71cdbe9 | 23 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
Sergunb | 0:8918a71cdbe9 | 24 | * |
Sergunb | 0:8918a71cdbe9 | 25 | * @author Oryx Embedded SARL (www.oryx-embedded.com) |
Sergunb | 0:8918a71cdbe9 | 26 | * @version 1.7.6 |
Sergunb | 0:8918a71cdbe9 | 27 | **/ |
Sergunb | 0:8918a71cdbe9 | 28 | |
Sergunb | 0:8918a71cdbe9 | 29 | #ifndef _RX63N_ETH_H |
Sergunb | 0:8918a71cdbe9 | 30 | #define _RX63N_ETH_H |
Sergunb | 0:8918a71cdbe9 | 31 | |
Sergunb | 0:8918a71cdbe9 | 32 | //Dependencies |
Sergunb | 0:8918a71cdbe9 | 33 | #include "core/nic.h" |
Sergunb | 0:8918a71cdbe9 | 34 | |
Sergunb | 0:8918a71cdbe9 | 35 | //Number of TX buffers |
Sergunb | 0:8918a71cdbe9 | 36 | #ifndef RX63N_ETH_TX_BUFFER_COUNT |
Sergunb | 0:8918a71cdbe9 | 37 | #define RX63N_ETH_TX_BUFFER_COUNT 3 |
Sergunb | 0:8918a71cdbe9 | 38 | #elif (RX63N_ETH_TX_BUFFER_COUNT < 1) |
Sergunb | 0:8918a71cdbe9 | 39 | #error RX63N_ETH_TX_BUFFER_COUNT parameter is not valid |
Sergunb | 0:8918a71cdbe9 | 40 | #endif |
Sergunb | 0:8918a71cdbe9 | 41 | |
Sergunb | 0:8918a71cdbe9 | 42 | //TX buffer size |
Sergunb | 0:8918a71cdbe9 | 43 | #ifndef RX63N_ETH_TX_BUFFER_SIZE |
Sergunb | 0:8918a71cdbe9 | 44 | #define RX63N_ETH_TX_BUFFER_SIZE 1536 |
Sergunb | 0:8918a71cdbe9 | 45 | #elif (RX63N_ETH_TX_BUFFER_SIZE != 1536) |
Sergunb | 0:8918a71cdbe9 | 46 | #error RX63N_ETH_TX_BUFFER_SIZE parameter is not valid |
Sergunb | 0:8918a71cdbe9 | 47 | #endif |
Sergunb | 0:8918a71cdbe9 | 48 | |
Sergunb | 0:8918a71cdbe9 | 49 | //Number of RX buffers |
Sergunb | 0:8918a71cdbe9 | 50 | #ifndef RX63N_ETH_RX_BUFFER_COUNT |
Sergunb | 0:8918a71cdbe9 | 51 | #define RX63N_ETH_RX_BUFFER_COUNT 6 |
Sergunb | 0:8918a71cdbe9 | 52 | #elif (RX63N_ETH_RX_BUFFER_COUNT < 1) |
Sergunb | 0:8918a71cdbe9 | 53 | #error RX63N_ETH_RX_BUFFER_COUNT parameter is not valid |
Sergunb | 0:8918a71cdbe9 | 54 | #endif |
Sergunb | 0:8918a71cdbe9 | 55 | |
Sergunb | 0:8918a71cdbe9 | 56 | //RX buffer size |
Sergunb | 0:8918a71cdbe9 | 57 | #ifndef RX63N_ETH_RX_BUFFER_SIZE |
Sergunb | 0:8918a71cdbe9 | 58 | #define RX63N_ETH_RX_BUFFER_SIZE 1536 |
Sergunb | 0:8918a71cdbe9 | 59 | #elif (RX63N_ETH_RX_BUFFER_SIZE != 1536) |
Sergunb | 0:8918a71cdbe9 | 60 | #error RX63N_ETH_RX_BUFFER_SIZE parameter is not valid |
Sergunb | 0:8918a71cdbe9 | 61 | #endif |
Sergunb | 0:8918a71cdbe9 | 62 | |
Sergunb | 0:8918a71cdbe9 | 63 | //Ethernet interrupt priority |
Sergunb | 0:8918a71cdbe9 | 64 | #ifndef RX63N_ETH_IRQ_PRIORITY |
Sergunb | 0:8918a71cdbe9 | 65 | #define RX63N_ETH_IRQ_PRIORITY 2 |
Sergunb | 0:8918a71cdbe9 | 66 | #elif (RX63N_ETH_IRQ_PRIORITY < 0) |
Sergunb | 0:8918a71cdbe9 | 67 | #error RX63N_ETH_IRQ_PRIORITY parameter is not valid |
Sergunb | 0:8918a71cdbe9 | 68 | #endif |
Sergunb | 0:8918a71cdbe9 | 69 | |
Sergunb | 0:8918a71cdbe9 | 70 | //EESR register |
Sergunb | 0:8918a71cdbe9 | 71 | #define EDMAC_EESR_TWB 0x40000000 |
Sergunb | 0:8918a71cdbe9 | 72 | #define EDMAC_EESR_TABT 0x04000000 |
Sergunb | 0:8918a71cdbe9 | 73 | #define EDMAC_EESR_RABT 0x02000000 |
Sergunb | 0:8918a71cdbe9 | 74 | #define EDMAC_EESR_RFCOF 0x01000000 |
Sergunb | 0:8918a71cdbe9 | 75 | #define EDMAC_EESR_ADE 0x00800000 |
Sergunb | 0:8918a71cdbe9 | 76 | #define EDMAC_EESR_ECI 0x00400000 |
Sergunb | 0:8918a71cdbe9 | 77 | #define EDMAC_EESR_TC 0x00200000 |
Sergunb | 0:8918a71cdbe9 | 78 | #define EDMAC_EESR_TDE 0x00100000 |
Sergunb | 0:8918a71cdbe9 | 79 | #define EDMAC_EESR_TFUF 0x00080000 |
Sergunb | 0:8918a71cdbe9 | 80 | #define EDMAC_EESR_FR 0x00040000 |
Sergunb | 0:8918a71cdbe9 | 81 | #define EDMAC_EESR_RDE 0x00020000 |
Sergunb | 0:8918a71cdbe9 | 82 | #define EDMAC_EESR_RFOF 0x00010000 |
Sergunb | 0:8918a71cdbe9 | 83 | #define EDMAC_EESR_CND 0x00000800 |
Sergunb | 0:8918a71cdbe9 | 84 | #define EDMAC_EESR_DLC 0x00000400 |
Sergunb | 0:8918a71cdbe9 | 85 | #define EDMAC_EESR_CD 0x00000200 |
Sergunb | 0:8918a71cdbe9 | 86 | #define EDMAC_EESR_TRO 0x00000100 |
Sergunb | 0:8918a71cdbe9 | 87 | #define EDMAC_EESR_RMAF 0x00000080 |
Sergunb | 0:8918a71cdbe9 | 88 | #define EDMAC_EESR_RRF 0x00000010 |
Sergunb | 0:8918a71cdbe9 | 89 | #define EDMAC_EESR_RTLF 0x00000008 |
Sergunb | 0:8918a71cdbe9 | 90 | #define EDMAC_EESR_RTSF 0x00000004 |
Sergunb | 0:8918a71cdbe9 | 91 | #define EDMAC_EESR_PRE 0x00000002 |
Sergunb | 0:8918a71cdbe9 | 92 | #define EDMAC_EESR_CERF 0x00000001 |
Sergunb | 0:8918a71cdbe9 | 93 | |
Sergunb | 0:8918a71cdbe9 | 94 | //Transmit DMA descriptor flags |
Sergunb | 0:8918a71cdbe9 | 95 | #define EDMAC_TD0_TACT 0x80000000 |
Sergunb | 0:8918a71cdbe9 | 96 | #define EDMAC_TD0_TDLE 0x40000000 |
Sergunb | 0:8918a71cdbe9 | 97 | #define EDMAC_TD0_TFP_SOF 0x20000000 |
Sergunb | 0:8918a71cdbe9 | 98 | #define EDMAC_TD0_TFP_EOF 0x10000000 |
Sergunb | 0:8918a71cdbe9 | 99 | #define EDMAC_TD0_TFE 0x08000000 |
Sergunb | 0:8918a71cdbe9 | 100 | #define EDMAC_TD0_TWBI 0x04000000 |
Sergunb | 0:8918a71cdbe9 | 101 | #define EDMAC_TD0_TFS_MASK 0x0000010F |
Sergunb | 0:8918a71cdbe9 | 102 | #define EDMAC_TD0_TFS_TABT 0x00000100 |
Sergunb | 0:8918a71cdbe9 | 103 | #define EDMAC_TD0_TFS_CND 0x00000008 |
Sergunb | 0:8918a71cdbe9 | 104 | #define EDMAC_TD0_TFS_DLC 0x00000004 |
Sergunb | 0:8918a71cdbe9 | 105 | #define EDMAC_TD0_TFS_CD 0x00000002 |
Sergunb | 0:8918a71cdbe9 | 106 | #define EDMAC_TD0_TFS_TRO 0x00000001 |
Sergunb | 0:8918a71cdbe9 | 107 | #define EDMAC_TD1_TBL 0xFFFF0000 |
Sergunb | 0:8918a71cdbe9 | 108 | #define EDMAC_TD2_TBA 0xFFFFFFFF |
Sergunb | 0:8918a71cdbe9 | 109 | |
Sergunb | 0:8918a71cdbe9 | 110 | //Receive DMA descriptor flags |
Sergunb | 0:8918a71cdbe9 | 111 | #define EDMAC_RD0_RACT 0x80000000 |
Sergunb | 0:8918a71cdbe9 | 112 | #define EDMAC_RD0_RDLE 0x40000000 |
Sergunb | 0:8918a71cdbe9 | 113 | #define EDMAC_RD0_RFP_SOF 0x20000000 |
Sergunb | 0:8918a71cdbe9 | 114 | #define EDMAC_RD0_RFP_EOF 0x10000000 |
Sergunb | 0:8918a71cdbe9 | 115 | #define EDMAC_RD0_RFE 0x08000000 |
Sergunb | 0:8918a71cdbe9 | 116 | #define EDMAC_RD0_RFS_MASK 0x0000039F |
Sergunb | 0:8918a71cdbe9 | 117 | #define EDMAC_RD0_RFS_RFOF 0x00000200 |
Sergunb | 0:8918a71cdbe9 | 118 | #define EDMAC_RD0_RFS_RABT 0x00000100 |
Sergunb | 0:8918a71cdbe9 | 119 | #define EDMAC_RD0_RFS_RMAF 0x00000080 |
Sergunb | 0:8918a71cdbe9 | 120 | #define EDMAC_RD0_RFS_RRF 0x00000010 |
Sergunb | 0:8918a71cdbe9 | 121 | #define EDMAC_RD0_RFS_RTLF 0x00000008 |
Sergunb | 0:8918a71cdbe9 | 122 | #define EDMAC_RD0_RFS_RTSF 0x00000004 |
Sergunb | 0:8918a71cdbe9 | 123 | #define EDMAC_RD0_RFS_PRE 0x00000002 |
Sergunb | 0:8918a71cdbe9 | 124 | #define EDMAC_RD0_RFS_CERF 0x00000001 |
Sergunb | 0:8918a71cdbe9 | 125 | #define EDMAC_RD1_RBL 0xFFFF0000 |
Sergunb | 0:8918a71cdbe9 | 126 | #define EDMAC_RD1_RFL 0x0000FFFF |
Sergunb | 0:8918a71cdbe9 | 127 | #define EDMAC_RD2_RBA 0xFFFFFFFF |
Sergunb | 0:8918a71cdbe9 | 128 | |
Sergunb | 0:8918a71cdbe9 | 129 | //Serial Management Interface |
Sergunb | 0:8918a71cdbe9 | 130 | #define SMI_SYNC 0xFFFFFFFF |
Sergunb | 0:8918a71cdbe9 | 131 | #define SMI_START 0x00000001 |
Sergunb | 0:8918a71cdbe9 | 132 | #define SMI_WRITE 0x00000001 |
Sergunb | 0:8918a71cdbe9 | 133 | #define SMI_READ 0x00000002 |
Sergunb | 0:8918a71cdbe9 | 134 | #define SMI_TA 0x00000002 |
Sergunb | 0:8918a71cdbe9 | 135 | |
Sergunb | 0:8918a71cdbe9 | 136 | |
Sergunb | 0:8918a71cdbe9 | 137 | /** |
Sergunb | 0:8918a71cdbe9 | 138 | * @brief Transmit DMA descriptor |
Sergunb | 0:8918a71cdbe9 | 139 | **/ |
Sergunb | 0:8918a71cdbe9 | 140 | |
Sergunb | 0:8918a71cdbe9 | 141 | typedef struct |
Sergunb | 0:8918a71cdbe9 | 142 | { |
Sergunb | 0:8918a71cdbe9 | 143 | uint32_t td0; |
Sergunb | 0:8918a71cdbe9 | 144 | uint32_t td1; |
Sergunb | 0:8918a71cdbe9 | 145 | uint32_t td2; |
Sergunb | 0:8918a71cdbe9 | 146 | uint32_t padding; |
Sergunb | 0:8918a71cdbe9 | 147 | } Rx63nTxDmaDesc; |
Sergunb | 0:8918a71cdbe9 | 148 | |
Sergunb | 0:8918a71cdbe9 | 149 | |
Sergunb | 0:8918a71cdbe9 | 150 | /** |
Sergunb | 0:8918a71cdbe9 | 151 | * @brief Receive DMA descriptor |
Sergunb | 0:8918a71cdbe9 | 152 | **/ |
Sergunb | 0:8918a71cdbe9 | 153 | |
Sergunb | 0:8918a71cdbe9 | 154 | typedef struct |
Sergunb | 0:8918a71cdbe9 | 155 | { |
Sergunb | 0:8918a71cdbe9 | 156 | uint32_t rd0; |
Sergunb | 0:8918a71cdbe9 | 157 | uint32_t rd1; |
Sergunb | 0:8918a71cdbe9 | 158 | uint32_t rd2; |
Sergunb | 0:8918a71cdbe9 | 159 | uint32_t padding; |
Sergunb | 0:8918a71cdbe9 | 160 | } Rx63nRxDmaDesc; |
Sergunb | 0:8918a71cdbe9 | 161 | |
Sergunb | 0:8918a71cdbe9 | 162 | |
Sergunb | 0:8918a71cdbe9 | 163 | //RX63N Ethernet MAC driver |
Sergunb | 0:8918a71cdbe9 | 164 | extern const NicDriver rx63nEthDriver; |
Sergunb | 0:8918a71cdbe9 | 165 | |
Sergunb | 0:8918a71cdbe9 | 166 | //RX63N Ethernet MAC related functions |
Sergunb | 0:8918a71cdbe9 | 167 | error_t rx63nEthInit(NetInterface *interface); |
Sergunb | 0:8918a71cdbe9 | 168 | void rx63nEthInitGpio(NetInterface *interface); |
Sergunb | 0:8918a71cdbe9 | 169 | void rx63nEthInitDmaDesc(NetInterface *interface); |
Sergunb | 0:8918a71cdbe9 | 170 | |
Sergunb | 0:8918a71cdbe9 | 171 | void rx63nEthTick(NetInterface *interface); |
Sergunb | 0:8918a71cdbe9 | 172 | |
Sergunb | 0:8918a71cdbe9 | 173 | void rx63nEthEnableIrq(NetInterface *interface); |
Sergunb | 0:8918a71cdbe9 | 174 | void rx63nEthDisableIrq(NetInterface *interface); |
Sergunb | 0:8918a71cdbe9 | 175 | void rx63nEthEventHandler(NetInterface *interface); |
Sergunb | 0:8918a71cdbe9 | 176 | |
Sergunb | 0:8918a71cdbe9 | 177 | error_t rx63nEthSendPacket(NetInterface *interface, |
Sergunb | 0:8918a71cdbe9 | 178 | const NetBuffer *buffer, size_t offset); |
Sergunb | 0:8918a71cdbe9 | 179 | |
Sergunb | 0:8918a71cdbe9 | 180 | error_t rx63nEthReceivePacket(NetInterface *interface); |
Sergunb | 0:8918a71cdbe9 | 181 | |
Sergunb | 0:8918a71cdbe9 | 182 | error_t rx63nEthSetMulticastFilter(NetInterface *interface); |
Sergunb | 0:8918a71cdbe9 | 183 | error_t rx63nEthUpdateMacConfig(NetInterface *interface); |
Sergunb | 0:8918a71cdbe9 | 184 | |
Sergunb | 0:8918a71cdbe9 | 185 | void rx63nEthWritePhyReg(uint8_t phyAddr, uint8_t regAddr, uint16_t data); |
Sergunb | 0:8918a71cdbe9 | 186 | uint16_t rx63nEthReadPhyReg(uint8_t phyAddr, uint8_t regAddr); |
Sergunb | 0:8918a71cdbe9 | 187 | |
Sergunb | 0:8918a71cdbe9 | 188 | void rx63nEthWriteSmi(uint32_t data, uint_t length); |
Sergunb | 0:8918a71cdbe9 | 189 | uint32_t rx63nEthReadSmi(uint_t length); |
Sergunb | 0:8918a71cdbe9 | 190 | |
Sergunb | 0:8918a71cdbe9 | 191 | #endif |
Sergunb | 0:8918a71cdbe9 | 192 |