You have to either use LPC54S018JET180 instead, or emulate the MDIO interface with SPI, by connecting SPI SCK to phy MDC signal, configure MOSI to open drain output, connect MOSI and MISO togather to phy MDIO, then you can read/write via 16bits SPI transfer. Remember to add a pull up resistor on the MDIO signal, which I think is required by most of the phy chips
#include "fsl_spi.h"
#define MDIO_START 0x4000u
#define MDIO_WRITE (MDIO_START | 0x1002u)
#define MDIO_READ (MDIO_START | 0x2003u)
int mdio_read(int addr, int reg)
{
uint16_t cmd = MDIO_READ | (((uint16_t)addr & 0x1fu) << 7) | (((uint16_t)reg & 0x1fu) << 2);
uint16_t cmdbuf[4] = {
0xffffu, 0xffffu, cmd, 0xffffu
};
uint16_t buf[4] = {0};
spi_transfer_t xfer = {
.txData = (void *)cmdbuf,
.rxData = (void *)buf,
.dataSize = sizeof(cmdbuf),
.configFlags = kSPI_FrameAssert,
};
status_t status = SPI_MasterTransferBlocking(SPI9, &xfer);
if (status != kStatus_Success) {
return -1;
}
return buf[3];
}
int mdio_write(int addr, int reg, uint16_t val)
{
uint16_t cmd = MDIO_WRITE | (((uint16_t)addr & 0x1fu) << 7) | (((uint16_t)reg & 0x1fu) << 2);
uint16_t cmdbuf[4] = {
0xffffu, 0xffffu, cmd, val,
};
uint16_t buf[4] = {0};
spi_transfer_t xfer = {
.txData = (void *)cmdbuf,
.rxData = (void *)buf,
.dataSize = sizeof(cmdbuf),
.configFlags = kSPI_FrameAssert,
};
status_t status = SPI_MasterTransferBlocking(SPI9, &xfer);
if (status != kStatus_Success) {
return -1;
}
return 0;
}