mbed library sources

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Thu Apr 24 10:45:06 2014 +0100
Revision:
168:cf9372ac0a74
Synchronized with git revision 94fd2228fb4a382fb98d0115f6691fc0b659eea8

Full URL: https://github.com/mbedmicro/mbed/commit/94fd2228fb4a382fb98d0115f6691fc0b659eea8/

Currently NET_7 (HttpClient test) and NET_8 (NTP test) fail for
unknown reasons.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 168:cf9372ac0a74 1 /*
mbed_official 168:cf9372ac0a74 2 * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
mbed_official 168:cf9372ac0a74 3 * All rights reserved.
mbed_official 168:cf9372ac0a74 4 *
mbed_official 168:cf9372ac0a74 5 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 168:cf9372ac0a74 6 * are permitted provided that the following conditions are met:
mbed_official 168:cf9372ac0a74 7 *
mbed_official 168:cf9372ac0a74 8 * o Redistributions of source code must retain the above copyright notice, this list
mbed_official 168:cf9372ac0a74 9 * of conditions and the following disclaimer.
mbed_official 168:cf9372ac0a74 10 *
mbed_official 168:cf9372ac0a74 11 * o Redistributions in binary form must reproduce the above copyright notice, this
mbed_official 168:cf9372ac0a74 12 * list of conditions and the following disclaimer in the documentation and/or
mbed_official 168:cf9372ac0a74 13 * other materials provided with the distribution.
mbed_official 168:cf9372ac0a74 14 *
mbed_official 168:cf9372ac0a74 15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
mbed_official 168:cf9372ac0a74 16 * contributors may be used to endorse or promote products derived from this
mbed_official 168:cf9372ac0a74 17 * software without specific prior written permission.
mbed_official 168:cf9372ac0a74 18 *
mbed_official 168:cf9372ac0a74 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
mbed_official 168:cf9372ac0a74 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
mbed_official 168:cf9372ac0a74 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 168:cf9372ac0a74 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
mbed_official 168:cf9372ac0a74 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
mbed_official 168:cf9372ac0a74 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
mbed_official 168:cf9372ac0a74 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
mbed_official 168:cf9372ac0a74 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
mbed_official 168:cf9372ac0a74 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
mbed_official 168:cf9372ac0a74 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 168:cf9372ac0a74 29 */
mbed_official 168:cf9372ac0a74 30 #ifndef __FSL_PHY_DRIVER_H__
mbed_official 168:cf9372ac0a74 31 #define __FSL_PHY_DRIVER_H__
mbed_official 168:cf9372ac0a74 32
mbed_official 168:cf9372ac0a74 33 #include <stdint.h>
mbed_official 168:cf9372ac0a74 34 #include <stdbool.h>
mbed_official 168:cf9372ac0a74 35 #include "fsl_enet_driver.h"
mbed_official 168:cf9372ac0a74 36 /*!
mbed_official 168:cf9372ac0a74 37 * @addtogroup phy_driver
mbed_official 168:cf9372ac0a74 38 * @{
mbed_official 168:cf9372ac0a74 39 */
mbed_official 168:cf9372ac0a74 40
mbed_official 168:cf9372ac0a74 41 /*! @file*/
mbed_official 168:cf9372ac0a74 42
mbed_official 168:cf9372ac0a74 43 /*******************************************************************************
mbed_official 168:cf9372ac0a74 44 * Definitions
mbed_official 168:cf9372ac0a74 45 ******************************************************************************/
mbed_official 168:cf9372ac0a74 46 /*! @brief Defines the PHY return status. */
mbed_official 168:cf9372ac0a74 47 typedef enum _phy_status
mbed_official 168:cf9372ac0a74 48 {
mbed_official 168:cf9372ac0a74 49 kStatus_PHY_Success = 0, /*!< Success*/
mbed_official 168:cf9372ac0a74 50 kStatus_PHY_InvaildInput = 1, /*!< Invalid PHY input parameter*/
mbed_official 168:cf9372ac0a74 51 kStatus_PHY_TimeOut = 2, /*!< PHY timeout*/
mbed_official 168:cf9372ac0a74 52 kStatus_PHY_Fail = 3 /*!< PHY fail*/
mbed_official 168:cf9372ac0a74 53 } phy_status_t;
mbed_official 168:cf9372ac0a74 54
mbed_official 168:cf9372ac0a74 55 /*! @brief Defines the ENET timeout.*/
mbed_official 168:cf9372ac0a74 56 typedef enum _phy_timeout
mbed_official 168:cf9372ac0a74 57 {
mbed_official 168:cf9372ac0a74 58 kPhyTimeout = 0x10000, /*!< ENET resets timeout.*/
mbed_official 168:cf9372ac0a74 59 } phy_timeout_t;
mbed_official 168:cf9372ac0a74 60
mbed_official 168:cf9372ac0a74 61 /*! @brief Defines the PHY register.*/
mbed_official 168:cf9372ac0a74 62 typedef enum _enet_phy_register
mbed_official 168:cf9372ac0a74 63 {
mbed_official 168:cf9372ac0a74 64 kEnetPhyCR = 0, /*!< PHY control register */
mbed_official 168:cf9372ac0a74 65 kEnetPhySR = 1, /*!< PHY status register*/
mbed_official 168:cf9372ac0a74 66 kEnetPhyId1 = 2, /*!< PHY identification register 1*/
mbed_official 168:cf9372ac0a74 67 kEnetPhyId2 = 3, /*!< PHY identification register 2*/
mbed_official 168:cf9372ac0a74 68 kEnetPhyCt2 = 0x1e /*!< PHY control2 register*/
mbed_official 168:cf9372ac0a74 69 } enet_phy_register_t;
mbed_official 168:cf9372ac0a74 70
mbed_official 168:cf9372ac0a74 71 /*! @brief Defines the control flag.*/
mbed_official 168:cf9372ac0a74 72 typedef enum _enet_phy_control
mbed_official 168:cf9372ac0a74 73 {
mbed_official 168:cf9372ac0a74 74 kEnetPhyAutoNeg = 0x1000,/*!< ENET PHY auto negotiation control*/
mbed_official 168:cf9372ac0a74 75 kEnetPhySpeed = 0x2000, /*! ENET PHY speed control*/
mbed_official 168:cf9372ac0a74 76 kEnetPhyLoop = 0x4000, /*!< ENET PHY loop control*/
mbed_official 168:cf9372ac0a74 77 kEnetPhyReset = 0x8000, /*!< ENET PHY reset control*/
mbed_official 168:cf9372ac0a74 78 kEnetPhy10HalfDuplex = 0x01, /*!< ENET PHY 10 M half duplex*/
mbed_official 168:cf9372ac0a74 79 kEnetPhy100HalfDuplex = 0x02,/*!< ENET PHY 100 M half duplex*/
mbed_official 168:cf9372ac0a74 80 kEnetPhy10FullDuplex = 0x05,/*!< ENET PHY 10 M full duplex*/
mbed_official 168:cf9372ac0a74 81 kEnetPhy100FullDuplex = 0x06/*!< ENET PHY 100 M full duplex*/
mbed_official 168:cf9372ac0a74 82 } enet_phy_control_t;
mbed_official 168:cf9372ac0a74 83
mbed_official 168:cf9372ac0a74 84 /*! @brief Defines the PHY link speed. */
mbed_official 168:cf9372ac0a74 85 typedef enum _enet_phy_speed
mbed_official 168:cf9372ac0a74 86 {
mbed_official 168:cf9372ac0a74 87 kEnetSpeed10M = 0, /*!< ENET PHY 10 M speed*/
mbed_official 168:cf9372ac0a74 88 kEnetSpeed100M = 1 /*!< ENET PHY 100 M speed*/
mbed_official 168:cf9372ac0a74 89 } enet_phy_speed_t;
mbed_official 168:cf9372ac0a74 90
mbed_official 168:cf9372ac0a74 91 /*! @brief Defines the PHY link duplex.*/
mbed_official 168:cf9372ac0a74 92 typedef enum _enet_phy_duplex
mbed_official 168:cf9372ac0a74 93 {
mbed_official 168:cf9372ac0a74 94 kEnetHalfDuplex = 0, /*!< ENET PHY half duplex*/
mbed_official 168:cf9372ac0a74 95 kEnetFullDuplex = 1 /*!< ENET PHY full duplex*/
mbed_official 168:cf9372ac0a74 96 } enet_phy_duplex_t;
mbed_official 168:cf9372ac0a74 97
mbed_official 168:cf9372ac0a74 98 /*! @brief Defines the PHY status.*/
mbed_official 168:cf9372ac0a74 99 typedef enum _enet_phy_status
mbed_official 168:cf9372ac0a74 100 {
mbed_official 168:cf9372ac0a74 101 kEnetPhyLinkStatus = 0x4, /*!< ENET PHY link status bit*/
mbed_official 168:cf9372ac0a74 102 kEnetPhyAutoNegAble = 0x08, /*!< ENET PHY auto negotiation ability*/
mbed_official 168:cf9372ac0a74 103 kEnetPhyAutoNegComplete = 0x20, /*!< ENET PHY auto negotiation complete*/
mbed_official 168:cf9372ac0a74 104 kEnetPhySpeedDulpexMask = 0x07 /*!< ENET PHY speed mask on status register 2*/
mbed_official 168:cf9372ac0a74 105 } enet_phy_status_t;
mbed_official 168:cf9372ac0a74 106
mbed_official 168:cf9372ac0a74 107 /*! @brief Defines the basic PHY application.*/
mbed_official 168:cf9372ac0a74 108 typedef struct ENETPhyApi
mbed_official 168:cf9372ac0a74 109 {
mbed_official 168:cf9372ac0a74 110 uint32_t (* phy_auto_discover)(enet_dev_if_t * enetIfPtr);/*!< PHY auto discover*/
mbed_official 168:cf9372ac0a74 111 uint32_t (* phy_init)(enet_dev_if_t * enetIfPtr);/*!< PHY initialize*/
mbed_official 168:cf9372ac0a74 112 uint32_t (* phy_get_link_speed)(enet_dev_if_t * enetIfPtr, enet_phy_speed_t *speed);/*!< Get PHY speed*/
mbed_official 168:cf9372ac0a74 113 uint32_t (* phy_get_link_status)(enet_dev_if_t * enetIfPtr, bool *status);/*! Get PHY link status*/
mbed_official 168:cf9372ac0a74 114 uint32_t (* phy_get_link_duplex)(enet_dev_if_t * enetIfPtr, enet_phy_duplex_t *duplex);/*!< Get PHY link duplex*/
mbed_official 168:cf9372ac0a74 115 } enet_phy_api_t;
mbed_official 168:cf9372ac0a74 116
mbed_official 168:cf9372ac0a74 117 /*******************************************************************************
mbed_official 168:cf9372ac0a74 118 * Global variables
mbed_official 168:cf9372ac0a74 119 ******************************************************************************/
mbed_official 168:cf9372ac0a74 120 extern const enet_phy_api_t g_enetPhyApi;
mbed_official 168:cf9372ac0a74 121
mbed_official 168:cf9372ac0a74 122 /*******************************************************************************
mbed_official 168:cf9372ac0a74 123 * API
mbed_official 168:cf9372ac0a74 124 ******************************************************************************/
mbed_official 168:cf9372ac0a74 125
mbed_official 168:cf9372ac0a74 126 #if defined(__cplusplus)
mbed_official 168:cf9372ac0a74 127 extern "C" {
mbed_official 168:cf9372ac0a74 128 #endif
mbed_official 168:cf9372ac0a74 129
mbed_official 168:cf9372ac0a74 130 /*!
mbed_official 168:cf9372ac0a74 131 * @name PHY Driver
mbed_official 168:cf9372ac0a74 132 * @{
mbed_official 168:cf9372ac0a74 133 */
mbed_official 168:cf9372ac0a74 134
mbed_official 168:cf9372ac0a74 135 /*!
mbed_official 168:cf9372ac0a74 136 * @brief Initializes PHY.
mbed_official 168:cf9372ac0a74 137 *
mbed_official 168:cf9372ac0a74 138 * @param enetIfPtr The ENET context structure.
mbed_official 168:cf9372ac0a74 139 * @return The execution status.
mbed_official 168:cf9372ac0a74 140 */
mbed_official 168:cf9372ac0a74 141 uint32_t phy_init(enet_dev_if_t * enetIfPtr);
mbed_official 168:cf9372ac0a74 142
mbed_official 168:cf9372ac0a74 143 /*!
mbed_official 168:cf9372ac0a74 144 * @brief PHY address auto discover.
mbed_official 168:cf9372ac0a74 145 *
mbed_official 168:cf9372ac0a74 146 * @param enetIfPtr The ENET context structure.
mbed_official 168:cf9372ac0a74 147 * @return The execution status.
mbed_official 168:cf9372ac0a74 148 */
mbed_official 168:cf9372ac0a74 149 uint32_t phy_auto_discover(enet_dev_if_t * enetIfPtr);
mbed_official 168:cf9372ac0a74 150
mbed_official 168:cf9372ac0a74 151 /*!
mbed_official 168:cf9372ac0a74 152 * @brief Gets the PHY link speed.
mbed_official 168:cf9372ac0a74 153 *
mbed_official 168:cf9372ac0a74 154 * @param enetIfPtr The ENET context structure.
mbed_official 168:cf9372ac0a74 155 * @param status The link speed of PHY.
mbed_official 168:cf9372ac0a74 156 * @return The execution status.
mbed_official 168:cf9372ac0a74 157 */
mbed_official 168:cf9372ac0a74 158 uint32_t phy_get_link_speed(enet_dev_if_t * enetIfPtr, enet_phy_speed_t *status);
mbed_official 168:cf9372ac0a74 159
mbed_official 168:cf9372ac0a74 160 /*!
mbed_official 168:cf9372ac0a74 161 * @brief Gets the PHY link status.
mbed_official 168:cf9372ac0a74 162 *
mbed_official 168:cf9372ac0a74 163 * @param enetIfPtr The ENET context structure.
mbed_official 168:cf9372ac0a74 164 * @param status The link on or down status of the PHY.
mbed_official 168:cf9372ac0a74 165 * @return The execution status.
mbed_official 168:cf9372ac0a74 166 */
mbed_official 168:cf9372ac0a74 167 uint32_t phy_get_link_status(enet_dev_if_t * enetIfPtr, bool *status);
mbed_official 168:cf9372ac0a74 168
mbed_official 168:cf9372ac0a74 169 /*!
mbed_official 168:cf9372ac0a74 170 * @brief Gets the PHY link duplex.
mbed_official 168:cf9372ac0a74 171 *
mbed_official 168:cf9372ac0a74 172 * @param enetIfPtr The ENET context structure.
mbed_official 168:cf9372ac0a74 173 * @param status The link duplex status of PHY.
mbed_official 168:cf9372ac0a74 174 * @return The execution status.
mbed_official 168:cf9372ac0a74 175 */
mbed_official 168:cf9372ac0a74 176 uint32_t phy_get_link_duplex(enet_dev_if_t * enetIfPtr, enet_phy_duplex_t *status);
mbed_official 168:cf9372ac0a74 177
mbed_official 168:cf9372ac0a74 178 /* @} */
mbed_official 168:cf9372ac0a74 179
mbed_official 168:cf9372ac0a74 180 #if defined(__cplusplus)
mbed_official 168:cf9372ac0a74 181 extern }
mbed_official 168:cf9372ac0a74 182 #endif
mbed_official 168:cf9372ac0a74 183
mbed_official 168:cf9372ac0a74 184 /*! @}*/
mbed_official 168:cf9372ac0a74 185
mbed_official 168:cf9372ac0a74 186 #endif /* __FSL_PHY_DRIVER_H__ */
mbed_official 168:cf9372ac0a74 187 /*******************************************************************************
mbed_official 168:cf9372ac0a74 188 * EOF
mbed_official 168:cf9372ac0a74 189 ******************************************************************************/
mbed_official 168:cf9372ac0a74 190