Counter

Dependencies:   EthernetInterface NTPClient SDFileSystem TextLCD WebSocketClient mbed-rtos mbed Socket lwip-eth lwip-sys lwip FATFileSystem

Committer:
Tuxitheone
Date:
Mon Feb 29 18:59:15 2016 +0000
Revision:
0:ecaf3e593122
TankCounter

Who changed what in which revision?

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