LibDriver LAN8720
Loading...
Searching...
No Matches
driver_lan8720.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_LAN8720_H
38#define DRIVER_LAN8720_H
39
40#include <stdio.h>
41#include <stdint.h>
42#include <string.h>
43
44#ifdef __cplusplus
45extern "C"{
46#endif
47
53
58
62typedef enum
63{
67
71typedef enum
72{
76
85
89typedef enum
90{
94
98
103
115
130
139
148
162
173
177typedef struct lan8720_handle_s
178{
179 uint8_t smi_addr;
180 uint8_t (*smi_init)(void);
181 uint8_t (*smi_deinit)(void);
182 uint8_t (*smi_read)(uint8_t addr, uint8_t reg, uint16_t *data);
183 uint8_t (*smi_write)(uint8_t addr, uint8_t reg, uint16_t data);
184 uint8_t (*reset_gpio_init)(void);
185 uint8_t (*reset_gpio_deinit)(void);
186 uint8_t (*reset_gpio_write)(uint8_t level);
187 void (*delay_ms)(uint32_t ms);
188 void (*debug_print)(const char *const fmt, ...);
189 uint8_t inited;
191
207
211
218
225#define DRIVER_LAN8720_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
226
233#define DRIVER_LAN8720_LINK_SMI_INIT(HANDLE, FUC) (HANDLE)->smi_init = FUC
234
241#define DRIVER_LAN8720_LINK_SMI_DEINIT(HANDLE, FUC) (HANDLE)->smi_deinit = FUC
242
249#define DRIVER_LAN8720_LINK_SMI_READ(HANDLE, FUC) (HANDLE)->smi_read = FUC
250
257#define DRIVER_LAN8720_LINK_SMI_WRITE(HANDLE, FUC) (HANDLE)->smi_write = FUC
258
265#define DRIVER_LAN8720_LINK_RESET_GPIO_INIT(HANDLE, FUC) (HANDLE)->reset_gpio_init = FUC
266
273#define DRIVER_LAN8720_LINK_RESET_GPIO_DEINIT(HANDLE, FUC) (HANDLE)->reset_gpio_deinit = FUC
274
281#define DRIVER_LAN8720_LINK_RESET_GPIO_WRITE(HANDLE, FUC) (HANDLE)->reset_gpio_write = FUC
282
289#define DRIVER_LAN8720_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
290
297#define DRIVER_LAN8720_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
298
302
309
318uint8_t lan8720_info(lan8720_info_t *info);
319
330uint8_t lan8720_set_address(lan8720_handle_t *handle, uint8_t addr);
331
341uint8_t lan8720_get_address(lan8720_handle_t *handle, uint8_t *addr);
342
354uint8_t lan8720_init(lan8720_handle_t *handle);
355
367uint8_t lan8720_deinit(lan8720_handle_t *handle);
368
381
394
407
420
433
446
459
472
485
498
511
524
537
550
563
576
589
602
615
628
641
654
667
680
693
706
719
732
745
758
762
769
786uint8_t lan8720_set_identifier(lan8720_handle_t *handle, uint32_t phy_id,
787 uint8_t model_number, uint8_t revision_number);
788
802uint8_t lan8720_get_identifier(lan8720_handle_t *handle, uint32_t *phy_id,
803 uint8_t *model_number, uint8_t *revision_number);
804
817
830
843
856
869
882
895
908
921
934
947
960
974
987
1000
1013
1026
1039
1052
1065
1078
1091
1104
1117
1130
1143
1156
1169
1182
1195
1208
1221
1234
1247
1260
1273
1285uint8_t lan8720_set_mode(lan8720_handle_t *handle, lan8720_mode_t mode);
1286
1298uint8_t lan8720_get_mode(lan8720_handle_t *handle, lan8720_mode_t *mode);
1299
1312uint8_t lan8720_set_phy_address(lan8720_handle_t *handle, uint8_t addr);
1313
1325uint8_t lan8720_get_phy_address(lan8720_handle_t *handle, uint8_t *addr);
1326
1338uint8_t lan8720_get_symbol_error_counter(lan8720_handle_t *handle, uint16_t *cnt);
1339
1352
1364uint8_t lan8720_get_auto_mdix(lan8720_handle_t *handle, lan8720_bool_t *enable);
1365
1378
1391
1404
1417
1430
1442uint8_t lan8720_get_polarity(lan8720_handle_t *handle, lan8720_polarity_t *polarity);
1443
1457
1471
1485
1498
1511
1515
1522
1536uint8_t lan8720_set_reg(lan8720_handle_t *handle, uint8_t reg, uint16_t value);
1537
1551uint8_t lan8720_get_reg(lan8720_handle_t *handle, uint8_t reg, uint16_t *value);
1552
1556
1560
1561#ifdef __cplusplus
1562}
1563#endif
1564
1565#endif
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
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
uint8_t lan8720_get_auto_negotiation_done(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiation done status
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
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
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
uint8_t lan8720_get_auto_mdix(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto mdix status
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
uint8_t lan8720_get_interrupt_mask(lan8720_handle_t *handle, lan8720_interrupt_t interrupt, lan8720_bool_t *enable)
get interrupt mask status
uint8_t lan8720_get_energy_detected(lan8720_handle_t *handle, lan8720_bool_t *enable)
get energy detected status
uint8_t lan8720_get_phy_address(lan8720_handle_t *handle, uint8_t *addr)
get phy address
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
uint8_t lan8720_get_auto_negotiation_advertisement_remote_fault(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiation advertisement remote fault status
uint8_t lan8720_set_interrupt_mask(lan8720_handle_t *handle, lan8720_interrupt_t interrupt, lan8720_bool_t enable)
set interrupt mask
uint8_t lan8720_set_auto_negotiation_advertisement_pause(lan8720_handle_t *handle, lan8720_pause_t pause)
set auto negotiation advertisement pause
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
lan8720_polarity_t
lan8720 polarity enumeration definition
uint8_t lan8720_get_symbol_error_counter(lan8720_handle_t *handle, uint16_t *cnt)
get symbol error counter
uint8_t lan8720_get_auto_negotiation_advertisement_100base_tx(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiation advertisement 100base tx status
struct lan8720_info_s lan8720_info_t
lan8720 information structure definition
uint8_t lan8720_get_energy_detect_power_down_mode(lan8720_handle_t *handle, lan8720_bool_t *enable)
get energy detect power down mode status
uint8_t lan8720_get_auto_negotiation_advertisement_selector_field(lan8720_handle_t *handle, uint8_t *selector)
get auto negotiation advertisement selector field
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
lan8720_mode_t
lan8720 mode enumeration definition
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
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
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
uint8_t lan8720_get_polarity(lan8720_handle_t *handle, lan8720_polarity_t *polarity)
get polarity
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
lan8720_manual_channel_select_t
lan8720 manual channel select enumeration definition
uint8_t lan8720_get_auto_negotiation_expansion_page_received(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiation expansion page received status
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
uint8_t lan8720_set_phy_address(lan8720_handle_t *handle, uint8_t addr)
set phy address
lan8720_interrupt_t
lan8720 interrupt enumeration definition
uint8_t lan8720_set_auto_negotiation_advertisement_selector_field(lan8720_handle_t *handle, uint8_t selector)
set auto negotiation advertisement selector field
uint8_t lan8720_get_far_loop_back(lan8720_handle_t *handle, lan8720_bool_t *enable)
get far loop back status
uint8_t lan8720_set_identifier(lan8720_handle_t *handle, uint32_t phy_id, uint8_t model_number, uint8_t revision_number)
set identifier
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
uint8_t lan8720_set_polarity(lan8720_handle_t *handle, lan8720_polarity_t polarity)
set polarity
uint8_t lan8720_set_far_loop_back(lan8720_handle_t *handle, lan8720_bool_t enable)
enable or disable far loop back
uint8_t lan8720_get_identifier(lan8720_handle_t *handle, uint32_t *phy_id, uint8_t *model_number, uint8_t *revision_number)
get identifier
uint8_t lan8720_set_mode(lan8720_handle_t *handle, lan8720_mode_t mode)
set mode
uint8_t lan8720_set_manual_channel_select(lan8720_handle_t *handle, lan8720_manual_channel_select_t select)
set manual channel select
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
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
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
uint8_t lan8720_get_interrupt_flag(lan8720_handle_t *handle, lan8720_interrupt_t interrupt, lan8720_bool_t *enable)
get interrupt flag status
uint8_t lan8720_get_speed_indication(lan8720_handle_t *handle, lan8720_speed_indication_t *speed)
get speed indication
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
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
uint8_t lan8720_get_auto_negotiation_advertisement_pause(lan8720_handle_t *handle, lan8720_pause_t *pause)
get auto negotiation advertisement pause
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
uint8_t lan8720_get_sqe_test_off(lan8720_handle_t *handle, lan8720_bool_t *enable)
get sqe test off status
lan8720_speed_indication_t
lan8720 speed indication enumeration definition
uint8_t lan8720_get_manual_channel_select(lan8720_handle_t *handle, lan8720_manual_channel_select_t *select)
get manual channel select
uint8_t lan8720_get_alternate_interrupt_mode(lan8720_handle_t *handle, lan8720_bool_t *enable)
get alternate interrupt mode status
uint8_t lan8720_set_auto_mdix(lan8720_handle_t *handle, lan8720_bool_t enable)
enable or disable auto mdix
uint8_t lan8720_set_alternate_interrupt_mode(lan8720_handle_t *handle, lan8720_bool_t enable)
enable or disable alternate interrupt mode
struct lan8720_handle_s lan8720_handle_t
lan8720 handle structure definition
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
uint8_t lan8720_get_mode(lan8720_handle_t *handle, lan8720_mode_t *mode)
get mode
uint8_t lan8720_get_auto_negotiation_advertisement_10base_t(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiation advertisement 10base t status
lan8720_pause_t
lan8720 pause enumeration definition
uint8_t lan8720_set_sqe_test_off(lan8720_handle_t *handle, lan8720_bool_t enable)
enable or disable sqe test off
@ LAN8720_POLARITY_REVERSED
@ LAN8720_POLARITY_NORMAL
@ LAN8720_MODE_100BASE_TX_HALF_DUPLEX
@ LAN8720_MODE_10BASE_T_HALF_DUPLEX
@ LAN8720_MODE_ALL_CAPABLE
@ LAN8720_MODE_100BASE_TX_HALF_DUPLEX_ADVERTISED
@ LAN8720_MODE_10BASE_T_FULL_DUPLEX
@ LAN8720_MODE_POWER_DOWN_MODE
@ LAN8720_MODE_REPEATER_MODE
@ LAN8720_MODE_100BASE_TX_FULL_DUPLEX
@ LAN8720_MANUAL_CHANNEL_SELECT_MDIX
@ LAN8720_MANUAL_CHANNEL_SELECT_MDI
@ LAN8720_INTERRUPT_ENERGY_ON
@ LAN8720_INTERRUPT_PARALLEL_DETECTION_FAULT
@ LAN8720_INTERRUPT_LINK_DOWN
@ LAN8720_INTERRUPT_REMOTE_FAULT
@ LAN8720_INTERRUPT_AUTO_NEGOTIATION_COMPLETE
@ LAN8720_INTERRUPT_AUTO_NEGOTIATION_PAGE_RECEIVED
@ LAN8720_INTERRUPT_AUTO_NEGOTIATION_LP_ACK
@ LAN8720_SPEED_INDICATION_100BASE_TX_HALF_DUPLEX
@ LAN8720_SPEED_INDICATION_10BASE_T_FULL_DUPLEX
@ LAN8720_SPEED_INDICATION_10BASE_T_HALF_DUPLEX
@ LAN8720_SPEED_INDICATION_100BASE_TX_FULL_DUPLEX
@ LAN8720_PAUSE_BOTH
@ LAN8720_PAUSE_NO
@ LAN8720_PAUSE_ASYMMETRIC
@ LAN8720_PAUSE_SYMMETRIC
uint8_t lan8720_set_duplex_mode(lan8720_handle_t *handle, lan8720_duplex_t mode)
set duplex mode
uint8_t lan8720_get_auto_negotiate_ability(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiate ability status
uint8_t lan8720_get_extended_status_information(lan8720_handle_t *handle, lan8720_bool_t *enable)
get extended status information status
uint8_t lan8720_get_electrical_isolation(lan8720_handle_t *handle, lan8720_bool_t *enable)
get electrical isolation status
uint8_t lan8720_get_100base_t4(lan8720_handle_t *handle, lan8720_bool_t *enable)
get 100base t4 status
uint8_t lan8720_set_loop_back(lan8720_handle_t *handle, lan8720_bool_t enable)
enable or disable loop back
uint8_t lan8720_get_address(lan8720_handle_t *handle, uint8_t *addr)
get the chip address
uint8_t lan8720_get_link_status(lan8720_handle_t *handle, lan8720_link_t *status)
get link status
uint8_t lan8720_set_speed_select(lan8720_handle_t *handle, lan8720_speed_t speed)
set speed select
uint8_t lan8720_get_restart_auto_negotiate(lan8720_handle_t *handle, lan8720_bool_t *enable)
get restart auto negotiate status
uint8_t lan8720_init(lan8720_handle_t *handle)
initialize the chip
uint8_t lan8720_get_duplex_mode(lan8720_handle_t *handle, lan8720_duplex_t *mode)
get duplex mode
uint8_t lan8720_get_100base_tx_full_duplex(lan8720_handle_t *handle, lan8720_bool_t *enable)
get 100base tx full duplex status
lan8720_bool_t
lan8720 bool enumeration definition
uint8_t lan8720_deinit(lan8720_handle_t *handle)
close the chip
uint8_t lan8720_get_auto_negotiation(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiation status
uint8_t lan8720_get_remote_fault(lan8720_handle_t *handle, lan8720_bool_t *enable)
get remote fault status
lan8720_duplex_t
lan8720 duplex enumeration definition
uint8_t lan8720_set_restart_auto_negotiate(lan8720_handle_t *handle, lan8720_bool_t enable)
enable or disable restart auto negotiate
uint8_t lan8720_get_100base_t2_half_duplex(lan8720_handle_t *handle, lan8720_bool_t *enable)
get 100base t2 half duplex status
uint8_t lan8720_get_100base_tx_half_duplex(lan8720_handle_t *handle, lan8720_bool_t *enable)
get 100base tx half duplex status
uint8_t lan8720_get_loop_back(lan8720_handle_t *handle, lan8720_bool_t *enable)
get loop back status
uint8_t lan8720_get_10base_t_full_duplex(lan8720_handle_t *handle, lan8720_bool_t *enable)
get 10base t full duplex status
uint8_t lan8720_set_soft_reset(lan8720_handle_t *handle, lan8720_bool_t enable)
enable or disable soft reset
uint8_t lan8720_get_speed_select(lan8720_handle_t *handle, lan8720_speed_t *speed)
get speed select status
lan8720_link_t
lan8720 link enumeration definition
uint8_t lan8720_set_auto_negotiation(lan8720_handle_t *handle, lan8720_bool_t enable)
enable or disable auto negotiation
uint8_t lan8720_get_soft_reset(lan8720_handle_t *handle, lan8720_bool_t *enable)
get soft reset status
uint8_t lan8720_get_auto_negotiate_complete(lan8720_handle_t *handle, lan8720_bool_t *enable)
get auto negotiate complete status
uint8_t lan8720_get_100base_t2_full_duplex(lan8720_handle_t *handle, lan8720_bool_t *enable)
get 100base t2 full duplex status
uint8_t lan8720_get_10base_t_half_duplex(lan8720_handle_t *handle, lan8720_bool_t *enable)
get 10base t half duplex status
uint8_t lan8720_info(lan8720_info_t *info)
get chip's information
uint8_t lan8720_set_power_down(lan8720_handle_t *handle, lan8720_bool_t enable)
enable or disable power down
uint8_t lan8720_get_extended_capabilities(lan8720_handle_t *handle, lan8720_bool_t *enable)
get extended capabilities status
uint8_t lan8720_get_jabber_detect(lan8720_handle_t *handle, lan8720_bool_t *enable)
get jabber detect status
lan8720_speed_t
lan8720 speed enumeration definition
uint8_t lan8720_set_address(lan8720_handle_t *handle, uint8_t addr)
set the chip address
uint8_t lan8720_get_power_down(lan8720_handle_t *handle, lan8720_bool_t *enable)
get power down status
uint8_t lan8720_set_electrical_isolation(lan8720_handle_t *handle, lan8720_bool_t enable)
enable or disable electrical isolation
@ LAN8720_BOOL_FALSE
@ LAN8720_BOOL_TRUE
@ LAN8720_DUPLEX_FULL
@ LAN8720_DUPLEX_HALF
@ LAN8720_LINK_UP
@ LAN8720_LINK_DOWN
@ LAN8720_SPEED_10M
@ LAN8720_SPEED_100M
uint8_t lan8720_set_reg(lan8720_handle_t *handle, uint8_t reg, uint16_t value)
set the chip register
uint8_t lan8720_get_reg(lan8720_handle_t *handle, uint8_t reg, uint16_t *value)
get the chip register
lan8720 handle structure definition
uint8_t(* smi_deinit)(void)
uint8_t(* smi_write)(uint8_t addr, uint8_t reg, uint16_t data)
void(* delay_ms)(uint32_t ms)
uint8_t(* smi_init)(void)
uint8_t(* reset_gpio_deinit)(void)
void(* debug_print)(const char *const fmt,...)
uint8_t(* reset_gpio_init)(void)
uint8_t(* smi_read)(uint8_t addr, uint8_t reg, uint16_t *data)
uint8_t(* reset_gpio_write)(uint8_t level)
lan8720 information structure definition
uint32_t driver_version
char manufacturer_name[32]