diff --git a/LUFA/ManPages/LUFAPoweredProjects.txt b/LUFA/ManPages/LUFAPoweredProjects.txt index bf61e9d4b6..454962ae91 100644 --- a/LUFA/ManPages/LUFAPoweredProjects.txt +++ b/LUFA/ManPages/LUFAPoweredProjects.txt @@ -64,13 +64,14 @@ * - BAP, A tiny LUFA based AVR Programmer: http://www.busware.de/tiki-index.php?page=BAP * - Digital Survey Instruments Magnetometer and Pointer: http://www.digitalsurveyinstruments.com/ * - Lightweight CC110x USB dongle for 868MHz Protocols: http://busware.de/tiki-index.php?page=CUL + * - Penguino, an Arduino Board With On-Board LUFA Powered Debugger/Programmer: http://wiki.icy.com.au/PenguinoAVR * - MIDIFighter, a USB-MIDI controller: http://www.midifighter.com/ * - Mobo 4.3, a USB controlled all band (160-10m) HF SDR transceiver: http://sites.google.com/site/lofturj/mobo4_3 - * - SEGA Megadrive/Super Nintendo Cartridge Reader: http://www.snega2usb.com + * - Retrode, a USB Games Console Cartridge Reader: http://www.snega2usb.com * - XMEGA Development Board, using LUFA as an On-Board Programmer: http://xmega.mattair.net/ - * - Penguino, an Arduino Board With On-Board LUFA Powered Debugger/Programmer: http://wiki.icy.com.au/PenguinoAVR * * \section Sec_LUFAPublications Publications Mentioning LUFA * - Elektor Magazine, "My First AVR-USB" by Antoine Authier (feature), January 2010 Issue * - Elektor Magazine, "USB is Cool/Sucks" by Jerry Jacobs and Chris Vossen (minor mention), January 2010 Issue + * - Elektor Magazine, "20 x Open Source", March 2010 Issue */ \ No newline at end of file diff --git a/Projects/Webserver/Lib/DHCPClientApp.c b/Projects/Webserver/Lib/DHCPClientApp.c index 0e51d57072..09bae73689 100644 --- a/Projects/Webserver/Lib/DHCPClientApp.c +++ b/Projects/Webserver/Lib/DHCPClientApp.c @@ -33,12 +33,10 @@ * DHCP Client Application. When connected to the uIP stack, this will retrieve IP configuration settings from the * DHCP server on the network. */ - + #include "DHCPClientApp.h" #if defined(ENABLE_DHCP_CLIENT) || defined(__DOXYGEN__) -/** Timer for managing the timeout period for a DHCP server to respond */ -struct timer DHCPTimer; /** Initialization function for the DHCP client. */ void DHCPClientApp_Init(void) @@ -54,13 +52,14 @@ void DHCPClientApp_Init(void) if (Connection != NULL) { uip_udp_appstate_t* const AppState = &Connection->appstate; - uip_udp_bind(Connection, HTONS(DHCPC_CLIENT_PORT)); + + /* Set the initial client state */ AppState->DHCPClient.CurrentState = DHCP_STATE_SendDiscover; - } - /* Set timeout period to half a second for a DHCP server to respond */ - timer_set(&DHCPTimer, CLOCK_SECOND / 2); + /* Set timeout period to half a second for a DHCP server to respond */ + timer_set(&AppState->DHCPClient.Timeout, CLOCK_SECOND / 2); + } } /** uIP stack application callback for the DHCP client. This function must be called each time the TCP/IP stack @@ -91,7 +90,7 @@ void DHCPClientApp_Callback(void) uip_udp_send(AppDataSize); /* Reset the timeout timer, progress to next state */ - timer_reset(&DHCPTimer); + timer_reset(&AppState->DHCPClient.Timeout); AppState->DHCPClient.CurrentState = DHCP_STATE_WaitForOffer; break; @@ -99,7 +98,7 @@ void DHCPClientApp_Callback(void) if (!(uip_newdata())) { /* Check if the DHCP timeout period has expired while waiting for a response */ - if (timer_expired(&DHCPTimer)) + if (timer_expired(&AppState->DHCPClient.Timeout)) AppState->DHCPClient.CurrentState = DHCP_STATE_SendDiscover; break; @@ -116,7 +115,7 @@ void DHCPClientApp_Callback(void) DHCPClientApp_GetOption(AppData->Options, DHCP_OPTION_ROUTER, &AppState->DHCPClient.DHCPOffer_Data.GatewayIP); DHCPClientApp_GetOption(AppData->Options, DHCP_OPTION_SERVER_ID, &AppState->DHCPClient.DHCPOffer_Data.ServerIP); - timer_reset(&DHCPTimer); + timer_reset(&AppState->DHCPClient.Timeout); AppState->DHCPClient.CurrentState = DHCP_STATE_SendRequest; } @@ -137,7 +136,7 @@ void DHCPClientApp_Callback(void) uip_udp_send(AppDataSize); /* Reset the timeout timer, progress to next state */ - timer_reset(&DHCPTimer); + timer_reset(&AppState->DHCPClient.Timeout); AppState->DHCPClient.CurrentState = DHCP_STATE_WaitForACK; break; @@ -145,7 +144,7 @@ void DHCPClientApp_Callback(void) if (!(uip_newdata())) { /* Check if the DHCP timeout period has expired while waiting for a response */ - if (timer_expired(&DHCPTimer)) + if (timer_expired(&AppState->DHCPClient.Timeout)) AppState->DHCPClient.CurrentState = DHCP_STATE_SendDiscover; break; diff --git a/Projects/Webserver/Lib/FATFs/ffconf.h b/Projects/Webserver/Lib/FATFs/ffconf.h index 3ad7a56af6..4b19f1326d 100644 --- a/Projects/Webserver/Lib/FATFs/ffconf.h +++ b/Projects/Webserver/Lib/FATFs/ffconf.h @@ -14,7 +14,7 @@ / Function and Buffer Configurations /----------------------------------------------------------------------------*/ -#define _FS_TINY 0 /* 0 or 1 */ +#define _FS_TINY 1 /* 0 or 1 */ /* When _FS_TINY is set to 1, FatFs uses the sector buffer in the file system / object instead of the sector buffer in the individual file object for file / data transfer. This reduces memory consumption 512 bytes each file object. */ diff --git a/Projects/Webserver/Lib/HTTPServerApp.c b/Projects/Webserver/Lib/HTTPServerApp.c index ad768c89bc..e781beb220 100644 --- a/Projects/Webserver/Lib/HTTPServerApp.c +++ b/Projects/Webserver/Lib/HTTPServerApp.c @@ -40,27 +40,27 @@ /** HTTP server response header, for transmission before the page contents. This indicates to the host that a page exists at the * given location, and gives extra connection information. */ -char PROGMEM HTTP200Header[] = "HTTP/1.1 200 OK\r\n" - "Server: LUFA " LUFA_VERSION_STRING "\r\n" - "Connection: close\r\n" - "MIME-version: 1.0\r\n" - "Content-Type: "; +const char PROGMEM HTTP200Header[] = "HTTP/1.1 200 OK\r\n" + "Server: LUFA " LUFA_VERSION_STRING "\r\n" + "Connection: close\r\n" + "MIME-version: 1.0\r\n" + "Content-Type: "; /** HTTP server response header, for transmission before a resource not found error. This indicates to the host that the given * given URL is invalid, and gives extra error information. */ -char PROGMEM HTTP404Header[] = "HTTP/1.1 404 Not Found\r\n" - "Server: LUFA " LUFA_VERSION_STRING "\r\n" - "Connection: close\r\n" - "MIME-version: 1.0\r\n" - "Content-Type: text/plain\r\n\r\n" - "Error 404: File Not Found"; +const char PROGMEM HTTP404Header[] = "HTTP/1.1 404 Not Found\r\n" + "Server: LUFA " LUFA_VERSION_STRING "\r\n" + "Connection: close\r\n" + "MIME-version: 1.0\r\n" + "Content-Type: text/plain\r\n\r\n" + "Error 404: File Not Found"; -/** Default MIME type sent if no other MIME type can be determined */ -char PROGMEM DefaultMIMEType[] = "text/plain"; +/** Default MIME type sent if no other MIME type can be determined. */ +const char PROGMEM DefaultMIMEType[] = "text/plain"; /** List of MIME types for each supported file extension. */ -MIME_Type_t PROGMEM MIMETypes[] = +const MIME_Type_t MIMETypes[] = { {.Extension = "htm", .MIMEType = "text/html"}, {.Extension = "jpg", .MIMEType = "image/jpeg"}, @@ -198,7 +198,7 @@ static void HTTPServerApp_SendResponseHeader(void) uip_tcp_appstate_t* const AppState = &uip_conn->appstate; char* const AppData = (char*)uip_appdata; - char* HeaderToSend; + const char* HeaderToSend; /* Determine which HTTP header should be sent to the client */ if (AppState->HTTPServer.FileOpen) @@ -234,10 +234,10 @@ static void HTTPServerApp_SendMIMETypeHeader(void) /* Look through the MIME type list, copy over the required MIME type if found */ for (int i = 0; i < (sizeof(MIMETypes) / sizeof(MIMETypes[0])); i++) { - if (strcmp_P(&Extension[1], MIMETypes[i].Extension) == 0) + if (strcmp(&Extension[1], MIMETypes[i].Extension) == 0) { - MIMEHeaderLength = strlen_P(MIMETypes[i].MIMEType); - strncpy_P(AppData, MIMETypes[i].MIMEType, MIMEHeaderLength); + MIMEHeaderLength = strlen(MIMETypes[i].MIMEType); + strncpy(AppData, MIMETypes[i].MIMEType, MIMEHeaderLength); break; } } diff --git a/Projects/Webserver/Lib/HTTPServerApp.h b/Projects/Webserver/Lib/HTTPServerApp.h index b1139280c0..d212cf2501 100644 --- a/Projects/Webserver/Lib/HTTPServerApp.h +++ b/Projects/Webserver/Lib/HTTPServerApp.h @@ -61,8 +61,8 @@ /** Type define for a MIME type handler. */ typedef struct { - char Extension[4]; /**< 3 or less character file extension */ - char MIMEType[30]; /**< Appropriate MIME type to send when the extension is encountered */ + char* Extension; /**< File extension (no leading '.' character) */ + char* MIMEType; /**< Appropriate MIME type to send when the extension is encountered */ } MIME_Type_t; /* Macros: */ diff --git a/Projects/Webserver/Lib/TELNETServerApp.c b/Projects/Webserver/Lib/TELNETServerApp.c index 291351ae89..7d8c907fe8 100644 --- a/Projects/Webserver/Lib/TELNETServerApp.c +++ b/Projects/Webserver/Lib/TELNETServerApp.c @@ -38,15 +38,15 @@ #include "TELNETServerApp.h" /** Welcome message to send to a TELNET client when a connection is first made. */ -char PROGMEM WelcomeHeader[] = "********************************************\r\n" - "* LUFA uIP Webserver (TELNET) *\r\n" - "********************************************\r\n"; +const char PROGMEM WelcomeHeader[] = "********************************************\r\n" + "* LUFA uIP Webserver (TELNET) *\r\n" + "********************************************\r\n"; /** Main TELNET menu, giving the user the list of available commands they may issue */ -char PROGMEM TELNETMenu[] = "\r\n" - " Available Commands:\r\n" - " c) List Active TCP Connections\r\n" - "\r\nCommand>"; +const char PROGMEM TELNETMenu[] = "\r\n" + " Available Commands:\r\n" + " c) List Active TCP Connections\r\n" + "\r\nCommand>"; /** Initialization function for the simple HTTP webserver. */ void TELNETServerApp_Init(void) diff --git a/Projects/Webserver/Lib/uIPManagement.c b/Projects/Webserver/Lib/uIPManagement.c index ba2a505e95..18e355bdeb 100644 --- a/Projects/Webserver/Lib/uIPManagement.c +++ b/Projects/Webserver/Lib/uIPManagement.c @@ -61,7 +61,7 @@ void uIPManagement_Init(void) uip_setethaddr(MACAddress); /* DHCP/Server IP Settings Initialization */ - #if defined(ENABLE_DHCP) + #if defined(ENABLE_DHCP_CLIENT) DHCPClientApp_Init(); #else uip_ipaddr_t IPAddress, Netmask, GatewayIPAddress; diff --git a/Projects/Webserver/Lib/uip/uipopt.h b/Projects/Webserver/Lib/uip/uipopt.h index 8a09c7248c..5fca686a24 100644 --- a/Projects/Webserver/Lib/uip/uipopt.h +++ b/Projects/Webserver/Lib/uip/uipopt.h @@ -626,6 +626,8 @@ void uip_log(char *msg); #include #include +#include "timer.h" + typedef uint8_t u8_t; typedef uint16_t u16_t; typedef uint32_t u32_t; @@ -716,7 +718,8 @@ typedef union { struct { - uint8_t CurrentState; + uint8_t CurrentState; + struct timer Timeout; struct { diff --git a/Projects/Webserver/Webserver.txt b/Projects/Webserver/Webserver.txt index 9cee32e8a7..3ea167f55a 100644 --- a/Projects/Webserver/Webserver.txt +++ b/Projects/Webserver/Webserver.txt @@ -78,26 +78,25 @@ * Description: * * - * ENABLE_DHCP_CLIENT=x + * ENABLE_DHCP_CLIENT * Makefile CDEFS - * When set to 1, this enables the DHCP client for dynamic IP allocation of the network settings from a DHCP server. - * To disable DHCP and use the fixed address settings set elsewhere, set this to zero (do not undefine it). + * When defined, this enables the DHCP client for dynamic IP allocation of the network settings from a DHCP server. * * * DEVICE_IP_ADDRESS * Lib/uIPManagement.h - * IP address that the webserver should use when connected to a RNDIS device (when ENABLE_DHCP_CLIENT is zero). + * IP address that the webserver should use when connected to a RNDIS device (when ENABLE_DHCP_CLIENT is not defined). * * * DEVICE_NETMASK * Lib/uIPManagement.h - * Netmask that the webserver should use when connected to a RNDIS device (when ENABLE_DHCP_CLIENT is zero). + * Netmask that the webserver should use when connected to a RNDIS device (when ENABLE_DHCP_CLIENT is not defined). * * * DEVICE_GATEWAY * Lib/uIPManagement.h * Default routing gateway that the webserver should use when connected to a RNDIS device (when ENABLE_DHCP_CLIENT - * is zero). + * is not defined). * * */ \ No newline at end of file diff --git a/Projects/Webserver/makefile b/Projects/Webserver/makefile index b0e26f3a46..d5eda4c44b 100644 --- a/Projects/Webserver/makefile +++ b/Projects/Webserver/makefile @@ -199,9 +199,9 @@ CSTANDARD = -std=gnu99 # Place -D or -U options here for C sources CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD) $(LUFA_OPTS) -CDEFS += -DENABLE_DHCP_CLIENT=1 +CDEFS += -DENABLE_DHCP_CLIENT -CDEFS += -DUIP_CONF_UDP=ENABLE_DHCP_CLIENT -DUIP_CONF_TCP=1 -DUIP_CONF_UDP_CONNS=1 -DUIP_CONF_MAX_CONNECTIONS=5 +CDEFS += -DUIP_CONF_UDP="defined(ENABLE_DHCP_CLIENT)" -DUIP_CONF_TCP=1 -DUIP_CONF_UDP_CONNS=1 -DUIP_CONF_MAX_CONNECTIONS=5 CDEFS += -DUIP_CONF_MAX_LISTENPORTS=5 -DUIP_URGDATA=0 -DUIP_CONF_BUFFER_SIZE=1514 -DUIP_ARCH_CHKSUM=0 CDEFS += -DUIP_CONF_LL_802154=0 -DUIP_CONF_LL_80211=0 -DUIP_CONF_ROUTER=0 -DUIP_CONF_ICMP6=0 CDEFS += -DUIP_ARCH_ADD32=0 -DUIP_CONF_ICMP_DEST_UNREACH=1 -DUIP_NEIGHBOR_CONF_ADDRTYPE=0