]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/include/phyHandling.h
Added back some TCP/IP stack port layer files.
[freertos] / FreeRTOS-Plus / Source / FreeRTOS-Plus-TCP / portable / NetworkInterface / include / phyHandling.h
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/include/phyHandling.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/include/phyHandling.h
new file mode 100644 (file)
index 0000000..9e8a113
--- /dev/null
@@ -0,0 +1,118 @@
+/*\r
+ * Handling of Ethernet PHY's\r
+ * PHY's communicate with an EMAC either through\r
+ * a Media-Independent Interface (MII), or a Reduced Media-Independent Interface (RMII).\r
+ * The EMAC can poll for PHY ports on 32 different addresses. Each of the PHY ports\r
+ * shall be treated independently.\r
+ * \r
+ */\r
+\r
+#ifndef PHYHANDLING_H\r
+\r
+#define PHYHANDLING_H\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+\r
+#ifndef ipconfigPHY_MAX_PORTS\r
+       /* There can be at most 32 PHY ports, but in most cases there are 4 or less. */\r
+       #define ipconfigPHY_MAX_PORTS   4\r
+#endif\r
+\r
+/* A generic user-provided function that reads from the PHY-port at 'xAddress'( 0-based ). A 16-bit value shall be stored in\r
+  '*pulValue'. xRegister is the register number ( 0 .. 31 ). In fact all PHY registers are 16-bit.\r
+  Return non-zero in case the action failed. */\r
+typedef BaseType_t ( *xApplicationPhyReadHook_t )( BaseType_t xAddress, BaseType_t xRegister, uint32_t *pulValue );\r
+\r
+/* A generic user-provided function that writes 'ulValue' to the\r
+   PHY-port at 'xAddress' ( 0-based ). xRegister is the register number ( 0 .. 31 ).\r
+   Return non-zero in case the action failed. */\r
+typedef BaseType_t ( *xApplicationPhyWriteHook_t )( BaseType_t xAddress, BaseType_t xRegister, uint32_t ulValue );\r
+\r
+typedef struct xPhyProperties\r
+{\r
+       uint8_t ucSpeed;\r
+       uint8_t ucMDI_X;                /* MDI-X : Medium Dependent Interface - Crossover */\r
+       uint8_t ucDuplex;\r
+       uint8_t ucSpare;\r
+} PhyProperties_t;\r
+\r
+typedef struct xEthernetPhy\r
+{\r
+       xApplicationPhyReadHook_t fnPhyRead;\r
+       xApplicationPhyWriteHook_t fnPhyWrite;\r
+       uint32_t ulPhyIDs[ ipconfigPHY_MAX_PORTS ];\r
+       uint8_t ucPhyIndexes[ ipconfigPHY_MAX_PORTS ];\r
+       TimeOut_t xLinkStatusTimer;\r
+       TickType_t xLinkStatusRemaining;\r
+       BaseType_t xPortCount;\r
+       uint32_t ulBCRValue;\r
+       uint32_t ulACRValue;\r
+       uint32_t ulLinkStatusMask;\r
+       PhyProperties_t xPhyPreferences;\r
+       PhyProperties_t xPhyProperties;\r
+} EthernetPhy_t;\r
+\r
+/* Some defines used internally here to indicate preferences about speed, MDIX\r
+(wired direct or crossed), and duplex (half or full). */\r
+\r
+/* Values for PhyProperties_t::ucSpeed : */\r
+#define        PHY_SPEED_10            1\r
+#define        PHY_SPEED_100           2\r
+#define        PHY_SPEED_AUTO          3\r
+\r
+/* Values for PhyProperties_t::ucMDI_X : */\r
+#define        PHY_MDIX_DIRECT         1\r
+#define        PHY_MDIX_CROSSED        2\r
+#define        PHY_MDIX_AUTO           3\r
+\r
+/* Values for PhyProperties_t::ucDuplex : */\r
+#define        PHY_DUPLEX_HALF         1\r
+#define        PHY_DUPLEX_FULL         2\r
+#define        PHY_DUPLEX_AUTO         3\r
+\r
+/* ID's of supported PHY's : */\r
+#define PHY_ID_LAN8742A                0x0007c130\r
+#define PHY_ID_LAN8720         0x0007c0f0\r
+\r
+#define PHY_ID_KSZ8041         0x000010A1\r
+#define PHY_ID_KSZ8051         0x000010A1\r
+#define PHY_ID_KSZ8081         0x000010A1\r
+\r
+#define PHY_ID_KSZ8863         0x00221430\r
+#define PHY_ID_KSZ8081MNXIA 0x00221560\r
+\r
+#define PHY_ID_DP83848I                0x20005C90\r
+\r
+\r
+/* Initialise the struct and assign a PHY-read and -write function. */\r
+void vPhyInitialise( EthernetPhy_t *pxPhyObject, xApplicationPhyReadHook_t fnPhyRead, xApplicationPhyWriteHook_t fnPhyWrite );\r
+\r
+/* Discover all PHY's connected by polling 32 indexes ( zero-based ) */\r
+BaseType_t xPhyDiscover( EthernetPhy_t *pxPhyObject );\r
+\r
+/* Send a reset command to the connected PHY ports and send configuration. */\r
+BaseType_t xPhyConfigure( EthernetPhy_t *pxPhyObject, const PhyProperties_t *pxPhyProperties );\r
+\r
+/* Give a command to start auto negotiation on a set of PHY port's. */\r
+BaseType_t xPhyStartAutoNegotiation( EthernetPhy_t *pxPhyObject, uint32_t ulPhyMask );\r
+\r
+/* Do not use auto negotiation but use predefined values from 'pxPhyObject->xPhyPreferences'. */\r
+BaseType_t xPhyFixedValue( EthernetPhy_t *pxPhyObject, uint32_t ulPhyMask );\r
+\r
+/* Check the current Link Status.\r
+'xHadReception' : make this true if a packet has been received since the\r
+last call to this function. */\r
+BaseType_t xPhyCheckLinkStatus( EthernetPhy_t *pxPhyObject, BaseType_t xHadReception );\r
+\r
+/* Get the bitmask of a given 'EthernetPhy_t'. */\r
+#define xPhyGetMask( pxPhyObject ) \\r
+       ( ( ( ( uint32_t ) 1u ) << ( pxPhyObject )->xPortCount ) - 1u )\r
+\r
+#ifdef __cplusplus\r
+} /* extern "C" */\r
+#endif\r
+\r
+#endif\r