Flotsam / mbed-modifed

Dependents:   EEPROMWrite Full-Project

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Thu Sep 18 14:00:17 2014 +0100
Revision:
324:406fd2029f23
Synchronized with git revision a73f28e6fbca9559fbed2726410eeb4c0534a4a5

Full URL: https://github.com/mbedmicro/mbed/commit/a73f28e6fbca9559fbed2726410eeb4c0534a4a5/

Extended #476, which does not break ethernet for K64F

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 324:406fd2029f23 1 /*
mbed_official 324:406fd2029f23 2 * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
mbed_official 324:406fd2029f23 3 * All rights reserved.
mbed_official 324:406fd2029f23 4 *
mbed_official 324:406fd2029f23 5 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 324:406fd2029f23 6 * are permitted provided that the following conditions are met:
mbed_official 324:406fd2029f23 7 *
mbed_official 324:406fd2029f23 8 * o Redistributions of source code must retain the above copyright notice, this list
mbed_official 324:406fd2029f23 9 * of conditions and the following disclaimer.
mbed_official 324:406fd2029f23 10 *
mbed_official 324:406fd2029f23 11 * o Redistributions in binary form must reproduce the above copyright notice, this
mbed_official 324:406fd2029f23 12 * list of conditions and the following disclaimer in the documentation and/or
mbed_official 324:406fd2029f23 13 * other materials provided with the distribution.
mbed_official 324:406fd2029f23 14 *
mbed_official 324:406fd2029f23 15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
mbed_official 324:406fd2029f23 16 * contributors may be used to endorse or promote products derived from this
mbed_official 324:406fd2029f23 17 * software without specific prior written permission.
mbed_official 324:406fd2029f23 18 *
mbed_official 324:406fd2029f23 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
mbed_official 324:406fd2029f23 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
mbed_official 324:406fd2029f23 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 324:406fd2029f23 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
mbed_official 324:406fd2029f23 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
mbed_official 324:406fd2029f23 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
mbed_official 324:406fd2029f23 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
mbed_official 324:406fd2029f23 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
mbed_official 324:406fd2029f23 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
mbed_official 324:406fd2029f23 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 324:406fd2029f23 29 */
mbed_official 324:406fd2029f23 30
mbed_official 324:406fd2029f23 31 #ifndef __FSL_ENET_RTCS_ADAPTOR_H__
mbed_official 324:406fd2029f23 32 #define __FSL_ENET_RTCS_ADAPTOR_H__
mbed_official 324:406fd2029f23 33
mbed_official 324:406fd2029f23 34 #include "fsl_enet_hal.h"
mbed_official 324:406fd2029f23 35
mbed_official 324:406fd2029f23 36 #ifndef MBED_NO_ENET
mbed_official 324:406fd2029f23 37
mbed_official 324:406fd2029f23 38 #ifdef FSL_RTOS_MQX
mbed_official 324:406fd2029f23 39 #include "rtcs.h"
mbed_official 324:406fd2029f23 40 #include "pcb.h"
mbed_official 324:406fd2029f23 41 #endif
mbed_official 324:406fd2029f23 42 /*!
mbed_official 324:406fd2029f23 43 * @addtogroup enet_rtcs_adaptor
mbed_official 324:406fd2029f23 44 * @{
mbed_official 324:406fd2029f23 45 */
mbed_official 324:406fd2029f23 46
mbed_official 324:406fd2029f23 47 /*******************************************************************************
mbed_official 324:406fd2029f23 48 * Definitions
mbed_official 324:406fd2029f23 49 ******************************************************************************/
mbed_official 324:406fd2029f23 50 /*! @brief Definitions of the task parameter*/
mbed_official 324:406fd2029f23 51 #ifndef FSL_RTOS_MQX
mbed_official 324:406fd2029f23 52 extern unsigned long _RTCSTASK_priority;
mbed_official 324:406fd2029f23 53 #endif
mbed_official 324:406fd2029f23 54 #define ENET_RECEIVE_TASK_PRIO (1)
mbed_official 324:406fd2029f23 55 #define ENET_TASK_STACK_SIZE (800)
mbed_official 324:406fd2029f23 56 #define ENET_PCB_NUM (16)
mbed_official 324:406fd2029f23 57
mbed_official 324:406fd2029f23 58 /*! @brief Definitions of the configuration parameter*/
mbed_official 324:406fd2029f23 59 #define ENET_RXBD_NUM (8)
mbed_official 324:406fd2029f23 60 #define ENET_TXBD_NUM (4)
mbed_official 324:406fd2029f23 61 #define ENET_EXTRXBD_NUM (4)
mbed_official 324:406fd2029f23 62 #define ENET_RXBuff_SIZE (kEnetMaxFrameSize)
mbed_official 324:406fd2029f23 63 #define ENET_TXBuff_SIZE (kEnetMaxFrameSize)
mbed_official 324:406fd2029f23 64 #define ENET_RXRTCSBUFF_NUM (8)
mbed_official 324:406fd2029f23 65 #define ENET_RX_BUFFER_ALIGNMENT (16)
mbed_official 324:406fd2029f23 66 #define ENET_TX_BUFFER_ALIGNMENT (16)
mbed_official 324:406fd2029f23 67 #define ENET_BD_ALIGNMENT (16)
mbed_official 324:406fd2029f23 68 #define ENET_RXBuffSizeAlign(n) ENET_ALIGN(n, ENET_RX_BUFFER_ALIGNMENT)
mbed_official 324:406fd2029f23 69 #define ENET_TXBuffSizeAlign(n) ENET_ALIGN(n, ENET_TX_BUFFER_ALIGNMENT)
mbed_official 324:406fd2029f23 70 #define ENET_MII_CLOCK (2500000L)
mbed_official 324:406fd2029f23 71 #if FSL_FEATURE_ENET_SUPPORT_PTP
mbed_official 324:406fd2029f23 72 #define ENET_PTP_TXTS_RING_LEN (25)
mbed_official 324:406fd2029f23 73 #define ENET_PTP_RXTS_RING_LEN (25)
mbed_official 324:406fd2029f23 74 #endif
mbed_official 324:406fd2029f23 75
mbed_official 324:406fd2029f23 76 /*! @brief Definitions of the error codes */
mbed_official 324:406fd2029f23 77 #define ENET_OK (0)
mbed_official 324:406fd2029f23 78 #define ENET_ERROR (0xff) /* General ENET error */
mbed_official 324:406fd2029f23 79
mbed_official 324:406fd2029f23 80 #define ENETERR_INVALID_DEVICE (kStatus_ENET_InvalidDevice) /* Device number out of range */
mbed_official 324:406fd2029f23 81 #define ENETERR_INIT_DEVICE (kStatus_ENET_Initialized) /* Device already initialized */
mbed_official 324:406fd2029f23 82
mbed_official 324:406fd2029f23 83 /*! @brief Definitions of the ENET protocol parameter*/
mbed_official 324:406fd2029f23 84 #define ENETPROT_IP 0x0800
mbed_official 324:406fd2029f23 85 #define ENETPROT_ARP 0x0806
mbed_official 324:406fd2029f23 86 #define ENETPROT_8021Q 0x8100
mbed_official 324:406fd2029f23 87 #define ENETPROT_IP6 0x86DD
mbed_official 324:406fd2029f23 88 #define ENETPROT_ETHERNET 0x88F7
mbed_official 324:406fd2029f23 89 #define ENET_OPT_8023 0x0001
mbed_official 324:406fd2029f23 90 #define ENET_OPT_8021QTAG 0x0002
mbed_official 324:406fd2029f23 91 #define ENET_SETOPT_8021QPRIO(p) (ENET_OPT_8021QTAG | (((uint_32)(p) & 0x7) << 2))
mbed_official 324:406fd2029f23 92 #define ENET_GETOPT_8021QPRIO(f) ((((unsigned int)f) >> 2) & 0x7)
mbed_official 324:406fd2029f23 93
mbed_official 324:406fd2029f23 94 /*! @brief Definitions of the ENET option macro*/
mbed_official 324:406fd2029f23 95 #define ENET_OPTION_HW_TX_IP_CHECKSUM 0x00001000
mbed_official 324:406fd2029f23 96 #define ENET_OPTION_HW_TX_PROTOCOL_CHECKSUM 0x00002000
mbed_official 324:406fd2029f23 97 #define ENET_OPTION_HW_RX_IP_CHECKSUM 0x00004000
mbed_official 324:406fd2029f23 98 #define ENET_OPTION_HW_RX_PROTOCOL_CHECKSUM 0x00008000
mbed_official 324:406fd2029f23 99 #define ENET_OPTION_HW_RX_MAC_ERR 0x00010000
mbed_official 324:406fd2029f23 100
mbed_official 324:406fd2029f23 101 /*! @brief Definitions of the ENET default Mac*/
mbed_official 324:406fd2029f23 102 #define ENET_DEFAULT_MAC_ADD { 0x00, 0x00, 0x5E, 0, 0, 0 }
mbed_official 324:406fd2029f23 103 #define PCB_MINIMUM_SIZE (sizeof(PCB2))
mbed_official 324:406fd2029f23 104 #define PCB_free(pcb_ptr) ((pcb_ptr)->FREE(pcb_ptr))
mbed_official 324:406fd2029f23 105
mbed_official 324:406fd2029f23 106 /*! @brief Definitions of the macro for byte-swap*/
mbed_official 324:406fd2029f23 107 #if SYSTEM_LITTLE_ENDIAN
mbed_official 324:406fd2029f23 108 #define RTCS_HTONS(n) BSWAP_16(n)
mbed_official 324:406fd2029f23 109 #define RTCS_HTONL(n) BSWAP_32(n)
mbed_official 324:406fd2029f23 110 #define RTCS_NTOHS(n) BSWAP_16(n)
mbed_official 324:406fd2029f23 111 #define RTCS_NTOHL(n) BSWAP_32(n)
mbed_official 324:406fd2029f23 112 #else
mbed_official 324:406fd2029f23 113 #define RTCS_HTONS(n) (n)
mbed_official 324:406fd2029f23 114 #define RTCS_HTONL(n) (n)
mbed_official 324:406fd2029f23 115 #define RTCS_NTOHS(n) (n)
mbed_official 324:406fd2029f23 116 #define RTCS_NTOHL(n) (n)
mbed_official 324:406fd2029f23 117 #endif
mbed_official 324:406fd2029f23 118
mbed_official 324:406fd2029f23 119 #ifndef FSL_RTOS_MQX
mbed_official 324:406fd2029f23 120 #define htonl(p,x) (((uint_8_ptr)(p))[0] = ((x) >> 24) & 0xFF, \
mbed_official 324:406fd2029f23 121 ((uint_8_ptr)(p))[1] = ((x) >> 16) & 0xFF, \
mbed_official 324:406fd2029f23 122 ((uint_8_ptr)(p))[2] = ((x) >> 8) & 0xFF, \
mbed_official 324:406fd2029f23 123 ((uint_8_ptr)(p))[3] = (x) & 0xFF, \
mbed_official 324:406fd2029f23 124 (x))
mbed_official 324:406fd2029f23 125
mbed_official 324:406fd2029f23 126 #define htons(p,x) (((uint_8_ptr)(p))[0] = ((x) >> 8) & 0xFF, \
mbed_official 324:406fd2029f23 127 ((uint_8_ptr)(p))[1] = (x) & 0xFF, \
mbed_official 324:406fd2029f23 128 (x))
mbed_official 324:406fd2029f23 129
mbed_official 324:406fd2029f23 130 #define htonc(p,x) (((uint_8_ptr)(p))[0] = (x) & 0xFF, \
mbed_official 324:406fd2029f23 131 (x))
mbed_official 324:406fd2029f23 132
mbed_official 324:406fd2029f23 133 #define ntohl(p) (\
mbed_official 324:406fd2029f23 134 (((uint_32)(((uint_8_ptr)(p))[0])) << 24) | \
mbed_official 324:406fd2029f23 135 (((uint_32)(((uint_8_ptr)(p))[1])) << 16) | \
mbed_official 324:406fd2029f23 136 (((uint_32)(((uint_8_ptr)(p))[2])) << 8) | \
mbed_official 324:406fd2029f23 137 ( (uint_32)(((uint_8_ptr)(p))[3])) \
mbed_official 324:406fd2029f23 138 )
mbed_official 324:406fd2029f23 139
mbed_official 324:406fd2029f23 140 #define ntohs(p) (\
mbed_official 324:406fd2029f23 141 (((uint_16)(((uint_8_ptr)(p))[0])) << 8) | \
mbed_official 324:406fd2029f23 142 ( (uint_16)(((uint_8_ptr)(p))[1])) \
mbed_official 324:406fd2029f23 143 )
mbed_official 324:406fd2029f23 144
mbed_official 324:406fd2029f23 145 #define ntohc(p) ((uint_8)(((uint_8_ptr)(p))[0]))
mbed_official 324:406fd2029f23 146 #endif
mbed_official 324:406fd2029f23 147 #define htone(p,x) ((p)[0] = (x)[0], \
mbed_official 324:406fd2029f23 148 (p)[1] = (x)[1], \
mbed_official 324:406fd2029f23 149 (p)[2] = (x)[2], \
mbed_official 324:406fd2029f23 150 (p)[3] = (x)[3], \
mbed_official 324:406fd2029f23 151 (p)[4] = (x)[4], \
mbed_official 324:406fd2029f23 152 (p)[5] = (x)[5] \
mbed_official 324:406fd2029f23 153 )
mbed_official 324:406fd2029f23 154
mbed_official 324:406fd2029f23 155 #define ntohe(p,x) ((x)[0] = (p)[0] & 0xFF, \
mbed_official 324:406fd2029f23 156 (x)[1] = (p)[1] & 0xFF, \
mbed_official 324:406fd2029f23 157 (x)[2] = (p)[2] & 0xFF, \
mbed_official 324:406fd2029f23 158 (x)[3] = (p)[3] & 0xFF, \
mbed_official 324:406fd2029f23 159 (x)[4] = (p)[4] & 0xFF, \
mbed_official 324:406fd2029f23 160 (x)[5] = (p)[5] & 0xFF \
mbed_official 324:406fd2029f23 161 )
mbed_official 324:406fd2029f23 162
mbed_official 324:406fd2029f23 163 /*! @brief Definitions of the add to queue*/
mbed_official 324:406fd2029f23 164 #define QUEUEADD(head,tail,pcb) \
mbed_official 324:406fd2029f23 165 if ((head) == NULL) { \
mbed_official 324:406fd2029f23 166 (head) = (pcb); \
mbed_official 324:406fd2029f23 167 } else { \
mbed_official 324:406fd2029f23 168 (tail)->PRIVATE = (pcb); \
mbed_official 324:406fd2029f23 169 } \
mbed_official 324:406fd2029f23 170 (tail) = (pcb); \
mbed_official 324:406fd2029f23 171 (pcb)->PRIVATE = NULL
mbed_official 324:406fd2029f23 172
mbed_official 324:406fd2029f23 173 /*! @brief Definitions of the get from queue*/
mbed_official 324:406fd2029f23 174 #define QUEUEGET(head,tail,pcb) \
mbed_official 324:406fd2029f23 175 (pcb) = (head); \
mbed_official 324:406fd2029f23 176 if (head) { \
mbed_official 324:406fd2029f23 177 (head) = (head)->PRIVATE; \
mbed_official 324:406fd2029f23 178 if ((head) == NULL) { \
mbed_official 324:406fd2029f23 179 (tail) = NULL; \
mbed_official 324:406fd2029f23 180 } \
mbed_official 324:406fd2029f23 181 }
mbed_official 324:406fd2029f23 182
mbed_official 324:406fd2029f23 183 /*! @brief Definition for ENET six-byte Mac type*/
mbed_official 324:406fd2029f23 184 typedef unsigned char _enet_address[6];
mbed_official 324:406fd2029f23 185
mbed_official 324:406fd2029f23 186 /*! @brief Definition of the IPCFG structure*/
mbed_official 324:406fd2029f23 187 typedef void * _enet_handle;
mbed_official 324:406fd2029f23 188
mbed_official 324:406fd2029f23 189 #ifndef FSL_RTOS_MQX
mbed_official 324:406fd2029f23 190 struct pcb;
mbed_official 324:406fd2029f23 191 typedef void (* PCB_FREE_FPTR)(struct pcb *);
mbed_official 324:406fd2029f23 192 #endif
mbed_official 324:406fd2029f23 193
mbed_official 324:406fd2029f23 194 /*! @brief Definition of the Ethernet packet header structure*/
mbed_official 324:406fd2029f23 195 typedef struct enet_header
mbed_official 324:406fd2029f23 196 {
mbed_official 324:406fd2029f23 197 _enet_address DEST; /*!< destination Mac address*/
mbed_official 324:406fd2029f23 198 _enet_address SOURCE; /*!< source Mac address*/
mbed_official 324:406fd2029f23 199 unsigned char TYPE[2]; /*!< protocol type*/
mbed_official 324:406fd2029f23 200 } ENET_HEADER, * ENET_HEADER_PTR;
mbed_official 324:406fd2029f23 201
mbed_official 324:406fd2029f23 202 #ifndef FSL_RTOS_MQX
mbed_official 324:406fd2029f23 203
mbed_official 324:406fd2029f23 204 /*! @brief Definition of the fragment PCB structure*/
mbed_official 324:406fd2029f23 205 typedef struct pcb_fragment
mbed_official 324:406fd2029f23 206 {
mbed_official 324:406fd2029f23 207 uint32_t LENGTH; /*!< Packet fragment length*/
mbed_official 324:406fd2029f23 208 unsigned char *FRAGMENT; /*!< brief Pointer to fragment*/
mbed_official 324:406fd2029f23 209 } PCB_FRAGMENT, * PCB_FRAGMENT_PTR;
mbed_official 324:406fd2029f23 210
mbed_official 324:406fd2029f23 211 /*! @brief Definition of the PCB structure for the RTCS adaptor*/
mbed_official 324:406fd2029f23 212 typedef struct pcb
mbed_official 324:406fd2029f23 213 {
mbed_official 324:406fd2029f23 214 PCB_FREE_FPTR FREE; /*!< Function that frees PCB*/
mbed_official 324:406fd2029f23 215 void *PRIVATE; /*!< Private PCB information*/
mbed_official 324:406fd2029f23 216 PCB_FRAGMENT FRAG[1]; /*!< Pointer to PCB fragment*/
mbed_official 324:406fd2029f23 217 } PCB, * PCB_PTR;
mbed_official 324:406fd2029f23 218
mbed_official 324:406fd2029f23 219 /*! @brief Definition of the two fragment PCB structure*/
mbed_official 324:406fd2029f23 220 typedef struct pcb2
mbed_official 324:406fd2029f23 221 {
mbed_official 324:406fd2029f23 222 PCB_FREE_FPTR FREE; /*!< Function that frees PCB*/
mbed_official 324:406fd2029f23 223 void *PRIVATE; /*!< Private PCB information*/
mbed_official 324:406fd2029f23 224 PCB_FRAGMENT FRAG[2]; /*!< Pointers to two PCB fragments*/
mbed_official 324:406fd2029f23 225 } PCB2, *PCB2_PTR;
mbed_official 324:406fd2029f23 226
mbed_official 324:406fd2029f23 227 #endif
mbed_official 324:406fd2029f23 228
mbed_official 324:406fd2029f23 229 /*! @brief Definition of the two fragment PCB structure*/
mbed_official 324:406fd2029f23 230 typedef struct pcb_queue
mbed_official 324:406fd2029f23 231 {
mbed_official 324:406fd2029f23 232 PCB *pcbHead; /*!< PCB buffer head*/
mbed_official 324:406fd2029f23 233 PCB *pcbTail; /*!< PCB buffer tail*/
mbed_official 324:406fd2029f23 234 }pcb_queue;
mbed_official 324:406fd2029f23 235
mbed_official 324:406fd2029f23 236 /*! @brief Definition of the ECB structure, which contains the protocol type and it's related service function*/
mbed_official 324:406fd2029f23 237 typedef struct ENETEcbStruct
mbed_official 324:406fd2029f23 238 {
mbed_official 324:406fd2029f23 239 uint16_t TYPE;
mbed_official 324:406fd2029f23 240 void (* SERVICE)(PCB_PTR, void *);
mbed_official 324:406fd2029f23 241 void *PRIVATE;
mbed_official 324:406fd2029f23 242 struct ENETEcbStruct *NEXT;
mbed_official 324:406fd2029f23 243 } enet_ecb_struct_t;
mbed_official 324:406fd2029f23 244
mbed_official 324:406fd2029f23 245 /*! @brief Definition of the 8022 header*/
mbed_official 324:406fd2029f23 246 typedef struct enet_8022_header
mbed_official 324:406fd2029f23 247 {
mbed_official 324:406fd2029f23 248 uint8_t dsap[1]; /*!< DSAP region*/
mbed_official 324:406fd2029f23 249 uint8_t ssap[1]; /*!< SSAP region*/
mbed_official 324:406fd2029f23 250 uint8_t command[1]; /*!< Command region*/
mbed_official 324:406fd2029f23 251 uint8_t oui[3]; /*!< OUI region*/
mbed_official 324:406fd2029f23 252 uint16_t type; /*!< type region*/
mbed_official 324:406fd2029f23 253 }enet_8022_header_t, *enet_8022_header_ptr;
mbed_official 324:406fd2029f23 254
mbed_official 324:406fd2029f23 255 /*! @brief Definition of the common status structure*/
mbed_official 324:406fd2029f23 256 typedef struct enet_commom_stats_struct {
mbed_official 324:406fd2029f23 257 uint32_t ST_RX_TOTAL; /*!< Total number of received packets*/
mbed_official 324:406fd2029f23 258 uint32_t ST_RX_MISSED; /*!< Number of missed packets*/
mbed_official 324:406fd2029f23 259 uint32_t ST_RX_DISCARDED; /*!< Discarded a protocol that was not recognized*/
mbed_official 324:406fd2029f23 260 uint32_t ST_RX_ERRORS; /*!< Discarded error during reception*/
mbed_official 324:406fd2029f23 261 uint32_t ST_TX_TOTAL; /*!< Total number of transmitted packets*/
mbed_official 324:406fd2029f23 262 uint32_t ST_TX_MISSED; /*!< Discarded transmit ring full*/
mbed_official 324:406fd2029f23 263 uint32_t ST_TX_DISCARDED; /*!< Discarded bad packet*/
mbed_official 324:406fd2029f23 264 uint32_t ST_TX_ERRORS; /*!< Error during transmission*/
mbed_official 324:406fd2029f23 265 } ENET_COMMON_STATS_STRUCT, * ENET_COMMON_STATS_STRUCT_PTR;
mbed_official 324:406fd2029f23 266
mbed_official 324:406fd2029f23 267 typedef struct enet_stats {
mbed_official 324:406fd2029f23 268 ENET_COMMON_STATS_STRUCT COMMON; /*!< Common status structure*/
mbed_official 324:406fd2029f23 269 uint32_t ST_RX_ALIGN; /*!< Frame Alignment error*/
mbed_official 324:406fd2029f23 270 uint32_t ST_RX_FCS; /*!< CRC error */
mbed_official 324:406fd2029f23 271 uint32_t ST_RX_RUNT; /*!< Runt packet received */
mbed_official 324:406fd2029f23 272 uint32_t ST_RX_GIANT; /*!< Giant packet received*/
mbed_official 324:406fd2029f23 273 uint32_t ST_RX_LATECOLL; /*!< Late collision */
mbed_official 324:406fd2029f23 274 uint32_t ST_RX_OVERRUN; /*!< DMA overrun*/
mbed_official 324:406fd2029f23 275 uint32_t ST_TX_SQE; /*!< Heartbeat lost*/
mbed_official 324:406fd2029f23 276 uint32_t ST_TX_DEFERRED; /*!< Transmission deferred*/
mbed_official 324:406fd2029f23 277 uint32_t ST_TX_LATECOLL; /*!< Late collision*/
mbed_official 324:406fd2029f23 278 uint32_t ST_TX_EXCESSCOLL; /*!< Excessive collisions*/
mbed_official 324:406fd2029f23 279 uint32_t ST_TX_CARRIER; /*!< Carrier sense lost*/
mbed_official 324:406fd2029f23 280 uint32_t ST_TX_UNDERRUN; /*!< DMA underrun*/
mbed_official 324:406fd2029f23 281 /* Following stats are collected by the Ethernet driver */
mbed_official 324:406fd2029f23 282 uint32_t ST_RX_COPY_SMALL; /*!< Driver had to copy packet */
mbed_official 324:406fd2029f23 283 uint32_t ST_RX_COPY_LARGE; /*!< Driver had to copy packet */
mbed_official 324:406fd2029f23 284 uint32_t ST_TX_COPY_SMALL; /*!< Driver had to copy packet */
mbed_official 324:406fd2029f23 285 uint32_t ST_TX_COPY_LARGE; /*!< Driver had to copy packet */
mbed_official 324:406fd2029f23 286 uint32_t RX_FRAGS_EXCEEDED;
mbed_official 324:406fd2029f23 287 uint32_t RX_PCBS_EXHAUSTED;
mbed_official 324:406fd2029f23 288 uint32_t RX_LARGE_BUFFERS_EXHAUSTED;
mbed_official 324:406fd2029f23 289 uint32_t TX_ALIGNED;
mbed_official 324:406fd2029f23 290 uint32_t TX_ALL_ALIGNED;
mbed_official 324:406fd2029f23 291 #if BSPCFG_ENABLE_ENET_HISTOGRAM
mbed_official 324:406fd2029f23 292 uint32_t RX_HISTOGRAM[ENET_HISTOGRAM_ENTRIES];
mbed_official 324:406fd2029f23 293 uint32_t TX_HISTOGRAM[ENET_HISTOGRAM_ENTRIES];
mbed_official 324:406fd2029f23 294 #endif
mbed_official 324:406fd2029f23 295
mbed_official 324:406fd2029f23 296 } ENET_STATS, * ENET_STATS_PTR;
mbed_official 324:406fd2029f23 297
mbed_official 324:406fd2029f23 298 /*******************************************************************************
mbed_official 324:406fd2029f23 299 * API
mbed_official 324:406fd2029f23 300 ******************************************************************************/
mbed_official 324:406fd2029f23 301
mbed_official 324:406fd2029f23 302 #if defined(__cplusplus)
mbed_official 324:406fd2029f23 303 extern "C" {
mbed_official 324:406fd2029f23 304 #endif
mbed_official 324:406fd2029f23 305
mbed_official 324:406fd2029f23 306 /*!
mbed_official 324:406fd2029f23 307 * @name ENET RTCS ADAPTOR
mbed_official 324:406fd2029f23 308 * @{
mbed_official 324:406fd2029f23 309 */
mbed_official 324:406fd2029f23 310
mbed_official 324:406fd2029f23 311 /*!
mbed_official 324:406fd2029f23 312 * @brief Initializes the ENET device.
mbed_official 324:406fd2029f23 313 *
mbed_official 324:406fd2029f23 314 * @param device The ENET device number.
mbed_official 324:406fd2029f23 315 * @param address The hardware address.
mbed_official 324:406fd2029f23 316 * @param flag The flag for upper layer.
mbed_official 324:406fd2029f23 317 * @param handle The address pointer for ENET device structure.
mbed_official 324:406fd2029f23 318 * @return The execution status.
mbed_official 324:406fd2029f23 319 */
mbed_official 324:406fd2029f23 320 uint32_t ENET_initialize(uint32_t device, _enet_address address,uint32_t flag, _enet_handle *handle);
mbed_official 324:406fd2029f23 321
mbed_official 324:406fd2029f23 322 /*!
mbed_official 324:406fd2029f23 323 * @brief Opens the ENET device.
mbed_official 324:406fd2029f23 324 *
mbed_official 324:406fd2029f23 325 * @param handle The address pointer for ENET device structure.
mbed_official 324:406fd2029f23 326 * @param type The ENET protocol type.
mbed_official 324:406fd2029f23 327 * @param service The service function for type.
mbed_official 324:406fd2029f23 328 * @param private The private data for ENET device.
mbed_official 324:406fd2029f23 329 * @return The execution status.
mbed_official 324:406fd2029f23 330 */
mbed_official 324:406fd2029f23 331 uint32_t ENET_open(_enet_handle handle, uint16_t type, void (* service)(PCB_PTR, void *), void *private);
mbed_official 324:406fd2029f23 332
mbed_official 324:406fd2029f23 333 /*!
mbed_official 324:406fd2029f23 334 * @brief Shuts down the ENET device.
mbed_official 324:406fd2029f23 335 *
mbed_official 324:406fd2029f23 336 * @param handle The address pointer for ENET device structure.
mbed_official 324:406fd2029f23 337 * @return The execution status.
mbed_official 324:406fd2029f23 338 */
mbed_official 324:406fd2029f23 339 uint32_t ENET_shutdown(_enet_handle handle);
mbed_official 324:406fd2029f23 340 #if !ENET_RECEIVE_ALL_INTERRUPT
mbed_official 324:406fd2029f23 341 /*!
mbed_official 324:406fd2029f23 342 * @brief ENET frame receive.
mbed_official 324:406fd2029f23 343 *
mbed_official 324:406fd2029f23 344 * @param enetIfPtr The address pointer for ENET device structure.
mbed_official 324:406fd2029f23 345 */
mbed_official 324:406fd2029f23 346 static void ENET_receive(task_param_t param);
mbed_official 324:406fd2029f23 347 #endif
mbed_official 324:406fd2029f23 348 /*!
mbed_official 324:406fd2029f23 349 * @brief ENET frame transmit.
mbed_official 324:406fd2029f23 350 *
mbed_official 324:406fd2029f23 351 * @param handle The address pointer for ENET device structure.
mbed_official 324:406fd2029f23 352 * @param packet The ENET packet buffer.
mbed_official 324:406fd2029f23 353 * @param type The ENET protocol type.
mbed_official 324:406fd2029f23 354 * @param dest The destination hardware address.
mbed_official 324:406fd2029f23 355 * @param flag The flag for upper layer.
mbed_official 324:406fd2029f23 356 * @return The execution status.
mbed_official 324:406fd2029f23 357 */
mbed_official 324:406fd2029f23 358 uint32_t ENET_send(_enet_handle handle, PCB_PTR packet, uint32_t type, _enet_address dest, uint32_t flags) ;
mbed_official 324:406fd2029f23 359
mbed_official 324:406fd2029f23 360 /*!
mbed_official 324:406fd2029f23 361 * @brief The ENET gets the address with the initialized device.
mbed_official 324:406fd2029f23 362 *
mbed_official 324:406fd2029f23 363 * @param handle The address pointer for ENET device structure.
mbed_official 324:406fd2029f23 364 * @param address The destination hardware address.
mbed_official 324:406fd2029f23 365 * @return The execution status.
mbed_official 324:406fd2029f23 366 */
mbed_official 324:406fd2029f23 367 uint32_t ENET_get_address(_enet_handle handle, _enet_address address);
mbed_official 324:406fd2029f23 368
mbed_official 324:406fd2029f23 369 /*!
mbed_official 324:406fd2029f23 370 * @brief The ENET gets the address with an uninitialized device.
mbed_official 324:406fd2029f23 371 *
mbed_official 324:406fd2029f23 372 * @param handle The address pointer for ENET device structure.
mbed_official 324:406fd2029f23 373 * @param value The value to change the last three bytes of hardware.
mbed_official 324:406fd2029f23 374 * @param address The destination hardware address.
mbed_official 324:406fd2029f23 375 * @return True if the execution status is success else false.
mbed_official 324:406fd2029f23 376 */
mbed_official 324:406fd2029f23 377 uint32_t ENET_get_mac_address(uint32_t device, uint32_t value, _enet_address address);
mbed_official 324:406fd2029f23 378 /*!
mbed_official 324:406fd2029f23 379 * @brief The ENET joins a multicast group address.
mbed_official 324:406fd2029f23 380 *
mbed_official 324:406fd2029f23 381 * @param handle The address pointer for ENET device structure.
mbed_official 324:406fd2029f23 382 * @param type The ENET protocol type.
mbed_official 324:406fd2029f23 383 * @param address The destination hardware address.
mbed_official 324:406fd2029f23 384 * @return The execution status.
mbed_official 324:406fd2029f23 385 */
mbed_official 324:406fd2029f23 386 uint32_t ENET_join(_enet_handle handle, uint16_t type, _enet_address address);
mbed_official 324:406fd2029f23 387
mbed_official 324:406fd2029f23 388 /*!
mbed_official 324:406fd2029f23 389 * @brief The ENET leaves a multicast group address.
mbed_official 324:406fd2029f23 390 *
mbed_official 324:406fd2029f23 391 * @param handle The address pointer for ENET device structure.
mbed_official 324:406fd2029f23 392 * @param type The ENET protocol type.
mbed_official 324:406fd2029f23 393 * @param address The destination hardware address.
mbed_official 324:406fd2029f23 394 * @return The execution status.
mbed_official 324:406fd2029f23 395 */
mbed_official 324:406fd2029f23 396 uint32_t ENET_leave(_enet_handle handle, uint16_t type, _enet_address address);
mbed_official 324:406fd2029f23 397 #if BSPCFG_ENABLE_ENET_STATS
mbed_official 324:406fd2029f23 398 /*!
mbed_official 324:406fd2029f23 399 * @brief The ENET gets the packet statistic.
mbed_official 324:406fd2029f23 400 *
mbed_official 324:406fd2029f23 401 * @param handle The address pointer for ENET device structure.
mbed_official 324:406fd2029f23 402 * @return The statistic.
mbed_official 324:406fd2029f23 403 */
mbed_official 324:406fd2029f23 404 ENET_STATS_PTR ENET_get_stats(_enet_handle handle);
mbed_official 324:406fd2029f23 405 #endif
mbed_official 324:406fd2029f23 406 /*!
mbed_official 324:406fd2029f23 407 * @brief The ENET gets the link status.
mbed_official 324:406fd2029f23 408 *
mbed_official 324:406fd2029f23 409 * @param handle The address pointer for ENET device structure.
mbed_official 324:406fd2029f23 410 * @return The link status.
mbed_official 324:406fd2029f23 411 */
mbed_official 324:406fd2029f23 412 bool ENET_link_status(_enet_handle handle);
mbed_official 324:406fd2029f23 413
mbed_official 324:406fd2029f23 414 /*!
mbed_official 324:406fd2029f23 415 * @brief The ENET gets the link speed.
mbed_official 324:406fd2029f23 416 *
mbed_official 324:406fd2029f23 417 * @param handle The address pointer for ENET device structure.
mbed_official 324:406fd2029f23 418 * @return The link speed.
mbed_official 324:406fd2029f23 419 */
mbed_official 324:406fd2029f23 420 uint32_t ENET_get_speed(_enet_handle handle);
mbed_official 324:406fd2029f23 421
mbed_official 324:406fd2029f23 422 /*!
mbed_official 324:406fd2029f23 423 * @brief The ENET gets the MTU.
mbed_official 324:406fd2029f23 424 *
mbed_official 324:406fd2029f23 425 * @param handle The address pointer for ENET device structure.
mbed_official 324:406fd2029f23 426 * @return The link MTU
mbed_official 324:406fd2029f23 427 */
mbed_official 324:406fd2029f23 428 uint32_t ENET_get_MTU(_enet_handle handle);
mbed_official 324:406fd2029f23 429
mbed_official 324:406fd2029f23 430 /*!
mbed_official 324:406fd2029f23 431 * @brief Gets the ENET PHY registers.
mbed_official 324:406fd2029f23 432 *
mbed_official 324:406fd2029f23 433 * @param handle The address pointer for ENET device structure.
mbed_official 324:406fd2029f23 434 * @param numRegs The number of registers.
mbed_official 324:406fd2029f23 435 * @param regPtr The buffer for data read from PHY registers.
mbed_official 324:406fd2029f23 436 * @return True if all numRegs registers are read succeed else false.
mbed_official 324:406fd2029f23 437 */
mbed_official 324:406fd2029f23 438 bool ENET_phy_registers(_enet_handle handle, uint32_t numRegs, uint32_t *regPtr);
mbed_official 324:406fd2029f23 439
mbed_official 324:406fd2029f23 440 /*!
mbed_official 324:406fd2029f23 441 * @brief Gets ENET options.
mbed_official 324:406fd2029f23 442 *
mbed_official 324:406fd2029f23 443 * @param handle The address pointer for ENET device structure.
mbed_official 324:406fd2029f23 444 * @return ENET options.
mbed_official 324:406fd2029f23 445 */
mbed_official 324:406fd2029f23 446 uint32_t ENET_get_options(_enet_handle handle);
mbed_official 324:406fd2029f23 447
mbed_official 324:406fd2029f23 448 /*!
mbed_official 324:406fd2029f23 449 * @brief Unregisters a protocol type on an Ethernet channel.
mbed_official 324:406fd2029f23 450 *
mbed_official 324:406fd2029f23 451 * @param handle The address pointer for ENET device structure.
mbed_official 324:406fd2029f23 452 * @return ENET options.
mbed_official 324:406fd2029f23 453 */
mbed_official 324:406fd2029f23 454 uint32_t ENET_close(_enet_handle handle, uint16_t type);
mbed_official 324:406fd2029f23 455
mbed_official 324:406fd2029f23 456 /*!
mbed_official 324:406fd2029f23 457 * @brief ENET mediactl.
mbed_official 324:406fd2029f23 458 *
mbed_official 324:406fd2029f23 459 * @param handle The address pointer for ENET device structure.
mbed_official 324:406fd2029f23 460 * @param The command ID.
mbed_official 324:406fd2029f23 461 * @param The buffer for input or output parameters.
mbed_official 324:406fd2029f23 462 * @return ENET options.
mbed_official 324:406fd2029f23 463 */
mbed_official 324:406fd2029f23 464 uint32_t ENET_mediactl(_enet_handle handle, uint32_t commandId, void *inOutParam);
mbed_official 324:406fd2029f23 465
mbed_official 324:406fd2029f23 466 /*!
mbed_official 324:406fd2029f23 467 * @brief Gets the next ENET device handle address.
mbed_official 324:406fd2029f23 468 *
mbed_official 324:406fd2029f23 469 * @param handle The address pointer for ENET device structure.
mbed_official 324:406fd2029f23 470 * @return The address of next ENET device handle.
mbed_official 324:406fd2029f23 471 */
mbed_official 324:406fd2029f23 472 _enet_handle ENET_get_next_device_handle(_enet_handle handle);
mbed_official 324:406fd2029f23 473
mbed_official 324:406fd2029f23 474 /*!
mbed_official 324:406fd2029f23 475 * @brief ENET free.
mbed_official 324:406fd2029f23 476 *
mbed_official 324:406fd2029f23 477 * @param packet The buffer address.
mbed_official 324:406fd2029f23 478 */
mbed_official 324:406fd2029f23 479 void ENET_free(PCB_PTR packet);
mbed_official 324:406fd2029f23 480
mbed_official 324:406fd2029f23 481 /*!
mbed_official 324:406fd2029f23 482 * @brief ENET error description.
mbed_official 324:406fd2029f23 483 *
mbed_official 324:406fd2029f23 484 * @param error The ENET error code.
mbed_official 324:406fd2029f23 485 * @return The error string.
mbed_official 324:406fd2029f23 486 */
mbed_official 324:406fd2029f23 487 const char * ENET_strerror(uint32_t error);
mbed_official 324:406fd2029f23 488
mbed_official 324:406fd2029f23 489
mbed_official 324:406fd2029f23 490
mbed_official 324:406fd2029f23 491 /* @} */
mbed_official 324:406fd2029f23 492
mbed_official 324:406fd2029f23 493 #if defined(__cplusplus)
mbed_official 324:406fd2029f23 494 }
mbed_official 324:406fd2029f23 495 #endif
mbed_official 324:406fd2029f23 496
mbed_official 324:406fd2029f23 497 /*! @}*/
mbed_official 324:406fd2029f23 498
mbed_official 324:406fd2029f23 499 #endif /* MBED_NO_ENET */
mbed_official 324:406fd2029f23 500
mbed_official 324:406fd2029f23 501 #endif /* __FSL_ENET_RTCS_ADAPTOR_H__ */
mbed_official 324:406fd2029f23 502 /*******************************************************************************
mbed_official 324:406fd2029f23 503 * EOF
mbed_official 324:406fd2029f23 504 ******************************************************************************/
mbed_official 324:406fd2029f23 505
mbed_official 324:406fd2029f23 506
mbed_official 324:406fd2029f23 507
mbed_official 324:406fd2029f23 508
mbed_official 324:406fd2029f23 509
mbed_official 324:406fd2029f23 510
mbed_official 324:406fd2029f23 511
mbed_official 324:406fd2029f23 512
mbed_official 324:406fd2029f23 513