/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  
  /* Setup STM32 system (clocks, Ethernet, GPIO, NVIC) and STM3210C-EVAL resources */
  System_Setup();
             
  /* Initilaize the LwIP satck */
  LwIP_Init();
  
  /* Initilaize the HelloWorld module */
  HelloWorld_init();

  /* Initilaize the webserver module */
  httpd_init();

  /* Initialize the TFTP server */
  tftpd_init();

  /* Infinite loop */
  while (1)
  {    
	/* Periodic tasks */
	System_Periodic_Handle();
  }
}
Beispiel #2
0
/**
  * @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;
}