From 4b6c6929cbfb4d1b92a62df84f92e83fa861f4d8 Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 20 Feb 2014 16:06:31 +0700 Subject: fix the duplicated plug connection status change with lpc17xx by using immediate reset on isr. However Khanh's G5 mouse is not enumerated !! remove TUSB_CFG_CONFIGURATION_MAX from config file fix some warning --- tinyusb/common/common.h | 7 +++++++ tinyusb/host/ohci/ohci.c | 6 ++++-- tinyusb/host/usbh.c | 2 +- tinyusb/osal/osal_none.h | 2 +- tinyusb/tusb_option.h | 8 ++++---- 5 files changed, 17 insertions(+), 8 deletions(-) (limited to 'tinyusb') diff --git a/tinyusb/common/common.h b/tinyusb/common/common.h index ecc7bf425..4933634d2 100644 --- a/tinyusb/common/common.h +++ b/tinyusb/common/common.h @@ -228,6 +228,13 @@ static inline uint32_t offset4k(uint32_t value) } //------------- Mathematics -------------// +static inline uint32_t abs_of(int32_t value) ATTR_ALWAYS_INLINE ATTR_CONST; +static inline uint32_t abs_of(int32_t value) +{ + return (value < 0) ? (-value) : value; +} + + /// inclusive range checking static inline bool is_in_range(uint32_t lower, uint32_t value, uint32_t upper) ATTR_ALWAYS_INLINE ATTR_CONST; static inline bool is_in_range(uint32_t lower, uint32_t value, uint32_t upper) diff --git a/tinyusb/host/ohci/ohci.c b/tinyusb/host/ohci/ohci.c index 75688cfca..f55563535 100644 --- a/tinyusb/host/ohci/ohci.c +++ b/tinyusb/host/ohci/ohci.c @@ -293,7 +293,7 @@ tusb_error_t hcd_pipe_control_xfer(uint8_t dev_addr, tusb_control_request_t con ohci_gtd_t *p_status = p_setup + 2; //------------- SETUP Phase -------------// - gtd_init(p_setup, p_request, 8); + gtd_init(p_setup, (void*) p_request, 8); p_setup->index = dev_addr; p_setup->pid = OHCI_PID_SETUP; p_setup->data_toggle = BIN8(10); // DATA0 @@ -664,9 +664,11 @@ void hcd_isr(uint8_t hostid) // TODO dual port is not yet supported if ( rhport_status & OHCI_RHPORT_CONNECT_STATUS_CHANGE_MASK ) { + // TODO check if remote wake-up if ( OHCI_REG->rhport_status_bit[0].current_connect_status ) { -// OHCI_REG->rhport_status[0] = OHCI_RHPORT_PORT_RESET_STATUS_MASK; // reset port immediately + // TODO reset port immediately, without this controller will got 2-3 (debouncing connection status change) + OHCI_REG->rhport_status[0] = OHCI_RHPORT_PORT_RESET_STATUS_MASK; usbh_hcd_rhport_plugged_isr(0); }else { diff --git a/tinyusb/host/usbh.c b/tinyusb/host/usbh.c index de9e15164..229c9da65 100644 --- a/tinyusb/host/usbh.c +++ b/tinyusb/host/usbh.c @@ -375,7 +375,7 @@ tusb_error_t enumeration_body_subtask(void) { if( hcd_port_connect_status(usbh_devices[0].core_id) ) { // connection event - osal_task_delay(200); // wait until device is stable + osal_task_delay(200); // wait until device is stable. Increase this if the first 8 bytes is failed to get if ( !hcd_port_connect_status(usbh_devices[0].core_id) ) SUBTASK_EXIT(TUSB_ERROR_NONE); // exit if device unplugged while delaying diff --git a/tinyusb/osal/osal_none.h b/tinyusb/osal/osal_none.h index adea45f32..7816cda33 100644 --- a/tinyusb/osal/osal_none.h +++ b/tinyusb/osal/osal_none.h @@ -203,7 +203,7 @@ static inline void osal_semaphore_reset(osal_semaphore_handle_t sem_hdl) timeout = osal_tick_get();\ state = __LINE__; case __LINE__:\ if( *(sem_hdl) == 0 ) {\ - if ( (msec != OSAL_TIMEOUT_WAIT_FOREVER) && (timeout + osal_tick_from_msec(msec) <= osal_tick_get()) ) /* time out */ \ + if ( ( ((uint32_t) (msec)) != OSAL_TIMEOUT_WAIT_FOREVER) && (timeout + osal_tick_from_msec(msec) <= osal_tick_get()) ) /* time out */ \ *(p_error) = TUSB_ERROR_OSAL_TIMEOUT;\ else\ return TUSB_ERROR_OSAL_WAITING;\ diff --git a/tinyusb/tusb_option.h b/tinyusb/tusb_option.h index 3e6ec3574..d27f21cbe 100644 --- a/tinyusb/tusb_option.h +++ b/tinyusb/tusb_option.h @@ -126,10 +126,10 @@ /** * Maximum number of supported USB's configuration (currently only support only 1) */ -#ifndef TUSB_CFG_CONFIGURATION_MAX - #define TUSB_CFG_CONFIGURATION_MAX 1 - #warning TUSB_CFG_CONFIGURATION_MAX is not defined, default value is 1 -#endif +//#ifndef TUSB_CFG_CONFIGURATION_MAX +// #define TUSB_CFG_CONFIGURATION_MAX 1 +// #warning TUSB_CFG_CONFIGURATION_MAX is not defined, default value is 1 +//#endif //--------------------------------------------------------------------+ // HOST OPTIONS -- cgit v1.3.1