Forum Discussion
Altera_Forum
Honored Contributor
14 years agotriple_speed_ethernet_design, I used this file. And I was ping for IP address successful.
But at that time, You should note your Ethernet, this mean that in your code you only need to consider some problem including, RX, TX, PHY, MAC address ... you ignore LCD, seg_led... and you remember to include full file. and Here you can see: /* Dinh nghia MicroC/OS-II */ # include "includes.h" # include <stdio.h> # include <errno.h> # include <ctype.h> # include "system.h" # include "altera_avalon_pio_regs.h" # include <unistd.h> /* Dinh nghia Web Server*/ # include "alt_error_handler.h" # include "web_server.h" /* Dinh nghia Nichestack*/ # include "ipport.h" # include "libport.h" # include "osport.h" # include "tcpport.h" # include "net.h" # ifndef ALT_INICHE # error # endif # ifndef __ucosii__ # error # endif # ifndef RO_ZIPFS # error # endif extern int current_flash_block; extern void WSTask(); static void WSCreateTasks(); /* NicheStack*/ extern struct net netstatic[STATIC_NETS]; TK_OBJECT(to_wstask); TK_ENTRY(WSTask); struct inet_taskinfo wstask = { &to_wstask, "web server", WSTask, HTTP_PRIO, APP_STACK_SIZE, }; /* WSInitialTask se khoi tao NichStack TCP/IP stack va ke do khoi tao * nhung phan con lai cua web_server */ void WSInitialTask(void* pdata) { INT8U error_code = OS_NO_ERR; // Bat dau khoi tao alt_iniche_init(); //Cho den khi network san sang de thuc hien netmain(); while (!iniche_net_ready) TK_SLEEP(1); TK_NEWTASK(&wstask); WSCreateTasks(); printf("\nWeb Server Dang duoc bat dau\n"); error_code = OSTaskDel(OS_PRIO_SELF); alt_uCOSIIErrorHandler(error_code, 0); while(1); /*dang cho.*/ } OS_STK WSInitialTaskStk[TASK_STACKSIZE]; OS_STK LEDTaskStk[TASK_STACKSIZE]; OS_STK SSDTaskStk[TASK_STACKSIZE]; OS_STK BCTaskStk[TASK_STACKSIZE]; OS_EVENT *board_control_mbox; int main (int argc, char* argv[], char* envp[]) { /* Khoi tao khoi Flash dang hien hanh*/ current_flash_block = -1; INT8U error_code; /* Xoa RTOS timer */ OSTimeSet(0); error_code = OSTaskCreateExt(WSInitialTask, NULL, (void *)&WSInitialTaskStk[TASK_STACKSIZE-1], WS_INITIAL_TASK_PRIO, WS_INITIAL_TASK_PRIO, WSInitialTaskStk, TASK_STACKSIZE, NULL, 0); alt_uCOSIIErrorHandler(error_code, 0); OSStart(); while(1); /* Cong lap cho. */ return -1; } static void WSCreateTasks() { INT8U error_code = OS_NO_ERR; /* Start LED Task. */ error_code = OSTaskCreateExt(LED_task, NULL, (void *)&LEDTaskStk[TASK_STACKSIZE-1], LED_PRIO, LED_PRIO, LEDTaskStk, TASK_STACKSIZE, NULL, 0); alt_uCOSIIErrorHandler(error_code, 0); /* Bat dau SSD Task. */ # ifdef SEVEN_SEG_PIO_NAME error_code = OSTaskCreateExt(SSD_task, NULL, (void *)&SSDTaskStk[TASK_STACKSIZE-1], SSD_PRIO, SSD_PRIO, SSDTaskStk, TASK_STACKSIZE, NULL, 0); alt_uCOSIIErrorHandler(error_code, 0); # endif error_code = OSTaskCreateExt(board_control_task, NULL, (void *)&BCTaskStk[TASK_STACKSIZE-1], BOARD_PRIO, BOARD_PRIO, BCTaskStk, TASK_STACKSIZE, NULL, 0); alt_uCOSIIErrorHandler(error_code, 0); OSTaskSuspend(LED_PRIO); OSTaskSuspend(SSD_PRIO); } void board_control_task(void *pdata) { INT8U error_code = OS_NO_ERR; board_control_mbox = OSMboxCreate((void *)NULL); struct http_form_data* board_control_mbox_contents; while(1) { board_control_mbox_contents = (void*)OSMboxPend(board_control_mbox, 0, &error_code); if (board_control_mbox_contents->LED_ON) { OSTaskResume(LED_PRIO); } else { OSTaskSuspend(LED_PRIO); IOWR_ALTERA_AVALON_PIO_DATA( LED_PIO_BASE, 0 ); } if (board_control_mbox_contents->SSD_ON) { OSTaskResume(SSD_PRIO); } else { OSTaskSuspend(SSD_PRIO); # ifdef SEVEN_SEG_PIO_NAME sevenseg_set_hex(0); # endif } } } void LED_task(void* pdata) { alt_u8 led = 0x2; alt_u8 dir = 0; while (1) { if (led & 0x81) { dir = (dir ^ 0x1); } if (dir) { led = led >> 1; } else { led = led << 1; } IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, led); OSTimeDlyHMSM(0,0,0,50); } }