Skip to content

Commit a54938a

Browse files
committed
cherryusb:Fixed the issue where the USB device in the cdc_rndis_template example could not enable DHCP.
1 parent 8ea7c14 commit a54938a

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

components/drivers/usb/cherryusb/demo/cdc_rndis_template.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,20 +183,20 @@ void usbd_rndis_data_send_done(uint32_t len)
183183
rndis_tx_done = true; // suggest you to use semaphore in os
184184
}
185185

186+
#include <rtthread.h>
187+
#include <rtdevice.h>
188+
#include <netif/ethernetif.h>
189+
#include <netdev.h>
190+
186191
#ifdef RT_USING_LWIP
187192

188193
#ifndef RT_LWIP_DHCP
189194
#error rndis must enable RT_LWIP_DHCP
190195
#endif
191196

192-
#ifndef LWIP_USING_DHCPD
193-
#error rndis must enable LWIP_USING_DHCPD
194-
#endif
195-
196-
#include <rtthread.h>
197-
#include <rtdevice.h>
198-
#include <netif/ethernetif.h>
197+
#ifdef LWIP_USING_DHCPD
199198
#include <dhcp_server.h>
199+
#endif
200200

201201
struct eth_device rndis_dev;
202202

@@ -250,7 +250,14 @@ void rndis_lwip_init(void)
250250
eth_device_init(&rndis_dev, "u0");
251251

252252
eth_device_linkchange(&rndis_dev, RT_TRUE);
253+
#ifdef LWIP_USING_DHCPD
253254
dhcpd_start("u0");
255+
#else
256+
struct netdev *netdev = netdev_get_by_name("u0");
257+
if (netdev) {
258+
netdev_dhcp_enabled(netdev, RT_TRUE);
259+
}
260+
#endif
254261
}
255262

256263
void usbd_rndis_data_recv_done(uint32_t len)

0 commit comments

Comments
 (0)