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.
  1. Open an instance of the MIIM driver.

    This is done using the local_miim_init() method.

  2. To read from a PHY register, use the LAN867x_Read_Register method.
    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.

  3. To write to a PHY register, use the LAN867x_Write_Register method.

    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.

  4. After completing the register operation, close the MIIM instance.

    This is done using the local_miim_close() method.