mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-06 03:40:18 +00:00
add CFG_TUH_API_EDPT_XFER to enable generic edpt xfer
This commit is contained in:
parent
55428d7dd2
commit
9dd2f11f4a
@ -81,11 +81,11 @@
|
|||||||
// 1 hub typically has 4 ports
|
// 1 hub typically has 4 ports
|
||||||
#define CFG_TUH_DEVICE_MAX (CFG_TUH_HUB ? 4 : 1)
|
#define CFG_TUH_DEVICE_MAX (CFG_TUH_HUB ? 4 : 1)
|
||||||
|
|
||||||
#define CFG_TUH_ENDPOINT_MAX 8
|
// Max endpoint per device
|
||||||
|
#define CFG_TUH_ENDPOINT_MAX 8
|
||||||
|
|
||||||
//------------- HID -------------//
|
// Enable tuh_edpt_xfer() API
|
||||||
|
#define CFG_TUH_API_EDPT_XFER 1
|
||||||
#define CFG_TUH_HID_EP_BUFSIZE 64
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -109,8 +109,15 @@ typedef struct {
|
|||||||
|
|
||||||
tu_edpt_state_t ep_status[CFG_TUH_ENDPOINT_MAX][2];
|
tu_edpt_state_t ep_status[CFG_TUH_ENDPOINT_MAX][2];
|
||||||
|
|
||||||
#if CFG_TUH_BARE
|
#if CFG_TUH_API_EDPT_XFER
|
||||||
|
// struct
|
||||||
|
// {
|
||||||
|
// uint8_t* buffer;
|
||||||
|
// tuh_xfer_cb_t complete_cb;
|
||||||
|
// uintptr_t user_arg;
|
||||||
|
//
|
||||||
|
// volatile uint16_t actual_len;
|
||||||
|
// }ep_xfer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} usbh_device_t;
|
} usbh_device_t;
|
||||||
@ -240,6 +247,16 @@ static osal_queue_t _usbh_q;
|
|||||||
CFG_TUSB_MEM_SECTION CFG_TUSB_MEM_ALIGN
|
CFG_TUSB_MEM_SECTION CFG_TUSB_MEM_ALIGN
|
||||||
static uint8_t _usbh_ctrl_buf[CFG_TUH_ENUMERATION_BUFSIZE];
|
static uint8_t _usbh_ctrl_buf[CFG_TUH_ENUMERATION_BUFSIZE];
|
||||||
|
|
||||||
|
//// internal version of tuh_xfer_t
|
||||||
|
//typedef struct
|
||||||
|
//{
|
||||||
|
// uint8_t* buffer;
|
||||||
|
// tuh_xfer_cb_t complete_cb;
|
||||||
|
// uintptr_t user_arg;
|
||||||
|
//
|
||||||
|
// volatile uint16_t actual_len;
|
||||||
|
//}usbh_xfer_t;
|
||||||
|
|
||||||
// Control transfer: since most controller does not support multiple control transfer
|
// Control transfer: since most controller does not support multiple control transfer
|
||||||
// on multiple devices concurrently. And control transfer is not used much except enumeration
|
// on multiple devices concurrently. And control transfer is not used much except enumeration
|
||||||
// We will only execute control transfer one at a time.
|
// We will only execute control transfer one at a time.
|
||||||
@ -890,6 +907,19 @@ static void _control_blocking_complete_cb(uint8_t daddr, tuh_xfer_t* xfer)
|
|||||||
*((xfer_result_t*) xfer->user_arg) = xfer->result;
|
*((xfer_result_t*) xfer->user_arg) = xfer->result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool tuh_control_xfer_sync(uint8_t daddr, tuh_xfer_t* xfer, uint32_t timeout_ms)
|
||||||
|
{
|
||||||
|
(void) timeout_ms;
|
||||||
|
|
||||||
|
// clear callback for sync
|
||||||
|
xfer->complete_cb = NULL;
|
||||||
|
|
||||||
|
// TODO use timeout to wait
|
||||||
|
TU_VERIFY(tuh_control_xfer(daddr, xfer));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool tuh_control_xfer (uint8_t daddr, tuh_xfer_t* xfer)
|
bool tuh_control_xfer (uint8_t daddr, tuh_xfer_t* xfer)
|
||||||
{
|
{
|
||||||
// pre-check to help reducing mutex lock
|
// pre-check to help reducing mutex lock
|
||||||
@ -956,19 +986,6 @@ bool tuh_control_xfer (uint8_t daddr, tuh_xfer_t* xfer)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tuh_control_xfer_sync(uint8_t daddr, tuh_xfer_t* xfer, uint32_t timeout_ms)
|
|
||||||
{
|
|
||||||
(void) timeout_ms;
|
|
||||||
|
|
||||||
// clear callback for sync
|
|
||||||
xfer->complete_cb = NULL;
|
|
||||||
|
|
||||||
// TODO use timeout to wait
|
|
||||||
TU_VERIFY(tuh_control_xfer(daddr, xfer));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
TU_ATTR_ALWAYS_INLINE static inline void _set_control_xfer_stage(uint8_t stage)
|
TU_ATTR_ALWAYS_INLINE static inline void _set_control_xfer_stage(uint8_t stage)
|
||||||
{
|
{
|
||||||
usbh_lock();
|
usbh_lock();
|
||||||
|
@ -113,13 +113,17 @@ static inline bool tuh_ready(uint8_t daddr)
|
|||||||
// Endpoint Asynchronous (non-blocking)
|
// Endpoint Asynchronous (non-blocking)
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
// Carry out a control transfer
|
// Submit a control transfer
|
||||||
// true on success, false if there is on-going control transfer or incorrect parameters
|
// true on success, false if there is on-going control transfer or incorrect parameters
|
||||||
// Note: blocking if complete callback is NULL. In this case 'xfer->result' will be updated
|
// Note: blocking if complete callback is NULL. In this case 'xfer->result' will be updated
|
||||||
// and if 'user_arg' point to a xfer_result_t variable, it will be updated as well.
|
// and if 'user_arg' point to a xfer_result_t variable, it will be updated as well.
|
||||||
bool tuh_control_xfer(uint8_t daddr, tuh_xfer_t* xfer);
|
bool tuh_control_xfer(uint8_t daddr, tuh_xfer_t* xfer);
|
||||||
|
|
||||||
//bool tuh_edpt_xfer(uint8_t daddr, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes);
|
// Submit a bulk/interrupt transfer
|
||||||
|
// true on success, false if there is on-going control transfer or incorrect parameters
|
||||||
|
// Note: blocking if complete callback is NULL. In this case 'xfer->result' will be updated
|
||||||
|
// and if 'user_arg' point to a xfer_result_t variable, it will be updated as well.
|
||||||
|
bool tuh_edpt_xfer(uint8_t daddr, tuh_xfer_t* xfer);
|
||||||
|
|
||||||
// Set Configuration (control transfer)
|
// Set Configuration (control transfer)
|
||||||
// config_num = 0 will un-configure device. Note: config_num = config_descriptor_index + 1
|
// config_num = 0 will un-configure device. Note: config_num = config_descriptor_index + 1
|
||||||
|
@ -392,6 +392,10 @@
|
|||||||
#define CFG_TUH_VENDOR 0
|
#define CFG_TUH_VENDOR 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef CFG_TUH_API_EDPT_XFER
|
||||||
|
#define CFG_TUH_API_EDPT_XFER 0
|
||||||
|
#endif
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Configuration Validation
|
// Configuration Validation
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user