Browse Source

[BT-6711] gigabit ethernet switch support

Sergey Alirzaev 3 years ago
parent
commit
4f486cc237

+ 4 - 0
modules/STM32F4x7_ETH_Driver/stm32f4x7_eth.c

@@ -394,6 +394,9 @@ uint32_t ETH_Init(ETH_InitTypeDef* ETH_InitStruct, uint16_t PHYAddress)
     
   if(ETH_InitStruct->ETH_AutoNegotiation != ETH_AutoNegotiation_Disable)
   {  
+#ifdef HARDWARE_BT6711
+    // for GbE auto-negotiation is a must
+#else
     /* We wait for linked status... */
     do
     {
@@ -405,6 +408,7 @@ uint32_t ETH_Init(ETH_InitTypeDef* ETH_InitStruct, uint16_t PHYAddress)
     {
       return ETH_ERROR;
     }
+#endif
 
     /* Reset Timeout counter */
     timeout = 0; 

+ 8 - 3
modules/STM32F4x7_ETH_Driver/stm32f4x7_eth_bsp.c

@@ -196,6 +196,11 @@ void ETH_GPIO_Config(void)
         ETH_RST_PIN     -------> PE2  - замена на PE13
   
    */
+#ifdef HARDWARE_BT6711
+#define ETH_RST_PIN GPIO_Pin_7
+#else
+#define ETH_RST_PIN GPIO_Pin_13
+#endif
 
   /* Configure PA1,PA2 and PA7 */
   GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_7;
@@ -224,16 +229,16 @@ void ETH_GPIO_Config(void)
   GPIO_PinAFConfig(GPIOC, GPIO_PinSource5, GPIO_AF_ETH);
 
   /* Configure the PHY RST  pin */
-  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
+  GPIO_InitStructure.GPIO_Pin = ETH_RST_PIN;
   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
   GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
   GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
   GPIO_Init(GPIOE, &GPIO_InitStructure);
 
-  GPIO_ResetBits(GPIOE, GPIO_Pin_13);	
+  GPIO_ResetBits(GPIOE, ETH_RST_PIN);
   for (i = 0; i < 20000; i++);
-  GPIO_SetBits(GPIOE, GPIO_Pin_13);
+  GPIO_SetBits(GPIOE, ETH_RST_PIN);
   for (i = 0; i < 20000; i++);
 }
 

+ 4 - 0
stm32/stm32f4x7_ethernet/stm32f4x7_eth.c

@@ -394,6 +394,9 @@ uint32_t ETH_Init(ETH_InitTypeDef* ETH_InitStruct, uint16_t PHYAddress)
     
   if(ETH_InitStruct->ETH_AutoNegotiation != ETH_AutoNegotiation_Disable)
   {  
+#ifdef HARDWARE_BT6711
+    // for GbE auto-negotiation is a must
+#else
     /* We wait for linked status... */
     do
     {
@@ -405,6 +408,7 @@ uint32_t ETH_Init(ETH_InitTypeDef* ETH_InitStruct, uint16_t PHYAddress)
     {
       return ETH_ERROR;
     }
+#endif
 
     /* Reset Timeout counter */
     timeout = 0; 

+ 8 - 3
stm32/stm32f4x7_ethernet/stm32f4x7_eth_bsp.c

@@ -191,6 +191,11 @@ void ETH_GPIO_Config(void)
         ETH_RST_PIN     -------> PE2  - замена на PE13
   
    */
+#ifdef HARDWARE_BT6711
+#define ETH_RST_PIN GPIO_Pin_7
+#else
+#define ETH_RST_PIN GPIO_Pin_13
+#endif
 
   /* Configure PA1,PA2 and PA7 */
   GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_7;
@@ -219,16 +224,16 @@ void ETH_GPIO_Config(void)
   GPIO_PinAFConfig(GPIOC, GPIO_PinSource5, GPIO_AF_ETH);
 
   /* Configure the PHY RST  pin */
-  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
+  GPIO_InitStructure.GPIO_Pin = ETH_RST_PIN;
   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
   GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
   GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
   GPIO_Init(GPIOE, &GPIO_InitStructure);
 
-  GPIO_ResetBits(GPIOE, GPIO_Pin_13);	
+  GPIO_ResetBits(GPIOE, ETH_RST_PIN);
   for (i = 0; i < 20000; i++);
-  GPIO_SetBits(GPIOE, GPIO_Pin_13);
+  GPIO_SetBits(GPIOE, ETH_RST_PIN);
   for (i = 0; i < 20000; i++);
 }