ethernet.h 7.5 KB

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