From ead101b730c61cb953a4e3a4d7fccb7f4268de82 Mon Sep 17 00:00:00 2001 From: liu Date: Wed, 25 Jun 2014 18:41:36 +0800 Subject: [PATCH] fixed the issue of basic scheduling at no time check mode --- .../usb/usb_host/host/source/host/khci/khci.c | 25 ++++++++++++---------- .../usb/usb_host/host/source/host/khci/khci.h | 2 +- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/adk-stack/transport/usb/usb_host/host/source/host/khci/khci.c b/adk-stack/transport/usb/usb_host/host/source/host/khci/khci.c index 92513e6..2bfd744 100755 --- a/adk-stack/transport/usb/usb_host/host/source/host/khci/khci.c +++ b/adk-stack/transport/usb/usb_host/host/source/host/khci/khci.c @@ -973,13 +973,7 @@ static int_32 _usb_khci_dispatch_transation( /* wait for next SOF */; //-usb_ptr->SOFTHLD = 0; - //usb_ptr->SOFTHLD = len * 7 / 6 + KHCICFG_THSLD_DELAY; - #ifndef SCHEDULING_CHECK_TIME - if (pipe_desc_ptr->G.SPEED == USB_SPEED_FULL) - usb_ptr->SOFTHLD = len * 7 / 6 + KHCICFG_THSLD_DELAY; - else - usb_ptr->SOFTHLD = len * 12 * 7 / 6 + KHCICFG_THSLD_DELAY; - #endif + //usb_ptr->SOFTHLD = len * 7 / 6 + KHCICFG_THSLD_DELAY; #else if (pipe_desc_ptr->G.SPEED == USB_SPEED_FULL) usb_ptr->SOFTHLD = len * 7 / 6 + KHCICFG_THSLD_DELAY; @@ -1249,8 +1243,10 @@ boolean get_next_schedule_transfer(USB_KHCI_HOST_STATE_STRUCT_PTR usb_host_ptr) static inline boolean update_free_bandwidth(USB_KHCI_HOST_STATE_STRUCT_PTR usb_host_ptr) { MQX_TICK_STRUCT cur_tick,diff_tick; + uint32_t cur_frame_num = _usb_khci_get_total_frame_count((_usb_host_handle)usb_host_ptr); //return TRUE; - if(_usb_khci_get_total_frame_count((_usb_host_handle)usb_host_ptr) != usb_host_ptr->frame_num) { + + if( cur_frame_num != usb_host_ptr->frame_num) { //usb_host_ptr->free_bandwidth = 0; return FALSE; } @@ -1379,7 +1375,7 @@ static inline void handle_ctrl_transaction_done(USB_KHCI_HOST_STATE_STRUCT_PTR u break; case TRF_SETUP_DTOH: // start ctrl read case TRF_SETUP_HTOD: // start ctrl write - if( res > 0 ) { + if( res >= 0 ) { pipe_tr->pos += res; if(pipe_tr->pos == total_len) state_step = 2; @@ -1394,13 +1390,14 @@ static inline void handle_ctrl_transaction_done(USB_KHCI_HOST_STATE_STRUCT_PTR u break; case TRF_SETUP_DTOH_IN: // continue ctrl read case TRF_SETUP_HTOD_OUT: // continue ctrl write - if( res > 0 ) { + if( res >= 0 ) { pipe_tr->pos += res; if(pipe_tr->pos == total_len) pipe_tr->status ++; /* ack status */ } - else + else { ctrl_transaction_fail = 1; + } break; case TRF_SETUP_DTOH_OUT: // ctrl read ack out case TRF_SETUP_HTOD_IN: // ctrl write ack in @@ -1773,11 +1770,15 @@ void handle_transaction_done(USB_KHCI_HOST_STATE_STRUCT_PTR usb_host_ptr) if (usb_ptr->ERRSTAT & USB_ERREN_CRC5EOFEN_MASK) { // retry = 0; //printf("detects End Of Frame (EOF) error conditions.\n"); +#ifdef SCHEDULING_CHECK_TIME // if don't check time then always happen EOF error! printf("EOF%d\n",usb_ptr->ERRSTAT); +#endif } #endif res = -usb_ptr->ERRSTAT; +#ifdef SCHEDULING_CHECK_TIME printf("ERRSTAT %d\n",res); +#endif // return res; // error handle by endpoint token done function } else { @@ -1795,6 +1796,7 @@ void handle_transaction_done(USB_KHCI_HOST_STATE_STRUCT_PTR usb_host_ptr) case 0x0e: // STALL res = KHCI_ATOM_TR_STALL; + printf("STALL error\n"); //retry = 0; break; @@ -1819,6 +1821,7 @@ void handle_transaction_done(USB_KHCI_HOST_STATE_STRUCT_PTR usb_host_ptr) case 0x0f: // data error //if this event happens during enumeration, then return means not finished enumeration res = KHCI_ATOM_TR_DATA_ERROR; + printf("data error\n"); //_time_delay(delay_const * (pipe_desc_ptr->G.NAK_COUNT - retry)); break; diff --git a/adk-stack/transport/usb/usb_host/host/source/host/khci/khci.h b/adk-stack/transport/usb/usb_host/host/source/host/khci/khci.h index 5dc41bb..20e9156 100755 --- a/adk-stack/transport/usb/usb_host/host/source/host/khci/khci.h +++ b/adk-stack/transport/usb/usb_host/host/source/host/khci/khci.h @@ -41,7 +41,7 @@ #define SCHEDULING_CHECK_TIME #ifndef SCHEDULING_CHECK_TIME -//#define SCHEDULING_CHECK_TRANSFERED +#define SCHEDULING_CHECK_TRANSFERED #endif /* Scheduling based on internal "deadtime" register THSLD; you can choose additional value passed to the register -- 2.11.4.GIT