Skip to content

Commit ddcea9a

Browse files
Added LAN8670_Read_PHY_ID1() and LAN8670_Read_Model_Number() to LAN8670 PHY Driver (#370)
1 parent 19bb7d4 commit ddcea9a

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

general/include/lan8670.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,22 @@ int32_t LAN8670_PLCA_ReadTOTMR(lan8670_t *lan, bool *buffer); // NOTE: This func
210210
*/
211211
int32_t LAN8670_PLCA_WriteTOTMR(lan8670_t *lan, uint8_t data); // NOTE: This function has not been tested yet (as of 01/31/2026).
212212

213+
/**
214+
* @brief Returns the value of the PHY_ID1 register. This register contains the first 16 bits of the OUI (Organizationally Unique Identifier). Should be: 0b0000000000000111 in reset according to the datasheet.
215+
*
216+
* @param lan Pointer to the lan8670_t instance.
217+
* @param data Buffer for the register value.
218+
* @return Status.
219+
*/
220+
int32_t LAN8670_Read_PHY_ID1(lan8670_t *lan, uint16_t *data);
221+
222+
/**
223+
* @brief Returns the PHY manufacturer's model number. Should be 0b00010110 for the LAN8670.
224+
*
225+
* @param lan Pointer to the lan8670_t instance.
226+
* @param data Buffer for the value.
227+
* @return Status.
228+
*/
229+
int32_t LAN8670_Read_Model_Number(lan8670_t *lan, uint8_t *data);
230+
213231
// clang-format on

general/src/lan8670.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,4 +560,34 @@ int32_t LAN8670_Get_Link_State(lan8670_t *lan, uint8_t *state)
560560
return LAN8670_STATUS_OK;
561561
}
562562

563+
/* Returns the value of the PHY_ID1 register. This register contains the first 16 bits of the OUI (Organizationally Unique Identifier). Should be: 0b0000000000000111 in reset according to the datasheet. */
564+
int32_t LAN8670_Read_PHY_ID1(lan8670_t *lan, uint16_t *data) {
565+
// Read all 16 bits of the PHY Identifier 1 register.
566+
uint32_t value = 0;
567+
int status = read_register_field(lan, REG_PHY_ID1, 0, 15, &value);
568+
if(status != LAN8670_STATUS_OK) {
569+
PRINTLN_ERROR("Failed to call read_register_field() (Status: %d).", status);
570+
return status;
571+
}
572+
573+
// Store the value
574+
*data = (uint16_t)value;
575+
return LAN8670_STATUS_OK;
576+
}
577+
578+
/* Returns the PHY manufacturer's model number. Should be 0b00010110 for the LAN8670. */
579+
int32_t LAN8670_Read_Model_Number(lan8670_t *lan, uint8_t *data) {
580+
// Read bits 9:4 of the PHY Identifier 2 Register.
581+
uint32_t value = 0;
582+
int status = read_register_field(lan, REG_PHY_ID2, 4, 9, &value);
583+
if(status != LAN8670_STATUS_OK) {
584+
PRINTLN_ERROR("Failed to call read_register_field() (Status: %d).", status);
585+
return status;
586+
}
587+
588+
// Store the value
589+
*data = (uint8_t)value;
590+
return LAN8670_STATUS_OK;
591+
}
592+
563593
// clang-format on

0 commit comments

Comments
 (0)