hd_eth.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*!
  2. \file gd32f30x_enet_eval.h
  3. \brief the header file of gd32f30x_enet_eval
  4. \version 2017-02-10, V1.0.0, firmware for GD32F30x
  5. \version 2018-10-10, V1.1.0, firmware for GD32F30x
  6. \version 2018-12-25, V2.0.0, firmware for GD32F30x
  7. */
  8. /*
  9. Copyright (c) 2018, GigaDevice Semiconductor Inc.
  10. All rights reserved.
  11. Redistribution and use in source and binary forms, with or without modification,
  12. are permitted provided that the following conditions are met:
  13. 1. Redistributions of source code must retain the above copyright notice, this
  14. list of conditions and the following disclaimer.
  15. 2. Redistributions in binary form must reproduce the above copyright notice,
  16. this list of conditions and the following disclaimer in the documentation
  17. and/or other materials provided with the distribution.
  18. 3. Neither the name of the copyright holder nor the names of its contributors
  19. may be used to endorse or promote products derived from this software without
  20. specific prior written permission.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  22. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  23. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  24. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  25. INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  26. NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  27. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  28. WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  29. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  30. OF SUCH DAMAGE.
  31. */
  32. #ifndef HD_ETH_H
  33. #define HD_ETH_H
  34. #define DP83848_PHY_ADDRESS 0x1
  35. #define ETH_INIT_FLAG 0x01 /* Ethernet Init Flag */
  36. #define ETH_LINK_FLAG 0x10 /* Ethernet Link Flag */
  37. #define USE_DHCP /* enable DHCP, if disabled static address is used */
  38. /* MAC address: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
  39. #define MAC_ADDR0 2
  40. //取唯一id做为MAC地址0x1fffF7E8为gd32f307芯片唯一id地址
  41. #define MAC_ADDR1 (uint8_t)((*(uint32_t*)(0x1fffF7E8))>> 0)
  42. #define MAC_ADDR2 (uint8_t)((*(uint32_t*)(0x1fffF7E8))>> 8)
  43. #define MAC_ADDR3 (uint8_t)((*(uint32_t*)(0x1fffF7E8))>> 16)
  44. #define MAC_ADDR4 (uint8_t)((*(uint32_t*)(0x1fffF7E8))>> 24)
  45. #define MAC_ADDR5 0
  46. /* static IP address: IP_ADDR0.IP_ADDR1.IP_ADDR2.IP_ADDR3 */
  47. #define IP_ADDR0 192
  48. #define IP_ADDR1 168
  49. #define IP_ADDR2 2
  50. #define IP_ADDR3 126
  51. /* remote station IP address: IP_S_ADDR0.IP_S_ADDR1.IP_S_ADDR2.IP_S_ADDR3 */
  52. #define IP_S_ADDR0 192
  53. #define IP_S_ADDR1 168
  54. #define IP_S_ADDR2 2
  55. #define IP_S_ADDR3 22
  56. /* net mask */
  57. #define NETMASK_ADDR0 255
  58. #define NETMASK_ADDR1 255
  59. #define NETMASK_ADDR2 254
  60. #define NETMASK_ADDR3 0
  61. /* gateway address */
  62. #define GW_ADDR0 192
  63. #define GW_ADDR1 168
  64. #define GW_ADDR2 2
  65. #define GW_ADDR3 1
  66. /* MII and RMII mode selection */
  67. //#define RMII_MODE // user have to provide the 50 MHz clock by soldering a 50 MHz oscillator
  68. #define MII_MODE
  69. /* clock the PHY from external 25MHz crystal (only for MII mode) */
  70. #ifdef MII_MODE
  71. #define PHY_CLOCK_MCO
  72. #endif
  73. /* function declarations */
  74. /* setup ethernet system(GPIOs, clocks, MAC, DMA, systick) */
  75. void enet_system_setup(void);
  76. extern volatile uint32_t EthStatus;
  77. #endif /* GD32F30x_ENET_EVAL_H */