Webserver+3d print

Dependents:   Nucleo

Committer:
Sergunb
Date:
Sat Feb 04 18:15:49 2017 +0000
Revision:
0:8918a71cdbe9
nothing else

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Sergunb 0:8918a71cdbe9 1 /**
Sergunb 0:8918a71cdbe9 2 * @file ksz8851.h
Sergunb 0:8918a71cdbe9 3 * @brief KSZ8851 Ethernet 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 _KSZ8851_H
Sergunb 0:8918a71cdbe9 30 #define _KSZ8851_H
Sergunb 0:8918a71cdbe9 31
Sergunb 0:8918a71cdbe9 32 //SPI interface support
Sergunb 0:8918a71cdbe9 33 #ifndef KSZ8851_SPI_SUPPORT
Sergunb 0:8918a71cdbe9 34 #define KSZ8851_SPI_SUPPORT ENABLED
Sergunb 0:8918a71cdbe9 35 #elif (KSZ8851_SPI_SUPPORT != ENABLED && KSZ8851_SPI_SUPPORT != DISABLED)
Sergunb 0:8918a71cdbe9 36 #error KSZ8851_SPI_SUPPORT parameter is not valid
Sergunb 0:8918a71cdbe9 37 #endif
Sergunb 0:8918a71cdbe9 38
Sergunb 0:8918a71cdbe9 39 //KSZ8851 data register
Sergunb 0:8918a71cdbe9 40 #ifndef KSZ8851_DATA_REG
Sergunb 0:8918a71cdbe9 41 #define KSZ8851_DATA_REG *((volatile uint16_t *) 0x60000000)
Sergunb 0:8918a71cdbe9 42 #endif
Sergunb 0:8918a71cdbe9 43
Sergunb 0:8918a71cdbe9 44 //KSZ8851 command register
Sergunb 0:8918a71cdbe9 45 #ifndef KSZ8851_CMD_REG
Sergunb 0:8918a71cdbe9 46 #define KSZ8851_CMD_REG *((volatile uint16_t *) 0x60000004)
Sergunb 0:8918a71cdbe9 47 #endif
Sergunb 0:8918a71cdbe9 48
Sergunb 0:8918a71cdbe9 49 //Device ID
Sergunb 0:8918a71cdbe9 50 #define KSZ8851_REV_A2_ID 0x8870
Sergunb 0:8918a71cdbe9 51 #define KSZ8851_REV_A3_ID 0x8872
Sergunb 0:8918a71cdbe9 52
Sergunb 0:8918a71cdbe9 53 //SPI command set
Sergunb 0:8918a71cdbe9 54 #define KSZ8851_CMD_RD_REG 0x00
Sergunb 0:8918a71cdbe9 55 #define KSZ8851_CMD_WR_REG 0x40
Sergunb 0:8918a71cdbe9 56 #define KSZ8851_CMD_RD_FIFO 0x80
Sergunb 0:8918a71cdbe9 57 #define KSZ8851_CMD_WR_FIFO 0xC0
Sergunb 0:8918a71cdbe9 58
Sergunb 0:8918a71cdbe9 59 //Byte enable bits
Sergunb 0:8918a71cdbe9 60 #if (KSZ8851_SPI_SUPPORT == ENABLED)
Sergunb 0:8918a71cdbe9 61 #define KSZ8851_CMD_B0 0x04
Sergunb 0:8918a71cdbe9 62 #define KSZ8851_CMD_B1 0x08
Sergunb 0:8918a71cdbe9 63 #define KSZ8851_CMD_B2 0x10
Sergunb 0:8918a71cdbe9 64 #define KSZ8851_CMD_B3 0x20
Sergunb 0:8918a71cdbe9 65 #else
Sergunb 0:8918a71cdbe9 66 #define KSZ8851_CMD_B0 0x1000
Sergunb 0:8918a71cdbe9 67 #define KSZ8851_CMD_B1 0x2000
Sergunb 0:8918a71cdbe9 68 #define KSZ8851_CMD_B2 0x4000
Sergunb 0:8918a71cdbe9 69 #define KSZ8851_CMD_B3 0x8000
Sergunb 0:8918a71cdbe9 70 #endif
Sergunb 0:8918a71cdbe9 71
Sergunb 0:8918a71cdbe9 72 //KSZ8851 registers
Sergunb 0:8918a71cdbe9 73 #define KSZ8851_REG_CCR 0x08
Sergunb 0:8918a71cdbe9 74 #define KSZ8851_REG_MARL 0x10
Sergunb 0:8918a71cdbe9 75 #define KSZ8851_REG_MARM 0x12
Sergunb 0:8918a71cdbe9 76 #define KSZ8851_REG_MARH 0x14
Sergunb 0:8918a71cdbe9 77 #define KSZ8851_REG_OBCR 0x20
Sergunb 0:8918a71cdbe9 78 #define KSZ8851_REG_EEPCR 0x22
Sergunb 0:8918a71cdbe9 79 #define KSZ8851_REG_MBIR 0x24
Sergunb 0:8918a71cdbe9 80 #define KSZ8851_REG_GRR 0x26
Sergunb 0:8918a71cdbe9 81 #define KSZ8851_REG_WFCR 0x2A
Sergunb 0:8918a71cdbe9 82 #define KSZ8851_REG_WF0CRC0 0x30
Sergunb 0:8918a71cdbe9 83 #define KSZ8851_REG_WF0CRC1 0x32
Sergunb 0:8918a71cdbe9 84 #define KSZ8851_REG_WF0BM0 0x34
Sergunb 0:8918a71cdbe9 85 #define KSZ8851_REG_WF0BM1 0x36
Sergunb 0:8918a71cdbe9 86 #define KSZ8851_REG_WF0BM2 0x38
Sergunb 0:8918a71cdbe9 87 #define KSZ8851_REG_WF0BM3 0x3A
Sergunb 0:8918a71cdbe9 88 #define KSZ8851_REG_WF1CRC0 0x40
Sergunb 0:8918a71cdbe9 89 #define KSZ8851_REG_WF1CRC1 0x42
Sergunb 0:8918a71cdbe9 90 #define KSZ8851_REG_WF1BM0 0x44
Sergunb 0:8918a71cdbe9 91 #define KSZ8851_REG_WF1BM1 0x46
Sergunb 0:8918a71cdbe9 92 #define KSZ8851_REG_WF1BM2 0x48
Sergunb 0:8918a71cdbe9 93 #define KSZ8851_REG_WF1BM3 0x4A
Sergunb 0:8918a71cdbe9 94 #define KSZ8851_REG_WF2CRC0 0x50
Sergunb 0:8918a71cdbe9 95 #define KSZ8851_REG_WF2CRC1 0x52
Sergunb 0:8918a71cdbe9 96 #define KSZ8851_REG_WF2BM0 0x54
Sergunb 0:8918a71cdbe9 97 #define KSZ8851_REG_WF2BM1 0x56
Sergunb 0:8918a71cdbe9 98 #define KSZ8851_REG_WF2BM2 0x58
Sergunb 0:8918a71cdbe9 99 #define KSZ8851_REG_WF2BM3 0x5A
Sergunb 0:8918a71cdbe9 100 #define KSZ8851_REG_WF3CRC0 0x60
Sergunb 0:8918a71cdbe9 101 #define KSZ8851_REG_WF3CRC1 0x62
Sergunb 0:8918a71cdbe9 102 #define KSZ8851_REG_WF3BM0 0x64
Sergunb 0:8918a71cdbe9 103 #define KSZ8851_REG_WF3BM1 0x66
Sergunb 0:8918a71cdbe9 104 #define KSZ8851_REG_WF3BM2 0x68
Sergunb 0:8918a71cdbe9 105 #define KSZ8851_REG_WF3BM3 0x6A
Sergunb 0:8918a71cdbe9 106 #define KSZ8851_REG_TXCR 0x70
Sergunb 0:8918a71cdbe9 107 #define KSZ8851_REG_TXSR 0x72
Sergunb 0:8918a71cdbe9 108 #define KSZ8851_REG_RXCR1 0x74
Sergunb 0:8918a71cdbe9 109 #define KSZ8851_REG_RXCR2 0x76
Sergunb 0:8918a71cdbe9 110 #define KSZ8851_REG_TXMIR 0x78
Sergunb 0:8918a71cdbe9 111 #define KSZ8851_REG_RXFHSR 0x7C
Sergunb 0:8918a71cdbe9 112 #define KSZ8851_REG_RXFHBCR 0x7E
Sergunb 0:8918a71cdbe9 113 #define KSZ8851_REG_TXQCR 0x80
Sergunb 0:8918a71cdbe9 114 #define KSZ8851_REG_RXQCR 0x82
Sergunb 0:8918a71cdbe9 115 #define KSZ8851_REG_TXFDPR 0x84
Sergunb 0:8918a71cdbe9 116 #define KSZ8851_REG_RXFDPR 0x86
Sergunb 0:8918a71cdbe9 117 #define KSZ8851_REG_RXDTTR 0x8C
Sergunb 0:8918a71cdbe9 118 #define KSZ8851_REG_RXDBCTR 0x8E
Sergunb 0:8918a71cdbe9 119 #define KSZ8851_REG_IER 0x90
Sergunb 0:8918a71cdbe9 120 #define KSZ8851_REG_ISR 0x92
Sergunb 0:8918a71cdbe9 121 #define KSZ8851_REG_RXFCTR 0x9C
Sergunb 0:8918a71cdbe9 122 #define KSZ8851_REG_TXNTFSR 0x9E
Sergunb 0:8918a71cdbe9 123 #define KSZ8851_REG_MAHTR0 0xA0
Sergunb 0:8918a71cdbe9 124 #define KSZ8851_REG_MAHTR1 0xA2
Sergunb 0:8918a71cdbe9 125 #define KSZ8851_REG_MAHTR2 0xA4
Sergunb 0:8918a71cdbe9 126 #define KSZ8851_REG_MAHTR3 0xA6
Sergunb 0:8918a71cdbe9 127 #define KSZ8851_REG_FCLWR 0xB0
Sergunb 0:8918a71cdbe9 128 #define KSZ8851_REG_FCHWR 0xB2
Sergunb 0:8918a71cdbe9 129 #define KSZ8851_REG_FCOWR 0xB4
Sergunb 0:8918a71cdbe9 130 #define KSZ8851_REG_CIDER 0xC0
Sergunb 0:8918a71cdbe9 131 #define KSZ8851_REG_CGCR 0xC6
Sergunb 0:8918a71cdbe9 132 #define KSZ8851_REG_IACR 0xC8
Sergunb 0:8918a71cdbe9 133 #define KSZ8851_REG_IADLR 0xD0
Sergunb 0:8918a71cdbe9 134 #define KSZ8851_REG_IADHR 0xD2
Sergunb 0:8918a71cdbe9 135 #define KSZ8851_REG_PMECR 0xD4
Sergunb 0:8918a71cdbe9 136 #define KSZ8851_REG_GSWUTR 0xD6
Sergunb 0:8918a71cdbe9 137 #define KSZ8851_REG_PHYRR 0xD8
Sergunb 0:8918a71cdbe9 138 #define KSZ8851_REG_P1MBCR 0xE4
Sergunb 0:8918a71cdbe9 139 #define KSZ8851_REG_P1MBSR 0xE6
Sergunb 0:8918a71cdbe9 140 #define KSZ8851_REG_PHY1ILR 0xE8
Sergunb 0:8918a71cdbe9 141 #define KSZ8851_REG_PHY1IHR 0xEA
Sergunb 0:8918a71cdbe9 142 #define KSZ8851_REG_P1ANAR 0xEC
Sergunb 0:8918a71cdbe9 143 #define KSZ8851_REG_P1ANLPR 0xEE
Sergunb 0:8918a71cdbe9 144 #define KSZ8851_REG_P1SCLMD 0xF4
Sergunb 0:8918a71cdbe9 145 #define KSZ8851_REG_P1CR 0xF6
Sergunb 0:8918a71cdbe9 146 #define KSZ8851_REG_P1SR 0xF8
Sergunb 0:8918a71cdbe9 147
Sergunb 0:8918a71cdbe9 148 //CCR register
Sergunb 0:8918a71cdbe9 149 #define CCR_BUS_ENDIAN_MODE 0x0400
Sergunb 0:8918a71cdbe9 150 #define CCR_EEPROM_PRESENCE 0x0200
Sergunb 0:8918a71cdbe9 151 #define CCR_SPI_MODE 0x0100
Sergunb 0:8918a71cdbe9 152 #define CCR_8_BIT_DATA_BUS 0x0080
Sergunb 0:8918a71cdbe9 153 #define CCR_16_BIT_DATA_BUS 0x0040
Sergunb 0:8918a71cdbe9 154 #define CCR_32_BIT_DATA_BUS 0x0020
Sergunb 0:8918a71cdbe9 155 #define CCR_BUS_SHARED_MODE 0x0010
Sergunb 0:8918a71cdbe9 156 #define CCR_128_PIN_PACKAGE 0x0008
Sergunb 0:8918a71cdbe9 157 #define CCR_48_PIN_PACKAGE 0x0002
Sergunb 0:8918a71cdbe9 158 #define CCR_32_PIN_PACKAGE 0x0001
Sergunb 0:8918a71cdbe9 159
Sergunb 0:8918a71cdbe9 160 //OBCR register
Sergunb 0:8918a71cdbe9 161 #define OBCR_OUT_DRIVE_STRENGTH 0x0040
Sergunb 0:8918a71cdbe9 162 #define OBCR_SPI_SO_DELAY2 0x0020
Sergunb 0:8918a71cdbe9 163 #define OBCR_SPI_SO_DELAY1 0x0010
Sergunb 0:8918a71cdbe9 164 #define OBCR_SPI_SO_DELAY0 0x0008
Sergunb 0:8918a71cdbe9 165 #define OBCR_BUS_CLOCK_SEL 0x0004
Sergunb 0:8918a71cdbe9 166 #define OBCR_BUS_CLOCK_DIV1 0x0002
Sergunb 0:8918a71cdbe9 167 #define OBCR_BUS_CLOCK_DIV0 0x0001
Sergunb 0:8918a71cdbe9 168
Sergunb 0:8918a71cdbe9 169 //EEPCR register
Sergunb 0:8918a71cdbe9 170 #define EEPCR_EESA 0x0010
Sergunb 0:8918a71cdbe9 171 #define EEPCR_EESB 0x0008
Sergunb 0:8918a71cdbe9 172 #define EEPCR_EECB2 0x0004
Sergunb 0:8918a71cdbe9 173 #define EEPCR_EECB1 0x0002
Sergunb 0:8918a71cdbe9 174 #define EEPCR_EECB0 0x0001
Sergunb 0:8918a71cdbe9 175
Sergunb 0:8918a71cdbe9 176 //MBIR register
Sergunb 0:8918a71cdbe9 177 #define MBIR_TXMBF 0x1000
Sergunb 0:8918a71cdbe9 178 #define MBIR_TXMBFA 0x0800
Sergunb 0:8918a71cdbe9 179 #define MBIR_TXMBFC2 0x0400
Sergunb 0:8918a71cdbe9 180 #define MBIR_TXMBFC1 0x0200
Sergunb 0:8918a71cdbe9 181 #define MBIR_TXMBFC0 0x0100
Sergunb 0:8918a71cdbe9 182 #define MBIR_RXMBF 0x0010
Sergunb 0:8918a71cdbe9 183 #define MBIR_RXMBFA 0x0008
Sergunb 0:8918a71cdbe9 184 #define MBIR_RXMBFC2 0x0004
Sergunb 0:8918a71cdbe9 185 #define MBIR_RXMBFC1 0x0002
Sergunb 0:8918a71cdbe9 186 #define MBIR_RXMBFC0 0x0001
Sergunb 0:8918a71cdbe9 187
Sergunb 0:8918a71cdbe9 188 //GRR register
Sergunb 0:8918a71cdbe9 189 #define GRR_QMU_MODULE_SOFT_RST 0x0002
Sergunb 0:8918a71cdbe9 190 #define GRR_GLOBAL_SOFT_RST 0x0001
Sergunb 0:8918a71cdbe9 191
Sergunb 0:8918a71cdbe9 192 //WFCR register
Sergunb 0:8918a71cdbe9 193 #define WFCR_MPRXE 0x0080
Sergunb 0:8918a71cdbe9 194 #define WFCR_WF3E 0x0008
Sergunb 0:8918a71cdbe9 195 #define WFCR_WF2E 0x0004
Sergunb 0:8918a71cdbe9 196 #define WFCR_WF1E 0x0002
Sergunb 0:8918a71cdbe9 197 #define WFCR_WF0E 0x0001
Sergunb 0:8918a71cdbe9 198
Sergunb 0:8918a71cdbe9 199 //TXCR register
Sergunb 0:8918a71cdbe9 200 #define TXCR_TCGICMP 0x0100
Sergunb 0:8918a71cdbe9 201 #define TXCR_TCGUDP 0x0080
Sergunb 0:8918a71cdbe9 202 #define TXCR_TCGTCP 0x0040
Sergunb 0:8918a71cdbe9 203 #define TXCR_TCGIP 0x0020
Sergunb 0:8918a71cdbe9 204 #define TXCR_FTXQ 0x0010
Sergunb 0:8918a71cdbe9 205 #define TXCR_TXFCE 0x0008
Sergunb 0:8918a71cdbe9 206 #define TXCR_TXPE 0x0004
Sergunb 0:8918a71cdbe9 207 #define TXCR_TXCE 0x0002
Sergunb 0:8918a71cdbe9 208 #define TXCR_TXE 0x0001
Sergunb 0:8918a71cdbe9 209
Sergunb 0:8918a71cdbe9 210 //TXSR register
Sergunb 0:8918a71cdbe9 211 #define TXSR_TXLC 0x2000
Sergunb 0:8918a71cdbe9 212 #define TXSR_TXMC 0x1000
Sergunb 0:8918a71cdbe9 213 #define TXSR_TXFID5 0x0020
Sergunb 0:8918a71cdbe9 214 #define TXSR_TXFID4 0x0010
Sergunb 0:8918a71cdbe9 215 #define TXSR_TXFID3 0x0008
Sergunb 0:8918a71cdbe9 216 #define TXSR_TXFID2 0x0004
Sergunb 0:8918a71cdbe9 217 #define TXSR_TXFID1 0x0002
Sergunb 0:8918a71cdbe9 218 #define TXSR_TXFID0 0x0001
Sergunb 0:8918a71cdbe9 219
Sergunb 0:8918a71cdbe9 220 //RXCR1 register
Sergunb 0:8918a71cdbe9 221 #define RXCR1_FRXQ 0x8000
Sergunb 0:8918a71cdbe9 222 #define RXCR1_RXUDPFCC 0x4000
Sergunb 0:8918a71cdbe9 223 #define RXCR1_RXTCPFCC 0x2000
Sergunb 0:8918a71cdbe9 224 #define RXCR1_RXIPFCC 0x1000
Sergunb 0:8918a71cdbe9 225 #define RXCR1_RXPAFMA 0x0800
Sergunb 0:8918a71cdbe9 226 #define RXCR1_RXFCE 0x0400
Sergunb 0:8918a71cdbe9 227 #define RXCR1_RXEFE 0x0200
Sergunb 0:8918a71cdbe9 228 #define RXCR1_RXMAFMA 0x0100
Sergunb 0:8918a71cdbe9 229 #define RXCR1_RXBE 0x0080
Sergunb 0:8918a71cdbe9 230 #define RXCR1_RXME 0x0040
Sergunb 0:8918a71cdbe9 231 #define RXCR1_RXUE 0x0020
Sergunb 0:8918a71cdbe9 232 #define RXCR1_RXAE 0x0010
Sergunb 0:8918a71cdbe9 233 #define RXCR1_RXINVF 0x0002
Sergunb 0:8918a71cdbe9 234 #define RXCR1_RXE 0x0001
Sergunb 0:8918a71cdbe9 235
Sergunb 0:8918a71cdbe9 236 //RXCR2 register
Sergunb 0:8918a71cdbe9 237 #define RXCR2_SRDBL2 0x0080
Sergunb 0:8918a71cdbe9 238 #define RXCR2_SRDBL1 0x0040
Sergunb 0:8918a71cdbe9 239 #define RXCR2_SRDBL0 0x0020
Sergunb 0:8918a71cdbe9 240 #define RXCR2_IUFFP 0x0010
Sergunb 0:8918a71cdbe9 241 #define RXCR2_RXIUFCEZ 0x0008
Sergunb 0:8918a71cdbe9 242 #define RXCR2_UDPLFE 0x0004
Sergunb 0:8918a71cdbe9 243 #define RXCR2_RXICMPFCC 0x0002
Sergunb 0:8918a71cdbe9 244 #define RXCR2_RXSAF 0x0001
Sergunb 0:8918a71cdbe9 245
Sergunb 0:8918a71cdbe9 246 //TXMIR register
Sergunb 0:8918a71cdbe9 247 #define TXMIR_TXMA_MASK 0x1FFF
Sergunb 0:8918a71cdbe9 248
Sergunb 0:8918a71cdbe9 249 //RXFHSR register
Sergunb 0:8918a71cdbe9 250 #define RXFHSR_RXFV 0x8000
Sergunb 0:8918a71cdbe9 251 #define RXFHSR_RXICMPFCS 0x2000
Sergunb 0:8918a71cdbe9 252 #define RXFHSR_RXIPFCS 0x1000
Sergunb 0:8918a71cdbe9 253 #define RXFHSR_RXTCPFCS 0x0800
Sergunb 0:8918a71cdbe9 254 #define RXFHSR_RXUDPFCS 0x0400
Sergunb 0:8918a71cdbe9 255 #define RXFHSR_RXBF 0x0080
Sergunb 0:8918a71cdbe9 256 #define RXFHSR_RXMF 0x0040
Sergunb 0:8918a71cdbe9 257 #define RXFHSR_RXUF 0x0020
Sergunb 0:8918a71cdbe9 258 #define RXFHSR_RXMR 0x0010
Sergunb 0:8918a71cdbe9 259 #define RXFHSR_RXFT 0x0008
Sergunb 0:8918a71cdbe9 260 #define RXFHSR_RXFTL 0x0004
Sergunb 0:8918a71cdbe9 261 #define RXFHSR_RXRF 0x0002
Sergunb 0:8918a71cdbe9 262 #define RXFHSR_RXCE 0x0001
Sergunb 0:8918a71cdbe9 263
Sergunb 0:8918a71cdbe9 264 //RXFHBCR register
Sergunb 0:8918a71cdbe9 265 #define RXFHBCR_RXBC_MASK 0x0FFF
Sergunb 0:8918a71cdbe9 266
Sergunb 0:8918a71cdbe9 267 //TXQCR register
Sergunb 0:8918a71cdbe9 268 #define TXQCR_AETFE 0x0004
Sergunb 0:8918a71cdbe9 269 #define TXQCR_TXQMAM 0x0002
Sergunb 0:8918a71cdbe9 270 #define TXQCR_METFE 0x0001
Sergunb 0:8918a71cdbe9 271
Sergunb 0:8918a71cdbe9 272 //RXQCR register
Sergunb 0:8918a71cdbe9 273 #define RXQCR_RXDTTS 0x1000
Sergunb 0:8918a71cdbe9 274 #define RXQCR_RXDBCTS 0x0800
Sergunb 0:8918a71cdbe9 275 #define RXQCR_RXFCTS 0x0400
Sergunb 0:8918a71cdbe9 276 #define RXQCR_RXIPHTOE 0x0200
Sergunb 0:8918a71cdbe9 277 #define RXQCR_RXDTTE 0x0080
Sergunb 0:8918a71cdbe9 278 #define RXQCR_RXDBCTE 0x0040
Sergunb 0:8918a71cdbe9 279 #define RXQCR_RXFCTE 0x0020
Sergunb 0:8918a71cdbe9 280 #define RXQCR_ADRFE 0x0010
Sergunb 0:8918a71cdbe9 281 #define RXQCR_SDA 0x0008
Sergunb 0:8918a71cdbe9 282 #define RXQCR_RRXEF 0x0001
Sergunb 0:8918a71cdbe9 283
Sergunb 0:8918a71cdbe9 284 //TXFDPR register
Sergunb 0:8918a71cdbe9 285 #define TXFDPR_TXFPAI 0x4000
Sergunb 0:8918a71cdbe9 286
Sergunb 0:8918a71cdbe9 287 //RXFDPR register
Sergunb 0:8918a71cdbe9 288 #define RXFDPR_RXFPAI 0x4000
Sergunb 0:8918a71cdbe9 289
Sergunb 0:8918a71cdbe9 290 //IER register
Sergunb 0:8918a71cdbe9 291 #define IER_LCIE 0x8000
Sergunb 0:8918a71cdbe9 292 #define IER_TXIE 0x4000
Sergunb 0:8918a71cdbe9 293 #define IER_RXIE 0x2000
Sergunb 0:8918a71cdbe9 294 #define IER_RXOIE 0x0800
Sergunb 0:8918a71cdbe9 295 #define IER_TXPSIE 0x0200
Sergunb 0:8918a71cdbe9 296 #define IER_RXPSIE 0x0100
Sergunb 0:8918a71cdbe9 297 #define IER_TXSAIE 0x0040
Sergunb 0:8918a71cdbe9 298 #define IER_RXWFDIE 0x0020
Sergunb 0:8918a71cdbe9 299 #define IER_RXMPDIE 0x0010
Sergunb 0:8918a71cdbe9 300 #define IER_LDIE 0x0008
Sergunb 0:8918a71cdbe9 301 #define IER_EDIE 0x0004
Sergunb 0:8918a71cdbe9 302 #define IER_SPIBEIE 0x0002
Sergunb 0:8918a71cdbe9 303 #define IER_DEDIE 0x0001
Sergunb 0:8918a71cdbe9 304
Sergunb 0:8918a71cdbe9 305 //ISR register
Sergunb 0:8918a71cdbe9 306 #define ISR_LCIS 0x8000
Sergunb 0:8918a71cdbe9 307 #define ISR_TXIS 0x4000
Sergunb 0:8918a71cdbe9 308 #define ISR_RXIS 0x2000
Sergunb 0:8918a71cdbe9 309 #define ISR_RXOIS 0x0800
Sergunb 0:8918a71cdbe9 310 #define ISR_TXPSIS 0x0200
Sergunb 0:8918a71cdbe9 311 #define ISR_RXPSIS 0x0100
Sergunb 0:8918a71cdbe9 312 #define ISR_TXSAIS 0x0040
Sergunb 0:8918a71cdbe9 313 #define ISR_RXWFDIS 0x0020
Sergunb 0:8918a71cdbe9 314 #define ISR_RXMPDIS 0x0010
Sergunb 0:8918a71cdbe9 315 #define ISR_LDIS 0x0008
Sergunb 0:8918a71cdbe9 316 #define ISR_EDIS 0x0004
Sergunb 0:8918a71cdbe9 317 #define ISR_SPIBEIS 0x0002
Sergunb 0:8918a71cdbe9 318
Sergunb 0:8918a71cdbe9 319 //CGCR register
Sergunb 0:8918a71cdbe9 320 #define CGCR_LEDSEL0 0x0200
Sergunb 0:8918a71cdbe9 321
Sergunb 0:8918a71cdbe9 322 //IACR register
Sergunb 0:8918a71cdbe9 323 #define IACR_READ_ENABLE 0x1000
Sergunb 0:8918a71cdbe9 324 #define IACR_TABLE_SELECT1 0x0800
Sergunb 0:8918a71cdbe9 325 #define IACR_TABLE_SELECT0 0x0400
Sergunb 0:8918a71cdbe9 326
Sergunb 0:8918a71cdbe9 327 //PMECR register
Sergunb 0:8918a71cdbe9 328 #define PMECR_PME_DELAY_EN 0x4000
Sergunb 0:8918a71cdbe9 329 #define PMECR_PME_POLARITY 0x1000
Sergunb 0:8918a71cdbe9 330 #define PMECR_PME_WUP_FRAME_EN 0x0800
Sergunb 0:8918a71cdbe9 331 #define PMECR_PME_MAGIC_EN 0x0400
Sergunb 0:8918a71cdbe9 332 #define PMECR_PME_LINK_UP_EN 0x0200
Sergunb 0:8918a71cdbe9 333 #define PMECR_PME_ENERGY_EN 0x0100
Sergunb 0:8918a71cdbe9 334 #define PMECR_AUTO_WUP_EN 0x0080
Sergunb 0:8918a71cdbe9 335 #define PMECR_WUP_NORMAL_OP_MODE 0x0040
Sergunb 0:8918a71cdbe9 336 #define PMECR_WUP_FROM_WUP_FRAME 0x0020
Sergunb 0:8918a71cdbe9 337 #define PMECR_WUP_FROM_MAGIC 0x0010
Sergunb 0:8918a71cdbe9 338 #define PMECR_WUP_FROM_LINK_UP 0x0008
Sergunb 0:8918a71cdbe9 339 #define PMECR_WUP_FROM_ENERGY 0x0004
Sergunb 0:8918a71cdbe9 340 #define PMECR_PWR_MODE1 0x0002
Sergunb 0:8918a71cdbe9 341 #define PMECR_PWR_MODE0 0x0001
Sergunb 0:8918a71cdbe9 342
Sergunb 0:8918a71cdbe9 343 //PHYRR register
Sergunb 0:8918a71cdbe9 344 #define PHYRR_PHY_RESET 0x0001
Sergunb 0:8918a71cdbe9 345
Sergunb 0:8918a71cdbe9 346 //P1MBCR register
Sergunb 0:8918a71cdbe9 347 #define P1MBCR_LOCAL_LOOPBACK 0x4000
Sergunb 0:8918a71cdbe9 348 #define P1MBCR_FORCE_100 0x2000
Sergunb 0:8918a71cdbe9 349 #define P1MBCR_AN_ENABLE 0x1000
Sergunb 0:8918a71cdbe9 350 #define P1MBCR_RESTART_AN 0x0200
Sergunb 0:8918a71cdbe9 351 #define P1MBCR_FORCE_FULL_DUPLEX 0x0100
Sergunb 0:8918a71cdbe9 352 #define P1MBCR_HP_MDIX 0x0020
Sergunb 0:8918a71cdbe9 353 #define P1MBCR_FORCE_MDIX 0x0010
Sergunb 0:8918a71cdbe9 354 #define P1MBCR_DISABLE_MDIX 0x0008
Sergunb 0:8918a71cdbe9 355 #define P1MBCR_DISABLE_TRANSMIT 0x0002
Sergunb 0:8918a71cdbe9 356 #define P1MBCR_DISABLE_LED 0x0001
Sergunb 0:8918a71cdbe9 357
Sergunb 0:8918a71cdbe9 358 //P1MBSR register
Sergunb 0:8918a71cdbe9 359 #define P1MBSR_T4_CAPABLE 0x8000
Sergunb 0:8918a71cdbe9 360 #define P1MBSR_100_FD_CAPABLE 0x4000
Sergunb 0:8918a71cdbe9 361 #define P1MBSR_100_CAPABLE 0x2000
Sergunb 0:8918a71cdbe9 362 #define P1MBSR_10_FD_CAPABLE 0x1000
Sergunb 0:8918a71cdbe9 363 #define P1MBSR_10_CAPABLE 0x0800
Sergunb 0:8918a71cdbe9 364 #define P1MBSR_PREAMBLE_SUPPR 0x0040
Sergunb 0:8918a71cdbe9 365 #define P1MBSR_AN_COMPLETE 0x0020
Sergunb 0:8918a71cdbe9 366 #define P1MBSR_AN_CAPABLE 0x0008
Sergunb 0:8918a71cdbe9 367 #define P1MBSR_LINK_STATUS 0x0004
Sergunb 0:8918a71cdbe9 368 #define P1MBSR_JABBER_TEST 0x0002
Sergunb 0:8918a71cdbe9 369 #define P1MBSR_EXTENDED_CAPABLE 0x0001
Sergunb 0:8918a71cdbe9 370
Sergunb 0:8918a71cdbe9 371 //P1ANAR register
Sergunb 0:8918a71cdbe9 372 #define P1ANAR_NEXT_PAGE 0x8000
Sergunb 0:8918a71cdbe9 373 #define P1ANAR_REMOTE_FAULT 0x2000
Sergunb 0:8918a71cdbe9 374 #define P1ANAR_ADV_PAUSE 0x0400
Sergunb 0:8918a71cdbe9 375 #define P1ANAR_ADV_100_FD 0x0100
Sergunb 0:8918a71cdbe9 376 #define P1ANAR_ADV_100 0x0080
Sergunb 0:8918a71cdbe9 377 #define P1ANAR_ADV_10_FD 0x0040
Sergunb 0:8918a71cdbe9 378 #define P1ANAR_ADV_10 0x0020
Sergunb 0:8918a71cdbe9 379 #define P1ANAR_SELECTOR_FIELD4 0x0010
Sergunb 0:8918a71cdbe9 380 #define P1ANAR_SELECTOR_FIELD3 0x0008
Sergunb 0:8918a71cdbe9 381 #define P1ANAR_SELECTOR_FIELD2 0x0004
Sergunb 0:8918a71cdbe9 382 #define P1ANAR_SELECTOR_FIELD1 0x0002
Sergunb 0:8918a71cdbe9 383 #define P1ANAR_SELECTOR_FIELD0 0x0001
Sergunb 0:8918a71cdbe9 384
Sergunb 0:8918a71cdbe9 385 //P1ANLPR register
Sergunb 0:8918a71cdbe9 386 #define P1ANLPR_NEXT_PAGE 0x8000
Sergunb 0:8918a71cdbe9 387 #define P1ANLPR_LP_ACK 0x4000
Sergunb 0:8918a71cdbe9 388 #define P1ANLPR_REMOTE_FAULT 0x2000
Sergunb 0:8918a71cdbe9 389 #define P1ANLPR_ADV_PAUSE 0x0400
Sergunb 0:8918a71cdbe9 390 #define P1ANLPR_ADV_100_FD 0x0100
Sergunb 0:8918a71cdbe9 391 #define P1ANLPR_ADV_100 0x0080
Sergunb 0:8918a71cdbe9 392 #define P1ANLPR_ADV_10_FD 0x0040
Sergunb 0:8918a71cdbe9 393 #define P1ANLPR_ADV_10 0x0020
Sergunb 0:8918a71cdbe9 394
Sergunb 0:8918a71cdbe9 395 //P1SCLMD register
Sergunb 0:8918a71cdbe9 396 #define P1SCLMD_VCT_RESULT1 0x4000
Sergunb 0:8918a71cdbe9 397 #define P1SCLMD_VCT_RESULT0 0x2000
Sergunb 0:8918a71cdbe9 398 #define P1SCLMD_VCT_EN 0x1000
Sergunb 0:8918a71cdbe9 399 #define P1SCLMD_FORCE_LNK 0x0800
Sergunb 0:8918a71cdbe9 400 #define P1SCLMD_REMOTE_LOOPBACK 0x0200
Sergunb 0:8918a71cdbe9 401
Sergunb 0:8918a71cdbe9 402 //P1CR register
Sergunb 0:8918a71cdbe9 403 #define P1CR_LED_OFF 0x8000
Sergunb 0:8918a71cdbe9 404 #define P1CR_TX_DISABLE 0x4000
Sergunb 0:8918a71cdbe9 405 #define P1CR_RESTART_AN 0x2000
Sergunb 0:8918a71cdbe9 406 #define P1CR_DISABLE_AUTO_MDIX 0x0400
Sergunb 0:8918a71cdbe9 407 #define P1CR_FORCE_MDIX 0x0200
Sergunb 0:8918a71cdbe9 408 #define P1CR_AN_ENABLE 0x0080
Sergunb 0:8918a71cdbe9 409 #define P1CR_FORCE_SPEED 0x0040
Sergunb 0:8918a71cdbe9 410 #define P1CR_FORCE_DUPLEX 0x0020
Sergunb 0:8918a71cdbe9 411 #define P1CR_ADV_PAUSE 0x0010
Sergunb 0:8918a71cdbe9 412 #define P1CR_ADV_100_FD 0x0008
Sergunb 0:8918a71cdbe9 413 #define P1CR_ADV_100 0x0004
Sergunb 0:8918a71cdbe9 414 #define P1CR_ADV_10_FD 0x0002
Sergunb 0:8918a71cdbe9 415 #define P1CR_ADV_10 0x0001
Sergunb 0:8918a71cdbe9 416
Sergunb 0:8918a71cdbe9 417 //P1SR register
Sergunb 0:8918a71cdbe9 418 #define P1SR_HP_MDIX 0x8000
Sergunb 0:8918a71cdbe9 419 #define P1SR_REVERSED_POLARITY 0x2000
Sergunb 0:8918a71cdbe9 420 #define P1SR_OPERATION_SPEED 0x0400
Sergunb 0:8918a71cdbe9 421 #define P1SR_OPERATION_DUPLEX 0x0200
Sergunb 0:8918a71cdbe9 422 #define P1SR_MDIX_STATUS 0x0080
Sergunb 0:8918a71cdbe9 423 #define P1SR_AN_DONE 0x0040
Sergunb 0:8918a71cdbe9 424 #define P1SR_LINK_GOOD 0x0020
Sergunb 0:8918a71cdbe9 425 #define P1SR_PARTNER_ADV_PAUSE 0x0010
Sergunb 0:8918a71cdbe9 426 #define P1SR_PARTNER_ADV_100_FD 0x0008
Sergunb 0:8918a71cdbe9 427 #define P1SR_PARTNER_ADV_100 0x0004
Sergunb 0:8918a71cdbe9 428 #define P1SR_PARTNER_ADV_10_FD 0x0002
Sergunb 0:8918a71cdbe9 429 #define P1SR_PARTNER_ADV_10 0x0001
Sergunb 0:8918a71cdbe9 430
Sergunb 0:8918a71cdbe9 431 //Transmit control word
Sergunb 0:8918a71cdbe9 432 #define TX_CTRL_TXIC 0x8000
Sergunb 0:8918a71cdbe9 433 #define TX_CTRL_TXFID 0x003F
Sergunb 0:8918a71cdbe9 434
Sergunb 0:8918a71cdbe9 435
Sergunb 0:8918a71cdbe9 436 /**
Sergunb 0:8918a71cdbe9 437 * @brief TX packet header
Sergunb 0:8918a71cdbe9 438 **/
Sergunb 0:8918a71cdbe9 439
Sergunb 0:8918a71cdbe9 440 typedef __start_packed struct
Sergunb 0:8918a71cdbe9 441 {
Sergunb 0:8918a71cdbe9 442 uint16_t controlWord;
Sergunb 0:8918a71cdbe9 443 uint16_t byteCount;
Sergunb 0:8918a71cdbe9 444 } __end_packed Ksz8851TxHeader;
Sergunb 0:8918a71cdbe9 445
Sergunb 0:8918a71cdbe9 446
Sergunb 0:8918a71cdbe9 447 /**
Sergunb 0:8918a71cdbe9 448 * @brief RX packet header
Sergunb 0:8918a71cdbe9 449 **/
Sergunb 0:8918a71cdbe9 450
Sergunb 0:8918a71cdbe9 451 typedef __start_packed struct
Sergunb 0:8918a71cdbe9 452 {
Sergunb 0:8918a71cdbe9 453 uint16_t statusWord;
Sergunb 0:8918a71cdbe9 454 uint16_t byteCount;
Sergunb 0:8918a71cdbe9 455 } __end_packed Ksz8851RxHeader;
Sergunb 0:8918a71cdbe9 456
Sergunb 0:8918a71cdbe9 457
Sergunb 0:8918a71cdbe9 458 /**
Sergunb 0:8918a71cdbe9 459 * @brief KSZ8851 driver context
Sergunb 0:8918a71cdbe9 460 **/
Sergunb 0:8918a71cdbe9 461
Sergunb 0:8918a71cdbe9 462 typedef struct
Sergunb 0:8918a71cdbe9 463 {
Sergunb 0:8918a71cdbe9 464 uint_t frameId; ///<Identify a frame and its associated status
Sergunb 0:8918a71cdbe9 465 uint8_t *txBuffer; ///<Transmit buffer
Sergunb 0:8918a71cdbe9 466 uint8_t *rxBuffer; ///<Receive buffer
Sergunb 0:8918a71cdbe9 467 } Ksz8851Context;
Sergunb 0:8918a71cdbe9 468
Sergunb 0:8918a71cdbe9 469
Sergunb 0:8918a71cdbe9 470 //KSZ8851 driver
Sergunb 0:8918a71cdbe9 471 extern const NicDriver ksz8851Driver;
Sergunb 0:8918a71cdbe9 472
Sergunb 0:8918a71cdbe9 473 //KSZ8851 related functions
Sergunb 0:8918a71cdbe9 474 error_t ksz8851Init(NetInterface *interface);
Sergunb 0:8918a71cdbe9 475
Sergunb 0:8918a71cdbe9 476 void ksz8851Tick(NetInterface *interface);
Sergunb 0:8918a71cdbe9 477
Sergunb 0:8918a71cdbe9 478 void ksz8851EnableIrq(NetInterface *interface);
Sergunb 0:8918a71cdbe9 479 void ksz8851DisableIrq(NetInterface *interface);
Sergunb 0:8918a71cdbe9 480 bool_t ksz8851IrqHandler(NetInterface *interface);
Sergunb 0:8918a71cdbe9 481 void ksz8851EventHandler(NetInterface *interface);
Sergunb 0:8918a71cdbe9 482
Sergunb 0:8918a71cdbe9 483 error_t ksz8851SendPacket(NetInterface *interface,
Sergunb 0:8918a71cdbe9 484 const NetBuffer *buffer, size_t offset);
Sergunb 0:8918a71cdbe9 485
Sergunb 0:8918a71cdbe9 486 error_t ksz8851ReceivePacket(NetInterface *interface);
Sergunb 0:8918a71cdbe9 487
Sergunb 0:8918a71cdbe9 488 error_t ksz8851SetMulticastFilter(NetInterface *interface);
Sergunb 0:8918a71cdbe9 489
Sergunb 0:8918a71cdbe9 490 void ksz8851WriteReg(NetInterface *interface, uint8_t address, uint16_t data);
Sergunb 0:8918a71cdbe9 491 uint16_t ksz8851ReadReg(NetInterface *interface, uint8_t address);
Sergunb 0:8918a71cdbe9 492
Sergunb 0:8918a71cdbe9 493 void ksz8851WriteFifo(NetInterface *interface, const uint8_t *data, size_t length);
Sergunb 0:8918a71cdbe9 494 void ksz8851ReadFifo(NetInterface *interface, uint8_t *data, size_t length);
Sergunb 0:8918a71cdbe9 495
Sergunb 0:8918a71cdbe9 496 void ksz8851SetBit(NetInterface *interface, uint8_t address, uint16_t mask);
Sergunb 0:8918a71cdbe9 497 void ksz8851ClearBit(NetInterface *interface, uint8_t address, uint16_t mask);
Sergunb 0:8918a71cdbe9 498
Sergunb 0:8918a71cdbe9 499 uint32_t ksz8851CalcCrc(const void *data, size_t length);
Sergunb 0:8918a71cdbe9 500
Sergunb 0:8918a71cdbe9 501 void ksz8851DumpReg(NetInterface *interface);
Sergunb 0:8918a71cdbe9 502
Sergunb 0:8918a71cdbe9 503 #endif
Sergunb 0:8918a71cdbe9 504