X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=boards%2Fat91sam7x-ek%2Fexamples%2Ftcp_server%2Fmain.c;fp=boards%2Fat91sam7x-ek%2Fexamples%2Ftcp_server%2Fmain.c;h=0000000000000000000000000000000000000000;hb=68cde3a340e6684e7f43bb2889d8625f8a4608a4;hp=71e678826a1902c6a3703405185b46d4f138f72b;hpb=aea9d17572b7fa5f8e05aae6639a3deff4f79aaf;p=bertos.git diff --git a/boards/at91sam7x-ek/examples/tcp_server/main.c b/boards/at91sam7x-ek/examples/tcp_server/main.c deleted file mode 100644 index 71e67882..00000000 --- a/boards/at91sam7x-ek/examples/tcp_server/main.c +++ /dev/null @@ -1,160 +0,0 @@ -/** - * \file - * - * - * \author Andrea Righi - * - * \brief lwIP TCP/IP echo server listening on port 80. - */ - -#include "hw/hw_led.h" - -#include - -#include -#include - -#include -#include - -#include -#include - -#include - -#include -#include -#include -#include -#include - -static Serial out; - -/* Network interface global variables */ -static struct ip_addr ipaddr, netmask, gw; -static struct netif netif; - -static void init(void) -{ - /* Enable all the interrupts */ - IRQ_ENABLE; - - /* Initialize debugging module (allow kprintf(), etc.) */ - kdbg_init(); - /* Initialize system timer */ - timer_init(); - /* Initialize UART0 */ - ser_init(&out, SER_UART0); - /* Configure UART0 to work at 115.200 bps */ - ser_setbaudrate(&out, 115200); - /* Initialize LED driver */ - LED_INIT(); - - /* - * Kernel initialization: processes (allow to create and dispatch - * processes using proc_new()). - */ - proc_init(); - - /* Initialize TCP/IP stack */ - tcpip_init(NULL, NULL); - - /* Bring up the network interface */ - netif_add(&netif, &ipaddr, &netmask, &gw, NULL, ethernetif_init, tcpip_input); - netif_set_default(&netif); - netif_set_up(&netif); -} - -static int tot_req; - -static NORETURN void monitor_process(void) -{ - int start = tot_req; - - while (1) - { - monitor_report(); - kprintf("tot_req=%d [%d reqs/s]\n", tot_req, tot_req - start); - start = tot_req; - timer_delay(1000); - } -} - -int main(void) -{ - struct netconn *server; - - /* Hardware initialization */ - init(); - - proc_new(monitor_process, NULL, KERN_MINSTACKSIZE * 2, NULL); - - dhcp_start(&netif); - /* - * Here we wait for an ip address, but it's not strictly - * necessary. The address is obtained in background and - * as long as we don't use network functions, we could go - * on with initialization - */ - while (!netif.ip_addr.addr) - timer_delay(200); - kprintf(">>> dhcp ok: ip = ip = %s (kernel %s)\n", - ip_ntoa(&netif.ip_addr.addr), - CONFIG_KERN_PREEMPT ? "preempt" : "coop"); - - server = netconn_new(NETCONN_TCP); - netconn_bind(server, IP_ADDR_ANY, 80); - netconn_listen(server); - - while (1) - { - struct netconn *client; - struct netbuf *rx_buf_conn; - char *rx_buf; - u16_t len; - - client = netconn_accept(server); - if (!client) - continue; - - tot_req++; - rx_buf_conn = netconn_recv(client); - if (rx_buf_conn) - { - netbuf_data(rx_buf_conn, (void **)&rx_buf, &len); - if (rx_buf) - netconn_write(client, rx_buf, len, NETCONN_COPY); - netbuf_delete(rx_buf_conn); - } - while (netconn_delete(client) != ERR_OK) - cpu_relax(); - } -}