Program for test the tcp/ip communication between mbed and Android phone

Dependencies:   EthernetInterface mbed-rtos mbed

Notebook page HERE

Committer:
edodm85
Date:
Wed Jul 20 20:24:15 2016 +0000
Revision:
0:149b394928f3
First commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
edodm85 0:149b394928f3 1 #include "lpc_phy.h"
edodm85 0:149b394928f3 2
edodm85 0:149b394928f3 3 /** \brief DP83848 PHY status definitions */
edodm85 0:149b394928f3 4 #define DP8_REMOTEFAULT (1 << 6) /**< Remote fault */
edodm85 0:149b394928f3 5 #define DP8_FULLDUPLEX (1 << 2) /**< 1=full duplex */
edodm85 0:149b394928f3 6 #define DP8_SPEED10MBPS (1 << 1) /**< 1=10MBps speed */
edodm85 0:149b394928f3 7 #define DP8_VALID_LINK (1 << 0) /**< 1=Link active */
edodm85 0:149b394928f3 8
edodm85 0:149b394928f3 9
edodm85 0:149b394928f3 10 // This function returns the current status of connection.
edodm85 0:149b394928f3 11 static bool get_link_status()
edodm85 0:149b394928f3 12 {
edodm85 0:149b394928f3 13 u32_t tmp = lpc_mii_read_data();
edodm85 0:149b394928f3 14 return (tmp & DP8_VALID_LINK) ? true : false;
edodm85 0:149b394928f3 15 }
edodm85 0:149b394928f3 16
edodm85 0:149b394928f3 17 // This function returns the status of transmission.
edodm85 0:149b394928f3 18 static char* get_transmission_status()
edodm85 0:149b394928f3 19 {
edodm85 0:149b394928f3 20 u32_t tmp = lpc_mii_read_data();
edodm85 0:149b394928f3 21 if(tmp & DP8_FULLDUPLEX)
edodm85 0:149b394928f3 22 {
edodm85 0:149b394928f3 23 return "FULL DUPLEX";
edodm85 0:149b394928f3 24 }else
edodm85 0:149b394928f3 25 {
edodm85 0:149b394928f3 26 return "HALF DUPLEX";
edodm85 0:149b394928f3 27 }
edodm85 0:149b394928f3 28 }
edodm85 0:149b394928f3 29
edodm85 0:149b394928f3 30 // This function returns the speed of the connection.
edodm85 0:149b394928f3 31 static int get_connection_speed()
edodm85 0:149b394928f3 32 {
edodm85 0:149b394928f3 33 u32_t tmp = lpc_mii_read_data();
edodm85 0:149b394928f3 34 return (tmp & DP8_SPEED10MBPS) ? 10 : 100;
edodm85 0:149b394928f3 35 }
edodm85 0:149b394928f3 36
edodm85 0:149b394928f3 37 // This function returns the current value in the MII data register.
edodm85 0:149b394928f3 38 static u32_t mii_read_data()
edodm85 0:149b394928f3 39 {
edodm85 0:149b394928f3 40 return lpc_mii_read_data(); // 16-bit MRDD - address 0x2008 4030
edodm85 0:149b394928f3 41 // 16661 = 100000100010101 (full duplex - 100Mbps) // 16659 = 100000100010011 (half duplex - 10Mbps)
edodm85 0:149b394928f3 42 }
edodm85 0:149b394928f3 43
edodm85 0:149b394928f3 44
edodm85 0:149b394928f3 45 /*
edodm85 0:149b394928f3 46 // Starts a read operation via the MII link (non-blocking)
edodm85 0:149b394928f3 47 u32_t lpc_mii_read_data(void)
edodm85 0:149b394928f3 48 {
edodm85 0:149b394928f3 49 u32_t data = LPC_EMAC->MRDD;
edodm85 0:149b394928f3 50 LPC_EMAC->MCMD = 0;
edodm85 0:149b394928f3 51
edodm85 0:149b394928f3 52 return data;
edodm85 0:149b394928f3 53 }
edodm85 0:149b394928f3 54 */