1 /** 2 * @file xmc_eth_phy.h 3 * @date 2015-12-15 4 * 5 * @cond 6 ********************************************************************************************************************* 7 * XMClib v2.1.24 - XMC Peripheral Driver Library 8 * 9 * Copyright (c) 2015-2019, Infineon Technologies AG 10 * All rights reserved. 11 * 12 * Redistribution and use in source and binary forms, with or without modification,are permitted provided that the 13 * following conditions are met: 14 * 15 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following 16 * disclaimer. 17 * 18 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following 19 * disclaimer in the documentation and/or other materials provided with the distribution. 20 * 21 * Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote 22 * products derived from this software without specific prior written permission. 23 * 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 25 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 * WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * 32 * To improve the quality of the software, users are encouraged to share modifications, enhancements or bug fixes with 33 * Infineon Technologies AG dave@infineon.com). 34 ********************************************************************************************************************* 35 * 36 * Change History 37 * -------------- 38 * 39 * 2015-06-20: 40 * - Initial 41 * 42 * 2015-12-15: 43 * - Added XMC_ETH_PHY_ExitPowerDown and XMC_ETH_PHY_Reset 44 * 45 * @endcond 46 */ 47 48 /** 49 * @addtogroup XMClib XMC Peripheral Library 50 * @{ 51 */ 52 53 /** 54 * @addtogroup ETH_PHY 55 * @brief Ethernet PHY driver for XMC4000 microcontroller family. 56 * 57 * The XMC_ETH_PHY low level driver provides functions used by XMC_ETH_MAC. 58 * @{ 59 */ 60 61 #ifndef XMC_ETH_PHY_H 62 #define XMC_ETH_PHY_H 63 64 /******************************************************************************* 65 * INCLUDES 66 *******************************************************************************/ 67 68 #include <xmc_eth_mac.h> 69 70 /******************************************************************************* 71 * ENUMS 72 *******************************************************************************/ 73 74 /** 75 * ETH PHY status returns 76 */ 77 typedef enum XMC_ETH_PHY_STATUS 78 { 79 XMC_ETH_PHY_STATUS_OK = 0U, /**< OK. All is well! */ 80 XMC_ETH_PHY_STATUS_BUSY = 1U, /**< Busy */ 81 XMC_ETH_PHY_STATUS_ERROR = 2U, /**< Error */ 82 XMC_ETH_PHY_STATUS_ERROR_DEVICE_ID = 3U, /**< Error in device identifier */ 83 XMC_ETH_PHY_STATUS_ERROR_TIMEOUT = 4U /**< Time-out error */ 84 } XMC_ETH_PHY_STATUS_t; 85 86 /******************************************************************************* 87 * DATA STRUCTURES 88 *******************************************************************************/ 89 90 /** 91 * ETH PHY configuration 92 */ 93 typedef struct XMC_ETH_PHY_CONFIG 94 { 95 XMC_ETH_LINK_INTERFACE_t interface; /**< Link interface */ 96 XMC_ETH_LINK_SPEED_t speed; /**< ETH speed: 100M or 10M? */ 97 XMC_ETH_LINK_DUPLEX_t duplex; /**< Half or full duplex? */ 98 bool enable_auto_negotiate; /**< Enable auto-negotiate? */ 99 bool enable_loop_back; /**< Enable loop-back? */ 100 } XMC_ETH_PHY_CONFIG_t; 101 102 /******************************************************************************* 103 * API PROTOTYPES 104 *******************************************************************************/ 105 106 #ifdef __cplusplus 107 extern "C" { 108 #endif 109 110 /** 111 * @param eth_mac A constant pointer to XMC_ETH_MAC_t, pointing to the ETH MAC base address 112 * @param phy_addr Physical address 113 * @param config A constant pointer to XMC_ETH_PHY_CONFIG_t, pointing to a physical layer config 114 * @return int32_t return status XMC_ETH_PHY_STATUS_t 115 * 116 * \par<b>Description: </b><br> 117 * Initialize the ETH physical layer interface <br> 118 * 119 * \par 120 * The function sets the link speed, applies the duplex mode, sets auto-negotiation 121 * and loop-back settings. 122 */ 123 int32_t XMC_ETH_PHY_Init(XMC_ETH_MAC_t *const eth_mac, uint8_t phy_addr, const XMC_ETH_PHY_CONFIG_t *const config); 124 125 /** 126 * @param eth_mac A constant pointer to XMC_ETH_MAC_t, pointing to the ETH MAC base address 127 * @param phy_addr Physical address 128 * @return int32_t return status XMC_ETH_PHY_STATUS_t 129 * 130 * \par<b>Description: </b><br> 131 * Enter power down mode <br> 132 * 133 */ 134 int32_t XMC_ETH_PHY_PowerDown(XMC_ETH_MAC_t *const eth_mac, uint8_t phy_addr); 135 136 /** 137 * @param eth_mac A constant pointer to XMC_ETH_MAC_t, pointing to the ETH MAC base address 138 * @param phy_addr Physical address 139 * @return int32_t return status XMC_ETH_PHY_STATUS_t 140 * 141 * \par<b>Description: </b><br> 142 * Exit power down mode <br> 143 * 144 */ 145 int32_t XMC_ETH_PHY_ExitPowerDown(XMC_ETH_MAC_t *const eth_mac, uint8_t phy_addr); 146 147 /** 148 * @param eth_mac A constant pointer to XMC_ETH_MAC_t, pointing to the ETH MAC base address 149 * @param phy_addr Physical address 150 * @return int32_t return status XMC_ETH_PHY_STATUS_t 151 * 152 * \par<b>Description: </b><br> 153 * Reset transciver <br> 154 * 155 */ 156 int32_t XMC_ETH_PHY_Reset(XMC_ETH_MAC_t *const eth_mac, uint8_t phy_addr); 157 158 /** 159 * @param eth_mac A constant pointer to XMC_ETH_MAC_t, pointing to the ETH MAC base address 160 * @param phy_addr Physical address 161 * @return XMC_ETH_LINK_STATUS_t ETH link status 162 * 163 * \par<b>Description: </b><br> 164 * Get link status <br> 165 * 166 * \par 167 * The function reads the physical layer interface and returns the link status. 168 * It returns either ::XMC_ETH_LINK_STATUS_UP or ::XMC_ETH_LINK_STATUS_DOWN. 169 */ 170 XMC_ETH_LINK_STATUS_t XMC_ETH_PHY_GetLinkStatus(XMC_ETH_MAC_t *const eth_mac, uint8_t phy_addr); 171 172 /** 173 * @param eth_mac A constant pointer to XMC_ETH_MAC_t, pointing to the ETH MAC base address 174 * @param phy_addr Physical address 175 * @return XMC_ETH_LINK_SPEED_t ETH link speed 176 * 177 * \par<b>Description: </b><br> 178 * Get link speed <br> 179 * 180 * \par 181 * The function reads the physical layer interface and returns the link speed. 182 * It returns either ::XMC_ETH_LINK_SPEED_100M or ::XMC_ETH_LINK_SPEED_10M. 183 */ 184 XMC_ETH_LINK_SPEED_t XMC_ETH_PHY_GetLinkSpeed(XMC_ETH_MAC_t *const eth_mac, uint8_t phy_addr); 185 186 /** 187 * @param eth_mac A constant pointer to XMC_ETH_MAC_t, pointing to the ETH MAC base address 188 * @param phy_addr Physical address 189 * @return XMC_ETH_LINK_DUPLEX_t ETH link duplex settings 190 * 191 * \par<b>Description: </b><br> 192 * Get link duplex settings <br> 193 * 194 * \par 195 * The function reads the physical layer interface and returns the link duplex settings. 196 * It returns either ::XMC_ETH_LINK_DUPLEX_FULL or ::XMC_ETH_LINK_DUPLEX_HALF. 197 */ 198 XMC_ETH_LINK_DUPLEX_t XMC_ETH_PHY_GetLinkDuplex(XMC_ETH_MAC_t *const eth_mac, uint8_t phy_addr); 199 200 /** 201 * @param eth_mac A constant pointer to XMC_ETH_MAC_t, pointing to the ETH MAC base address 202 * @param phy_addr Physical address 203 * @return bool True if autonegotiation process is finished otherwise false 204 * 205 * \par<b>Description: </b><br> 206 * Get status of autonegotiation <br> 207 */ 208 bool XMC_ETH_PHY_IsAutonegotiationCompleted(XMC_ETH_MAC_t *const eth_mac, uint8_t phy_addr); 209 210 #ifdef __cplusplus 211 } 212 #endif 213 214 /** 215 * @} 216 */ 217 218 /** 219 * @} 220 */ 221 222 #endif /* XMC_ETH_PHY_H */ 223