Onenet

Dependents:   K64F_eCompass_OneNET_JW

Committer:
robert_jw
Date:
Mon Jun 20 01:40:20 2016 +0000
Revision:
0:b2805b6888dc
ADS

Who changed what in which revision?

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