From 787c891702a9e6f4ddfe4f4c04457d7304fd21d5 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 21 Jul 2020 21:00:11 +0700 Subject: [PATCH 1/2] add note for MS OS 1.0 Descriptor at 0xEE --- examples/device/cdc_dual_ports/src/usb_descriptors.c | 4 +++- examples/device/cdc_msc/src/usb_descriptors.c | 4 +++- examples/device/cdc_msc_freertos/src/usb_descriptors.c | 4 +++- examples/device/dfu_rt/src/usb_descriptors.c | 4 +++- examples/device/dynamic_configuration/src/usb_descriptors.c | 4 +++- examples/device/hid_composite/src/usb_descriptors.c | 4 +++- examples/device/hid_composite_freertos/src/usb_descriptors.c | 4 +++- examples/device/hid_generic_inout/src/usb_descriptors.c | 4 +++- examples/device/midi_test/src/usb_descriptors.c | 4 +++- examples/device/msc_dual_lun/src/usb_descriptors.c | 4 +++- examples/device/net_lwip_webserver/src/usb_descriptors.c | 4 +++- examples/device/usbtmc/src/usb_descriptors.c | 4 +++- examples/device/webusb_serial/src/usb_descriptors.c | 4 +++- 13 files changed, 39 insertions(+), 13 deletions(-) diff --git a/examples/device/cdc_dual_ports/src/usb_descriptors.c b/examples/device/cdc_dual_ports/src/usb_descriptors.c index f23e42036..8e19678e5 100644 --- a/examples/device/cdc_dual_ports/src/usb_descriptors.c +++ b/examples/device/cdc_dual_ports/src/usb_descriptors.c @@ -170,7 +170,8 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid) chr_count = 1; }else { - // Convert ASCII string into UTF-16 + // Note: the 0xEE index string is a Microsoft OS 1.0 Descriptors. + // https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/microsoft-defined-usb-descriptors if ( !(index < sizeof(string_desc_arr)/sizeof(string_desc_arr[0])) ) return NULL; @@ -180,6 +181,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid) chr_count = strlen(str); if ( chr_count > 31 ) chr_count = 31; + // Convert ASCII string into UTF-16 for(uint8_t i=0; i 31 ) chr_count = 31; + // Convert ASCII string into UTF-16 for(uint8_t i=0; i 31 ) chr_count = 31; + // Convert ASCII string into UTF-16 for(uint8_t i=0; i 31 ) chr_count = 31; + // Convert ASCII string into UTF-16 for(uint8_t i=0; i 31 ) chr_count = 31; + // Convert ASCII string into UTF-16 for(uint8_t i=0; i 31 ) chr_count = 31; + // Convert ASCII string into UTF-16 for(uint8_t i=0; i 31 ) chr_count = 31; + // Convert ASCII string into UTF-16 for(uint8_t i=0; i 31 ) chr_count = 31; + // Convert ASCII string into UTF-16 for(uint8_t i=0; i 31 ) chr_count = 31; + // Convert ASCII string into UTF-16 for(uint8_t i=0; i (TU_ARRAY_SIZE(_desc_str) - 1)) chr_count = TU_ARRAY_SIZE(_desc_str) - 1; + // Convert ASCII string into UTF-16 for (unsigned int i=0; i 31 ) chr_count = 31; + // Convert ASCII string into UTF-16 for(uint8_t i=0; i Date: Tue, 21 Jul 2020 21:06:10 +0700 Subject: [PATCH 2/2] follow up to pr468 --- src/osal/osal_freertos.h | 41 +++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/src/osal/osal_freertos.h b/src/osal/osal_freertos.h index 416065eeb..004bd1b6b 100644 --- a/src/osal/osal_freertos.h +++ b/src/osal/osal_freertos.h @@ -32,7 +32,6 @@ #include "semphr.h" #include "queue.h" #include "task.h" -#include "tusb_option.h" #ifdef __cplusplus extern "C" { @@ -59,19 +58,23 @@ static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semde static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) { - if(!in_isr){ + if ( !in_isr ) + { return xSemaphoreGive(sem_hdl) != 0; } - BaseType_t xHigherPriorityTaskWoken; - BaseType_t res = xSemaphoreGiveFromISR(sem_hdl, &xHigherPriorityTaskWoken); + else + { + BaseType_t xHigherPriorityTaskWoken; + BaseType_t res = xSemaphoreGiveFromISR(sem_hdl, &xHigherPriorityTaskWoken); + #if CFG_TUSB_MCU == OPT_MCU_ESP32S2 - if (xHigherPriorityTaskWoken) { - portYIELD_FROM_ISR(); - } + if ( xHigherPriorityTaskWoken ) portYIELD_FROM_ISR(); #else - portYIELD_FROM_ISR(xHigherPriorityTaskWoken); + portYIELD_FROM_ISR(xHigherPriorityTaskWoken); #endif - return res != 0; + + return res != 0; + } } static inline bool osal_semaphore_wait (osal_semaphore_t sem_hdl, uint32_t msec) @@ -138,19 +141,23 @@ static inline bool osal_queue_receive(osal_queue_t qhdl, void* data) static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in_isr) { - if(!in_isr){ + if ( !in_isr ) + { return xQueueSendToBack(qhdl, data, OSAL_TIMEOUT_WAIT_FOREVER) != 0; } - BaseType_t xHigherPriorityTaskWoken; - BaseType_t res = xQueueSendToBackFromISR(qhdl, data, &xHigherPriorityTaskWoken); + else + { + BaseType_t xHigherPriorityTaskWoken; + BaseType_t res = xQueueSendToBackFromISR(qhdl, data, &xHigherPriorityTaskWoken); + #if CFG_TUSB_MCU == OPT_MCU_ESP32S2 - if (xHigherPriorityTaskWoken) { - portYIELD_FROM_ISR(); - } + if ( xHigherPriorityTaskWoken ) portYIELD_FROM_ISR(); #else - portYIELD_FROM_ISR(xHigherPriorityTaskWoken); + portYIELD_FROM_ISR(xHigherPriorityTaskWoken); #endif - return res != 0; + + return res != 0; + } } static inline bool osal_queue_empty(osal_queue_t qhdl)