Skip to content

Commit eec89fd

Browse files
Rbb666sakumisu
authored andcommitted
fix:Fix RNDIS DHCP dependency,and delay implementation
1 parent e453e72 commit eec89fd

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

demo/cdc_rndis_template.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,14 @@ void usbd_rndis_data_send_done(uint32_t len)
189189
#error rndis must enable RT_LWIP_DHCP
190190
#endif
191191

192-
#ifndef LWIP_USING_DHCPD
193-
#error rndis must enable LWIP_USING_DHCPD
192+
#ifdef LWIP_USING_DHCPD
193+
#include <dhcp_server.h>
194194
#endif
195195

196196
#include <rtthread.h>
197197
#include <rtdevice.h>
198198
#include <netif/ethernetif.h>
199-
#include <dhcp_server.h>
199+
#include <netdev.h>
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)

port/kinetis/usb_glue_mcx.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,12 @@ void usb_dc_low_level_deinit(uint8_t busid)
8282

8383
void usbd_kinetis_delay_ms(uint8_t ms)
8484
{
85+
#ifdef __RTTHREAD__
86+
rt_thread_mdelay(ms);
87+
#else
88+
for (uint32_t i = 0; i < ms; i++)
89+
{
90+
for (volatile uint32_t j = 0; j < 10000; j++);
91+
}
92+
#endif
8593
}

0 commit comments

Comments
 (0)