1
0

ethernet.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. //*****************************************************************************
  2. //
  3. // ethernet.h - Defines and Macros for the ethernet module.
  4. //
  5. // Copyright (c) 2006-2011 Texas Instruments Incorporated. All rights reserved.
  6. // Software License Agreement
  7. //
  8. // Texas Instruments (TI) is supplying this software for use solely and
  9. // exclusively on TI's microcontroller products. The software is owned by
  10. // TI and/or its suppliers, and is protected under applicable copyright
  11. // laws. You may not combine this software with "viral" open-source
  12. // software in order to form a larger program.
  13. //
  14. // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
  15. // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
  16. // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  17. // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
  18. // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
  19. // DAMAGES, FOR ANY REASON WHATSOEVER.
  20. //
  21. // This is part of revision 8264 of the Stellaris Peripheral Driver Library.
  22. //
  23. //*****************************************************************************
  24. #ifndef __ETHERNET_H__
  25. #define __ETHERNET_H__
  26. //*****************************************************************************
  27. //
  28. // If building with a C++ compiler, make all of the definitions in this header
  29. // have a C binding.
  30. //
  31. //*****************************************************************************
  32. #ifdef __cplusplus
  33. extern "C"
  34. {
  35. #endif
  36. //*****************************************************************************
  37. //
  38. // Values that can be passed to EthernetConfigSet as the ulConfig value, and
  39. // returned from EthernetConfigGet.
  40. //
  41. //*****************************************************************************
  42. #define ETH_CFG_TS_TSEN 0x010000 // Enable Timestamp (CCP)
  43. #define ETH_CFG_RX_BADCRCDIS 0x000800 // Disable RX BAD CRC Packets
  44. #define ETH_CFG_RX_PRMSEN 0x000400 // Enable RX Promiscuous
  45. #define ETH_CFG_RX_AMULEN 0x000200 // Enable RX Multicast
  46. #define ETH_CFG_TX_DPLXEN 0x000010 // Enable TX Duplex Mode
  47. #define ETH_CFG_TX_CRCEN 0x000004 // Enable TX CRC Generation
  48. #define ETH_CFG_TX_PADEN 0x000002 // Enable TX Padding
  49. //*****************************************************************************
  50. //
  51. // Values that can be passed to EthernetIntEnable, EthernetIntDisable, and
  52. // EthernetIntClear as the ulIntFlags parameter, and returned from
  53. // EthernetIntStatus.
  54. //
  55. //*****************************************************************************
  56. #define ETH_INT_PHY 0x040 // PHY Event/Interrupt
  57. #define ETH_INT_MDIO 0x020 // Management Transaction
  58. #define ETH_INT_RXER 0x010 // RX Error
  59. #define ETH_INT_RXOF 0x008 // RX FIFO Overrun
  60. #define ETH_INT_TX 0x004 // TX Complete
  61. #define ETH_INT_TXER 0x002 // TX Error
  62. #define ETH_INT_RX 0x001 // RX Complete
  63. //*****************************************************************************
  64. //
  65. // Helper Macros for Ethernet Processing
  66. //
  67. //*****************************************************************************
  68. //
  69. // htonl/ntohl - big endian/little endian byte swapping macros for
  70. // 32-bit (long) values
  71. //
  72. //*****************************************************************************
  73. #ifndef htonl
  74. #define htonl(a) \
  75. ((((a) >> 24) & 0x000000ff) | \
  76. (((a) >> 8) & 0x0000ff00) | \
  77. (((a) << 8) & 0x00ff0000) | \
  78. (((a) << 24) & 0xff000000))
  79. #endif
  80. #ifndef ntohl
  81. #define ntohl(a) htonl((a))
  82. #endif
  83. //*****************************************************************************
  84. //
  85. // htons/ntohs - big endian/little endian byte swapping macros for
  86. // 16-bit (short) values
  87. //
  88. //*****************************************************************************
  89. #ifndef htons
  90. #define htons(a) \
  91. ((((a) >> 8) & 0x00ff) | \
  92. (((a) << 8) & 0xff00))
  93. #endif
  94. #ifndef ntohs
  95. #define ntohs(a) htons((a))
  96. #endif
  97. //*****************************************************************************
  98. //
  99. // API Function prototypes
  100. //
  101. //*****************************************************************************
  102. extern void EthernetInitExpClk(unsigned long ulBase, unsigned long ulEthClk);
  103. extern void EthernetConfigSet(unsigned long ulBase, unsigned long ulConfig);
  104. extern unsigned long EthernetConfigGet(unsigned long ulBase);
  105. extern void EthernetMACAddrSet(unsigned long ulBase,
  106. unsigned char *pucMACAddr);
  107. extern void EthernetMACAddrGet(unsigned long ulBase,
  108. unsigned char *pucMACAddr);
  109. extern void EthernetEnable(unsigned long ulBase);
  110. extern void EthernetDisable(unsigned long ulBase);
  111. extern tBoolean EthernetPacketAvail(unsigned long ulBase);
  112. extern tBoolean EthernetSpaceAvail(unsigned long ulBase);
  113. extern long EthernetPacketGetNonBlocking(unsigned long ulBase,
  114. unsigned char *pucBuf,
  115. long lBufLen);
  116. extern long EthernetPacketGet(unsigned long ulBase, unsigned char *pucBuf,
  117. long lBufLen);
  118. extern long EthernetPacketPutNonBlocking(unsigned long ulBase,
  119. unsigned char *pucBuf,
  120. long lBufLen);
  121. extern long EthernetPacketPut(unsigned long ulBase, unsigned char *pucBuf,
  122. long lBufLen);
  123. extern void EthernetIntRegister(unsigned long ulBase,
  124. void (*pfnHandler)(void));
  125. extern void EthernetIntUnregister(unsigned long ulBase);
  126. extern void EthernetIntEnable(unsigned long ulBase, unsigned long ulIntFlags);
  127. extern void EthernetIntDisable(unsigned long ulBase, unsigned long ulIntFlags);
  128. extern unsigned long EthernetIntStatus(unsigned long ulBase, tBoolean bMasked);
  129. extern void EthernetIntClear(unsigned long ulBase, unsigned long ulIntFlags);
  130. extern void EthernetPHYAddrSet(unsigned long ulBase, unsigned char ucAddr);
  131. extern void EthernetPHYWrite(unsigned long ulBase, unsigned char ucRegAddr,
  132. unsigned long ulData);
  133. extern unsigned long EthernetPHYRead(unsigned long ulBase,
  134. unsigned char ucRegAddr);
  135. extern void EthernetPHYPowerOff(unsigned long ulBase);
  136. extern void EthernetPHYPowerOn(unsigned long ulBase);
  137. //*****************************************************************************
  138. //
  139. // Several Ethernet APIs have been renamed, with the original function name
  140. // being deprecated. These defines provide backward compatibility.
  141. //
  142. //*****************************************************************************
  143. #ifndef DEPRECATED
  144. #include "driverlib/sysctl.h"
  145. #define EthernetInit(a) \
  146. EthernetInitExpClk(a, SysCtlClockGet())
  147. #define EthernetPacketNonBlockingGet(a, b, c) \
  148. EthernetPacketGetNonBlocking(a, b, c)
  149. #define EthernetPacketNonBlockingPut(a, b, c) \
  150. EthernetPacketPutNonBlocking(a, b, c)
  151. #endif
  152. //*****************************************************************************
  153. //
  154. // Mark the end of the C bindings section for C++ compilers.
  155. //
  156. //*****************************************************************************
  157. #ifdef __cplusplus
  158. }
  159. #endif
  160. #endif // __ETHERNET_H__