2.1.2 app.c
The app.c file provides an example of how to access and modify a PHY register when
necessary.
Important: Before accessing a PHY register,
ensure that TCPIP_STACK_Status(sysObj.tcpip) == SYS_STATUS_READY.
- Open an instance of the MIIM driver.
This is done using the local_miim_init() method.
- To read from a PHY register, use the
LAN867x_Read_Registermethod.In the example, this is demonstrated in the APP_Task() method, under the switch case APP_READ_OPERATION_MODE.opRes = LAN867x_Read_Register(&clientObj,PHY_PLCA_CONTROL_0,&data);Here, the value of the PHY_PLCA_CONTROL_0 register is read and stored in the data variable.
- To write to a PHY register, use the
LAN867x_Write_Registermethod.In the example, this is shown in the APP_Task() method, under the switch case APP_WRITE_PLCA_CONFIGURATION.
data = F2R_(0, PHY_PLCA_CTRL1_ID0) | F2R_(5, PHY_PLCA_CTRL1_NCNT); opRes = LAN867x_Write_Register (&clientObj, PHY_PLCA_CONTROL_1, data);Here, the value of data is written to the PHY_PLCA_CONTROL_1 register. It also shows how to configure the Local Node Id as 0 and the Node Count as 5.
- After completing the register
operation, close the MIIM instance.
This is done using the local_miim_close() method.
