drv_eth.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /**
  2. * Copyright (C) 2016 CSI Project. All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef _CSI_NET_H_
  17. #define _CSI_NET_H_
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. #define CSI_ETH_VERSION_MAJOR_MINOR(major,minor) (((major) << 8) | (minor))
  22. /**
  23. \brief Driver Version
  24. */
  25. typedef struct csi_driver_version {
  26. uint16_t api; ///< API version
  27. uint16_t drv; ///< Driver version
  28. } csi_drv_version_t;
  29. /* General return codes */
  30. #define CSI_ETH_OK 0 ///< Operation succeeded
  31. #define CSI_ETH_ERROR CSI_DRV_ERRNO_ETH_BASE+1 ///< Unspecified error
  32. #define CSI_ETH_ERROR_BUSY CSI_DRV_ERRNO_ETH_BASE+2 ///< Driver is busy
  33. #define CSI_ETH_ERROR_TIMEOUT CSI_DRV_ERRNO_ETH_BASE+3 ///< Timeout occurred
  34. #define CSI_ETH_ERROR_UNSUPPORTED CSI_DRV_ERRNO_ETH_BASE+4 ///< Operation not supported
  35. #define CSI_ETH_ERROR_PARAMETER CSI_DRV_ERRNO_ETH_BASE+5 ///< Parameter error
  36. #define CSI_ETH_ERROR_SPECIFIC CSI_DRV_ERRNO_ETH_BASE+6 ///< Start of driver specific errors
  37. /**
  38. \brief General power states
  39. */
  40. typedef enum eth_power_state {
  41. CSI_ETH_POWER_OFF, ///< Power off: no operation possible
  42. CSI_ETH_POWER_LOW, ///< Low Power mode: retain state, detect and signal wake-up events
  43. CSI_ETH_POWER_FULL ///< Power on: full operation at maximum performance
  44. } eth_power_state_t;
  45. /**
  46. \brief Ethernet Media Interface type
  47. */
  48. #define CSI_ETH_INTERFACE_MII (0) ///< Media Independent Interface (MII)
  49. #define CSI_ETH_INTERFACE_RMII (1) ///< Reduced Media Independent Interface (RMII)
  50. #define CSI_ETH_INTERFACE_SMII (2) ///< Serial Media Independent Interface (SMII)
  51. /**
  52. \brief Ethernet link speed
  53. */
  54. #define CSI_ETH_SPEED_10M (0) ///< 10 Mbps link speed
  55. #define CSI_ETH_SPEED_100M (1) ///< 100 Mbps link speed
  56. #define CSI_ETH_SPEED_1G (2) ///< 1 Gpbs link speed
  57. /**
  58. \brief Ethernet duplex mode
  59. */
  60. #define CSI_ETH_DUPLEX_HALF (0) ///< Half duplex link
  61. #define CSI_ETH_DUPLEX_FULL (1) ///< Full duplex link
  62. /**
  63. \brief Ethernet link state
  64. */
  65. typedef enum eth_link_state {
  66. ETH_LINK_DOWN, ///< Link is down
  67. ETH_LINK_UP ///< Link is up
  68. } eth_link_state_t;
  69. /**
  70. \brief Ethernet link information
  71. */
  72. typedef volatile struct eth_link_info {
  73. uint32_t speed : 2; ///< Link speed: 0= 10 MBit, 1= 100 MBit, 2= 1 GBit
  74. uint32_t duplex : 1; ///< Duplex mode: 0= Half, 1= Full
  75. uint32_t Autonegotiation : 1; ///< Set the interface to Auto Negotiation mode of transmission parameters
  76. uint32_t Loopback : 1; ///< Set the interface into a Loop-back test mode
  77. uint32_t Isolation : 1; ///< Set to indicate electrical isolation of PHY interface from MII/RMII interface
  78. uint32_t reserved : 26;
  79. } eth_link_info_t;
  80. /**
  81. \brief Ethernet MAC Address
  82. */
  83. typedef struct eth_mac_addr {
  84. uint8_t b[6]; ///< MAC Address (6 bytes), MSB first
  85. } eth_mac_addr_t;
  86. #ifdef __cplusplus
  87. }
  88. #endif
  89. #endif /* CSI_NET_H_ */