|
12 | 12 | extern "C" { |
13 | 13 | #endif |
14 | 14 |
|
| 15 | +/** |
| 16 | + * @brief Ethernet handle type |
| 17 | + * |
| 18 | + * This is a handle to an Ethernet instance, used for managing Ethernet operations. |
| 19 | + */ |
15 | 20 | typedef void *iot_eth_handle_t; |
16 | 21 |
|
| 22 | +/** |
| 23 | + * @brief Ethernet configuration structure |
| 24 | + * |
| 25 | + * This structure holds the configuration for initializing an Ethernet instance. |
| 26 | + */ |
17 | 27 | typedef struct { |
18 | | - iot_eth_driver_t *driver; |
19 | | - esp_err_t (*on_lowlevel_init_done)(iot_eth_handle_t handle); |
20 | | - esp_err_t (*on_lowlevel_deinit)(iot_eth_handle_t handle); |
21 | | - esp_err_t (*stack_input)(iot_eth_handle_t handle, uint8_t *data, size_t len, void *user_data); |
22 | | - void *user_data; |
| 28 | + iot_eth_driver_t *driver; /*!< Pointer to the Ethernet driver */ |
| 29 | + esp_err_t (*on_lowlevel_init_done)(iot_eth_handle_t handle); /*!< Callback for low-level initialization completion */ |
| 30 | + esp_err_t (*on_lowlevel_deinit)(iot_eth_handle_t handle); /*!< Callback for low-level deinitialization */ |
| 31 | + esp_err_t (*stack_input)(iot_eth_handle_t handle, uint8_t *data, size_t len, void *user_data); /*!< Function pointer for stack input */ |
| 32 | + void *user_data; /*!< User data for callbacks */ |
23 | 33 | } iot_eth_config_t; |
24 | 34 |
|
| 35 | +/* |
| 36 | + * @brief Install Ethernet driver |
| 37 | + * |
| 38 | + * This function initializes the Ethernet driver and network interface. |
| 39 | + * |
| 40 | + * @param config Ethernet configuration |
| 41 | + * @param handle Pointer to the Ethernet handle |
| 42 | + * |
| 43 | + * @return |
| 44 | + * - ESP_OK on success |
| 45 | + * - ESP_ERR_INVALID_ARG if arguments are invalid |
| 46 | + * - ESP_ERR_NO_MEM if memory allocation fails |
| 47 | + * - Other error codes from initialization functions |
| 48 | + */ |
25 | 49 | esp_err_t iot_eth_install(iot_eth_config_t *config, iot_eth_handle_t *handle); |
26 | 50 |
|
| 51 | +/* |
| 52 | + * @brief Uninstall Ethernet driver |
| 53 | + * |
| 54 | + * This function deinitializes the Ethernet driver and frees resources. |
| 55 | + * |
| 56 | + * @param handle Ethernet handle |
| 57 | + * |
| 58 | + * @return |
| 59 | + * - ESP_OK on success |
| 60 | + * - Error code from driver deinitialization |
| 61 | + */ |
27 | 62 | esp_err_t iot_eth_uninstall(iot_eth_handle_t handle); |
28 | 63 |
|
| 64 | +/* |
| 65 | + * @brief Start Ethernet driver |
| 66 | + * |
| 67 | + * This function starts the Ethernet driver. |
| 68 | + * |
| 69 | + * @param handle Ethernet handle |
| 70 | + * |
| 71 | + * @return |
| 72 | + * - ESP_OK on success |
| 73 | + * - Error code from driver start function |
| 74 | + */ |
29 | 75 | esp_err_t iot_eth_start(iot_eth_handle_t handle); |
30 | 76 |
|
| 77 | +/* |
| 78 | + * @brief Stop Ethernet driver |
| 79 | + * |
| 80 | + * This function stops the Ethernet driver. |
| 81 | + * |
| 82 | + * @param handle Ethernet handle |
| 83 | + * |
| 84 | + * @return |
| 85 | + * - ESP_OK on success |
| 86 | + * - Error code from driver stop function |
| 87 | + */ |
31 | 88 | esp_err_t iot_eth_stop(iot_eth_handle_t handle); |
32 | 89 |
|
| 90 | +/* |
| 91 | + * @brief Transmit data over Ethernet |
| 92 | + * |
| 93 | + * This function sends data through the Ethernet driver. |
| 94 | + * |
| 95 | + * @param handle Ethernet handle |
| 96 | + * @param data Pointer to the data to be sent |
| 97 | + * @param len Length of the data to be sent |
| 98 | + * |
| 99 | + * @return |
| 100 | + * - ESP_OK on success |
| 101 | + * - ESP_ERR_INVALID_ARG if arguments are invalid |
| 102 | + * - ESP_ERR_INVALID_STATE if Ethernet link is down |
| 103 | + */ |
33 | 104 | esp_err_t iot_eth_transmit(iot_eth_handle_t handle, uint8_t *data, size_t len); |
34 | 105 |
|
| 106 | +/* |
| 107 | + * @brief Get Ethernet MAC address |
| 108 | + * |
| 109 | + * This function retrieves the MAC address of the Ethernet interface. |
| 110 | + * |
| 111 | + * @param handle Ethernet handle |
| 112 | + * @param mac Pointer to the MAC address buffer |
| 113 | + * |
| 114 | + * @return |
| 115 | + * - ESP_OK on success |
| 116 | + * - Error code from driver get address function |
| 117 | + */ |
35 | 118 | esp_err_t iot_eth_get_addr(iot_eth_handle_t handle, uint8_t *mac); |
36 | 119 |
|
37 | 120 | #ifdef __cplusplus |
|
0 commit comments