diff options
| author | hathach <[email protected]> | 2018-03-31 14:09:48 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2018-03-31 14:09:48 +0700 |
| commit | 7a77aed8fa67cf6740943cf25a00485d4f288cfb (patch) | |
| tree | b2579f69d1bd263ceed4701193412df5da7ff6c3 /tinyusb/device/usbd_pvt.h | |
| parent | f1f7153b3b469d2565d5f5b5b8feb932ad219b98 (diff) | |
change usbd_control_xfer_st from function to macro to prevent compiler issue with substask
Diffstat (limited to 'tinyusb/device/usbd_pvt.h')
| -rw-r--r-- | tinyusb/device/usbd_pvt.h | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/tinyusb/device/usbd_pvt.h b/tinyusb/device/usbd_pvt.h index 07d941d1c..cf1d822b2 100644 --- a/tinyusb/device/usbd_pvt.h +++ b/tinyusb/device/usbd_pvt.h @@ -41,6 +41,9 @@ extern "C" { #endif +// for used by usbd_control_xfer_st() only, must not be used directly +extern osal_semaphore_t _usbd_ctrl_sem; + //--------------------------------------------------------------------+ // INTERNAL API //--------------------------------------------------------------------+ @@ -48,7 +51,25 @@ tusb_error_t usbd_init(void); void usbd_task( void* param); // Carry out Data and Status stage of control transfer -tusb_error_t usbd_control_xfer_st(uint8_t rhport, tusb_dir_t dir, uint8_t * buffer, uint16_t length); +//tusb_error_t usbd_control_xfer_st(uint8_t rhport, tusb_dir_t dir, uint8_t * buffer, uint16_t length); + +// Carry out Data and Status stage of control transfer +// Must be call in a subtask (_st) function +#define usbd_control_xfer_st(_rhport, _dir, _buffer, _len) \ + do {\ + if (_len) { \ + tusb_error_t err;\ + dcd_control_xfer(_rhport, _dir, _buffer, _len);\ + osal_semaphore_wait( _usbd_ctrl_sem, OSAL_TIMEOUT_NORMAL, &err );\ + STASK_ASSERT_ERR( err );\ + }\ + /* No need to wait for status to complete therefore */ \ + /* status phase must not call dcd_control_complete/dcd_xfer_complete*/ \ + dcd_control_status(_rhport, _dir);\ + }while(0) + + + #ifdef __cplusplus } |
