Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface HttpServer TextLCD mbed-rpc mbed-rtos mbed Socket lwip-eth lwip-sys lwip
EthernetInterface/lwip-eth/arch/lpc_phy.h@2:14b689a85306, 2014-03-12 (annotated)
- Committer:
- yueee_yt
- Date:
- Wed Mar 12 04:39:15 2014 +0000
- Revision:
- 2:14b689a85306
- Parent:
- 0:7766f6712673
bug fix
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| yueee_yt | 0:7766f6712673 | 1 | /********************************************************************** | 
| yueee_yt | 0:7766f6712673 | 2 | * $Id$ lpc_phy.h 2011-11-20 | 
| yueee_yt | 0:7766f6712673 | 3 | *//** | 
| yueee_yt | 0:7766f6712673 | 4 | * @file lpc_phy.h | 
| yueee_yt | 0:7766f6712673 | 5 | * @brief Common PHY definitions used with all PHYs | 
| yueee_yt | 0:7766f6712673 | 6 | * @version 1.0 | 
| yueee_yt | 0:7766f6712673 | 7 | * @date 20 Nov. 2011 | 
| yueee_yt | 0:7766f6712673 | 8 | * @author NXP MCU SW Application Team | 
| yueee_yt | 0:7766f6712673 | 9 | * | 
| yueee_yt | 0:7766f6712673 | 10 | * Copyright(C) 2011, NXP Semiconductor | 
| yueee_yt | 0:7766f6712673 | 11 | * All rights reserved. | 
| yueee_yt | 0:7766f6712673 | 12 | * | 
| yueee_yt | 0:7766f6712673 | 13 | *********************************************************************** | 
| yueee_yt | 0:7766f6712673 | 14 | * Software that is described herein is for illustrative purposes only | 
| yueee_yt | 0:7766f6712673 | 15 | * which provides customers with programming information regarding the | 
| yueee_yt | 0:7766f6712673 | 16 | * products. This software is supplied "AS IS" without any warranties. | 
| yueee_yt | 0:7766f6712673 | 17 | * NXP Semiconductors assumes no responsibility or liability for the | 
| yueee_yt | 0:7766f6712673 | 18 | * use of the software, conveys no license or title under any patent, | 
| yueee_yt | 0:7766f6712673 | 19 | * copyright, or mask work right to the product. NXP Semiconductors | 
| yueee_yt | 0:7766f6712673 | 20 | * reserves the right to make changes in the software without | 
| yueee_yt | 0:7766f6712673 | 21 | * notification. NXP Semiconductors also make no representation or | 
| yueee_yt | 0:7766f6712673 | 22 | * warranty that such application will be suitable for the specified | 
| yueee_yt | 0:7766f6712673 | 23 | * use without further testing or modification. | 
| yueee_yt | 0:7766f6712673 | 24 | **********************************************************************/ | 
| yueee_yt | 0:7766f6712673 | 25 | |
| yueee_yt | 0:7766f6712673 | 26 | #ifndef __LPC_PHY_H_ | 
| yueee_yt | 0:7766f6712673 | 27 | #define __LPC_PHY_H_ | 
| yueee_yt | 0:7766f6712673 | 28 | |
| yueee_yt | 0:7766f6712673 | 29 | #include "lwip/opt.h" | 
| yueee_yt | 0:7766f6712673 | 30 | #include "lwip/err.h" | 
| yueee_yt | 0:7766f6712673 | 31 | #include "lwip/netif.h" | 
| yueee_yt | 0:7766f6712673 | 32 | |
| yueee_yt | 0:7766f6712673 | 33 | #ifdef __cplusplus | 
| yueee_yt | 0:7766f6712673 | 34 | extern "C" | 
| yueee_yt | 0:7766f6712673 | 35 | { | 
| yueee_yt | 0:7766f6712673 | 36 | #endif | 
| yueee_yt | 0:7766f6712673 | 37 | |
| yueee_yt | 0:7766f6712673 | 38 | /* These PHY functions are usually part of the EMAC driver */ | 
| yueee_yt | 0:7766f6712673 | 39 | |
| yueee_yt | 0:7766f6712673 | 40 | /** \brief Phy status update state machine | 
| yueee_yt | 0:7766f6712673 | 41 | * | 
| yueee_yt | 0:7766f6712673 | 42 | * This function provides a state machine for maintaining the PHY | 
| yueee_yt | 0:7766f6712673 | 43 | * status without blocking. It must be occasionally called for the | 
| yueee_yt | 0:7766f6712673 | 44 | * PHY status to be maintained. | 
| yueee_yt | 0:7766f6712673 | 45 | * | 
| yueee_yt | 0:7766f6712673 | 46 | * \param[in] netif NETIF structure | 
| yueee_yt | 0:7766f6712673 | 47 | */ | 
| yueee_yt | 0:7766f6712673 | 48 | s32_t lpc_phy_sts_sm(struct netif *netif); | 
| yueee_yt | 0:7766f6712673 | 49 | |
| yueee_yt | 0:7766f6712673 | 50 | /** \brief Initialize the PHY | 
| yueee_yt | 0:7766f6712673 | 51 | * | 
| yueee_yt | 0:7766f6712673 | 52 | * This function initializes the PHY. It will block until complete. | 
| yueee_yt | 0:7766f6712673 | 53 | * This function is called as part of the EMAC driver | 
| yueee_yt | 0:7766f6712673 | 54 | * initialization. Configuration of the PHY at startup is | 
| yueee_yt | 0:7766f6712673 | 55 | * controlled by setting up configuration defines in lpc_phy.h. | 
| yueee_yt | 0:7766f6712673 | 56 | * | 
| yueee_yt | 0:7766f6712673 | 57 | * \param[in] netif NETIF structure | 
| yueee_yt | 0:7766f6712673 | 58 | * \param[in] rmii If set, configures the PHY for RMII mode | 
| yueee_yt | 0:7766f6712673 | 59 | * \return ERR_OK if the setup was successful, otherwise ERR_TIMEOUT | 
| yueee_yt | 0:7766f6712673 | 60 | */ | 
| yueee_yt | 0:7766f6712673 | 61 | err_t lpc_phy_init(struct netif *netif, int rmii); | 
| yueee_yt | 0:7766f6712673 | 62 | |
| yueee_yt | 0:7766f6712673 | 63 | /** \brief Write a value via the MII link (non-blocking) | 
| yueee_yt | 0:7766f6712673 | 64 | * | 
| yueee_yt | 0:7766f6712673 | 65 | * This function will write a value on the MII link interface to a PHY | 
| yueee_yt | 0:7766f6712673 | 66 | * or a connected device. The function will return immediately without | 
| yueee_yt | 0:7766f6712673 | 67 | * a status. Status needs to be polled later to determine if the write | 
| yueee_yt | 0:7766f6712673 | 68 | * was successful. | 
| yueee_yt | 0:7766f6712673 | 69 | * | 
| yueee_yt | 0:7766f6712673 | 70 | * \param[in] PhyReg PHY register to write to | 
| yueee_yt | 0:7766f6712673 | 71 | * \param[in] Value Value to write | 
| yueee_yt | 0:7766f6712673 | 72 | */ | 
| yueee_yt | 0:7766f6712673 | 73 | void lpc_mii_write_noblock(u32_t PhyReg, u32_t Value); | 
| yueee_yt | 0:7766f6712673 | 74 | |
| yueee_yt | 0:7766f6712673 | 75 | /** \brief Write a value via the MII link (blocking) | 
| yueee_yt | 0:7766f6712673 | 76 | * | 
| yueee_yt | 0:7766f6712673 | 77 | * This function will write a value on the MII link interface to a PHY | 
| yueee_yt | 0:7766f6712673 | 78 | * or a connected device. The function will block until complete. | 
| yueee_yt | 0:7766f6712673 | 79 | * | 
| yueee_yt | 0:7766f6712673 | 80 | * \param[in] PhyReg PHY register to write to | 
| yueee_yt | 0:7766f6712673 | 81 | * \param[in] Value Value to write | 
| yueee_yt | 0:7766f6712673 | 82 | * \returns 0 if the write was successful, otherwise !0 | 
| yueee_yt | 0:7766f6712673 | 83 | */ | 
| yueee_yt | 0:7766f6712673 | 84 | err_t lpc_mii_write(u32_t PhyReg, u32_t Value); | 
| yueee_yt | 0:7766f6712673 | 85 | |
| yueee_yt | 0:7766f6712673 | 86 | /** \brief Reads current MII link busy status | 
| yueee_yt | 0:7766f6712673 | 87 | * | 
| yueee_yt | 0:7766f6712673 | 88 | * This function will return the current MII link busy status and is meant to | 
| yueee_yt | 0:7766f6712673 | 89 | * be used with non-blocking functions for monitor PHY status such as | 
| yueee_yt | 0:7766f6712673 | 90 | * connection state. | 
| yueee_yt | 0:7766f6712673 | 91 | * | 
| yueee_yt | 0:7766f6712673 | 92 | * \returns !0 if the MII link is busy, otherwise 0 | 
| yueee_yt | 0:7766f6712673 | 93 | */ | 
| yueee_yt | 0:7766f6712673 | 94 | u32_t lpc_mii_is_busy(void); | 
| yueee_yt | 0:7766f6712673 | 95 | |
| yueee_yt | 0:7766f6712673 | 96 | /** \brief Starts a read operation via the MII link (non-blocking) | 
| yueee_yt | 0:7766f6712673 | 97 | * | 
| yueee_yt | 0:7766f6712673 | 98 | * This function returns the current value in the MII data register. It is | 
| yueee_yt | 0:7766f6712673 | 99 | * meant to be used with the non-blocking oeprations. This value should | 
| yueee_yt | 0:7766f6712673 | 100 | * only be read after a non-block read command has been issued and the | 
| yueee_yt | 0:7766f6712673 | 101 | * MII status has been determined to be good. | 
| yueee_yt | 0:7766f6712673 | 102 | * | 
| yueee_yt | 0:7766f6712673 | 103 | * \returns The current value in the MII value register | 
| yueee_yt | 0:7766f6712673 | 104 | */ | 
| yueee_yt | 0:7766f6712673 | 105 | u32_t lpc_mii_read_data(void); | 
| yueee_yt | 0:7766f6712673 | 106 | |
| yueee_yt | 0:7766f6712673 | 107 | /** \brief Starts a read operation via the MII link (non-blocking) | 
| yueee_yt | 0:7766f6712673 | 108 | * | 
| yueee_yt | 0:7766f6712673 | 109 | * This function will start a read operation on the MII link interface | 
| yueee_yt | 0:7766f6712673 | 110 | * from a PHY or a connected device. The function will not block and | 
| yueee_yt | 0:7766f6712673 | 111 | * the status mist be polled until complete. Once complete, the data | 
| yueee_yt | 0:7766f6712673 | 112 | * can be read. | 
| yueee_yt | 0:7766f6712673 | 113 | * | 
| yueee_yt | 0:7766f6712673 | 114 | * \param[in] PhyReg PHY register to read from | 
| yueee_yt | 0:7766f6712673 | 115 | */ | 
| yueee_yt | 0:7766f6712673 | 116 | err_t lpc_mii_read(u32_t PhyReg, u32_t *data); | 
| yueee_yt | 0:7766f6712673 | 117 | |
| yueee_yt | 0:7766f6712673 | 118 | /** \brief Read a value via the MII link (blocking) | 
| yueee_yt | 0:7766f6712673 | 119 | * | 
| yueee_yt | 0:7766f6712673 | 120 | * This function will read a value on the MII link interface from a PHY | 
| yueee_yt | 0:7766f6712673 | 121 | * or a connected device. The function will block until complete. | 
| yueee_yt | 0:7766f6712673 | 122 | * | 
| yueee_yt | 0:7766f6712673 | 123 | * \param[in] PhyReg PHY register to read from | 
| yueee_yt | 0:7766f6712673 | 124 | * \param[in] data Pointer to where to save data read via MII | 
| yueee_yt | 0:7766f6712673 | 125 | * \returns 0 if the read was successful, otherwise !0 | 
| yueee_yt | 0:7766f6712673 | 126 | */ | 
| yueee_yt | 0:7766f6712673 | 127 | void lpc_mii_read_noblock(u32_t PhyReg); | 
| yueee_yt | 0:7766f6712673 | 128 | |
| yueee_yt | 0:7766f6712673 | 129 | /** | 
| yueee_yt | 0:7766f6712673 | 130 | * This function provides a method for the PHY to setup the EMAC | 
| yueee_yt | 0:7766f6712673 | 131 | * for the PHY negotiated duplex mode. | 
| yueee_yt | 0:7766f6712673 | 132 | * | 
| yueee_yt | 0:7766f6712673 | 133 | * @param[in] full_duplex 0 = half duplex, 1 = full duplex | 
| yueee_yt | 0:7766f6712673 | 134 | */ | 
| yueee_yt | 0:7766f6712673 | 135 | void lpc_emac_set_duplex(int full_duplex); | 
| yueee_yt | 0:7766f6712673 | 136 | |
| yueee_yt | 0:7766f6712673 | 137 | /** | 
| yueee_yt | 0:7766f6712673 | 138 | * This function provides a method for the PHY to setup the EMAC | 
| yueee_yt | 0:7766f6712673 | 139 | * for the PHY negotiated bit rate. | 
| yueee_yt | 0:7766f6712673 | 140 | * | 
| yueee_yt | 0:7766f6712673 | 141 | * @param[in] mbs_100 0 = 10mbs mode, 1 = 100mbs mode | 
| yueee_yt | 0:7766f6712673 | 142 | */ | 
| yueee_yt | 0:7766f6712673 | 143 | void lpc_emac_set_speed(int mbs_100); | 
| yueee_yt | 0:7766f6712673 | 144 | |
| yueee_yt | 0:7766f6712673 | 145 | #ifdef __cplusplus | 
| yueee_yt | 0:7766f6712673 | 146 | } | 
| yueee_yt | 0:7766f6712673 | 147 | #endif | 
| yueee_yt | 0:7766f6712673 | 148 | |
| yueee_yt | 0:7766f6712673 | 149 | #endif /* __LPC_PHY_H_ */ | 
| yueee_yt | 0:7766f6712673 | 150 | |
| yueee_yt | 0:7766f6712673 | 151 | /* --------------------------------- End Of File ------------------------------ */ |