1212#include "lwip/prot/dhcp.h"
1313#endif
1414
15- #include "FreeRTOS.h"
16- #include "task.h"
17- #include "semphr.h"
18- #include "timers.h"
19-
2015#include "usbh_core.h"
2116
2217#if LWIP_TCPIP_CORE_LOCKING_INPUT != 1
@@ -84,11 +79,11 @@ void usbh_lwip_eth_input_common(struct netif *netif, uint8_t *buf, uint32_t len)
8479 }
8580}
8681
87- TimerHandle_t dhcp_handle ;
82+ struct usb_osal_timer * dhcp_handle ;
8883
89- static void dhcp_timeout (TimerHandle_t xTimer )
84+ static void dhcp_timeout (void * arg )
9085{
91- struct netif * netif = (struct netif * )pvTimerGetTimerID ( xTimer ) ;
86+ struct netif * netif = (struct netif * )arg ;
9287#if LWIP_DHCP
9388 struct dhcp * dhcp ;
9489#endif
@@ -102,7 +97,7 @@ static void dhcp_timeout(TimerHandle_t xTimer)
10297 USB_LOG_INFO ("IPv4 Subnet mask : %s\r\n" , ipaddr_ntoa (& netif -> netmask ));
10398 USB_LOG_INFO ("IPv4 Gateway : %s\r\n\r\n" , ipaddr_ntoa (& netif -> gw ));
10499
105- xTimerStop ( xTimer , 0 );
100+ usb_osal_timer_stop ( dhcp_handle );
106101#if LWIP_DHCP
107102 }
108103#endif
@@ -164,7 +159,7 @@ void usbh_cdc_ecm_run(struct usbh_cdc_ecm *cdc_ecm_class)
164159 while (!netif_is_up (netif )) {
165160 }
166161
167- dhcp_handle = xTimerCreate (( const char * ) "dhcp" , ( TickType_t ) 200 , ( UBaseType_t ) pdTRUE , ( void * const ) netif , ( TimerCallbackFunction_t ) dhcp_timeout );
162+ dhcp_handle = usb_osal_timer_create ( "dhcp" , 200 , dhcp_timeout , netif , true );
168163 if (dhcp_handle == NULL ) {
169164 USB_LOG_ERR ("timer creation failed! \r\n" );
170165 while (1 ) {
@@ -174,7 +169,7 @@ void usbh_cdc_ecm_run(struct usbh_cdc_ecm *cdc_ecm_class)
174169 usb_osal_thread_create ("usbh_cdc_ecm_rx" , 2048 , CONFIG_USBHOST_PSC_PRIO + 1 , usbh_cdc_ecm_rx_thread , NULL );
175170#if LWIP_DHCP
176171 dhcp_start (netif );
177- xTimerStart (dhcp_handle , 0 );
172+ usb_osal_timer_start (dhcp_handle );
178173#endif
179174}
180175
@@ -186,8 +181,7 @@ void usbh_cdc_ecm_stop(struct usbh_cdc_ecm *cdc_ecm_class)
186181#if LWIP_DHCP
187182 dhcp_stop (netif );
188183 dhcp_cleanup (netif );
189- xTimerStop (dhcp_handle , 0 );
190- xTimerDelete (dhcp_handle , 0 );
184+ usb_osal_timer_delete (dhcp_handle );
191185#endif
192186 netif_set_down (netif );
193187 netif_remove (netif );
@@ -197,19 +191,19 @@ void usbh_cdc_ecm_stop(struct usbh_cdc_ecm *cdc_ecm_class)
197191#ifdef CONFIG_USBHOST_PLATFORM_CDC_RNDIS
198192#include "usbh_rndis.h"
199193
200- TimerHandle_t timer_handle ;
194+ struct usb_osal_timer * timer_handle ;
201195
202- static void rndis_dev_keepalive_timeout (TimerHandle_t xTimer )
196+ static void rndis_dev_keepalive_timeout (void * arg )
203197{
204- struct usbh_rndis * rndis_class = (struct usbh_rndis * )pvTimerGetTimerID ( xTimer ) ;
198+ struct usbh_rndis * rndis_class = (struct usbh_rndis * )arg ;
205199 usbh_rndis_keepalive (rndis_class );
206200}
207201
208202void timer_init (struct usbh_rndis * rndis_class )
209203{
210- timer_handle = xTimerCreate (( const char * ) NULL , ( TickType_t ) 5000 , ( UBaseType_t ) pdTRUE , ( void * const ) rndis_class , ( TimerCallbackFunction_t ) rndis_dev_keepalive_timeout );
204+ timer_handle = usb_osal_timer_create ( "rndis_keepalive" , 5000 , rndis_dev_keepalive_timeout , rndis_class , true );
211205 if (NULL != timer_handle ) {
212- xTimerStart (timer_handle , 0 );
206+ usb_osal_timer_start (timer_handle );
213207 } else {
214208 USB_LOG_ERR ("timer creation failed! \r\n" );
215209 for (;;) {
@@ -269,7 +263,7 @@ void usbh_rndis_run(struct usbh_rndis *rndis_class)
269263 while (!netif_is_up (netif )) {
270264 }
271265
272- dhcp_handle = xTimerCreate (( const char * ) "dhcp" , ( TickType_t ) 200 , ( UBaseType_t ) pdTRUE , ( void * const ) netif , ( TimerCallbackFunction_t ) dhcp_timeout );
266+ dhcp_handle = usb_osal_timer_create ( "dhcp" , 200 , dhcp_timeout , netif , true );
273267 if (dhcp_handle == NULL ) {
274268 USB_LOG_ERR ("timer creation failed! \r\n" );
275269 while (1 ) {
@@ -282,7 +276,7 @@ void usbh_rndis_run(struct usbh_rndis *rndis_class)
282276
283277#if LWIP_DHCP
284278 dhcp_start (netif );
285- xTimerStart (dhcp_handle , 0 );
279+ usb_osal_timer_start (dhcp_handle );
286280#endif
287281}
288282
@@ -294,8 +288,7 @@ void usbh_rndis_stop(struct usbh_rndis *rndis_class)
294288#if LWIP_DHCP
295289 dhcp_stop (netif );
296290 dhcp_cleanup (netif );
297- xTimerStop (dhcp_handle , 0 );
298- xTimerDelete (dhcp_handle , 0 );
291+ usb_osal_timer_delete (dhcp_handle );
299292#endif
300293 netif_set_down (netif );
301294 netif_remove (netif );
@@ -358,7 +351,7 @@ void usbh_cdc_ncm_run(struct usbh_cdc_ncm *cdc_ncm_class)
358351 while (!netif_is_up (netif )) {
359352 }
360353
361- dhcp_handle = xTimerCreate (( const char * ) "dhcp" , ( TickType_t ) 200 , ( UBaseType_t ) pdTRUE , ( void * const ) netif , ( TimerCallbackFunction_t ) dhcp_timeout );
354+ dhcp_handle = usb_osal_timer_create ( "dhcp" , 200 , dhcp_timeout , netif , true );
362355 if (dhcp_handle == NULL ) {
363356 USB_LOG_ERR ("timer creation failed! \r\n" );
364357 while (1 ) {
@@ -368,7 +361,7 @@ void usbh_cdc_ncm_run(struct usbh_cdc_ncm *cdc_ncm_class)
368361 usb_osal_thread_create ("usbh_cdc_ncm_rx" , 2048 , CONFIG_USBHOST_PSC_PRIO + 1 , usbh_cdc_ncm_rx_thread , NULL );
369362#if LWIP_DHCP
370363 dhcp_start (netif );
371- xTimerStart (dhcp_handle , 0 );
364+ usb_osal_timer_start (dhcp_handle );
372365#endif
373366}
374367
@@ -380,8 +373,7 @@ void usbh_cdc_ncm_stop(struct usbh_cdc_ncm *cdc_ncm_class)
380373#if LWIP_DHCP
381374 dhcp_stop (netif );
382375 dhcp_cleanup (netif );
383- xTimerStop (dhcp_handle , 0 );
384- xTimerDelete (dhcp_handle , 0 );
376+ usb_osal_timer_delete (dhcp_handle );
385377#endif
386378 netif_set_down (netif );
387379 netif_remove (netif );
@@ -442,7 +434,7 @@ void usbh_asix_run(struct usbh_asix *asix_class)
442434 while (!netif_is_up (netif )) {
443435 }
444436
445- dhcp_handle = xTimerCreate (( const char * ) "dhcp" , ( TickType_t ) 200 , ( UBaseType_t ) pdTRUE , ( void * const ) netif , ( TimerCallbackFunction_t ) dhcp_timeout );
437+ dhcp_handle = usb_osal_timer_create ( "dhcp" , 200 , dhcp_timeout , netif , true );
446438 if (dhcp_handle == NULL ) {
447439 USB_LOG_ERR ("timer creation failed! \r\n" );
448440 while (1 ) {
@@ -452,7 +444,7 @@ void usbh_asix_run(struct usbh_asix *asix_class)
452444 usb_osal_thread_create ("usbh_asix_rx" , 2048 , CONFIG_USBHOST_PSC_PRIO + 1 , usbh_asix_rx_thread , NULL );
453445#if LWIP_DHCP
454446 dhcp_start (netif );
455- xTimerStart (dhcp_handle , 0 );
447+ usb_osal_timer_start (dhcp_handle );
456448#endif
457449}
458450
@@ -464,8 +456,7 @@ void usbh_asix_stop(struct usbh_asix *asix_class)
464456#if LWIP_DHCP
465457 dhcp_stop (netif );
466458 dhcp_cleanup (netif );
467- xTimerStop (dhcp_handle , 0 );
468- xTimerDelete (dhcp_handle , 0 );
459+ usb_osal_timer_delete (dhcp_handle );
469460#endif
470461 netif_set_down (netif );
471462 netif_remove (netif );
@@ -526,7 +517,7 @@ void usbh_rtl8152_run(struct usbh_rtl8152 *rtl8152_class)
526517 while (!netif_is_up (netif )) {
527518 }
528519
529- dhcp_handle = xTimerCreate (( const char * ) "dhcp" , ( TickType_t ) 200 , ( UBaseType_t ) pdTRUE , ( void * const ) netif , ( TimerCallbackFunction_t ) dhcp_timeout );
520+ dhcp_handle = usb_osal_timer_create ( "dhcp" , 200 , dhcp_timeout , netif , true );
530521 if (dhcp_handle == NULL ) {
531522 USB_LOG_ERR ("timer creation failed! \r\n" );
532523 while (1 ) {
@@ -536,7 +527,7 @@ void usbh_rtl8152_run(struct usbh_rtl8152 *rtl8152_class)
536527 usb_osal_thread_create ("usbh_rtl8152_rx" , 2048 , CONFIG_USBHOST_PSC_PRIO + 1 , usbh_rtl8152_rx_thread , NULL );
537528#if LWIP_DHCP
538529 dhcp_start (netif );
539- xTimerStart (dhcp_handle , 0 );
530+ usb_osal_timer_start (dhcp_handle );
540531#endif
541532}
542533
@@ -548,8 +539,7 @@ void usbh_rtl8152_stop(struct usbh_rtl8152 *rtl8152_class)
548539#if LWIP_DHCP
549540 dhcp_stop (netif );
550541 dhcp_cleanup (netif );
551- xTimerStop (dhcp_handle , 0 );
552- xTimerDelete (dhcp_handle , 0 );
542+ usb_osal_timer_delete (dhcp_handle );
553543#endif
554544 netif_set_down (netif );
555545 netif_remove (netif );
@@ -630,13 +620,13 @@ void usbh_bl616_run(struct usbh_bl616 *bl616_class)
630620 netif_set_down (netif );
631621 netif_set_default (netif );
632622
633- dhcp_handle = xTimerCreate (( const char * ) "dhcp" , ( TickType_t ) 200 , ( UBaseType_t ) pdTRUE , ( void * const ) netif , ( TimerCallbackFunction_t ) dhcp_timeout );
623+ dhcp_handle = usb_osal_timer_create ( "dhcp" , 200 , dhcp_timeout , netif , true );
634624 if (dhcp_handle == NULL ) {
635625 USB_LOG_ERR ("timer creation failed! \r\n" );
636626 while (1 ) {
637627 }
638628 }
639- xTimerStart (dhcp_handle , 0 );
629+ usb_osal_timer_start (dhcp_handle );
640630
641631 usb_osal_thread_create ("usbh_bl616" , 2048 , CONFIG_USBHOST_PSC_PRIO + 1 , usbh_bl616_rx_thread , NULL );
642632}
0 commit comments