LibDriver LAN8720  1.0.0
LAN8720 full-featured driver
driver_lan8720.h File Reference

driver lan8720 header file More...

#include <stdio.h>
#include <stdint.h>
#include <string.h>

Go to the source code of this file.

Data Structures

struct  lan8720_handle_s
 lan8720 handle structure definition More...
 
struct  lan8720_info_s
 lan8720 information structure definition More...
 

Macros

#define DRIVER_LAN8720_LINK_INIT(HANDLE, STRUCTURE)   memset(HANDLE, 0, sizeof(STRUCTURE))
 initialize lan8720_handle_t structure More...
 
#define DRIVER_LAN8720_LINK_SMI_INIT(HANDLE, FUC)   (HANDLE)->smi_init = FUC
 link smi_init function More...
 
#define DRIVER_LAN8720_LINK_SMI_DEINIT(HANDLE, FUC)   (HANDLE)->smi_deinit = FUC
 link smi_deinit function More...
 
#define DRIVER_LAN8720_LINK_SMI_READ(HANDLE, FUC)   (HANDLE)->smi_read = FUC
 link smi_read function More...
 
#define DRIVER_LAN8720_LINK_SMI_WRITE(HANDLE, FUC)   (HANDLE)->smi_write = FUC
 link smi_write function More...
 
#define DRIVER_LAN8720_LINK_RESET_GPIO_INIT(HANDLE, FUC)   (HANDLE)->reset_gpio_init = FUC
 link reset_gpio_init function More...
 
#define DRIVER_LAN8720_LINK_RESET_GPIO_DEINIT(HANDLE, FUC)   (HANDLE)->reset_gpio_deinit = FUC
 link reset_gpio_deinit function More...
 
#define DRIVER_LAN8720_LINK_RESET_GPIO_WRITE(HANDLE, FUC)   (HANDLE)->reset_gpio_write = FUC
 link reset_gpio_write function More...
 
#define DRIVER_LAN8720_LINK_DELAY_MS(HANDLE, FUC)   (HANDLE)->delay_ms = FUC
 link delay_ms function More...
 
#define DRIVER_LAN8720_LINK_DEBUG_PRINT(HANDLE, FUC)   (HANDLE)->debug_print = FUC
 link debug_print function More...
 

Typedefs

typedef struct lan8720_handle_s lan8720_handle_t
 lan8720 handle structure definition More...
 
typedef struct lan8720_info_s lan8720_info_t
 lan8720 information structure definition More...
 

Enumerations

enum  lan8720_bool_t { LAN8720_BOOL_FALSE = 0x00 , LAN8720_BOOL_TRUE = 0x01 }
 lan8720 bool enumeration definition More...
 
enum  lan8720_speed_t { LAN8720_SPEED_10M = 0x00 , LAN8720_SPEED_100M = 0x01 }
 lan8720 speed enumeration definition More...
 
enum  lan8720_duplex_t { LAN8720_DUPLEX_HALF = 0x00 , LAN8720_DUPLEX_FULL = 0x01 }
 lan8720 duplex enumeration definition More...
 
enum  lan8720_link_t { LAN8720_LINK_DOWN = 0x00 , LAN8720_LINK_UP = 0x01 }
 lan8720 link enumeration definition More...
 
enum  lan8720_pause_t { LAN8720_PAUSE_NO = 0x00 , LAN8720_PAUSE_SYMMETRIC = 0x01 , LAN8720_PAUSE_ASYMMETRIC = 0x02 , LAN8720_PAUSE_BOTH = 0x03 }
 lan8720 pause enumeration definition More...
 
enum  lan8720_mode_t {
  LAN8720_MODE_10BASE_T_HALF_DUPLEX = 0x00 , LAN8720_MODE_10BASE_T_FULL_DUPLEX = 0x01 , LAN8720_MODE_100BASE_TX_HALF_DUPLEX = 0x02 , LAN8720_MODE_100BASE_TX_FULL_DUPLEX = 0x03 ,
  LAN8720_MODE_100BASE_TX_HALF_DUPLEX_ADVERTISED = 0x04 , LAN8720_MODE_REPEATER_MODE = 0x05 , LAN8720_MODE_POWER_DOWN_MODE = 0x06 , LAN8720_MODE_ALL_CAPABLE = 0x07
}
 lan8720 mode enumeration definition More...
 
enum  lan8720_manual_channel_select_t { LAN8720_MANUAL_CHANNEL_SELECT_MDI = 0x00 , LAN8720_MANUAL_CHANNEL_SELECT_MDIX = 0x01 }
 lan8720 manual channel select enumeration definition More...
 
enum  lan8720_polarity_t { LAN8720_POLARITY_NORMAL = 0x00 , LAN8720_POLARITY_REVERSED = 0x01 }
 lan8720 polarity enumeration definition More...
 
enum  lan8720_interrupt_t {
  LAN8720_INTERRUPT_ENERGY_ON = 7 , LAN8720_INTERRUPT_AUTO_NEGOTIATION_COMPLETE = 6 , LAN8720_INTERRUPT_REMOTE_FAULT = 5 , LAN8720_INTERRUPT_LINK_DOWN = 4 ,
  LAN8720_INTERRUPT_AUTO_NEGOTIATION_LP_ACK = 3 , LAN8720_INTERRUPT_PARALLEL_DETECTION_FAULT = 2 , LAN8720_INTERRUPT_AUTO_NEGOTIATION_PAGE_RECEIVED = 1
}
 lan8720 interrupt enumeration definition More...
 
enum  lan8720_speed_indication_t { LAN8720_SPEED_INDICATION_10BASE_T_HALF_DUPLEX = 0x01 , LAN8720_SPEED_INDICATION_10BASE_T_FULL_DUPLEX = 0x05 , LAN8720_SPEED_INDICATION_100BASE_TX_HALF_DUPLEX = 0x02 , LAN8720_SPEED_INDICATION_100BASE_TX_FULL_DUPLEX = 0x06 }
 lan8720 speed indication enumeration definition More...
 

Functions

uint8_t lan8720_info (lan8720_info_t *info)
 get chip's information More...
 
uint8_t lan8720_set_address (lan8720_handle_t *handle, uint8_t addr)
 set the chip address More...
 
uint8_t lan8720_get_address (lan8720_handle_t *handle, uint8_t *addr)
 get the chip address More...
 
uint8_t lan8720_init (lan8720_handle_t *handle)
 initialize the chip More...
 
uint8_t lan8720_deinit (lan8720_handle_t *handle)
 close the chip More...
 
uint8_t lan8720_set_soft_reset (lan8720_handle_t *handle, lan8720_bool_t enable)
 enable or disable soft reset More...
 
uint8_t lan8720_get_soft_reset (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get soft reset status More...
 
uint8_t lan8720_set_loop_back (lan8720_handle_t *handle, lan8720_bool_t enable)
 enable or disable loop back More...
 
uint8_t lan8720_get_loop_back (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get loop back status More...
 
uint8_t lan8720_set_speed_select (lan8720_handle_t *handle, lan8720_speed_t speed)
 set speed select More...
 
uint8_t lan8720_get_speed_select (lan8720_handle_t *handle, lan8720_speed_t *speed)
 get speed select status More...
 
uint8_t lan8720_set_auto_negotiation (lan8720_handle_t *handle, lan8720_bool_t enable)
 enable or disable auto negotiation More...
 
uint8_t lan8720_get_auto_negotiation (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get auto negotiation status More...
 
uint8_t lan8720_set_power_down (lan8720_handle_t *handle, lan8720_bool_t enable)
 enable or disable power down More...
 
uint8_t lan8720_get_power_down (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get power down status More...
 
uint8_t lan8720_set_electrical_isolation (lan8720_handle_t *handle, lan8720_bool_t enable)
 enable or disable electrical isolation More...
 
uint8_t lan8720_get_electrical_isolation (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get electrical isolation status More...
 
uint8_t lan8720_set_restart_auto_negotiate (lan8720_handle_t *handle, lan8720_bool_t enable)
 enable or disable restart auto negotiate More...
 
uint8_t lan8720_get_restart_auto_negotiate (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get restart auto negotiate status More...
 
uint8_t lan8720_set_duplex_mode (lan8720_handle_t *handle, lan8720_duplex_t mode)
 set duplex mode More...
 
uint8_t lan8720_get_duplex_mode (lan8720_handle_t *handle, lan8720_duplex_t *mode)
 get duplex mode More...
 
uint8_t lan8720_get_100base_t4 (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get 100base t4 status More...
 
uint8_t lan8720_get_100base_tx_full_duplex (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get 100base tx full duplex status More...
 
uint8_t lan8720_get_100base_tx_half_duplex (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get 100base tx half duplex status More...
 
uint8_t lan8720_get_10base_t_full_duplex (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get 10base t full duplex status More...
 
uint8_t lan8720_get_10base_t_half_duplex (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get 10base t half duplex status More...
 
uint8_t lan8720_get_100base_t2_full_duplex (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get 100base t2 full duplex status More...
 
uint8_t lan8720_get_100base_t2_half_duplex (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get 100base t2 half duplex status More...
 
uint8_t lan8720_get_extended_status_information (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get extended status information status More...
 
uint8_t lan8720_get_auto_negotiate_complete (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get auto negotiate complete status More...
 
uint8_t lan8720_get_remote_fault (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get remote fault status More...
 
uint8_t lan8720_get_auto_negotiate_ability (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get auto negotiate ability status More...
 
uint8_t lan8720_get_link_status (lan8720_handle_t *handle, lan8720_link_t *status)
 get link status More...
 
uint8_t lan8720_get_jabber_detect (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get jabber detect status More...
 
uint8_t lan8720_get_extended_capabilities (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get extended capabilities status More...
 
uint8_t lan8720_set_identifier (lan8720_handle_t *handle, uint32_t phy_id, uint8_t model_number, uint8_t revision_number)
 set identifier More...
 
uint8_t lan8720_get_identifier (lan8720_handle_t *handle, uint32_t *phy_id, uint8_t *model_number, uint8_t *revision_number)
 get identifier More...
 
uint8_t lan8720_set_auto_negotiation_advertisement_remote_fault (lan8720_handle_t *handle, lan8720_bool_t enable)
 enable or disable auto negotiation advertisement remote fault More...
 
uint8_t lan8720_get_auto_negotiation_advertisement_remote_fault (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get auto negotiation advertisement remote fault status More...
 
uint8_t lan8720_set_auto_negotiation_advertisement_pause (lan8720_handle_t *handle, lan8720_pause_t pause)
 set auto negotiation advertisement pause More...
 
uint8_t lan8720_get_auto_negotiation_advertisement_pause (lan8720_handle_t *handle, lan8720_pause_t *pause)
 get auto negotiation advertisement pause More...
 
uint8_t lan8720_set_auto_negotiation_advertisement_100base_tx_full_duplex (lan8720_handle_t *handle, lan8720_bool_t enable)
 enable or disable auto negotiation advertisement 100base tx full duplex More...
 
uint8_t lan8720_get_auto_negotiation_advertisement_100base_tx_full_duplex (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get auto negotiation advertisement 100base tx full duplex status More...
 
uint8_t lan8720_set_auto_negotiation_advertisement_100base_tx (lan8720_handle_t *handle, lan8720_bool_t enable)
 enable or disable auto negotiation advertisement 100base tx More...
 
uint8_t lan8720_get_auto_negotiation_advertisement_100base_tx (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get auto negotiation advertisement 100base tx status More...
 
uint8_t lan8720_set_auto_negotiation_advertisement_10base_t_full_duplex (lan8720_handle_t *handle, lan8720_bool_t enable)
 enable or disable auto negotiation advertisement 10base t full duplex More...
 
uint8_t lan8720_get_auto_negotiation_advertisement_10base_t_full_duplex (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get auto negotiation advertisement 10base t full duplex status More...
 
uint8_t lan8720_set_auto_negotiation_advertisement_10base_t (lan8720_handle_t *handle, lan8720_bool_t enable)
 enable or disable auto negotiation advertisement 10base t More...
 
uint8_t lan8720_get_auto_negotiation_advertisement_10base_t (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get auto negotiation advertisement 10base t status More...
 
uint8_t lan8720_set_auto_negotiation_advertisement_selector_field (lan8720_handle_t *handle, uint8_t selector)
 set auto negotiation advertisement selector field More...
 
uint8_t lan8720_get_auto_negotiation_advertisement_selector_field (lan8720_handle_t *handle, uint8_t *selector)
 get auto negotiation advertisement selector field More...
 
uint8_t lan8720_get_auto_negotiation_link_partner_ability_next_page (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get auto negotiation link partner ability next page status More...
 
uint8_t lan8720_get_auto_negotiation_link_partner_ability_acknowledge (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get auto negotiation link partner ability acknowledge status More...
 
uint8_t lan8720_get_auto_negotiation_link_partner_ability_remote_fault (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get auto negotiation link partner ability remote fault status More...
 
uint8_t lan8720_get_auto_negotiation_link_partner_ability_pause (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get auto negotiation link partner ability pause status More...
 
uint8_t lan8720_get_auto_negotiation_link_partner_ability_100base_t4 (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get auto negotiation link partner ability 100base t4 status More...
 
uint8_t lan8720_get_auto_negotiation_link_partner_ability_100base_tx_full_duplex (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get auto negotiation link partner ability 100base tx full duplex status More...
 
uint8_t lan8720_get_auto_negotiation_link_partner_ability_100base_tx (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get auto negotiation link partner ability 100base tx status More...
 
uint8_t lan8720_get_auto_negotiation_link_partner_ability_10base_t_full_duplex (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get auto negotiation link partner ability 10base t full duplex status More...
 
uint8_t lan8720_get_auto_negotiation_link_partner_ability_10base_t (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get auto negotiation link partner ability 10base t status More...
 
uint8_t lan8720_get_auto_negotiation_link_partner_ability_selector_field (lan8720_handle_t *handle, uint8_t *selector)
 get auto negotiation link partner ability selector field More...
 
uint8_t lan8720_get_auto_negotiation_expansion_parallel_detection_fault (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get auto negotiation expansion parallel detection fault status More...
 
uint8_t lan8720_get_auto_negotiation_expansion_link_partner_next_page_able (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get auto negotiation expansion link partner next page able status More...
 
uint8_t lan8720_get_auto_negotiation_expansion_next_page_able (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get auto negotiation expansion next page able status More...
 
uint8_t lan8720_get_auto_negotiation_expansion_page_received (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get auto negotiation expansion page received status More...
 
uint8_t lan8720_get_auto_negotiation_expansion_link_partner_auto_negotiation_able (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get auto negotiation expansion link partner auto negotiation able status More...
 
uint8_t lan8720_set_energy_detect_power_down_mode (lan8720_handle_t *handle, lan8720_bool_t enable)
 enable or disable energy detect power down mode More...
 
uint8_t lan8720_get_energy_detect_power_down_mode (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get energy detect power down mode status More...
 
uint8_t lan8720_set_far_loop_back (lan8720_handle_t *handle, lan8720_bool_t enable)
 enable or disable far loop back More...
 
uint8_t lan8720_get_far_loop_back (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get far loop back status More...
 
uint8_t lan8720_set_alternate_interrupt_mode (lan8720_handle_t *handle, lan8720_bool_t enable)
 enable or disable alternate interrupt mode More...
 
uint8_t lan8720_get_alternate_interrupt_mode (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get alternate interrupt mode status More...
 
uint8_t lan8720_get_energy_detected (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get energy detected status More...
 
uint8_t lan8720_set_mode (lan8720_handle_t *handle, lan8720_mode_t mode)
 set mode More...
 
uint8_t lan8720_get_mode (lan8720_handle_t *handle, lan8720_mode_t *mode)
 get mode More...
 
uint8_t lan8720_set_phy_address (lan8720_handle_t *handle, uint8_t addr)
 set phy address More...
 
uint8_t lan8720_get_phy_address (lan8720_handle_t *handle, uint8_t *addr)
 get phy address More...
 
uint8_t lan8720_get_symbol_error_counter (lan8720_handle_t *handle, uint16_t *cnt)
 get symbol error counter More...
 
uint8_t lan8720_set_auto_mdix (lan8720_handle_t *handle, lan8720_bool_t enable)
 enable or disable auto mdix More...
 
uint8_t lan8720_get_auto_mdix (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get auto mdix status More...
 
uint8_t lan8720_set_manual_channel_select (lan8720_handle_t *handle, lan8720_manual_channel_select_t select)
 set manual channel select More...
 
uint8_t lan8720_get_manual_channel_select (lan8720_handle_t *handle, lan8720_manual_channel_select_t *select)
 get manual channel select More...
 
uint8_t lan8720_set_sqe_test_off (lan8720_handle_t *handle, lan8720_bool_t enable)
 enable or disable sqe test off More...
 
uint8_t lan8720_get_sqe_test_off (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get sqe test off status More...
 
uint8_t lan8720_set_polarity (lan8720_handle_t *handle, lan8720_polarity_t polarity)
 set polarity More...
 
uint8_t lan8720_get_polarity (lan8720_handle_t *handle, lan8720_polarity_t *polarity)
 get polarity More...
 
uint8_t lan8720_get_interrupt_flag (lan8720_handle_t *handle, lan8720_interrupt_t interrupt, lan8720_bool_t *enable)
 get interrupt flag status More...
 
uint8_t lan8720_set_interrupt_mask (lan8720_handle_t *handle, lan8720_interrupt_t interrupt, lan8720_bool_t enable)
 set interrupt mask More...
 
uint8_t lan8720_get_interrupt_mask (lan8720_handle_t *handle, lan8720_interrupt_t interrupt, lan8720_bool_t *enable)
 get interrupt mask status More...
 
uint8_t lan8720_get_auto_negotiation_done (lan8720_handle_t *handle, lan8720_bool_t *enable)
 get auto negotiation done status More...
 
uint8_t lan8720_get_speed_indication (lan8720_handle_t *handle, lan8720_speed_indication_t *speed)
 get speed indication More...
 
uint8_t lan8720_set_reg (lan8720_handle_t *handle, uint8_t reg, uint16_t value)
 set the chip register More...
 
uint8_t lan8720_get_reg (lan8720_handle_t *handle, uint8_t reg, uint16_t *value)
 get the chip register More...
 

Detailed Description

driver lan8720 header file

Copyright (c) 2015 - present LibDriver All rights reserved

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Version
1.0.0
Author
Shifeng Li
Date
2023-08-15

history

Date Version Author Description
2023/08/15 1.0 Shifeng Li first upload

Definition in file driver_lan8720.h.