summaryrefslogtreecommitdiff
path: root/src/device/usbd_pvt.h
diff options
context:
space:
mode:
authorhathach <[email protected]>2018-07-14 15:12:42 +0700
committerhathach <[email protected]>2018-07-14 15:12:42 +0700
commite0c4e11ea343e0189ccaa45591f42670962490fe (patch)
tree61c45fe8525268e484ead82a37a304bcdc823848 /src/device/usbd_pvt.h
parent7a1f40593f984d37d602cdf6457d0f8c6f7c01d7 (diff)
use _usbd_ctrl_buf for control transferm refactor cdc device
Diffstat (limited to 'src/device/usbd_pvt.h')
-rw-r--r--src/device/usbd_pvt.h31
1 files changed, 13 insertions, 18 deletions
diff --git a/src/device/usbd_pvt.h b/src/device/usbd_pvt.h
index 452df5934..f30cb943e 100644
--- a/src/device/usbd_pvt.h
+++ b/src/device/usbd_pvt.h
@@ -44,14 +44,7 @@
// for used by usbd_control_xfer_st() only, must not be used directly
extern osal_semaphore_t _usbd_ctrl_sem;
-
-
-typedef struct
-{
- uint8_t itf_num;
- uint8_t ep_count;
- uint8_t ep_arr[1];
-}usbd_itf_t;
+extern uint8_t _usbd_ctrl_buf[CFG_TUD_CTRL_BUFSIZE];
//--------------------------------------------------------------------+
// INTERNAL API for stack management
@@ -67,16 +60,18 @@ tusb_error_t usbd_open_edpt_pair(uint8_t rhport, tusb_desc_endpoint_t const* p_d
// 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, (uint8_t*) _buffer, _len);\
- osal_semaphore_wait( _usbd_ctrl_sem, OSAL_TIMEOUT_CONTROL_XFER, &err );\
- STASK_ASSERT_ERR( err );\
- }\
- /* No need to wait for status to complete therefore */ \
- dcd_control_status(_rhport, _dir);\
+#define usbd_control_xfer_st(_rhport, _dir, _buffer, _len) \
+ do { \
+ if (_len) { \
+ tusb_error_t err; \
+ if ( _dir ) memcpy(_usbd_ctrl_buf, _buffer, _len); \
+ dcd_control_xfer(_rhport, _dir, _usbd_ctrl_buf, _len); \
+ osal_semaphore_wait( _usbd_ctrl_sem, OSAL_TIMEOUT_CONTROL_XFER, &err ); \
+ STASK_ASSERT_ERR( err ); \
+ if (!_dir) memcpy((uint8_t*) _buffer, _usbd_ctrl_buf, _len); \
+ } \
+ dcd_control_status(_rhport, _dir); \
+ /* No need to wait for status phase to complete */ \
}while(0)