mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
able to complete enumeration with os none blocking
This commit is contained in:
parent
5d4d3431c2
commit
5f7d7a34f5
@ -66,7 +66,7 @@ int main(void)
|
|||||||
|
|
||||||
led_blinking_task();
|
led_blinking_task();
|
||||||
|
|
||||||
#if CFG_TUD_CDC
|
#if CFG_TUSB_HOST_CDC
|
||||||
virtual_com_task();
|
virtual_com_task();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -81,7 +81,26 @@ int main(void)
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// USB CDC
|
// USB CDC
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
#if CFG_TUD_CDC
|
#if CFG_TUSB_HOST_CDC
|
||||||
|
|
||||||
|
void tuh_cdc_mounted_cb(uint8_t dev_addr)
|
||||||
|
{
|
||||||
|
// application set-up
|
||||||
|
printf("\na CDC device (address %d) is mounted\n", dev_addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tuh_cdc_unmounted_cb(uint8_t dev_addr)
|
||||||
|
{
|
||||||
|
// application tear-down
|
||||||
|
printf("\na CDC device (address %d) is unmounted \n", dev_addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// invoked ISR context
|
||||||
|
void tuh_cdc_xfer_isr(uint8_t dev_addr, xfer_result_t event, cdc_pipeid_t pipe_id, uint32_t xferred_bytes)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void virtual_com_task(void)
|
void virtual_com_task(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@
|
|||||||
#define CFG_TUSB_HOST_HID_MOUSE 0
|
#define CFG_TUSB_HOST_HID_MOUSE 0
|
||||||
#define CFG_TUSB_HOST_HID_GENERIC 0 // (not yet supported)
|
#define CFG_TUSB_HOST_HID_GENERIC 0 // (not yet supported)
|
||||||
#define CFG_TUSB_HOST_MSC 0
|
#define CFG_TUSB_HOST_MSC 0
|
||||||
#define CFG_TUSB_HOST_CDC 0
|
#define CFG_TUSB_HOST_CDC 1
|
||||||
|
|
||||||
#define CFG_TUSB_HOST_DEVICE_MAX (CFG_TUSB_HOST_HUB ? 5 : 1) // normal hub has 4 ports
|
#define CFG_TUSB_HOST_DEVICE_MAX (CFG_TUSB_HOST_HUB ? 5 : 1) // normal hub has 4 ports
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ void cdch_init(void)
|
|||||||
|
|
||||||
tusb_error_t cdch_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_interface_desc, uint16_t *p_length)
|
tusb_error_t cdch_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_interface_desc, uint16_t *p_length)
|
||||||
{
|
{
|
||||||
OSAL_SUBTASK_BEGIN
|
//OSAL_SUBTASK_BEGIN
|
||||||
// TODO change following assert to subtask_assert
|
// TODO change following assert to subtask_assert
|
||||||
|
|
||||||
if ( CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL != p_interface_desc->bInterfaceSubClass) return TUSB_ERROR_CDC_UNSUPPORTED_SUBCLASS;
|
if ( CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL != p_interface_desc->bInterfaceSubClass) return TUSB_ERROR_CDC_UNSUPPORTED_SUBCLASS;
|
||||||
@ -218,7 +218,7 @@ tusb_error_t cdch_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_
|
|||||||
tuh_cdc_mounted_cb(dev_addr);
|
tuh_cdc_mounted_cb(dev_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
OSAL_SUBTASK_END
|
//OSAL_SUBTASK_END
|
||||||
}
|
}
|
||||||
|
|
||||||
void cdch_isr(pipe_handle_t pipe_hdl, xfer_result_t event, uint32_t xferred_bytes)
|
void cdch_isr(pipe_handle_t pipe_hdl, xfer_result_t event, uint32_t xferred_bytes)
|
||||||
|
@ -96,15 +96,14 @@ static inline void osal_semaphore_reset(osal_semaphore_t sem_hdl)
|
|||||||
sem_hdl->count = 0;
|
sem_hdl->count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline tusb_error_t osal_semaphore_wait(osal_semaphore_t sem_hdl, uint32_t msec) {
|
static inline tusb_error_t osal_semaphore_wait(osal_semaphore_t sem_hdl, uint32_t msec)
|
||||||
|
{
|
||||||
(void) msec;
|
(void) msec;
|
||||||
while (true) {
|
|
||||||
while (sem_hdl->count == 0) { }
|
// TODO blocking for now
|
||||||
if (sem_hdl->count == 0) {
|
while (sem_hdl->count == 0) { }
|
||||||
sem_hdl->count--;
|
sem_hdl->count--;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return TUSB_ERROR_NONE;
|
return TUSB_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user