Quellcode durchsuchen

ethernetif change notification

haitao vor 6 Monaten
Ursprung
Commit
2fee834fd0

BIN
app/MDKProject/Objects/dtu_lan_gateway.axf


+ 21 - 46
app/MDKProject/dtu_lan_gateway.uvoptx

@@ -157,89 +157,64 @@
         <Bp>
           <Number>0</Number>
           <Type>0</Type>
-          <LineNumber>1159</LineNumber>
+          <LineNumber>764</LineNumber>
           <EnabledFlag>1</EnabledFlag>
-          <Address>134231092</Address>
+          <Address>134266160</Address>
           <ByteObject>0</ByteObject>
           <HtxType>0</HtxType>
           <ManyObjects>0</ManyObjects>
           <SizeOfObject>0</SizeOfObject>
           <BreakByAccess>0</BreakByAccess>
           <BreakIfRCount>1</BreakIfRCount>
-          <Filename>..\HARDWARE\source\nandflash.c</Filename>
+          <Filename>..\Middlewares\Third_Party\LwIP\src\core\netif.c</Filename>
           <ExecCommand></ExecCommand>
-          <Expression>\\dtu_lan_gateway\../HARDWARE/source/nandflash.c\1159</Expression>
+          <Expression>\\dtu_lan_gateway\../Middlewares/Third_Party/LwIP/src/core/netif.c\764</Expression>
         </Bp>
         <Bp>
           <Number>1</Number>
           <Type>0</Type>
-          <LineNumber>39</LineNumber>
+          <LineNumber>550</LineNumber>
           <EnabledFlag>1</EnabledFlag>
-          <Address>134246406</Address>
+          <Address>134248282</Address>
           <ByteObject>0</ByteObject>
           <HtxType>0</HtxType>
           <ManyObjects>0</ManyObjects>
           <SizeOfObject>0</SizeOfObject>
           <BreakByAccess>0</BreakByAccess>
           <BreakIfRCount>1</BreakIfRCount>
-          <Filename>C:\Users\16936\Desktop\dtu_lan_gateway_hal\Middlewares\Third_Party\FatFS\src\diskio.c</Filename>
+          <Filename>..\USER\source\ethernetif.c</Filename>
           <ExecCommand></ExecCommand>
-          <Expression>\\dtu_lan_gateway\../Middlewares/Third_Party/FatFS/src/diskio.c\39</Expression>
+          <Expression>\\dtu_lan_gateway\../USER/source/ethernetif.c\550</Expression>
         </Bp>
         <Bp>
           <Number>2</Number>
           <Type>0</Type>
-          <LineNumber>73</LineNumber>
+          <LineNumber>546</LineNumber>
           <EnabledFlag>1</EnabledFlag>
-          <Address>134246246</Address>
+          <Address>134248274</Address>
           <ByteObject>0</ByteObject>
           <HtxType>0</HtxType>
           <ManyObjects>0</ManyObjects>
           <SizeOfObject>0</SizeOfObject>
           <BreakByAccess>0</BreakByAccess>
           <BreakIfRCount>1</BreakIfRCount>
-          <Filename>C:\Users\16936\Desktop\dtu_lan_gateway_hal\Middlewares\Third_Party\FatFS\src\diskio.c</Filename>
+          <Filename>..\USER\source\ethernetif.c</Filename>
           <ExecCommand></ExecCommand>
-          <Expression>\\dtu_lan_gateway\../Middlewares/Third_Party/FatFS/src/diskio.c\73</Expression>
-        </Bp>
-        <Bp>
-          <Number>3</Number>
-          <Type>0</Type>
-          <LineNumber>110</LineNumber>
-          <EnabledFlag>1</EnabledFlag>
-          <Address>134246388</Address>
-          <ByteObject>0</ByteObject>
-          <HtxType>0</HtxType>
-          <ManyObjects>0</ManyObjects>
-          <SizeOfObject>0</SizeOfObject>
-          <BreakByAccess>0</BreakByAccess>
-          <BreakIfRCount>1</BreakIfRCount>
-          <Filename>C:\Users\16936\Desktop\dtu_lan_gateway_hal\Middlewares\Third_Party\FatFS\src\diskio.c</Filename>
-          <ExecCommand></ExecCommand>
-          <Expression>\\dtu_lan_gateway\../Middlewares/Third_Party/FatFS/src/diskio.c\110</Expression>
-        </Bp>
-        <Bp>
-          <Number>4</Number>
-          <Type>0</Type>
-          <LineNumber>4202</LineNumber>
-          <EnabledFlag>1</EnabledFlag>
-          <Address>134255216</Address>
-          <ByteObject>0</ByteObject>
-          <HtxType>0</HtxType>
-          <ManyObjects>0</ManyObjects>
-          <SizeOfObject>0</SizeOfObject>
-          <BreakByAccess>0</BreakByAccess>
-          <BreakIfRCount>1</BreakIfRCount>
-          <Filename>C:\Users\16936\Desktop\dtu_lan_gateway_hal\Middlewares\Third_Party\FatFS\src\ff.c</Filename>
-          <ExecCommand></ExecCommand>
-          <Expression>\\dtu_lan_gateway\../Middlewares/Third_Party/FatFS/src/ff.c\4202</Expression>
+          <Expression>\\dtu_lan_gateway\../USER/source/ethernetif.c\546</Expression>
         </Bp>
       </Breakpoint>
+      <WatchWindow1>
+        <Ww>
+          <count>0</count>
+          <WinNumber>1</WinNumber>
+          <ItemText>gnetif</ItemText>
+        </Ww>
+      </WatchWindow1>
       <MemoryWindow1>
         <Mm>
           <WinNumber>1</WinNumber>
-          <SubType>8</SubType>
-          <ItemText>stream</ItemText>
+          <SubType>0</SubType>
+          <ItemText>gnetif</ItemText>
           <AccSizeX>0</AccSizeX>
         </Mm>
       </MemoryWindow1>

+ 1 - 1
app/Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c

@@ -61,7 +61,7 @@ task.h is included from an application file. */
 	heap - probably so it can be placed in a special segment or address. */
 	extern uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];
 #else
-	static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ] __attribute__((at(0x68000000)));//ʹÓÃÍⲿSRAM
+	static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ] __attribute__((at(0x68000000)));			//ʹÓÃÍⲿSRAM
 #endif /* configAPPLICATION_ALLOCATED_HEAP */
 
 /* Define the linked list structure.  This is used to link free blocks in order

+ 1 - 3
app/USER/source/app_ethernet.c

@@ -46,7 +46,6 @@ void User_notification(struct netif *netif)
     DHCP_state = DHCP_START;
 #else  
     /* Turn On LED 1 to indicate ETH and LwIP init success*/
-//    BSP_LED_On(LED1);
 #endif /* USE_DHCP */
  }
  else
@@ -56,7 +55,6 @@ void User_notification(struct netif *netif)
     DHCP_state = DHCP_LINK_DOWN;
 #else
     /* Turn On LED 2 to indicate ETH and LwIP init error */
-//    BSP_LED_On(LED2);
 #endif  /* USE_DHCP */ 
   } 
 }
@@ -96,7 +94,6 @@ void DHCP_thread(void const * argument)
         {
           DHCP_state = DHCP_ADDRESS_ASSIGNED;
           dhcp_done=1;
-
         }
         else
         {
@@ -137,4 +134,5 @@ void DHCP_thread(void const * argument)
 }
 #endif  /* USE_DHCP */
 
+
 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 3 - 3
app/USER/source/ethernetif.c

@@ -529,8 +529,8 @@ void ethernetif_set_link(void const *argument)
   
   for(;;)
   {
-    if (osSemaphoreWait( link_arg->semaphore, osWaitForever)== osOK)
-    {
+//    if (osSemaphoreWait( link_arg->semaphore, osWaitForever)== osOK)
+//    {
       /* Read PHY_MISR*/
       HAL_ETH_ReadPHYRegister(&EthHandle, PHY_MISR, &regvalue);
       
@@ -550,7 +550,7 @@ void ethernetif_set_link(void const *argument)
           netif_set_link_down(link_arg->netif);
         }
       }
-    }
+//    }
   }
 }
 

+ 46 - 24
app/USER/source/main.c

@@ -48,20 +48,14 @@ int main(void)
   SystemClock_Config();
 	MX_FSMC_SRAM_Init();
 	NAND_Init();
-	volatile uint32_t nandid=NAND_ReadID();
-//	NAND_Format();
-	
-	
-	char *p=malloc(10);
-	sprintf(p,"hello");
-	write_file("device.txt",p,strlen(p));
-  SRAM_Test();
 	
 	
   /* Init task */
   osThreadDef(Start, StartThread, osPriorityNormal, 0, configMINIMAL_STACK_SIZE * 4);
 
   osThreadCreate (osThread(Start), NULL);
+	
+
   
   /* Start scheduler */
   osKernelStart();
@@ -98,8 +92,8 @@ static void StartThread(void const * argument)
 #endif
   
   /* Start toogleLed4 task : Toggle LED4  every 250ms */
-  osThreadDef(LED4, ToggleLed4, osPriorityNormal, 0, configMINIMAL_STACK_SIZE*8);
-  osThreadCreate(osThread(LED4), NULL);
+//  osThreadDef(LED4, ToggleLed4, osPriorityNormal, 0, configMINIMAL_STACK_SIZE*8);
+//  osThreadCreate(osThread(LED4), NULL);
 
 	   
   for( ;; )
@@ -145,6 +139,18 @@ static void Netif_Config(void)
     /* When the netif link is down this function must be called */
     netif_set_down(&gnetif);
   }
+	netif_set_link_callback(&gnetif,ethernetif_update_config);
+	
+	  /* create a binary semaphore used for informing ethernetif of frame reception */
+  osSemaphoreDef(Netif_SEM); 
+  Netif_LinkSemaphore = osSemaphoreCreate(osSemaphore(Netif_SEM) , 1 );
+
+  link_arg.netif = &gnetif;
+  link_arg.semaphore = Netif_LinkSemaphore;
+	
+	osThreadDef(LinkThr, ethernetif_set_link, osPriorityBelowNormal, 0, configMINIMAL_STACK_SIZE * 2);
+  osThreadCreate (osThread(LinkThr), &link_arg);
+	
 }
 
 
@@ -157,21 +163,21 @@ static void BSP_Config(void)
 {
 }
 
-/**
-  * @brief  Toggle LED4 thread
-  * @param  pvParameters not used
-  * @retval None
-  */
-static void ToggleLed4(void const * argument)
-{
-  for( ;; )
-  {
-    /* Toggle LED4 each 250ms */
+///**
+//  * @brief  Toggle LED4 thread
+//  * @param  pvParameters not used
+//  * @retval None
+//  */
+//static void ToggleLed4(void const * argument)
+//{
+//  for( ;; )
+//  {
+//    /* Toggle LED4 each 250ms */
 
-		LOG_PRINT(LOG_INFO,"udp");
-    osDelay(100);
-  }
-}
+//		LOG_PRINT(LOG_INFO,"udp");
+//    osDelay(100);
+//  }
+//}
 
 ///**
 //  * @brief  EXTI line detection callbacks
@@ -250,6 +256,8 @@ static void Error_Handler(void)
   }
 }
 
+
+
 void vApplicationMallocFailedHook( void )
 {
 	LOG_PRINT(LOG_ERROR,"malloc error");
@@ -286,4 +294,18 @@ void assert_failed(uint8_t* file, uint32_t line)
 }
 #endif
 
+void ethernetif_notify_conn_changed(struct netif *netif)
+{
+  if (netif_is_link_up(netif))
+  {
+    LOG_PRINT(LOG_INFO,"link up");
+  }
+  else
+  {
+    LOG_PRINT(LOG_INFO,"link down");
+  }
+  
+}
+
+
 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 1 - 9
app/USER/source/stm32f2xx_it.c

@@ -115,15 +115,7 @@ void SysTick_Handler(void)
   osSystickHandler();
 }
 
-///**
-//  * @brief  This function handles External lines 15_10 interrupt request.
-//  * @param  None
-//  * @retval None
-//  */
-//void EXTI15_10_IRQHandler(void)
-//{
-//  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_14);
-//}
+
 
 /**
   * @brief  This function handles Ethernet interrupt request.