コード例 #1
0
//以太网中断服务函数
void ETH_IRQHandler(void)
{
	while(ETH_GetRxPktSize(DMARxDescToGet)!=0) 	//检测是否收到数据包
	{ 
		LwIP_Pkt_Handle();		
	}
	ETH_DMAClearITPendingBit(ETH_DMA_IT_R);
	ETH_DMAClearITPendingBit(ETH_DMA_IT_NIS);
}   
コード例 #2
0
ファイル: stm32f4xx_it.c プロジェクト: korrav/emmiter_slave
/**
  * @brief  This function handles ETH interrupt request.
  * @param  None
  * @retval None
  */
void ETH_IRQHandler(void)
{
  	/* Handles all the received frames */
  	while(ETH_GetRxPktSize(DMARxDescToGet) != 0) 
  	{		
	  LwIP_Pkt_Handle();
  	}

  	/* Clear the Eth DMA Rx IT pending bits */
  	ETH_DMAClearITPendingBit(ETH_DMA_IT_R);
  	ETH_DMAClearITPendingBit(ETH_DMA_IT_NIS);
}
コード例 #3
0
ファイル: ethernetif.c プロジェクト: 003900107/wpa900-com
/**
 * This function should be called when a packet is ready to be read
 * from the interface. It uses the function low_level_input() that
 * should handle the actual reception of bytes from the network
 * interface. Then the type of the received packet is determined and
 * the appropriate input function is called.
 *
 * @param netif the lwip network interface structure for this ethernetif
 */
err_t  ethernetif_1_input (struct netif *netif)
{
  //(void)p_arg;
  //INT8U     err;
  struct pbuf *p;
  extern struct netif netif_1;
  
  netif = &netif_1;
  
  while(1)
  {
//    OSSemPend(Eth1_pkt_Sem,0,&err);
//    printf("\n\n\r网口1数据包接收信号量");
    //ethernetif_1_input(netif);
    if(ETH_GetRxPktSize() != 0)
    {
      //ethernetif_1_input(netif);
      SYS_ARCH_DECL_PROTECT(sr);
  
      SYS_ARCH_PROTECT(sr);
      /* move received packet into a new pbuf */
      p = low_level_1_input(netif);
      SYS_ARCH_UNPROTECT(sr);
      
      if (p != NULL)
      {
        err_t err;
        err = netif->input(p, netif); // 将pbuf传递给上层协议栈
        if (err != ERR_OK)
        {
          LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
          pbuf_free(p);
          p = NULL;
        }
      }
    }
    else
    {
      OSTimeDlyHMSM(0, 0, 0, 5);
    }
  }
}
コード例 #4
0
/* Eth Isr routine */
static void Eth_Isr(void)
{
	uint32_t res = 0;

	while((ETH_GetRxPktSize() != 0) && (res == 0))
	{
		  /* move received packet into a new pbuf */
		  struct pbuf *p = low_level_input(&netif);

          if(p!=NULL){
        	  tcpip_input(p, &netif);
          }else{
        	  res = 1;
          }
	}

	/* Clear the Eth DMA Rx IT pending bits */
	ETH_DMAClearITPendingBit(ETH_DMA_IT_R);
	ETH_DMAClearITPendingBit(ETH_DMA_IT_NIS);
	ETH_DMAClearITPendingBit(ETH_DMA_IT_RO);
	ETH_DMAClearITPendingBit(ETH_DMA_IT_RBU);
}
コード例 #5
0
ファイル: main.c プロジェクト: 003900107/netIAP
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  FlagStatus status;
  uint16_t bak_dr10;
  //uint16_t bak_dr9;
  
  //RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
  //PWR_BackupAccessCmd(ENABLE);  
  
  //bak_dr10 = BKP_ReadBackupRegister(BKP_DR10);
  //bak_dr9 = BKP_ReadBackupRegister(BKP_DR9);
  
  //BKP_WriteBackupRegister(BKP_DR10, 0x0707);
  //BKP_WriteBackupRegister(BKP_DR9, 0x0001);
  
  
  /* Test if Key push-button on STM3210C-EVAL Board is not pressed */
  //if((bak_dr10 == 0x0707) /*&& (bak_dr9 != 0x0000)*/)
  if(1)
  {
    /* Setup STM32 system (clocks, Ethernet, GPIO, NVIC) and STM3210C-EVAL resources */
    System_Setup();
    
    Delay(1000);
    //可添加延时, 用以确保DM9000启动时电压满足芯片要求
    //"nRST must not go high until after the VDDIO and VDD_CORE supplies are stable"  手册P51
    GPIO_WriteBit(ETH_RESET,  Bit_SET);   //拉高DM9000 nRST, 复位启动    
    /* Configure the Ethernet peripheral */
    Ethernet_Configuration();
    
    /*
    //判断设备是否是初次上电, 如果'是', 重启一次, 确保以太网初始化正常
    status = RCC_GetFlagStatus(RCC_FLAG_SFTRST);
    RCC_ClearFlag(); 
    if(!status)
    {   
      Delay(10);
      
      NVIC_SystemReset();
    }
    */
 
    /* Initilaize the LwIP stack */
    LwIP_Init();
    
#ifdef USE_IAP_HTTP
    /* Initilaize the webserver module */
    IAP_httpd_init();
#endif
    
#ifdef USE_IAP_TFTP    
    /* Initialize the TFTP server */
    IAP_tftpd_init();
#endif    
    
    /* Infinite loop */
    while (1)
    {
      /* check if any packet received */
      if (ETH_GetRxPktSize()!=0)
      { 
        /* process received eth packet */
        LwIP_Pkt_Handle();
      }
      /* Periodic tasks */
      System_Periodic_Handle();
    }    
  }
  /* enter in IAP mode */
  else
  {
    /* Key push-button not pressed: jump to user application */
    
    /* Check if valid stack address (RAM address) then jump to user application */
    if (((*(__IO uint32_t*)USER_FLASH_FIRST_PAGE_ADDRESS) & 0x2FFE0000 ) == 0x20000000)
    {
      /* Jump to user application */
      JumpAddress = *(__IO uint32_t*) (USER_FLASH_FIRST_PAGE_ADDRESS + 4);
      Jump_To_Application = (pFunction) JumpAddress;
      /* Initialize user application's Stack Pointer */
      __set_MSP(*(__IO uint32_t*) USER_FLASH_FIRST_PAGE_ADDRESS);
      Jump_To_Application();
    }
    else
    {/* Otherwise, do nothing */
      /* LED3 (RED) ON to indicate bad software (when not valid stack address) */
      //STM_EVAL_LEDInit(LED3);
      //STM_EVAL_LEDOn(LED3);
      /* do nothing */
      while(1);
    }    
  }
  
  return 0;
}