117 lines
3.7 KiB
C
117 lines
3.7 KiB
C
/* USER CODE BEGIN Header */
|
|
/**
|
|
******************************************************************************
|
|
* @file : hal_stm32f4_eth.h
|
|
* @brief : STM32F4 specific Ethernet interface header file
|
|
******************************************************************************
|
|
*/
|
|
/* USER CODE END Header */
|
|
|
|
#ifndef HAL_STM32F4_ETH_H
|
|
#define HAL_STM32F4_ETH_H
|
|
|
|
#include "../../hal_eth.h"
|
|
#include "stm32f4xx_hal.h"
|
|
|
|
/**
|
|
* @brief STM32F4 Ethernet handle structure
|
|
*/
|
|
typedef struct {
|
|
ETH_HandleTypeDef heth; /*!< Ethernet handle */
|
|
uint8_t initialized; /*!< Initialization flag */
|
|
hal_eth_phy_addr_t phy_addr; /*!< PHY address */
|
|
uint32_t rx_packets; /*!< Received packets count */
|
|
uint32_t tx_packets; /*!< Transmitted packets count */
|
|
uint32_t rx_errors; /*!< Receive errors count */
|
|
uint32_t tx_errors; /*!< Transmit errors count */
|
|
} hal_stm32f4_eth_handle_t;
|
|
|
|
/**
|
|
* @brief Initialize STM32F4 Ethernet module
|
|
* @param config: Pointer to Ethernet configuration structure
|
|
* @retval HAL status code
|
|
*/
|
|
hal_ret_t hal_stm32f4_eth_init(const hal_eth_config_t* config);
|
|
|
|
/**
|
|
* @brief Deinitialize STM32F4 Ethernet module
|
|
* @param instance: Ethernet instance
|
|
* @retval HAL status code
|
|
*/
|
|
hal_ret_t hal_stm32f4_eth_deinit(hal_eth_instance_t instance);
|
|
|
|
/**
|
|
* @brief Get STM32F4 Ethernet status
|
|
* @param instance: Ethernet instance
|
|
* @param status: Pointer to Ethernet status structure
|
|
* @retval HAL status code
|
|
*/
|
|
hal_ret_t hal_stm32f4_eth_get_status(hal_eth_instance_t instance, hal_eth_status_t* status);
|
|
|
|
/**
|
|
* @brief Set STM32F4 Ethernet MAC address
|
|
* @param instance: Ethernet instance
|
|
* @param mac_addr: Pointer to MAC address structure
|
|
* @retval HAL status code
|
|
*/
|
|
hal_ret_t hal_stm32f4_eth_set_mac_addr(hal_eth_instance_t instance, const hal_eth_mac_addr_t* mac_addr);
|
|
|
|
/**
|
|
* @brief Get STM32F4 Ethernet MAC address
|
|
* @param instance: Ethernet instance
|
|
* @param mac_addr: Pointer to MAC address structure
|
|
* @retval HAL status code
|
|
*/
|
|
hal_ret_t hal_stm32f4_eth_get_mac_addr(hal_eth_instance_t instance, hal_eth_mac_addr_t* mac_addr);
|
|
|
|
/**
|
|
* @brief Check STM32F4 Ethernet link status
|
|
* @param instance: Ethernet instance
|
|
* @param link_up: Pointer to store link up status
|
|
* @retval HAL status code
|
|
*/
|
|
hal_ret_t hal_stm32f4_eth_check_link(hal_eth_instance_t instance, uint8_t* link_up);
|
|
|
|
/**
|
|
* @brief Reset STM32F4 Ethernet PHY
|
|
* @param instance: Ethernet instance
|
|
* @param phy_addr: PHY address
|
|
* @retval HAL status code
|
|
*/
|
|
hal_ret_t hal_stm32f4_eth_reset_phy(hal_eth_instance_t instance, hal_eth_phy_addr_t phy_addr);
|
|
|
|
/**
|
|
* @brief Read STM32F4 Ethernet PHY register
|
|
* @param instance: Ethernet instance
|
|
* @param phy_addr: PHY address
|
|
* @param reg_addr: Register address
|
|
* @param value: Pointer to store register value
|
|
* @retval HAL status code
|
|
*/
|
|
hal_ret_t hal_stm32f4_eth_read_phy_reg(hal_eth_instance_t instance, hal_eth_phy_addr_t phy_addr, uint16_t reg_addr, uint16_t* value);
|
|
|
|
/**
|
|
* @brief Write STM32F4 Ethernet PHY register
|
|
* @param instance: Ethernet instance
|
|
* @param phy_addr: PHY address
|
|
* @param reg_addr: Register address
|
|
* @param value: Register value
|
|
* @retval HAL status code
|
|
*/
|
|
hal_ret_t hal_stm32f4_eth_write_phy_reg(hal_eth_instance_t instance, hal_eth_phy_addr_t phy_addr, uint16_t reg_addr, uint16_t value);
|
|
|
|
/**
|
|
* @brief Configure STM32F4 Ethernet GPIO
|
|
* @retval HAL status code
|
|
*/
|
|
hal_ret_t hal_stm32f4_eth_gpio_config(void);
|
|
|
|
/**
|
|
* @brief Get STM32F4 Ethernet handle
|
|
* @param instance: Ethernet instance
|
|
* @retval Pointer to Ethernet handle structure
|
|
*/
|
|
hal_stm32f4_eth_handle_t* hal_stm32f4_eth_get_handle(hal_eth_instance_t instance);
|
|
|
|
#endif /* HAL_STM32F4_ETH_H */
|