LAN8742 Part Drivers API Documentation - ETH IO

This page documents the API of the “ETH” IO component of the LAN8742 Part Drivers.

An overview of the driver is also available here: main_doc .

Documentation for the Core component is also availabe here: LAN8742 Part Drivers API Documentation - Core.

Functions

Functions

int32_t lan8742_io_init ( lan8742_io_t * pio )

Initializes the IO layer. This specific implementation does nothing.

Note

This function must be overridden (using codegen or otherwise) with a proper implementation.

Return values :

-1 – (always fail)

int32_t lan8742_io_read_c22_reg ( lan8742_io_t * pio , uint8_t reg , uint16_t * pvalue )

Read a value from a LAN8742 register.

Parameters :
  • pio[in] the IO instance object

  • reg[in] the device register to read

  • pvalue[out] the pointer where the read data is written

Return values :

0 – in case of success, -1 in case of error

int32_t lan8742_io_write_c22_reg ( lan8742_io_t * pio , uint8_t reg , uint16_t value )

Write a value to a LAN8742 register.

Parameters :
  • pio[in] the IO instance object

  • reg[in] the device register to write

  • value[in] the data to write

Return values :

0 – in case of success, -1 in case of error

int32_t lan8742_io_get_phy_address ( lan8742_io_t * pio , uint8_t * paddr )

Retrieve the current MDIO address used by the IO layer.

Parameters :
  • pio – [in] Pointer to the IO interface instance.

  • paddr – [out] Pointer to store the MDIO address (0..31).

Return values :

0 – on success, -1 otherwise.

int32_t lan8742_io_set_phy_address ( lan8742_io_t * pio , uint8_t addr )

Set the MDIO address used by the IO layer for subsequent accesses.

Parameters :
  • pio – [in] Pointer to the IO interface instance.

  • addr – [in] MDIO address to set (0..31).

Return values :

0 – on success, -1 otherwise.

void lan8742_io_hw_reset ( lan8742_io_t * pio )

Initializes the hardware reset sequence for the LAN8742 Ethernet PHY.

This function asserts and de-asserts the nRST (reset) pin of the LAN8742 PHY according to the specified active state in the provided IO structure. If a valid nRST pin is defined, the function will:

  • Set the nRST pin to its active state.

  • Wait for 10 milliseconds to ensure the reset is asserted.

  • Set the nRST pin to its inactive state. If no valid nRST pin is defined, the function does nothing and only software reset will be used for the PHY.

Parameters :

pio – [in] Pointer to the LAN8742 IO structure containing GPIO configuration.

int32_t lan8742_io_enable_irq ( lan8742_io_t * pio )

Enables the IRQ line and starts the EXTI.

Parameters :

pio [in] : Pointer to io interface object

Return values :

error – status

int32_t lan8742_io_disable_irq ( lan8742_io_t * pio )

Disables the IRQ line and clears the interrupt pending bit.

Parameters :

pio [in] Pointer to io interface object

Return values :

error – status

int32_t lan8742_io_register_callback ( lan8742_io_t * pio , lan8742_io_callback_t io_cb , void * arg )

Registers a callback on the IT pin of the LAN8742.

Parameters :
  • pio[inout] : Pointer to io interface object

  • io_cb[in] : Callback function to be registered

  • arg[in] : Optional argument given to the callback

Return values :

error – status (0=success, -1=error)

Types

Typedefs

typedef struct lan8742_io_s lan8742_io_t

IO callback function pointer definition

typedef void ( * lan8742_io_callback_t ) ( lan8742_io_t * pio , void * arg )
struct lan8742_io_s

ETH IO interface structure.

Public Members

hal_eth_handle_t * heth

ETH HAL handle for communication

uint8_t addr

PHY address on the MDIO bus

hal_exti_handle_t * hexti

EXTI HAL handle for asynchronous features

IRQn_Type irq_src

LAN8742 interrupt request line

hal_gpio_t it_port

IT GPIO port

uint32_t it_pin

IT GPIO pin

lan8742_io_cb_ctx_t exti_cb_ctx

Callback context storing the function pointer and argument

uint32_t nrst_pin

RST PIN

hal_gpio_t nrst_port

RST GPIO port

uint8_t nrst_active_state

RST PIN active state

uint32_t id

LAN8742 part ID

struct lan8742_io_cb_ctx_t

Constants and macros

Defines

LAN8742_INVALID_PIN 0xFFuL

Macros definitions.

LAN8742_INVALID_IRQ ((IRQn_Type) INT32_MAX)