summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2021-10-23 21:23:56 +0700
committerGitHub <[email protected]>2021-10-23 21:23:56 +0700
commit311c05b401591507cbc4977926bcc878d3f119aa (patch)
tree4119b44658bc6d66947ba0e4605fea16ea4ea678 /examples
parent6fcf4bee8c1540618b5d8d8709ef76cd2aa1c66f (diff)
parentb541c0f5e07696ead205666e43c726b14277e0d9 (diff)
Merge branch 'master' into fix-warnings
Diffstat (limited to 'examples')
-rw-r--r--examples/device/cdc_msc/src/usb_descriptors.c2
-rw-r--r--examples/device/cdc_msc_freertos/src/usb_descriptors.c2
-rw-r--r--examples/device/msc_dual_lun/src/usb_descriptors.c2
-rw-r--r--examples/device/net_lwip_webserver/Makefile19
-rw-r--r--examples/device/net_lwip_webserver/src/lwipopts.h12
-rw-r--r--examples/device/net_lwip_webserver/src/main.c40
-rw-r--r--examples/device/video_capture/src/usb_descriptors.h9
7 files changed, 61 insertions, 25 deletions
diff --git a/examples/device/cdc_msc/src/usb_descriptors.c b/examples/device/cdc_msc/src/usb_descriptors.c
index 5e397d15a..40f75d6f6 100644
--- a/examples/device/cdc_msc/src/usb_descriptors.c
+++ b/examples/device/cdc_msc/src/usb_descriptors.c
@@ -232,7 +232,7 @@ char const* string_desc_arr [] =
(const char[]) { 0x09, 0x04 }, // 0: is supported language is English (0x0409)
"TinyUSB", // 1: Manufacturer
"TinyUSB Device", // 2: Product
- "123456", // 3: Serials, should use chip ID
+ "123456789012", // 3: Serials, should use chip ID
"TinyUSB CDC", // 4: CDC Interface
"TinyUSB MSC", // 5: MSC Interface
};
diff --git a/examples/device/cdc_msc_freertos/src/usb_descriptors.c b/examples/device/cdc_msc_freertos/src/usb_descriptors.c
index f3ff305f8..9585822a3 100644
--- a/examples/device/cdc_msc_freertos/src/usb_descriptors.c
+++ b/examples/device/cdc_msc_freertos/src/usb_descriptors.c
@@ -218,7 +218,7 @@ char const* string_desc_arr [] =
(const char[]) { 0x09, 0x04 }, // 0: is supported language is English (0x0409)
"TinyUSB", // 1: Manufacturer
"TinyUSB Device", // 2: Product
- "123456", // 3: Serials, should use chip ID
+ "123456789012", // 3: Serials, should use chip ID
"TinyUSB CDC", // 4: CDC Interface
"TinyUSB MSC", // 5: MSC Interface
};
diff --git a/examples/device/msc_dual_lun/src/usb_descriptors.c b/examples/device/msc_dual_lun/src/usb_descriptors.c
index 7e194ea7a..2afd391af 100644
--- a/examples/device/msc_dual_lun/src/usb_descriptors.c
+++ b/examples/device/msc_dual_lun/src/usb_descriptors.c
@@ -141,7 +141,7 @@ char const* string_desc_arr [] =
(const char[]) { 0x09, 0x04 }, // 0: is supported language is English (0x0409)
"TinyUSB", // 1: Manufacturer
"TinyUSB Device", // 2: Product
- "123456", // 3: Serials, should use chip ID
+ "123456789012", // 3: Serials, should use chip ID
};
static uint16_t _desc_str[32];
diff --git a/examples/device/net_lwip_webserver/Makefile b/examples/device/net_lwip_webserver/Makefile
index 5649a172a..881866a56 100644
--- a/examples/device/net_lwip_webserver/Makefile
+++ b/examples/device/net_lwip_webserver/Makefile
@@ -3,13 +3,11 @@ DEPS_SUBMODULES += lib/lwip
include ../../../tools/top.mk
include ../../make.mk
-CFLAGS += \
- -DPBUF_POOL_SIZE=2 \
- -DTCP_WND=2*TCP_MSS \
- -DHTTPD_USE_CUSTOM_FSDATA=0
-
# suppress warning caused by lwip
-CFLAGS += -Wno-error=null-dereference
+CFLAGS += \
+ -Wno-error=null-dereference \
+ -Wno-error=unused-parameter \
+ -Wno-error=unused-variable
INC += \
src \
@@ -53,6 +51,15 @@ SRC_C += \
lib/lwip/src/core/ipv4/ip4.c \
lib/lwip/src/core/ipv4/ip4_addr.c \
lib/lwip/src/core/ipv4/ip4_frag.c \
+ lib/lwip/src/core/ipv6/dhcp6.c \
+ lib/lwip/src/core/ipv6/ethip6.c \
+ lib/lwip/src/core/ipv6/icmp6.c \
+ lib/lwip/src/core/ipv6/inet6.c \
+ lib/lwip/src/core/ipv6/ip6.c \
+ lib/lwip/src/core/ipv6/ip6_addr.c \
+ lib/lwip/src/core/ipv6/ip6_frag.c \
+ lib/lwip/src/core/ipv6/mld6.c \
+ lib/lwip/src/core/ipv6/nd6.c \
lib/lwip/src/netif/ethernet.c \
lib/lwip/src/netif/slipif.c \
lib/lwip/src/apps/http/httpd.c \
diff --git a/examples/device/net_lwip_webserver/src/lwipopts.h b/examples/device/net_lwip_webserver/src/lwipopts.h
index 5a8096f50..a215017c7 100644
--- a/examples/device/net_lwip_webserver/src/lwipopts.h
+++ b/examples/device/net_lwip_webserver/src/lwipopts.h
@@ -42,11 +42,14 @@
#define LWIP_ICMP 1
#define LWIP_UDP 1
#define LWIP_TCP 1
+#define LWIP_IPV4 1
+#define LWIP_IPV6 0
#define ETH_PAD_SIZE 0
#define LWIP_IP_ACCEPT_UDP_PORT(p) ((p) == PP_NTOHS(67))
#define TCP_MSS (1500 /*mtu*/ - 20 /*iphdr*/ - 20 /*tcphhr*/)
#define TCP_SND_BUF (2 * TCP_MSS)
+#define TCP_WND (TCP_MSS)
#define ETHARP_SUPPORT_STATIC_ENTRIES 1
@@ -56,4 +59,13 @@
#define LWIP_SINGLE_NETIF 1
+#define PBUF_POOL_SIZE 2
+
+#define HTTPD_USE_CUSTOM_FSDATA 0
+
+#define LWIP_MULTICAST_PING 1
+#define LWIP_BROADCAST_PING 1
+#define LWIP_IPV6_MLD 0
+#define LWIP_IPV6_SEND_ROUTER_SOLICIT 0
+
#endif /* __LWIPOPTS_H__ */
diff --git a/examples/device/net_lwip_webserver/src/main.c b/examples/device/net_lwip_webserver/src/main.c
index a5bd2153a..30bb3577b 100644
--- a/examples/device/net_lwip_webserver/src/main.c
+++ b/examples/device/net_lwip_webserver/src/main.c
@@ -50,8 +50,11 @@ try changing the first byte of tud_network_mac_address[] below from 0x02 to 0x00
#include "dnserver.h"
#include "lwip/init.h"
#include "lwip/timeouts.h"
+#include "lwip/ethip6.h"
#include "httpd.h"
+#define INIT_IP4(a,b,c,d) { PP_HTONL(LWIP_MAKEU32(a,b,c,d)) }
+
/* lwip context */
static struct netif netif_data;
@@ -64,24 +67,24 @@ static struct pbuf *received_frame;
const uint8_t tud_network_mac_address[6] = {0x02,0x02,0x84,0x6A,0x96,0x00};
/* network parameters of this MCU */
-static const ip_addr_t ipaddr = IPADDR4_INIT_BYTES(192, 168, 7, 1);
-static const ip_addr_t netmask = IPADDR4_INIT_BYTES(255, 255, 255, 0);
-static const ip_addr_t gateway = IPADDR4_INIT_BYTES(0, 0, 0, 0);
+static const ip4_addr_t ipaddr = INIT_IP4(192, 168, 7, 1);
+static const ip4_addr_t netmask = INIT_IP4(255, 255, 255, 0);
+static const ip4_addr_t gateway = INIT_IP4(0, 0, 0, 0);
/* database IP addresses that can be offered to the host; this must be in RAM to store assigned MAC addresses */
static dhcp_entry_t entries[] =
{
/* mac ip address lease time */
- { {0}, IPADDR4_INIT_BYTES(192, 168, 7, 2), 24 * 60 * 60 },
- { {0}, IPADDR4_INIT_BYTES(192, 168, 7, 3), 24 * 60 * 60 },
- { {0}, IPADDR4_INIT_BYTES(192, 168, 7, 4), 24 * 60 * 60 },
+ { {0}, INIT_IP4(192, 168, 7, 2), 24 * 60 * 60 },
+ { {0}, INIT_IP4(192, 168, 7, 3), 24 * 60 * 60 },
+ { {0}, INIT_IP4(192, 168, 7, 4), 24 * 60 * 60 },
};
static const dhcp_config_t dhcp_config =
{
- .router = IPADDR4_INIT_BYTES(0, 0, 0, 0), /* router address (if any) */
+ .router = INIT_IP4(0, 0, 0, 0), /* router address (if any) */
.port = 67, /* listen port */
- .dns = IPADDR4_INIT_BYTES(192, 168, 7, 1), /* dns server (if any) */
+ .dns = INIT_IP4(192, 168, 7, 1), /* dns server (if any) */
"usb", /* dns suffix */
TU_ARRAY_SIZE(entries), /* num entry */
entries /* entries */
@@ -108,11 +111,18 @@ static err_t linkoutput_fn(struct netif *netif, struct pbuf *p)
}
}
-static err_t output_fn(struct netif *netif, struct pbuf *p, const ip_addr_t *addr)
+static err_t ip4_output_fn(struct netif *netif, struct pbuf *p, const ip4_addr_t *addr)
{
return etharp_output(netif, p, addr);
}
+#if LWIP_IPV6
+static err_t ip6_output_fn(struct netif *netif, struct pbuf *p, const ip6_addr_t *addr)
+{
+ return ethip6_output(netif, p, addr);
+}
+#endif
+
static err_t netif_init_cb(struct netif *netif)
{
LWIP_ASSERT("netif != NULL", (netif != NULL));
@@ -122,7 +132,10 @@ static err_t netif_init_cb(struct netif *netif)
netif->name[0] = 'E';
netif->name[1] = 'X';
netif->linkoutput = linkoutput_fn;
- netif->output = output_fn;
+ netif->output = ip4_output_fn;
+#if LWIP_IPV6
+ netif->output_ip6 = ip6_output_fn;
+#endif
return ERR_OK;
}
@@ -138,11 +151,14 @@ static void init_lwip(void)
netif->hwaddr[5] ^= 0x01;
netif = netif_add(netif, &ipaddr, &netmask, &gateway, NULL, netif_init_cb, ip_input);
+#if LWIP_IPV6
+ netif_create_ip6_linklocal_address(netif, 1);
+#endif
netif_set_default(netif);
}
/* handle any DNS requests from dns-server */
-bool dns_query_proc(const char *name, ip_addr_t *addr)
+bool dns_query_proc(const char *name, ip4_addr_t *addr)
{
if (0 == strcmp(name, "tiny.usb"))
{
@@ -218,7 +234,7 @@ int main(void)
init_lwip();
while (!netif_is_up(&netif_data));
while (dhserv_init(&dhcp_config) != ERR_OK);
- while (dnserv_init(&ipaddr, 53, dns_query_proc) != ERR_OK);
+ while (dnserv_init(IP_ADDR_ANY, 53, dns_query_proc) != ERR_OK);
httpd_init();
while (1)
diff --git a/examples/device/video_capture/src/usb_descriptors.h b/examples/device/video_capture/src/usb_descriptors.h
index 340b3f799..eeaef6bd2 100644
--- a/examples/device/video_capture/src/usb_descriptors.h
+++ b/examples/device/video_capture/src/usb_descriptors.h
@@ -48,7 +48,7 @@ enum {
/* control */\
+ TUD_VIDEO_DESC_STD_VC_LEN\
+ (TUD_VIDEO_DESC_CS_VC_LEN + 1/*bInCollection*/)\
- + TUD_VIDEO_DESC_INPUT_TERM_LEN\
+ + TUD_VIDEO_DESC_CAMERA_TERM_LEN\
+ TUD_VIDEO_DESC_OUTPUT_TERM_LEN\
/* Interface 1, Alternate 0 */\
+ TUD_VIDEO_DESC_STD_VS_LEN\
@@ -79,9 +79,11 @@ enum {
TUD_VIDEO_DESC_STD_VC(ITF_NUM_VIDEO_CONTROL, 0, _stridx), \
TUD_VIDEO_DESC_CS_VC( /* UVC 1.5*/ 0x0150, \
/* wTotalLength - bLength */ \
- TUD_VIDEO_DESC_INPUT_TERM_LEN + TUD_VIDEO_DESC_OUTPUT_TERM_LEN, \
+ TUD_VIDEO_DESC_CAMERA_TERM_LEN + TUD_VIDEO_DESC_OUTPUT_TERM_LEN, \
UVC_CLOCK_FREQUENCY, 1), \
- TUD_VIDEO_DESC_INPUT_TERM(UVC_ENTITY_CAP_INPUT_TERMINAL, VIDEO_ETT_COMPOSITE_CONNECTOR, 0, 0), \
+ TUD_VIDEO_DESC_CAMERA_TERM(UVC_ENTITY_CAP_INPUT_TERMINAL, 0, 0,\
+ /*wObjectiveFocalLengthMin*/0, /*wObjectiveFocalLengthMax*/0,\
+ /*wObjectiveFocalLength*/0, /*bmControls*/0), \
TUD_VIDEO_DESC_OUTPUT_TERM(UVC_ENTITY_CAP_OUTPUT_TERMINAL, VIDEO_TT_STREAMING, 0, 1, 0), \
/* Video stream alt. 0 */ \
TUD_VIDEO_DESC_STD_VS( 1, 0, 0, 0), \
@@ -108,5 +110,4 @@ enum {
/* EP */ \
TUD_VIDEO_DESC_EP_ISO(_epin, _epsize, 1)
-
#endif