Пример #1
0
/* SSSInitialTask will initialize the NicheStack
 * TCP/IP Stack and then initialize the rest of the Simple Socket Server example 
 * RTOS structures and tasks. 
 */
void SSSInitialTask(void *task_data)
{
  INT8U error_code;
  
  /*
   * Initialize Altera NicheStack TCP/IP Stack - Nios II Edition specific code.
   * NicheStack is initialized from a task, so that RTOS will have started, and 
   * I/O drivers are available.  Two tasks are created:
   *    "Inet main"  task with priority 2
   *    "clock tick" task with priority 3
   */   
  alt_iniche_init();
  netmain(); 

  /* Wait for the network stack to be ready before proceeding. 
   * iniche_net_ready indicates that TCP/IP stack is ready, and IP address is obtained.
   */
  while (!iniche_net_ready)
    TK_SLEEP(1);

  /* Now that the stack is running, perform the application initialization steps */
  
  /* Application Specific Task Launching Code Block Begin */

  printf("\nSimple Socket Server starting up\n");

  /* Create the main simple socket server task. */
  TK_NEWTASK(&ssstask);
  
  /*create os data structures */
  SSSCreateOSDataStructs(); 

  /* create the other tasks */
  SSSCreateTasks();

  /* Application Specific Task Launching Code Block End */
  
  /*This task is deleted because there is no need for it to run again */
  error_code = OSTaskDel(OS_PRIO_SELF);
  alt_uCOSIIErrorHandler(error_code, 0);
  
  while (1); /* Correct Program Flow should never get here */
}
Пример #2
0
void WSInitialTask(void* pdata)
{
  INT8U error_code = OS_NO_ERR;

  /*
  * Initialize Altera NicheStack TCP/IP Stack - Nios II Edition specific code.
  * NicheStack is initialized from a task, so that RTOS will have started, and 
  * I/O drivers are available.  Two tasks are created:
  *    "Inet main"  task with priority 2
  *    "clock tick" task with priority 3
  */   
  alt_iniche_init();
  /* Start the Iniche-specific network tasks and initialize the network
   * devices.
   */
  netmain(); 
  /* Wait for the network stack to be ready before proceeding. */
  while (!iniche_net_ready)
    TK_SLEEP(1);

  /* Create the main network task.  In this case, a web server. */
  TK_NEWTASK(&wstask);

  /* Application specific code starts here... */
  
  /*Create Tasks*/
  WSCreateTasks();
  printf("\nWeb Server starting up\n");
  /* Application specific code ends here. */

  /* Display the IP Address on the LCD Display. */
  #ifdef LCD_NAME
  lcd_ip_addr();
  #endif
  /*This task deletes itself, since there's no reason to keep it around, once
   *it's complete.
   */
  error_code = OSTaskDel(OS_PRIO_SELF);
  alt_uCOSIIErrorHandler(error_code, 0);

  while(1); /*Correct Program Flow should not reach here.*/
}
Пример #3
0
/* SSSInitialTask will initialize the NicheStack
 * TCP/IP Stack and then initialize the rest of the Nios II Simple Socket Server example
 * RTOS structures and tasks.
 */
void SSSInitialTask(void *task_data)
{
  INT8U error_code;

  system_dhcp_hostname = "NEEK_1";

  wait_on_phy();

/*
 * Register new DHCP "IP attained" callback function.
 * If DHCP is acquired, ws_ipset will be called instead of dhc_main_ipset().
 */
#ifdef DHCP_CLIENT
  dhc_set_callback( 0, ws_ipset );
#endif


  /*
   * Initialize Altera NicheStack TCP/IP Stack - Nios II Edition specific code.
   * NicheStack is initialized from a task, so that RTOS will have started, and
   * I/O drivers are available.  Two tasks are created:
   *    "Inet main"  task with priority 2
   *    "clock tick" task with priority 3
   */
  alt_iniche_init();

  /* Start the Iniche-specific network tasks and initialize the network
   * devices.
   */
  netmain();

  /* Wait for the network stack to be ready before proceeding. */
  while (!iniche_net_ready)
  {
    TK_SLEEP(1);
 /*
  * Allow other tasks to run, while waiting for network.
  */
    OSTimeDlyHMSM(0, 0, 3, 0);
  }

/*
 * Nichestack is ready.
 */

  /* Application Specific Task Launching Code Block Begin */

  printf("\nNios II Simple Socket Server starting up.\n");

  /* Create the phy monitoring task. */
  TK_NEWTASK(&sssphytask);

  /* Create the main Nios II Simple socket server task. */
  //TK_NEWTASK(&ssstask);

  TK_NEWTASK(&ssspenetask);

  /*create os data structures */
  SSSCreateOSDataStructs();

  /* create the other tasks */
  SSSCreateTasks();

  /* Application Specific Task Launching Code Block End */

  /*This task is deleted because there is no need for it to run again */
  error_code = OSTaskDel(OS_PRIO_SELF);
  alt_uCOSIIErrorHandler(error_code, 0);

  while (1); /* Correct Program Flow should never get here */
}
Пример #4
0
int
main(void)
{
   INT8U mute_err;
   int priort;
   int i;

   iniche_net_ready = 0;
   
/* OSInit(); */
   OSTimeSet(0);

   /* create all of the various semaphores */
   mheap_sem_ptr = OSSemCreate(1);      /* npalloc() heap */
   if (!mheap_sem_ptr)
      panic("mheap_sem_ptr create err");

   rcvdq_sem_ptr = OSSemCreate(0);      /* RCVD queue "ready" */
   if (!rcvdq_sem_ptr)
      panic("rcvdq_sem_ptr create err"); 

#ifdef OS_PREEMPTIVE
   for (i = 0; i <= MAX_RESID; i++)
   {
      resid_semaphore[i] = OSSemCreate(1);
      if (!resid_semaphore[i])
         panic("resid_semaphore create err");  
   }
   for (i = 0; i <= MAX_SEMID; i++)
   {
      app_semaphore[i] = OSSemCreate(1);
      if (!app_semaphore[i])
         panic("app_semaphore create err");  
   }
#endif  /* OS_PREEMPTIVE */

#ifndef TCPWAKE_RTOS
   /* 
    * clear global_TCPwakeup_set
    */
   for (i = 0; i < GLOBWAKE_SZ; i++)
   {
      global_TCPwakeup_set[i].ctick = 0;
      global_TCPwakeup_set[i].soc_event = NULL;
      global_TCPwakeup_set[i].semaphore = OSSemCreate(0);
      if (!global_TCPwakeup_set[i].semaphore)
         panic("globwake_semaphore create err");  
   }
   global_TCPwakeup_setIndx = 0;

#endif /* TCPWAKE_RTOS */

   /* We have to lock scheduler while creating net tasks. Even though the RTOS
    * technically running yet, the ISR hooks to change tasks don't know this.
    * Since the UART uses interrupts heavly, we have to resort to this to
    * get console output during net_init.
    */
   OSLockNesting++;
   netmain();        /* Create net tasks */
   OSLockNesting--;

   dprintf("+++ uCOS init, app_priority = %d\n", app_priority);

   OSStart();        /* Jump to uCOS-II - Start system; never returns */
   panic("uCOS-II returned");

   return 0;
}