The SDK consists of the sample application, the EtherCAT Stack API and a Custom PHY library. Each of these parts must be considered for the PHY configuration. Following sections describe what changes must be made to make PHY configurations or adding a new PHY.
The EtherCAT SDK is delivered with the following PHY drivers. The source and header files can be found in the custom_phy folder of the Industrial Communication SDK examples folder.
| PHY Name |
|---|
| TI DP83869 |
| TI DP83826e |
| TI DP83826b |
The SDK provides an API to configure the PHYs:
| Custom PHY function | Description |
|---|---|
| CUST_PHY_CBregisterReset | Register PHY reset function |
| EC_API_SLV_registerPhy | Register PHY index, MII address, link polarity and use of RxLink |
| CUST_PHY_CBregisterLibDetect | Register a PHY not covered by the SDK |
| CUST_PHY_readReg | Read PHY Register |
| CUST_PHY_writeReg | Write PHY Register |
In this section the integration of new PHYs, which are not convered by the SDK delivery, is shown from a example perspective. Before you consider a PHY, please make sure that it suppports the EtherCAT network. For more information refer to the Beckhoff Application Note –PHY Selection Guide on the Beckhoff home page.
The new PHY in this example is named "ADIN1200".
In the "TI Board Drivers" section, select the "ETHPHY" module and change the following:
Depending on the actual hardware, there might be other changes which must be done e.g. in the GPIO section.
While writing a PHY driver is the responsibility of the corresponding developer, the existing drivers can be used as templates. You can find the files in your Industrial Communications SDK installation folder under examples/industrial_comms/custom_phy/.
The drivers consist of three parts:
The first two defines you will notice are:
These are important to automatically detect which PHYs are connected to the controller. The value will compared in the function CUST_PHY_ADIN1200_detect(), which is also responsible for connecting the functions to the TI PHY interface:
The detect function "CUST_PHY_ADIN1200_detect()" must be added to the struct "CUST_PHY_knownImplementation_s", which is defined in "CUST_PHY_base.c".
The define "CUST_PHY_ADIN1200" must be added to the "Predefined Symbols" section of the CCS project.
Functions like "CUST_PHY_ADIN1200_softwareReset()" must be written accordingly to the PHY datasheet. Because of our current architecture not implementing these functions isn't an option. If the function isn't needed, the function body can be left empty.
Assuming the new PHY drivers are named accordingly to the existing ones and are placed in the Industrial Communications SDK directory under "/examples/industrial_comms/custom_phy/src/" and "/inc", select both files "CUST_PHY_ADIN1200.c" and "CUST_PHY_ADIN1200.c" and drag and drop them into the project in the Project Explorer. Following window appears, asking how to import the files to the project. Adopt these changes:
The example project abstracts the board initialization with functions written for the demo. The function "EC_SLV_APP_SS_registerStacklessBoardFunctions()" in "ecSubDeviceSimple.c" calls three APIs:
The first one is a API written exclusively for the example and calls the stack API "EC_API_SLV_registerPhy()", which takes, apart from the context handle, four parameters:
| Parameter | Description |
|---|---|
| phyIdx | Index of the PHY (0/1) |
| phyAddr | PHY address on MII bus |
| invertLinkPolarity | true: link polarity active high, false: link polarity active low |
| useRxLinkPin | true: use RxLink pin for Link Detection, false: use MDIO state machine |
In the example, these parameters are defined in "ESL_BOARD_config.h" and must be adapted according to the PHY:
The second API registers the function "CUST_PHY_detect()" from "CUST_PHY_base.c", the third API registers functions regarding the PHY reset as a callback, which are then called from the stack.