コード例 #1
0
ファイル: main.c プロジェクト: korrav/madOnSTM32F417
int main(void) {
    int temp = 5;
    //configures the priority grouping
    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_3);
    //start time
    start_timer();
    //configure spi
    SPI_Config();
    //ETHERNET INITIALIZATION
    ETH_BSP_Config();
    /* Initilaize the LwIP stack */
    LwIP_Init();
    //udp initialization
    if (!udp_echoserver_init())
        return 1;
    while (1)
    {
        //PROCESSING OF PEREODIC TIMERS FOR LWIP
        LwIP_Periodic_Handle(gettime());
        //PROCESSING OF INCOMING PACKET
        if (ETH_CheckFrameReceived())
        {
            /* process received ethernet packet */
            LwIP_Pkt_Handle();
        }
        trans_Control((void*)&temp, sizeof(temp));
    }
}
コード例 #2
0
ファイル: main.c プロジェクト: blackphoenix208/ARMWork
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured to 
       168 MHz, this is done through SystemInit() function which is called from
       startup file (startup_stm32f4xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f4xx.c file
     */  

#ifdef SERIAL_DEBUG
  DebugComPort_Init();
#endif
  
  /*Initialize LCD and Leds */ 
  LCD_LED_BUTTON_Init();
  
  /* Configure ethernet (GPIOs, clocks, MAC, DMA) */ 
  ETH_BSP_Config();
    
  /* Initilaize the LwIP stack */
  LwIP_Init();
      
  /* Infinite loop */
  while (1)
  {  
    /* check if any packet received */
    if (ETH_CheckFrameReceived())
    { 
      /* process received ethernet packet */
      LwIP_Pkt_Handle();
    }
    /* handle periodic timers for LwIP */
    LwIP_Periodic_Handle(LocalTime);
  }   
}
コード例 #3
0
/**
  * @brief  Main task
  * @param  pvParameters not used
  * @retval None
  */
void Main_task(void * pvParameters)
{
#ifdef SERIAL_DEBUG
  DebugComPort_Init();
#endif
  
  /* configure ethernet (GPIOs, clocks, MAC, DMA) */ 
  ETH_BSP_Config();

  /* Initialize the LwIP stack */
  LwIP_Init();

  /* Initialize tcp echo server */
  //tcpecho_init();

  /* Initialize udp echo server */
  udpecho_init();

#ifdef USE_DHCP
  /* Start DHCPClient */
  xTaskCreate(LwIP_DHCP_task, (int8_t *)"DHCP", configMINIMAL_STACK_SIZE * 2, NULL,DHCP_TASK_PRIO, NULL);
#endif

#if 0
  /* Start toogleLed4 task : Toggle LED4  every 250ms */
  xTaskCreate(ToggleLed4, (int8_t *)"LED4", configMINIMAL_STACK_SIZE, NULL, LED_TASK_PRIO, NULL);
#endif

  for( ;; )
  {
    vTaskDelete(NULL);
  }
}
コード例 #4
0
void net_init()
{
	int i;
  uint8_t mac_addr[6];

	mac_addr[0] = MAC_ADDR0;
	mac_addr[1] = MAC_ADDR1;
	mac_addr[2] = MAC_ADDR2;
	mac_addr[3] = MAC_ADDR3;
	mac_addr[4] = MAC_ADDR4;
	mac_addr[5] = MAC_ADDR5;

	ETH_BSP_Config();

	ETH_MACAddressConfig(ETH_MAC_Address0, &mac_addr);

	ETH_DMATxDescChainInit(DMATxDscrTab, &Tx_Buff[0][0], ETH_TXBUFNB);
	ETH_DMARxDescChainInit(DMARxDscrTab, &Rx_Buff[0][0], ETH_RXBUFNB);

	for (i = 0; i < ETH_TXBUFNB; i++)
	{
		ETH_DMATxDescChecksumInsertionConfig(&DMATxDscrTab[i], ETH_DMATxDesc_ChecksumByPass);
	}

	ETH_Start();
}
コード例 #5
0
ファイル: main.c プロジェクト: vpcola/Projects
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured to 
       144 MHz, this is done through SystemInit() function which is called from
       startup file (startup_stm32f4xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f4xx.c file
     */  

  /*Initialize LCD and Leds */ 
  LCD_LED_Init();
  
  /* configure ethernet (GPIOs, clocks, MAC, DMA) */ 
  ETH_BSP_Config();
    
  /* Initilaize the LwIP stack */
  LwIP_Init();
  
  /* Initialize webserver demo */
  http_server_socket_init();

#ifdef USE_DHCP
  /* Start DHCPClient */
  xTaskCreate(LwIP_DHCP_task, (const signed char *) "DHCPClient", configMINIMAL_STACK_SIZE * 2, NULL,DHCP_TASK_PRIO, NULL);
#endif
    
  /* Start toogleLed4 task : Toggle LED4  every 250ms */
  xTaskCreate(ToggleLed4, (const signed char *) "LED4", configMINIMAL_STACK_SIZE, NULL, LED_TASK_PRIO, NULL);
  
  /* Start scheduler */
  vTaskStartScheduler();

  /* We should never get here as control is now taken by the scheduler */
  for ( ;; );
}
コード例 #6
0
ファイル: emmiter.c プロジェクト: korrav/emmiter_slave
int main(void) {
	struct b_pool* pbuf;
	struct head* h;
	init_pools_buffers();
	//configure NVIC
	NVIC_Configuration();
	//start time
	start_timer();
	//configure adc
	ADC_config();
	//configure pwm
	pwm_Config();
	//ETHERNET INITIALIZATION
	ETH_BSP_Config();
	/* Initilaize the LwIP stack */
  LwIP_Init();
	//enable clock
	/*__disable_irq();
	clockHseInit();
	__enable_irq();*/
	/*Initilaize the PTP stack*/
	PTPd_Init();
	//udp initialization
	udp_echoserver_init();
	//configure state
	//init_current_state(&cur);
	cur.status = STOP;
	cur.id_sig = 0;
  while (1)
  {  
    //PROCESSING OF PEREODIC TASKS FOR LWIP
    LwIP_Periodic_Handle(gettime());
		//PROCESSING OF PEREODIC TASKS FOR PTP
		ptpd_Periodic_Handle(gettime());
		//PROCESSING OF QUEUING BUFFERS
		pbuf = pull_out_queue();
		if(pbuf != NULL) {
			h = (struct head*)pbuf->pbuf;
			if(h->dst & SLAVE) {
				if(h->type == COMMAND)
					handl_command(pbuf);
			} else
				transPackage(pbuf, eth_write);
			free_buf(pbuf);
		}
		//PROCESSING OF DEBUG_INFO
		if(debug.time > 0) {
			if(debug.num == -1 || debug.num > 0)  {
				debug_info();
			}
			else
				debug.time = 0;
			if (debug.num > 0)
				debug.num --;
		}
		//PROCESSING OF TEMP BUFFER
		
  }   
}
コード例 #7
0
ファイル: main.c プロジェクト: elmat-dev/Central_Dev
int main(void)
{
  SystemInit();						// initialize MCU clocks and registers
  TM_DELAY_Init();					// initialize Delay library
  TM_DELAY_SetTime(0);				// Reset couter for systime
  Laser_GPIO_Conf();				// configure GPIO for laser control (to be able to enable/disable lasers via software
  TM_BKPSRAM_Init();				// initialize BKP RAM access library
  Laser_Update();			// load laser statuses saved in BKP RAM
  TM_USART_Init(OUTPUT_USART, OUTPUT_USART_PINS, OUTPUT_USART_SPEED);		// initialize UART used for collected Data output
  TM_USART_Init(MENU_USART, MENU_USART_PINS, MENU_USART_SPEED);				// initialize UART used for configuration
  TM_RTC_Init(TM_RTC_ClockSource_External);									// initialize RTC library
  TM_GPIO_Init(GPIOD, GPIO_Pin_8, TM_GPIO_Mode_OUT, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_Low); // configure GPIO for GSM status indication (RED LED)
  TM_GPIO_Init(GPIOD, GPIO_Pin_9, TM_GPIO_Mode_OUT, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_Low); // configure GPIO for GSM status indication (GREEN LED)
  Laser_ADC_Init();					// initialize ADC peripherals
  Menu_Init();						// initialize CLI library
  sfpInit();						// configure GPIO for SFP modules
  gsm_Init();						// initialize GSM module


  /* configure and initialize Ethernet hardware and LwIP stack */

  ETH_BSP_Config();					// configure ETH GPIOs
  printf("Ethernet MAC and PHY configured successfully!\n");
  LwIP_Init();						// start LwIP stack
  printf("LwIP stack initialized successfully!\n");
  UDP_Server_Init();				// start UDP Server
  printf("UDP Server initialized successfully!\n");

  //start periodic tasks

  /* GSM Status update "task" */
  GSM_Status_Update_Timer = TM_DELAY_TimerCreate(GSM_CHECK_INTERVAL, 1, 1, GSM_Status_Update_Timer_Task, NULL);
  printf("GSM status check task created!\n");
  /* Print results from remote devices "task" */
  Print_Results_Timer = TM_DELAY_TimerCreate(DATA_OUT_INTERVAL, 1, 1, Print_Results_Timer_Task, NULL);
  printf("Print collected data task created!\n");
  /* LaserLock status update "task" */
  LaserLock_Timer = TM_DELAY_TimerCreate(1000, 1, 1, LaserLock_Timer_Task, NULL);
  printf("Laser lock check task created!\n");

  while (1) {
	  /* CLI menu update */
	  Menu_Update();
      /* check if any packet received */
	  if (ETH_CheckFrameReceived())
	  {
		  /* process received ethernet packet */
		  LwIP_Pkt_Handle();
	  }
    /* handle periodic timers for LwIP */
    LwIP_Periodic_Handle(LocalTime);
    /* update laser statuses */
    Laser_Update();
    /* remove SMS messages which were read by system */
    delete_read_gsm_messages();
  }
} 
コード例 #8
0
ファイル: contiki-main.c プロジェクト: jensnielsen/contiki
/*---------------------------------------------------------------------------*/
int main(void)
{

  /*
   * Initialise hardware.
   */
  //halInit();
    clock_init();

  //uart1_init(115200);

    // Led initialisation
    leds_init();
    leds_on(LEDS_RED);

    /* configure ethernet (GPIOs, clocks, MAC, DMA) */
    ETH_BSP_Config();



  //INTERRUPTS_ON();

    /*
     * Initialize Contiki and our processes.
     */

    process_init();
/*
#if WITH_SERIAL_LINE_INPUT
  uart1_set_input(serial_line_input_byte);
  serial_line_init();
#endif*/
  /* rtimer and ctimer should be initialized before radio duty cycling layers*/
    rtimer_init();
  /* etimer_process should be initialized before ctimer */
    process_start(&etimer_process, NULL);
    ctimer_init();

    netstack_init();

    procinit_init();

    autostart_start(autostart_processes);

    while (1)
    {
        int r;

        do
        {
            leds_toggle(LEDS_YELLOW);
            r = process_run();
        } while (r > 0);
    }
}
コード例 #9
0
ファイル: main.cpp プロジェクト: hanbiao/stm32
/*-----------------------------------------------*/
extern "C" void MainTask(void* args)
{
    /* configure Ethernet (GPIOs, clocks, MAC, DMA) */
    ETH_BSP_Config();

    /* Initialize the LwIP stack */
	LwIP_Init();

	xTaskCreate(ros_main, (const signed char*)"ROSMain", 128, NULL, 2, NULL);
	xTaskCreate(led_task, (const signed char*)"LedTask", 128, NULL, 2, NULL);

    vTaskDelete(NULL);
}
コード例 #10
0
/**
 * Initializes the Tekdaqc's Ethernet communications and lwIP stack. This is necessary for both
 * the main application functionality as well as the IAP update function.
 *
 * @param none
 * @retval none
 */
void Communication_Init(void) {
	for (uint_fast8_t i = 0; i < SIZE_TOSTRING_BUFFER; ++i) {
		TOSTRING_BUFFER[i] = '\0';
	}

	/* Initialize the generic delay timer */
	Timer_Config();

	/* Configure ethernet (GPIOs, clocks, MAC, DMA) */
	ETH_BSP_Config();

	/* Initilaize the LwIP stack */
	LwIP_Init();
}
コード例 #11
0
ファイル: main.c プロジェクト: GottfriedSp/stm-ledstrip-net
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{

	SystemInit();
	init_systick();

#ifdef SERIAL_DEBUG
  DebugComPort_Init();  
#endif
  printf(" Artnet2WS2811 Receiver\r\n ");
  /*Initialize LCD and Leds */ 
  LED_Init();
  
  /* configure ethernet (GPIOs, clocks, MAC, DMA) */ 
  ETH_BSP_Config();
    
  /* Initilaize the LwIP stack */
  LwIP_Init();
  
  /* tcp echo server Init */
  //tcp_echoserver_init();
  telnetserver_init();
  //artnet_init();

  ws2812_init();
  /* Initialize variables for ws2812 */

	delay_ms(20);




  /* Infinite loop */
  while (1)
  {  
    /* check if any packet received */

	  if (ETH_CheckFrameReceived())
    {
      /* process received ethernet packet */
      LwIP_Pkt_Handle();
    }
    /* handle periodic timers for LwIP */
    LwIP_Periodic_Handle(system_time);

    DRAW_LED();
  }   
}
コード例 #12
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured to 
       168 MHz, this is done through SystemInit() function which is called from
       startup file (startup_stm32f4xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f4xx.c file
     */
//add a long delay wait for DP83848 finish reset  
unsigned int i,j;
for(i=0;i<50;i++)
{
	for(j=0;j < 65500;j++);
}
#ifdef SERIAL_DEBUG
  DebugComPort_Init();
#endif
  
  /*Initialize LCD and Leds */ 
  LCD_LED_Init();
  
  /* configure ethernet (GPIOs, clocks, MAC, DMA) */ 
  ETH_BSP_Config();
    
  /* Initilaize the LwIP stack */
  LwIP_Init();
  
  /* Initialize tcp echo server */
  tcpecho_init();
  
  /* Initialize udp echo server */
  udpecho_init();

#ifdef USE_DHCP
  /* Start DHCPClient */
  xTaskCreate(LwIP_DHCP_task, "DHCPClient", configMINIMAL_STACK_SIZE * 2, NULL,DHCP_TASK_PRIO, NULL);
#endif
    
  /* Start toogleLed4 task : Toggle LED4  every 250ms */
  xTaskCreate(ToggleLed4, "LED4", configMINIMAL_STACK_SIZE, NULL, LED_TASK_PRIO, NULL);
  
  /* Start scheduler */
  vTaskStartScheduler();

  /* We should never get here as control is now taken by the scheduler */
  for( ;; );
}
コード例 #13
0
ファイル: main.c プロジェクト: zhenhong66/My_STM32F2
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured to 
       120 MHz, this is done through SystemInit() function which is called from
       startup file (startup_stm32f2xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f2xx.c file
     */  
//add a long delay wait for DP83848 finish reset  
unsigned int i,j;
for(i=0;i<36;i++)
{
	for(j=0;j < 65500;j++);
}  
#ifdef SERIAL_DEBUG
  DebugComPort_Init();
#endif

  /* Initialize LCD and Leds */ 
  LCD_LED_Init();
  
  /* Configure ethernet (GPIOs, clocks, MAC, DMA) */ 
  ETH_BSP_Config();
    
  /* Initilaize the LwIP stack */
  LwIP_Init();
      
  /* TFTP server Init */
  tftpd_init();
    
  /* Infinite loop */
  while (1)
  {  
    /* check if any packet received */
    if (ETH_CheckFrameReceived())
    { 
      /* process received ethernet packet */
      LwIP_Pkt_Handle();
    }
    /* handle periodic timers for LwIP */
    LwIP_Periodic_Handle(LocalTime);
  }   
}
コード例 #14
0
ファイル: ethernet.c プロジェクト: TSURKOVSERGEY/meteo
void UDP_Config(void)
{
  
  if(ETH_BSP_Config() == ETH_ERROR) CriticalError(ERR_ETH_CONFIG);
  
  LwIP_Init();
  
  delay(500);
  
  IP4_ADDR(&ip_addr_tx,192,9,206,251);
  
  if((pudp_pcb = udp_new()) == NULL) CriticalError(ERR_UDP_NEW);
 
  if((udp_bind(pudp_pcb,IP_ADDR_ANY,RX_PORT) != ERR_OK)) CriticalError(ERR_UDP_BIND);
 
  udp_recv(pudp_pcb,&udp_rx_handler,NULL);

  if(!(pOut = pbuf_alloc(PBUF_TRANSPORT,sizeof(tx_udp_msg),PBUF_RAM))) CriticalError(ERR_POUT_NEW);
}
コード例 #15
0
ファイル: ethernet.c プロジェクト: TSURKOVSERGEY/meteo
int TCP_CLIENT_Config(void)
{ 
  if(ETH_BSP_Config() == ETH_ERROR) CriticalError(ERR_ETH_CONFIG);
  
  LwIP_Init();
  
  delay(500);
  
  if((ptcp_pcb = tcp_new()) == NULL) CriticalError(ERR_UDP_NEW);
   
  IP4_ADDR(&ip_addr_tx,192,9,206,251);
  
  if(tcp_connect(ptcp_pcb,&ip_addr_tx,TX_PORT,tcp_echoclient_connected) == ERR_OK) 
  {
    pbuf_free(ptcp_pcb->refused_data);
    return 0;
  }
  else return 1;
}
コード例 #16
0
ファイル: Ethernet.c プロジェクト: jdaheron/GHB
/*------------------------------------------------------------------------------------------------*/
void Ethernet_Init(Bool_e UseConfIni)
{
	Ethernet_t TmpThis;
	Status_e ReadStatus;


	_CONSOLE(LogId, "---------- CONF_ETHERNET INIT ----------\n");

	//------------------------------------------------------
	// Lecture des donnees flash
	//------------------------------------------------------
	DatabaseEeprom_InitData(DatabaseEeprom_Ethernet, NULL, sizeof(Ethernet_t));
	ReadStatus = DatabaseEeprom_Read(DatabaseEeprom_Ethernet, &TmpThis);
	DatabaseEeprom_Display(DatabaseEeprom_Ethernet, &TmpThis);
	if (ReadStatus == Status_KO)
	{
		_CONSOLE(LogId, "Invalid Eeprom Read: Default restored\n");
		DatabaseEeprom_Write(DatabaseEeprom_Ethernet, &This);
		memcpy(&TmpThis, &This, sizeof(Ethernet_t));
		This.Cfg_Restored 	= TRUE;
	}
	else
	{
		_CONSOLE(LogId, "Valid Eeprom Read \n");
		memcpy(&This, &TmpThis, sizeof(Ethernet_t));
		This.Cfg_Restored = FALSE;
	}

	//------------------------------------------------------
	// Comparaison avec fichier ini
	//------------------------------------------------------
	if ((ConfIni_Get()->IsValide == TRUE) && (UseConfIni == TRUE))
	{
		_CONSOLE(LogId, "Check SD cfg\n");

		memcpy(This.Cfg_IP_Adresse,		ConfIni_Get()->ETH_IP_Adresse, 4);
		memcpy(This.Cfg_IP_Masque,		ConfIni_Get()->ETH_IP_Masque, 4);
		memcpy(This.Cfg_IP_Passerelle,	ConfIni_Get()->ETH_IP_Passerelle, 4);
		memcpy(This.Cfg_MAC_Adresse,	ConfIni_Get()->ETH_MAC_Adresse, 6);
		This.Cfg_DHCP_Actif = ConfIni_Get()->ETH_DHCP_Actif;

		if (memcmp(&TmpThis, &This, sizeof(Ethernet_t)) != 0)
		{
			_CONSOLE(LogId, "Cfg SD copied\n");
			DatabaseEeprom_Write(DatabaseEeprom_Ethernet, &This);
		}
		else
		{
			_CONSOLE(LogId, "Cfg unchanged\n");
		}
	}


	//------------------------------------------------------
	// Affichage de la configuration
	//------------------------------------------------------
	_CONSOLE(LogId, "IP_Adresse    = %d.%d.%d.%d\n",		This.Cfg_IP_Adresse[0], This.Cfg_IP_Adresse[1], This.Cfg_IP_Adresse[2], This.Cfg_IP_Adresse[3]);
	_CONSOLE(LogId, "IP_Masque     = %d.%d.%d.%d\n",		This.Cfg_IP_Masque[0], This.Cfg_IP_Masque[1], This.Cfg_IP_Masque[2], This.Cfg_IP_Masque[3]);
	_CONSOLE(LogId, "IP_Passerelle = %d.%d.%d.%d\n", 		This.Cfg_IP_Passerelle[0], This.Cfg_IP_Passerelle[1], This.Cfg_IP_Passerelle[2], This.Cfg_IP_Passerelle[3]);
	_CONSOLE(LogId, "MAC_Adresse   = %d:%d:%d:%d:%d:%d\n",	This.Cfg_MAC_Adresse[0], This.Cfg_MAC_Adresse[1], This.Cfg_MAC_Adresse[2], This.Cfg_MAC_Adresse[3], This.Cfg_MAC_Adresse[4], This.Cfg_MAC_Adresse[5]);
	_CONSOLE(LogId, "DHCP_Actif    = %d\n",					This.Cfg_DHCP_Actif		);


	//------------------------------------------------------
	// Application de la configuration
	//------------------------------------------------------

	ETH_BSP_Config();	// Configure ethernet (GPIOs, clocks, MAC, DMA)
	LwIP_Init(This.Cfg_IP_Adresse, This.Cfg_IP_Masque, This.Cfg_IP_Passerelle, This.Cfg_DHCP_Actif, This.Cfg_MAC_Adresse);		// Initilaize the LwIP stack
	tftpd_init();		// TFTP server Init
	//httpd_init();		// Http webserver Init
	Telnet_Init();
}
コード例 #17
0
ファイル: mod_ethernet.c プロジェクト: denisweir/STM32F40X
/**
  * @brief  Draw the Ethernet page backgound
  * @param  None
  * @retval None
  */
static void InitEthernet(void)
{
  uint8_t temp[45];
  uint8_t buf[30];

  if( EthernetSettings.InitDone == 0)
  {
  MOD_GetParam(3 , &EthCfg.d32);
  EthernetSettings.InitDone  = 1;
  if(EthernetSettings.WebserverEnabled == 1)
  {
    EthernetCurrentPage = EthernetWebServerPage;
  }
  else if(EthernetSettings.DistantControlEnabled == 1)
  {
    EthernetCurrentPage = EthernetDistantControlPage;
  }

  if(TCPIP_Task_Handle != NULL)
  {
    if(xTaskIsTaskSuspended(TCPIP_Task_Handle) == pdTRUE)
    {
      vTaskResume(TCPIP_Task_Handle);
    }
  }

  if (EthernetSettings.BackgroundEnabled == 0)
  {
    memset (temp, ' ', 45);

    if(EthStatus == 0)
    {
      ETH_BSP_Config();

      if(EthStatus == 1) /* Network cable is connected */
      {
        EthLinkStatus = 0;
        RefreshLabel(EthernetCurrentPage, 3, temp);  
        RefreshLabel(EthernetCurrentPage, 3, (uint8_t *)"Ethernet initialization..OK");
        LastInitMessageIndex = 1;
      }
      else /* Network cable is unplugged */
      {
        RefreshLabel(EthernetCurrentPage, 3, temp);
        RefreshLabel(EthernetCurrentPage, 4, temp);
        RefreshLabel(EthernetCurrentPage, 5, temp);
        RefreshLabel(EthernetCurrentPage, 3, (uint8_t *)"Ethernet initialization failed, Please");
        RefreshLabel(EthernetCurrentPage, 4, (uint8_t *)"verify if the Ethernet cable is connected");
        RefreshLabel(EthernetCurrentPage, 5, (uint8_t *)"and try again.");
        LastInitMessageIndex = 2;
        return;
      }
    }
    if(EthLinkStatus == 0) /* Network Cable is connected */
    {
      ETHERNET_UpdateIcon(ethernet_conn_icon);
      sprintf((char*)buf, "Ethernet Speed: %d.0Mbps", (int)EthSpeed);
      RefreshLabel(EthernetCurrentPage, 3, temp);
      RefreshLabel(EthernetCurrentPage, 3, buf);
      LastInitMessageIndex = 3;
    }
    else
    {
      ETHERNET_UpdateIcon(ethernet_disconn_icon);
      RefreshLabel(EthernetCurrentPage, 4, temp);
      RefreshLabel(EthernetCurrentPage, 5, temp);
      RefreshLabel(EthernetCurrentPage, 4, (uint8_t *)"Please verify if the Ethernet cable ");
      RefreshLabel(EthernetCurrentPage, 5, (uint8_t *)"is connected and try again. ");
      LastInitMessageIndex = 4;
      return;
    }
    LwIP_Init();
    http_init();
    if(EthCfg.b.DHCPEnable == 1)
    {
      if(DHCP_Task_Handle == NULL)
      {
        xTaskCreate(LwIP_DHCP_task, (signed char const*)"DHCP_P", DHCP_THREAD_STACK_SIZE, NULL, DHCP_THREAD_PRIO, &DHCP_Task_Handle);
      }
    }
    else
    {
      vTaskPrioritySet(Task_Handle, (configMAX_PRIORITIES - 7));//5//7
    }

    if(EthernetSettings.WebserverEnabled == 1)
    {
      if(EthCfg.b.SelectedImageFormat == 1)
      {
        IPCAM_ImageBuffer.ImageFormat = BMP_QQVGA;
      }
      else if(EthCfg.b.SelectedImageFormat == 2)
      {
        IPCAM_ImageBuffer.ImageFormat = BMP_QVGA;
      }
      else
      {
        IPCAM_ImageBuffer.ImageFormat = BMP_QQVGA;
      }
      IPCAM_ImageCaptureInit();
    }
  }
  else
  {
    LastInitMessageIndex = 5;
    RefreshLabel(EthernetCurrentPage, 4, temp);
    RefreshLabel(EthernetCurrentPage, 4, DHCPStatus[DHCPStatusIndex]);
    RefreshLabel(EthernetCurrentPage, 5, temp);
    RefreshLabel(EthernetCurrentPage, 5, IPAddressAssigned);
    if (EthernetSettings.DistantControlEnabled == 1)
    {
      vTaskDelay(1000);
      EthernetSettings.BackgroundEnabled = 1;
      ETHERNET_SwitchPage(EthernetDistantControlPage, PAGE_MENU);
      EthernetDistantControlPage = NULL;
    }
  }
 }
 else
 {
   switch(LastInitMessageIndex)
   {
   case 1:
     RefreshLabel(EthernetCurrentPage, 3, (uint8_t *)"                                        ");  
     RefreshLabel(EthernetCurrentPage, 3, (uint8_t *)"Ethernet initialization..OK");
     break;
   case 2:
     RefreshLabel(EthernetCurrentPage, 3, (uint8_t *)"                                        ");
     RefreshLabel(EthernetCurrentPage, 4, (uint8_t *)"                                        ");
     RefreshLabel(EthernetCurrentPage, 5, (uint8_t *)"                                        ");
     RefreshLabel(EthernetCurrentPage, 3, (uint8_t *)"Ethernet initialization failed, Please");
     RefreshLabel(EthernetCurrentPage, 4, (uint8_t *)"verify if the Ethernet cable is connected");
     RefreshLabel(EthernetCurrentPage, 5, (uint8_t *)"and try again.");
     break;
   case 3: 
     ETHERNET_UpdateIcon(ethernet_conn_icon);
     sprintf((char*)buf, "Ethernet Speed: %d.0Mbps", (int)EthSpeed);
     RefreshLabel(EthernetCurrentPage, 3, (uint8_t *)"                                        ");
     RefreshLabel(EthernetCurrentPage, 3, buf);
     break;
   case 4: 
     ETHERNET_UpdateIcon(ethernet_disconn_icon);
     RefreshLabel(EthernetCurrentPage, 4, (uint8_t *)"                                        ");
     RefreshLabel(EthernetCurrentPage, 5, (uint8_t *)"                                        ");
     RefreshLabel(EthernetCurrentPage, 4, (uint8_t *)"Please verify if the Ethernet cable     ");
     RefreshLabel(EthernetCurrentPage, 5, (uint8_t *)"is connected and try again.             ");
     break;
   case 5:
     RefreshLabel(EthernetCurrentPage, 4, (uint8_t *)"                                        ");
     RefreshLabel(EthernetCurrentPage, 4, DHCPStatus[DHCPStatusIndex]);
     RefreshLabel(EthernetCurrentPage, 5, (uint8_t *)"                                        ");
     RefreshLabel(EthernetCurrentPage, 5, IPAddressAssigned);

     if(IPaddress !=0)
     {
       sprintf((char*)temp, "%s",IPAddressAssigned);
       ETHERNET_UpdateDHCPState(4,temp);
       ETHERNET_UpdateIcon(ethernet_conn_icon);
     }
     break;

   case 6:
     RefreshLabel(EthernetCurrentPage ,6 , (uint8_t *)"Network Cable is unplugged !!!");
     break;

   case 7:
     RefreshLabel(EthernetCurrentPage, 6, (uint8_t *)"Network Cable is now connected");     
     break;
   }
 }
}
コード例 #18
0
ファイル: main.c プロジェクト: lordhippo/ImmortalsSender
int main(void)
{
	int i;		
	unsigned char add[5]={110,110,8,110,110};
  /*!< At this stage the microcontroller clock setting is already configured to 
       120 MHz, this is done through SystemInit() function which is called from
       startup file (startup_stm32f2xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f2xx.c file
     */
  
#ifdef SERIAL_DEBUG
  DebugComPort_Init();
#endif
  
	initLED();
	init_Timer();
	//while(1);
	
  /*Initialize LCD and Leds */ 
  //LCD_LED_Init();
	
	delay_ms(500);				
	
	for(i=0;i<100;i++)
	{
		setNumber(i);
		delay_ms(10);				
	}
	beep(40);
	offSegment(3);
	delay_ms(100);
	setNumber(0);
	delay_ms(100);
	beep(40);
	offSegment(3);
	delay_ms(100);
	setNumber(0);
	delay_ms(100);
	beep(40);
	
	//USART2_Init();
	//USART3_Init();
	
	init_NRF1_IO();
	init_NRF2_IO();
	SPI1_Config();
	SPI3_Config();
	SPI_Cmd(SPI1, ENABLE);
	SPI_Cmd(SPI3, ENABLE);
	
  nrf24l01_initialize_debug(false, TX_PAYLOAD_SIZE, false);
	nrf24l01_clear_flush();
	add[2]=8;
	nrf24l01_set_tx_addr(add , 5);
	add[2]=30;
	nrf24l01_set_rx_addr(add,5,0);
	nrf24l01_set_rf_ch(tx_channel);


	nrf24l02_initialize_debug(false, RX_PAYLOAD_SIZE, false);	
 	nrf24l02_clear_flush();
	add[2]=8;
	nrf24l02_set_tx_addr(add , 5);
	add[2]=30;
	nrf24l02_set_rx_addr(add,5,0);	
	nrf24l02_set_rf_ch(rx_channel);
	nrf24l02_set_as_rx(true);		
	
  /* configure ethernet */ 
  ETH_BSP_Config();
    
  /* Initilaize the LwIP stack */
  LwIP_Init();
  
  /* UDP echoserver */
  udp_echoserver_init();
  
    
  /* Infinite loop */
  while (1)
  {  
    /* check if any packet received */
					
    if (ETH_CheckFrameReceived())
    {
      /* process received ethernet packet */
      LwIP_Pkt_Handle();
    }
    /* handle periodic timers for LwIP */
    LwIP_Periodic_Handle(LocalTime);
		
		process_incoming_rf();
		
		if(firstPacketRecieved==0)
		{
			demo();
			setNumber(22);			
		}
							
  }   
}
コード例 #19
0
ファイル: ethernet.c プロジェクト: TSURKOVSERGEY/sdi
void ETH_Config(void)
{
  //info_ini.at24_error = AT24_Read(0,(uint8_t*)&eth_ini_dat,sizeof(ethernet_initial_struct));
  
  if(crc32(&eth_ini_dat,sizeof(eth_ini_dat)-4,sizeof(eth_ini_dat)-4) != eth_ini_dat.crc)
  {
    eth_ini_dat.IP_ADR[0] = IP_ADDR0;
    eth_ini_dat.IP_ADR[1] = IP_ADDR1;
    eth_ini_dat.IP_ADR[2] = IP_ADDR2;
    eth_ini_dat.IP_ADR[3] = IP_ADDR3;
    
    eth_ini_dat.GW_ADR[0] = GW_ADDR0;
    eth_ini_dat.GW_ADR[1] = GW_ADDR1;
    eth_ini_dat.GW_ADR[2] = GW_ADDR2;
    eth_ini_dat.GW_ADR[3] = GW_ADDR3;
      
    eth_ini_dat.MASK[0] = NETMASK_ADDR0;
    eth_ini_dat.MASK[1] = NETMASK_ADDR1;
    eth_ini_dat.MASK[2] = NETMASK_ADDR2;
    eth_ini_dat.MASK[3] = NETMASK_ADDR3;

    eth_ini_dat.MAC_ADR[0] = MAC_ADDR0;
    eth_ini_dat.MAC_ADR[1] = MAC_ADDR1;
    eth_ini_dat.MAC_ADR[2] = MAC_ADDR2;
    eth_ini_dat.MAC_ADR[3] = MAC_ADDR3;
    eth_ini_dat.MAC_ADR[4] = MAC_ADDR4;
    eth_ini_dat.MAC_ADR[5] = MAC_ADDR5;
     
    for(int i = 0; i < MAX_UDP_SOCK; i++)
    {
      switch(i)
      {
        case 0:
          eth_ini_dat.UDP_RX_PORT[i] = PORT_RX0_UDP; 
          eth_ini_dat.UDP_TX_PORT[i] = PORT_TX0_UDP; 
          IP4_ADDR(&eth_ini_dat.addr[i],ADR0_TX0_UDP, ADR1_TX0_UDP, ADR2_TX0_UDP, ADR3_TX0_UDP); 
        break;
        case 1:
          eth_ini_dat.UDP_RX_PORT[i] = PORT_RX1_UDP; 
          eth_ini_dat.UDP_TX_PORT[i] = PORT_TX1_UDP; 
          IP4_ADDR(&eth_ini_dat.addr[i],ADR0_TX1_UDP, ADR1_TX1_UDP, ADR2_TX1_UDP, ADR3_TX1_UDP); 
        break;
        case 2:
          eth_ini_dat.UDP_RX_PORT[i] = PORT_RX2_UDP; 
          eth_ini_dat.UDP_TX_PORT[i] = PORT_TX2_UDP; 
          IP4_ADDR(&eth_ini_dat.addr[i],ADR0_TX2_UDP, ADR1_TX2_UDP, ADR2_TX2_UDP, ADR3_TX2_UDP); 
        break;
      }
    }
    
  }

  if(ETH_BSP_Config() == ETH_ERROR)
  {
    t_info.eth_bsp_error = 1;
  }
  else 
  {
    LwIP_Init();
    UDP_Config();
  }
  
}
コード例 #20
0
ファイル: main.c プロジェクト: UCC-LCRS/Demo-Ethernet
int main(void) {
	/*!< At this stage the microcontroller clock setting is already configured to
	 168 MHz, this is done through SystemInit() function which is called from
	 startup file (startup_stm32f4xx.s) before to branch to application main.
	 To reconfigure the default setting of SystemInit() function, refer to
	 system_stm32f4xx.c file
	 */
	char pase = 0;
	char pase1 = 0;
	uint16_t duty = 0;
	char led = 0;
	int i;

	uint8_t valor_web=0;

	RCC_GetClocksFreq(&RCC_Clocks);

#ifdef SERIAL_DEBUG
	DebugComPort_Init();
	printf("STM32DISCOVERY is booting...\r\n");
#endif



	/* configure ethernet (GPIOs, clocks, MAC, DMA) */
	ETH_BSP_Config();

	/* Initilaize the LwIP stack */
	LwIP_Init();

	/* Http webserver Init */
	httpd_init();

	/*Se inicializa la placa de expansion*/
	STM_EVAL_EXP_INIT();

	/* Infinite loop */
	while (1) {
		/* check if any packet received */
		if (ETH_CheckFrameReceived()) {
			/* process received ethernet packet */
			LwIP_Pkt_Handle();
		}
		/* handle periodic timers for LwIP */
		LwIP_Periodic_Handle(LocalTime);

		if (LocalTime % 20 == 0) {
			if (!pase1) {
				pase1 = 1;

				if (LocalTime % 100 == 0) {

					// escalera Led
					STM_EVAL_EXP_LED_TOGGLE(led);
					led++;
					if (led > 7)
						led = 0;
				}
			}
		} else {
			pase1 = 0;
		}

	}
	return 0;
}
コード例 #21
0
int main(void)
{
	char s[] = "1442936700,0,1,4,#2346W,3,#0800O#1900C#0900O#1800C";  // for str_processing test
	
	
	RCC_ClocksTypeDef RCC_Clocks;

	/* SysTick end of count event each 10ms */
	RCC_GetClocksFreq(&RCC_Clocks);
	SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);
	RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_RNG, ENABLE);
	RNG_Cmd(ENABLE);
	/* Initialize the timer for dht11 */
	tim_init(TIM2);
	/* Initialize the SRAM ****************************************************/
	PSRAM_Init();
	/* Initialize the LCD *****************************************************/
	LCD_Init();
	LCD_LOG_Init();
  LCD_LOG_SetHeader((uint8_t*)" Ethernet test");
	LCD_LOG_SetFooter ((uint8_t*)"     localtime: ");
	/* Add your application code here */
	/* Configure ethernet (GPIOs, clocks, MAC, DMA) */
	ETH_BSP_Config();
	/* Initilaize the LwIP stack */
	LwIP_Init();
	schedule_init(&schedule_got,schedule_string); // schedule string store in schedule_string
	DNS_Init();
	//while(!schedule_got); // wait until string got
	
	LCD_DisplayStringLine(Line2, (uint8_t*)schedule_string);
	LCD_DisplayStringLine(Line3, (uint8_t*)"0");
	/* Main Loop */
	
	//process ste str form internet

	Str_Split(s, Init_time);   // s is temp string

	RTC_Config();
	Time_Date_Setting(Init_time->year, Init_time->mon, Init_time->day, Init_time->hour +3, Init_time->min, Init_time->sec);
	
	
	
	
	while (1)
	{
		uint8_t year, mon, day;
		uint8_t hour, min, sec;
		RTC_TimeTypeDef RTC_TimeStruct_main;
		RTC_DateTypeDef RTC_DateStruct_main;
		RTC_GetDate(RTC_Format_BIN, &RTC_DateStruct_main);
		RTC_GetTime(RTC_Format_BIN, &RTC_TimeStruct_main);
		
		year = RTC_DateStruct_main.RTC_Year;	
		mon = RTC_DateStruct_main.RTC_Month;
		day = RTC_DateStruct_main.RTC_Date;
		hour = RTC_TimeStruct_main.RTC_Hours;
		min = RTC_TimeStruct_main.RTC_Minutes;
		sec = RTC_TimeStruct_main.RTC_Seconds;
		
		//detect whether it is time to turn on Motor and LED, then execute it.
		Soak(day, hour, min );
		Water(day, hour, min, sec);
		Light(mon, day, hour, min);
		//detect over
			
		/* check if any packet received */
		if (ETH_CheckFrameReceived())
		{
			/* process received ethernet packet */
			LwIP_Pkt_Handle();
		}
		/* handle periodic timers for LwIP */
		LwIP_Periodic_Handle(LocalTime);
		
	}
}