예제 #1
0
파일: main.c 프로젝트: cjc1029nice/ksdk
/*!
 * @brief main function
 */
int main(void)
{
    struct netif fsl_netif0;
    ip_addr_t fsl_netif0_ipaddr, fsl_netif0_netmask, fsl_netif0_gw;

    app_low_level_init();
    OSA_Init();
    lwip_init();
	
    IP4_ADDR(&fsl_netif0_ipaddr, 192,168,2,102);
    IP4_ADDR(&fsl_netif0_netmask, 255,255,255,0);
    IP4_ADDR(&fsl_netif0_gw, 192,168,2,100);
    netif_add(&fsl_netif0, &fsl_netif0_ipaddr, &fsl_netif0_netmask, &fsl_netif0_gw, NULL, ethernetif_init, ethernet_input);
    netif_set_default(&fsl_netif0);
    netif_set_up(&fsl_netif0);
    echo_init();

#if !ENET_RECEIVE_ALL_INTERRUPT
    uint32_t devNumber = 0; 
    enet_dev_if_t * enetIfPtr;
#if LWIP_HAVE_LOOPIF
    devNumber = fsl_netif0.num - 1;
#else
    devNumber = fsl_netif0.num;
#endif
    enetIfPtr = (enet_dev_if_t *)&enetDevIf[devNumber];
#endif
    while(1)
    {
#if !ENET_RECEIVE_ALL_INTERRUPT
        ENET_receive(enetIfPtr);
#endif
        sys_check_timeouts();
    }
}
예제 #2
0
/* Private functions ---------------------------------------------------------*/
int main(void) {

	/* STM32F4xx HAL library initialization:
		 - Configure the Flash prefetch, instruction and Data caches
		 - Configure the Systick to generate an interrupt each 1 msec
		 - Set NVIC Group Priority to 4
		 - Global MSP (MCU Support Package) initialization
	*/
	HAL_Init();
	SystemClock_Config(); //Configure the System clock to have a frequency of 168 MHz
	BSP_Config(); //Configure the BSP (Board Support Package)
	lwip_init(); //Initilaize the LwIP stack
	Netif_Config(); //Configurates the network interface
	concentrator_init();
	User_notification(&gnetif); //Notify the User about the nework interface config status
	
	/* Compute the value of ARR regiter to generate signal frequency at 17.57 Khz */
	uhTimerPeriod = (uint32_t) ((SystemCoreClock / 17570 ) - 1);
	/* Compute CCR1 value to generate a duty cycle at 50% at the beggining */
	aCCValue_Buffer = (uint32_t)(((uint32_t) uhADCxConvertedValuePercent * (uhTimerPeriod - 1)) / 100);

	TIM_Config(); //TIM3, TIM4, TIM8 Peripheral Configuration
	ADC_Config(); //Configure the ADC3 peripheral

	while (1) {
		/* Read a received packet from the Ethernet buffers and send it 
		to the lwIP for handling */
		ethernetif_input(&gnetif);
		sys_check_timeouts(); //Handle timeouts
	}

}
예제 #3
0
STATIC mp_obj_t mod_lwip_callback() {
    if (lwip_poll_list.poll != NULL) {
        lwip_poll_list.poll(lwip_poll_list.poll_arg);
    }
    sys_check_timeouts();
    return mp_const_none;
}
예제 #4
0
파일: main.c 프로젝트: xueliu/nRF51822
/**@brief Function to handle interface up event. */
void nrf51_driver_interface_up(void)
{
    APPL_LOG ("[APPL]: IPv6 interface up.\r\n");

    sys_check_timeouts();

    m_display_state = LEDS_IPV6_IF_UP;
}
예제 #5
0
파일: main.c 프로젝트: cr1901/artiq
static void lwip_service(void)
{
    sys_check_timeouts();
    if(ethmac_sram_writer_ev_pending_read() & ETHMAC_EV_SRAM_WRITER) {
        liteeth_input(&netif);
        ethmac_sram_writer_ev_pending_write(ETHMAC_EV_SRAM_WRITER);
    }
}
예제 #6
0
void 
main(void)
{
  struct netif netif;

  lwip_init();

  netif_add(&netif, IP4_ADDR_ANY, IP4_ADDR_ANY, IP4_ADDR_ANY, NULL, netif_init, netif_input);
  netif.name[0] = 'e';
  netif.name[1] = '0';
  netif_create_ip6_linklocal_address(&netif, 1);
  netif.ip6_autoconfig_enabled = 1;
  netif_set_status_callback(&netif, netif_status_callback);
  netif_set_default(&netif);
  netif_set_up(&netif);
  
  /* Start DHCP and HTTPD */
  dhcp_start(&netif );
  httpd_init();

  while(1) {
    /* Check link state, e.g. via MDIO communication with PHY */
    if(link_state_changed()) {
      if(link_is_up()) {
        netif_set_link_up(&netif);
      } else {
        netif_set_link_down(&netif);
      }
    }

    /* Check for received frames, feed them to lwIP */
    lock_interrupts();
    struct pbuf* p = queue_try_get(&queue);
    unlock_interrupts();

    if(p != NULL) {
      LINK_STATS_INC(link.recv);
 
      /* Update SNMP stats (only if you use SNMP) */
      MIB2_STATS_NETIF_ADD(netif, ifinoctets, p->tot_len);
      int unicast = ((p->payload[0] & 0x01) == 0);
      if (unicast) {
        MIB2_STATS_NETIF_INC(netif, ifinucastpkts);
      } else {
        MIB2_STATS_NETIF_INC(netif, ifinnucastpkts);
      }

      if(netif.input(p, &netif) != ERR_OK) {
        pbuf_free(p);
      }
    }
     
    /* Cyclic lwIP timers check */
    sys_check_timeouts();
     
    /* your application goes here */
  }
}
예제 #7
0
void check_timeouts() {
// TODO: Remove when sal-driver-lwip-k64f-eth/#8 is fixed
#ifdef YOTTA_SAL_DRIVER_LWIP_K64F_ETH_VERSION_STRING
    emac_timer_fired = 1;
    vIRQ_SetPendingIRQ(ENET_Receive_IRQn);
#else
    sys_check_timeouts();
#endif

}
예제 #8
0
파일: main.c 프로젝트: xueliu/nRF51822
/**@brief Function to handle interface up event. */
void nrf51_driver_interface_up(void)
{
    APPL_LOG ("[APPL]: IPv6 Interface Up.\r\n");

    sys_check_timeouts();

    // Set flag indicating interface state.
    m_interface_state = true;
    m_display_state = LEDS_IPV6_IF_UP;
}
예제 #9
0
/**
 * ----------------------------------------------------------------------
 * Function given to help user to continue LwIP Initialization
 * Up to user to complete or change this function ...
 * Up to user to call this function in main.c in while (1) of main(void) 
 *-----------------------------------------------------------------------
 * Read a received packet from the Ethernet buffers 
 * Send it to the lwIP stack for handling
 * Handle timeouts if NO_SYS_NO_TIMERS not set and without RTOS
 */
void MX_LWIP_Process(void)
{
  ethernetif_input(&gnetif);
       
  /* Handle timeouts */
  #if !NO_SYS_NO_TIMERS && NO_SYS
    sys_check_timeouts();
  #endif
    
}
예제 #10
0
파일: main.c 프로젝트: sische/MasterThesis
/**@brief Function to handle interface up event. */
void nrf_driver_interface_up(void)
{   
    APPL_LOG ("[APPL]: IPv6 interface up.\r\n");
#ifdef COMMISSIONING_ENABLED
    commissioning_joining_mode_timer_ctrl(JOINING_MODE_TIMER_STOP_RESET);
#endif // COMMISSIONING_ENABLED
            
    sys_check_timeouts();
    
    m_display_state = LEDS_IPV6_IF_UP;
}
예제 #11
0
/**@brief Timer callback used for periodic servicing of LwIP protocol timers.
 *        This trigger is also used in the example to trigger sending UDP packets on the port.
 *
 * @details Timer callback used for periodic servicing of LwIP protocol timers.
 *
 * @param[in]   p_context   Pointer used for passing context. No context used in this application.
 */
static void system_timer_callback(void * p_context)
{
    UNUSED_VARIABLE(p_context);
    static int count = 0;
    sys_check_timeouts();
    count++;
    if (count == 10)
    {
        count = 9;
        udp_data_send();
    }
}
예제 #12
0
파일: Ethernet.c 프로젝트: Sasha7b9/Osci
//------------------------------------------------------------------------------------------------------------------------------------------------------
void Ethernet_Update(uint timeMS)
{
    uint time = gTimerMS;

    do
    {
        gBF.cableEthIsConnected = gTimerMS - gEthTimeLastEthifInput <= 1500;

        ethernetif_input(&gnetif);
        sys_check_timeouts();
    } while (gTimerMS - time < timeMS);
}
예제 #13
0
파일: tun.cpp 프로젝트: blitz/macgyvernet
  void start_timer()
  {
    timer.expires_from_now(boost::posix_time::milliseconds(100));
    timer.async_wait([this] (const asio::error_code &err) {
        if (err) {
          LOG(ERROR) << "Timer error: " << err;
          return;
        }

        sys_check_timeouts();
        start_timer();
      });
  }
예제 #14
0
STATIC void pyb_lwip_poll(void) {
    // Poll all the NICs for incoming data
    for (struct netif *netif = netif_list; netif != NULL; netif = netif->next) {
        if (netif->flags & NETIF_FLAG_LINK_UP) {
            mod_network_nic_type_t *nic = netif->state;
            if (nic->poll_callback) {
                nic->poll_callback(nic, netif);
            }
        }
    }
    // Run the lwIP internal updates
    sys_check_timeouts();
}
예제 #15
0
/**@brief Function to handle interface up event. */
void nrf51_driver_interface_up(void)
{
    uint32_t err_code;

    APPL_LOG ("[APPL]: IPv6 interface up.\r\n");

    sys_check_timeouts();

    err_code = app_timer_start(m_sys_timer_id, LWIP_SYS_TIMER_INTERVAL, NULL);
    APP_ERROR_CHECK(err_code);

    LEDS_OFF(ADVERTISING_LED);
    LEDS_ON(CONNECTED_LED);
}
예제 #16
0
파일: main.c 프로젝트: sische/MasterThesis
/**@brief Function to handle interface up event. */
void nrf_driver_interface_up(void)
{
    m_is_ipv6_if_up = true;

#ifdef COMMISSIONING_ENABLED
    commissioning_joining_mode_timer_ctrl(JOINING_MODE_TIMER_STOP_RESET);
#endif // COMMISSIONING_ENABLED

    APPL_LOG ("[APPL]: IPv6 interface up.\r\n");

    sys_check_timeouts();

    LEDS_OFF(LED_ONE);
    LEDS_ON(LED_TWO);
}
예제 #17
0
파일: main.c 프로젝트: xueliu/nRF51822
/**@brief Function to handle interface up event. */
void nrf51_driver_interface_up(void)
{
    uint32_t err_code;

    APPL_LOG ("[APPL]: IPv6 Interface Up.\r\n");

    sys_check_timeouts();

    err_code = app_timer_start(m_sys_timer_id, LWIP_SYS_TIMER_INTERVAL, NULL);
    APP_ERROR_CHECK(err_code);

    m_display_state = LEDS_IPV6_IF_UP;
    err_code = app_timer_start(m_led_blink_timer, LED_BLINK_INTERVAL, NULL);
    APP_ERROR_CHECK(err_code);
}
/*
 * The timer for lwIP timeouts has gone off.  Check timeouts, and possibly set
 * a new timer.
 */
static void
expire_lwip_timer(int arg __unused)
{

	/* Let lwIP do its work. */
	sys_check_timeouts();

	/*
	 * See if we have to update our timer for the next lwIP timer.  Doing
	 * this here, rather than from the main loop, avoids one kernel call.
	 */
	set_lwip_timer();

	recheck_timer = FALSE;
}
예제 #19
0
int main(void)
{
    rtc_setup();

    board_setup();

    mch_net_init();

    testapp_init();

    while (1) {
        mch_net_poll();
        sys_check_timeouts();
    }
}
예제 #20
0
int main(void)
{

  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration----------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* Configure the system clock */
  SystemClock_Config();

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_USART3_UART_Init();
  MX_LWIP_Init();
  MX_ADC3_Init();

  /* USER CODE BEGIN 2 */
  
  /* Http webserver Init */
  http_server_init();
  
  /* Notify user about the network interface config */
  User_notification(&gnetif);
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */
    /* Read a received packet from the Ethernet buffers and send it 
       to the lwIP for handling */
    ethernetif_input(&gnetif);

    /* Handle timeouts */
    sys_check_timeouts();
  }
  /* USER CODE END 3 */

}
예제 #21
0
파일: main.c 프로젝트: vlsi1217/STM32F7Cube
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
    /* Enable the CPU Cache */
    CPU_CACHE_Enable();

    /* STM32F7xx HAL library initialization:
         - Configure the Flash ART accelerator on ITCM interface
         - Configure the Systick to generate an interrupt each 1 msec
         - Set NVIC Group Priority to 4
         - Global MSP (MCU Support Package) initialization
       */
    HAL_Init();

    /* Configure the system clock to 200 MHz */
    SystemClock_Config();

    /* Configure the BSP */
    BSP_Config();

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

    /* Configure the Network interface */
    Netif_Config();

    /* Http webserver Init */
    httpd_init();

    /* Notify user about the network interface config */
    User_notification(&gnetif);

    /* Infinite loop */
    while (1)
    {
        /* Read a received packet from the Ethernet buffers and send it
           to the lwIP for handling */
        ethernetif_input(&gnetif);

        /* Handle timeouts */
        sys_check_timeouts();

#ifdef USE_DHCP
        /* handle periodic timers for DHCP */
        DHCP_Periodic_Handle(&gnetif);
#endif
    }
}
예제 #22
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* STM32F4xx HAL library initialization:
       - Configure the Flash prefetch, instruction and Data caches
       - Configure the Systick to generate an interrupt each 1 msec
       - Set NVIC Group Priority to 4
       - Global MSP (MCU Support Package) initialization
     */
  HAL_Init();

  /* Configure the system clock to 168 MHz */
  SystemClock_Config();

  /* Configure the BSP */
  BSP_Config();

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

  /* Configure the Network interface */
  Netif_Config();

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

  /* Notify user about the network interface config */
  User_notification(&gnetif);

  /* Link the SD Card disk I/O driver */
  FATFS_LinkDriver(&SD_Driver, SD_Path);

  /* Infinite loop */
  while (1)
  {
    /* Read a received packet from the Ethernet buffers and send it
    to the lwIP for handling */
    ethernetif_input(&gnetif);

    /* Handle timeouts */
    sys_check_timeouts();

#ifdef USE_DHCP
    /* handle periodic timers for LwIP */
    DHCP_Periodic_Handle(&gnetif);
#endif
  }
}
예제 #23
0
void ENET_Receive_IRQHandler(void) {
    enet_dev_if_t *enetIfPtr = (enet_dev_if_t *)&enetDevIf[BOARD_DEBUG_ENET_INSTANCE];

    if (enet_hal_get_interrupt_status(((enet_dev_if_t *)enetIfPtr)->deviceNumber, kEnetRxFrameInterrupt))
        enet_mac_rx_isr(enetIfHandle);
    if (enet_hal_get_interrupt_status(((enet_dev_if_t *)enetIfPtr)->deviceNumber, kEnetTxFrameInterrupt))
        enet_mac_tx_isr(enetIfHandle);
    if (emac_timer_fired) {
          // TODO: this will have to be replaced with a proper "PHY task" that can detect changes in link status.
        if (k64f_phy_state.connected == STATE_UNKNOWN) {
            k64f_phy_state.connected = 1;
            netif_set_link_up(k64f_enetdata.netif);
        }
        emac_timer_fired = 0;
        sys_check_timeouts();
     }
}
예제 #24
0
static void lwip_task(void * p) {
    net_init();
    httpd_init();

    uint32_t currentIP = board_netif.ip_addr.addr;
    while (1) {
        xSemaphoreTake(lwip_sem, 10 / portTICK_RATE_MS);
        interface_check_input(&board_netif);
        sys_check_timeouts();
        if (board_netif.ip_addr.addr != currentIP) {
            currentIP = board_netif.ip_addr.addr;
            printf("got an IP address: %i.%i.%i.%i\n",
                (board_netif.ip_addr.addr >>  0) & 0xff,
                (board_netif.ip_addr.addr >>  8) & 0xff,
                (board_netif.ip_addr.addr >> 16) & 0xff,
                (board_netif.ip_addr.addr >> 24) & 0xff);
        }
    }
예제 #25
0
int
main(int argc, char **argv)
{
        struct netif netif;

        /* startup defaults (may be overridden by one or more opts). this is
         * hard-coded v4 even in presence of v6, which does auto-discovery and
         * should thus wind up with an address of fe80::12:34ff:fe56:78ab%tap0
         * */
        IP4_ADDR(&gw, 192,168,113,1);
        IP4_ADDR(&ipaddr, 192,168,113,2);
        IP4_ADDR(&netmask, 255,255,255,0);

        lwip_init();

        printf("TCP/IP initialized.\n");

        netif_add(&netif, &ipaddr, &netmask, &gw, NULL, tapif_init, ethernet_input);
        netif.flags |= NETIF_FLAG_ETHARP;
        netif_set_default(&netif);
        netif_set_up(&netif);
#if LWIP_IPV6
        netif_create_ip6_linklocal_address(&netif, 1);
#endif

        /* start applications here */

        server_coap_init();

        printf("Applications started.\n");


        while (1) {
                /* poll netif, pass packet to lwIP */
                tapif_select(&netif);

                sys_check_timeouts();

                server_coap_poll();
        }

        return 0;
}
예제 #26
0
/**
 * Wait (forever) for a message to arrive in an mbox.
 * While waiting, timeouts are processed.
 *
 * @param mbox the mbox to fetch the message from
 * @param msg the place to store the message
 */
void
sys_timeouts_mbox_fetch(sys_mbox_t *mbox, void **msg)
{
  u32_t sleeptime;

again:
  if (!next_timeout) {
    sys_arch_mbox_fetch(mbox, msg, 0);
    return;
  }

  sleeptime = sys_timeouts_sleeptime();
  if (sleeptime == 0 || sys_arch_mbox_fetch(mbox, msg, sleeptime) == SYS_ARCH_TIMEOUT) {
    /* If a SYS_ARCH_TIMEOUT value is returned, a timeout occurred
       before a message could be fetched. */
    sys_check_timeouts();
    /* We try again to fetch a message from the mbox. */
    goto again;
  }
}
예제 #27
0
파일: main.c 프로젝트: cjc1029nice/ksdk
void ping_init(void)
{
#if !ENET_RECEIVE_ALL_INTERRUPT
    uint32_t devNumber = 0; 
    enet_dev_if_t * enetIfPtr;
#if LWIP_HAVE_LOOPIF
    devNumber = fsl_netif0.num - 1;
#else
    devNumber = fsl_netif0.num;
#endif
    enetIfPtr = (enet_dev_if_t *)&enetDevIf[devNumber];
#endif
    ping_raw_init();
    while(1)
    {
#if !ENET_RECEIVE_ALL_INTERRUPT
        ENET_receive(enetIfPtr);
#endif
        sys_check_timeouts();
    }
}
예제 #28
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* STM32F4xx HAL library initialization:
       - Configure the Flash prefetch, instruction and Data caches
       - Configure the Systick to generate an interrupt each 1 msec
       - Set NVIC Group Priority to 4
       - Global MSP (MCU Support Package) initialization
     */
  HAL_Init();  
  
  /* Configure the system clock to 180 MHz */
  SystemClock_Config();
  
  /* Configure the BSP */
  BSP_Config();
    
  /* Initilaize the LwIP stack */
  lwip_init();
  
  /* Configure the Network interface */
  Netif_Config();
  
  /* tcp echo server Init */
  udp_echoserver_init();
  
  /* Notify user about the netwoek interface config */
  User_notification(&gnetif);
  
  /* Infinite loop */
  while (1)
  {  
    /* Read a received packet from the Ethernet buffers and send it 
       to the lwIP for handling */
    ethernetif_input(&gnetif);

    /* Handle timeouts */
    sys_check_timeouts();
  }
}
예제 #29
0
/**
 * ----------------------------------------------------------------------
 * Function given to help user to continue LwIP Initialization
 * Up to user to complete or change this function ...
 * Up to user to call this function in main.c in while (1) of main(void) 
 *-----------------------------------------------------------------------
 * Read a received packet from the Ethernet buffers 
 * Send it to the lwIP stack for handling
 * Handle timeouts if NO_SYS_NO_TIMERS not set and without RTOS
 */
void MX_LWIP_Process(void)
{
  ethernetif_input(&gnetif);
       
  /* Handle timeouts */
  #if !NO_SYS_NO_TIMERS && NO_SYS
    sys_check_timeouts();
  #endif
    
    if (gnetif.ip_addr.addr !=ip)
    {
      
      ip = gnetif.ip_addr.addr;
       a = ip & 0xFF;
       b = ip & 0xFF00;
       b = b >> 0x8;
       c = ip & 0xFF0000 ;
       c = c >> 0x10;
       d = ip & 0xFF000000 ;
       d = d >> 0x18;
       
       printf("got ip address %i.%i.%i.%i\n\r",a,b,c,d);
    }
예제 #30
0
파일: main.c 프로젝트: sanjay900/AdAway
/**
 * @brief Function for application main entry.
 */
int main(void)
{

  cs_log_set_file(stdout);

  bleconfig_init();

  {
    struct mg_mgr mgr;

    mg_mgr_init(&mgr, NULL);  // Initialize event manager object

    // Note that many connections can be added to a single event manager
    // Connections can be created at any point, e.g. in event handler function
    const char *err;
    struct mg_bind_opts opts;
    struct mg_connection *nc = NULL;
    memset(&opts, 0x00, sizeof(opts));
    opts.error_string = &err;
    nc = mg_bind_opt(&mgr, "80", ev_handler, opts);  // Create listening connection and add it to the event manager
    if (nc == NULL) {
      printf("Failed to create listener: %s\n", err);
      return 1;
    }
    mg_set_protocol_http_websocket(nc);

    for (;;) {  // Start infinite event loop
      bleconfig_poll();
      sys_check_timeouts();
      mg_mgr_poll(&mgr, 0);
    }

    mg_mgr_free(&mgr);
    return 0;
  }

}