This commit is contained in:
hathach 2020-09-05 13:57:07 +07:00
parent 10d5dac913
commit 4d57b4ea33
5 changed files with 20 additions and 21 deletions

View File

@ -41,8 +41,6 @@
//--------------------------------------------------------------------+
// Init device stack
// Note: when using with RTOS, this should be called after scheduler/kernel is started.
// Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
bool tud_init (void);
// Task function should be called in main/rtos loop

View File

@ -116,7 +116,7 @@ enum { USBH_CLASS_DRIVER_COUNT = TU_ARRAY_SIZE(usbh_class_drivers) };
CFG_TUSB_MEM_SECTION usbh_device_t _usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1];
// Event queue
// role device/host is used by OS NONE for mutex (disable usb isr) only
// role device/host is used by OS NONE for mutex (disable usb isr)
OSAL_QUEUE_DEF(OPT_MODE_HOST, _usbh_qdef, CFG_TUH_TASK_QUEUE_SZ, hcd_event_t);
static osal_queue_t _usbh_q;
@ -137,7 +137,6 @@ tusb_device_state_t tuh_device_get_state (uint8_t const dev_addr)
return (tusb_device_state_t) _usbh_devices[dev_addr].state;
}
static inline void osal_task_delay(uint32_t msec)
{
(void) msec;
@ -149,7 +148,7 @@ static inline void osal_task_delay(uint32_t msec)
//--------------------------------------------------------------------+
// CLASS-USBD API (don't require to verify parameters)
//--------------------------------------------------------------------+
bool usbh_init(void)
bool tuh_init(void)
{
tu_memclr(_usbh_devices, sizeof(usbh_device_t)*(CFG_TUSB_HOST_DEVICE_MAX+1));
@ -385,13 +384,10 @@ bool enum_task(hcd_event_t* event)
#endif
};
// for OSAL_NONE local variable won't retain value after blocking service sem_wait/queue_recv
static uint8_t configure_selected = 1; // TODO move
usbh_device_t* dev0 = &_usbh_devices[0];
tusb_control_request_t request;
dev0->rhport = event->rhport; // TODO refractor integrate to device_pool
dev0->rhport = event->rhport; // TODO refractor integrate to device_pool
dev0->hub_addr = event->attach.hub_addr;
dev0->hub_port = event->attach.hub_port;
dev0->state = TUSB_DEVICE_STATE_UNPLUG;
@ -552,7 +548,7 @@ bool enum_task(hcd_event_t* event)
new_dev->product_id = ((tusb_desc_device_t*) _usbh_ctrl_buf)->idProduct;
new_dev->configure_count = ((tusb_desc_device_t*) _usbh_ctrl_buf)->bNumConfigurations;
configure_selected = get_configure_number_for_device((tusb_desc_device_t*) _usbh_ctrl_buf);
uint8_t const configure_selected = get_configure_number_for_device((tusb_desc_device_t*) _usbh_ctrl_buf);
TU_ASSERT(configure_selected <= new_dev->configure_count); // TODO notify application when invalid configuration
//------------- Get 9 bytes of configuration descriptor -------------//

View File

@ -70,6 +70,11 @@ typedef struct {
//--------------------------------------------------------------------+
// APPLICATION API
//--------------------------------------------------------------------+
// Init host stack
bool tuh_init(void);
// Task function should be called in main/rtos loop
void tuh_task(void);
// Interrupt handler, name alias to HCD
@ -97,11 +102,7 @@ TU_ATTR_WEAK void tuh_umount_cb(uint8_t dev_addr);
// CLASS-USBH & INTERNAL API
//--------------------------------------------------------------------+
// Note: when using with RTOS, this should be called after scheduler/kernel is started.
// Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
bool usbh_init(void);
bool usbh_control_xfer (uint8_t dev_addr, tusb_control_request_t* request, uint8_t* data);
bool usbh_edpt_open(uint8_t rhport, uint8_t dev_addr, tusb_desc_endpoint_t const * ep_desc);
#ifdef __cplusplus

View File

@ -43,7 +43,7 @@ bool tusb_init(void)
if (_initialized) return true;
#if TUSB_OPT_HOST_ENABLED
TU_ASSERT( usbh_init() ); // init host stack
TU_ASSERT( tuh_init() ); // init host stack
#endif
#if TUSB_OPT_DEVICE_ENABLED

View File

@ -4,6 +4,10 @@ import sys
import subprocess
import time
SUCCEEDED = "\033[32msucceeded\033[0m"
FAILED = "\033[31mfailed\033[0m"
SKIPPED = "\033[33mskipped\033[0m"
success_count = 0
fail_count = 0
skip_count = 0
@ -11,7 +15,7 @@ exit_status = 0
total_time = time.monotonic()
build_format = '| {:23} | {:30} | {:9} | {:7} | {:6} | {:6} |'
build_format = '| {:23} | {:30} | {:18} | {:7} | {:6} | {:6} |'
build_separator = '-' * 100
# 1st Argument is Example, build all examples if not existed
@ -58,7 +62,7 @@ def skip_example(example, board):
return 0
print(build_separator)
print(build_format.format('Example', 'Board', 'Result', 'Time', 'Flash', 'SRAM'))
print(build_format.format('Example', 'Board', '\033[39mResult\033[0m', 'Time', 'Flash', 'SRAM'))
print(build_separator)
for example in all_examples:
@ -70,19 +74,19 @@ for example in all_examples:
# Check if board is skipped
if skip_example(example, board):
success = "\033[33mskipped\033[0m "
success = SKIPPED
skip_count += 1
print(build_format.format(example, board, success, '-', flash_size, sram_size))
else:
build_result = build_example(example, board)
if build_result.returncode == 0:
success = "\033[32msucceeded\033[0m"
success = SUCCEEDED
success_count += 1
(flash_size, sram_size) = build_size(example, board)
else:
exit_status = build_result.returncode
success = "\033[31mfailed\033[0m "
success = FAILED
fail_count += 1
build_duration = time.monotonic() - start_time
@ -95,7 +99,7 @@ for example in all_examples:
total_time = time.monotonic() - total_time
print(build_separator)
print("Build Sumamary: {} \033[32msucceeded\033[0m, {} \033[31mfailed\033[0m, {} \033[33mskipped\033[0m and took {:.2f}s".format(success_count, fail_count, skip_count, total_time))
print("Build Summary: {} {}, {} {}, {} {} and took {:.2f}s".format(success_count, SUCCEEDED, fail_count, FAILED, skip_count, SKIPPED, total_time))
print(build_separator)
sys.exit(exit_status)