mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-07 05:54:11 +08:00
Additional fix related to issue #1018. Corrects the usage of TU_ATTR_WEAK for the Keil
compiler for the callback functions: * tud_descriptor_bos_cb() * tud_vendor_control_xfer_cb() * tud_mount_cb() * tud_umount_cb() * tud_suspend_cb() * tud_resume_cb() Without the fix for the first two functions, the USB device won't enumerate properly, if the device makes use of a BOS description. For example when using a Microsoft OS 2.0 platform capability descriptor to set a specific Device Interface GUID for WinUSB. The fix for the other four functions were added, because it's probably just a matter of time before someone runs into the same problem with those callback functions.
This commit is contained in:
parent
c48d2eba0d
commit
d040644b6c
@ -55,6 +55,30 @@ TU_ATTR_WEAK void tud_sof_cb(uint32_t frame_count) {
|
|||||||
(void)frame_count;
|
(void)frame_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TU_ATTR_WEAK uint8_t const * tud_descriptor_bos_cb(void) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
TU_ATTR_WEAK void tud_mount_cb(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
TU_ATTR_WEAK void tud_umount_cb(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
TU_ATTR_WEAK void tud_suspend_cb(bool remote_wakeup_en) {
|
||||||
|
(void)remote_wakeup_en;
|
||||||
|
}
|
||||||
|
|
||||||
|
TU_ATTR_WEAK void tud_resume_cb(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
TU_ATTR_WEAK bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request) {
|
||||||
|
(void)rhport;
|
||||||
|
(void)stage;
|
||||||
|
(void)request;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
TU_ATTR_WEAK bool dcd_deinit(uint8_t rhport) {
|
TU_ATTR_WEAK bool dcd_deinit(uint8_t rhport) {
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
return false;
|
return false;
|
||||||
@ -557,7 +581,7 @@ void tud_task_ext(uint32_t timeout_ms, bool in_isr) {
|
|||||||
case DCD_EVENT_UNPLUGGED:
|
case DCD_EVENT_UNPLUGGED:
|
||||||
TU_LOG_USBD("\r\n");
|
TU_LOG_USBD("\r\n");
|
||||||
usbd_reset(event.rhport);
|
usbd_reset(event.rhport);
|
||||||
if (tud_umount_cb) tud_umount_cb();
|
tud_umount_cb();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DCD_EVENT_SETUP_RECEIVED:
|
case DCD_EVENT_SETUP_RECEIVED:
|
||||||
@ -617,7 +641,7 @@ void tud_task_ext(uint32_t timeout_ms, bool in_isr) {
|
|||||||
// e.g suspend -> resume -> unplug/plug. Skip suspend/resume if not connected
|
// e.g suspend -> resume -> unplug/plug. Skip suspend/resume if not connected
|
||||||
if (_usbd_dev.connected) {
|
if (_usbd_dev.connected) {
|
||||||
TU_LOG_USBD(": Remote Wakeup = %u\r\n", _usbd_dev.remote_wakeup_en);
|
TU_LOG_USBD(": Remote Wakeup = %u\r\n", _usbd_dev.remote_wakeup_en);
|
||||||
if (tud_suspend_cb) tud_suspend_cb(_usbd_dev.remote_wakeup_en);
|
tud_suspend_cb(_usbd_dev.remote_wakeup_en);
|
||||||
} else {
|
} else {
|
||||||
TU_LOG_USBD(" Skipped\r\n");
|
TU_LOG_USBD(" Skipped\r\n");
|
||||||
}
|
}
|
||||||
@ -626,7 +650,7 @@ void tud_task_ext(uint32_t timeout_ms, bool in_isr) {
|
|||||||
case DCD_EVENT_RESUME:
|
case DCD_EVENT_RESUME:
|
||||||
if (_usbd_dev.connected) {
|
if (_usbd_dev.connected) {
|
||||||
TU_LOG_USBD("\r\n");
|
TU_LOG_USBD("\r\n");
|
||||||
if (tud_resume_cb) tud_resume_cb();
|
tud_resume_cb();
|
||||||
} else {
|
} else {
|
||||||
TU_LOG_USBD(" Skipped\r\n");
|
TU_LOG_USBD(" Skipped\r\n");
|
||||||
}
|
}
|
||||||
@ -758,9 +782,9 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
|
|||||||
_usbd_dev.cfg_num = 0;
|
_usbd_dev.cfg_num = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ( tud_mount_cb ) tud_mount_cb();
|
tud_mount_cb();
|
||||||
} else {
|
} else {
|
||||||
if ( tud_umount_cb ) tud_umount_cb();
|
tud_umount_cb();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid);
|
|||||||
|
|
||||||
// Invoked when received GET BOS DESCRIPTOR request
|
// Invoked when received GET BOS DESCRIPTOR request
|
||||||
// Application return pointer to descriptor
|
// Application return pointer to descriptor
|
||||||
TU_ATTR_WEAK uint8_t const * tud_descriptor_bos_cb(void);
|
uint8_t const * tud_descriptor_bos_cb(void);
|
||||||
|
|
||||||
// Invoked when received GET DEVICE QUALIFIER DESCRIPTOR request
|
// Invoked when received GET DEVICE QUALIFIER DESCRIPTOR request
|
||||||
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete.
|
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete.
|
||||||
@ -140,17 +140,17 @@ TU_ATTR_WEAK uint8_t const* tud_descriptor_device_qualifier_cb(void);
|
|||||||
TU_ATTR_WEAK uint8_t const* tud_descriptor_other_speed_configuration_cb(uint8_t index);
|
TU_ATTR_WEAK uint8_t const* tud_descriptor_other_speed_configuration_cb(uint8_t index);
|
||||||
|
|
||||||
// Invoked when device is mounted (configured)
|
// Invoked when device is mounted (configured)
|
||||||
TU_ATTR_WEAK void tud_mount_cb(void);
|
void tud_mount_cb(void);
|
||||||
|
|
||||||
// Invoked when device is unmounted
|
// Invoked when device is unmounted
|
||||||
TU_ATTR_WEAK void tud_umount_cb(void);
|
void tud_umount_cb(void);
|
||||||
|
|
||||||
// Invoked when usb bus is suspended
|
// Invoked when usb bus is suspended
|
||||||
// Within 7ms, device must draw an average of current less than 2.5 mA from bus
|
// Within 7ms, device must draw an average of current less than 2.5 mA from bus
|
||||||
TU_ATTR_WEAK void tud_suspend_cb(bool remote_wakeup_en);
|
void tud_suspend_cb(bool remote_wakeup_en);
|
||||||
|
|
||||||
// Invoked when usb bus is resumed
|
// Invoked when usb bus is resumed
|
||||||
TU_ATTR_WEAK void tud_resume_cb(void);
|
void tud_resume_cb(void);
|
||||||
|
|
||||||
// Invoked when there is a new usb event, which need to be processed by tud_task()/tud_task_ext()
|
// Invoked when there is a new usb event, which need to be processed by tud_task()/tud_task_ext()
|
||||||
void tud_event_hook_cb(uint8_t rhport, uint32_t eventid, bool in_isr);
|
void tud_event_hook_cb(uint8_t rhport, uint32_t eventid, bool in_isr);
|
||||||
@ -159,7 +159,7 @@ void tud_event_hook_cb(uint8_t rhport, uint32_t eventid, bool in_isr);
|
|||||||
void tud_sof_cb(uint32_t frame_count);
|
void tud_sof_cb(uint32_t frame_count);
|
||||||
|
|
||||||
// Invoked when received control request with VENDOR TYPE
|
// Invoked when received control request with VENDOR TYPE
|
||||||
TU_ATTR_WEAK bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request);
|
bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request);
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// Binary Device Object Store (BOS) Descriptor Templates
|
// Binary Device Object Store (BOS) Descriptor Templates
|
||||||
|
Loading…
x
Reference in New Issue
Block a user