Skip to content

Commit 37592da

Browse files
committed
usbd: support set EP0 buffer size
Signed-off-by: HiFiPhile <[email protected]>
1 parent d4fa891 commit 37592da

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/device/usbd_control.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ typedef struct {
6060
static usbd_control_xfer_t _ctrl_xfer;
6161

6262
CFG_TUD_MEM_SECTION static struct {
63-
TUD_EPBUF_DEF(buf, CFG_TUD_ENDPOINT0_SIZE);
63+
TUD_EPBUF_DEF(buf, CFG_TUD_EP0_BUFSIZE);
6464
} _ctrl_epbuf;
6565

6666
//--------------------------------------------------------------------+
@@ -88,13 +88,13 @@ bool tud_control_status(uint8_t rhport, const tusb_control_request_t* request) {
8888
// Each transaction has up to Endpoint0's max packet size.
8989
// This function can also transfer an zero-length packet
9090
static bool data_stage_xact(uint8_t rhport) {
91-
const uint16_t xact_len = tu_min16(_ctrl_xfer.data_len - _ctrl_xfer.total_xferred, CFG_TUD_ENDPOINT0_SIZE);
91+
const uint16_t xact_len = tu_min16(_ctrl_xfer.data_len - _ctrl_xfer.total_xferred, CFG_TUD_EP0_BUFSIZE);
9292
uint8_t ep_addr = EDPT_CTRL_OUT;
9393

9494
if (_ctrl_xfer.request.bmRequestType_bit.direction == TUSB_DIR_IN) {
9595
ep_addr = EDPT_CTRL_IN;
9696
if (xact_len) {
97-
TU_VERIFY(0 == tu_memcpy_s(_ctrl_epbuf.buf, CFG_TUD_ENDPOINT0_SIZE, _ctrl_xfer.buffer, xact_len));
97+
TU_VERIFY(0 == tu_memcpy_s(_ctrl_epbuf.buf, CFG_TUD_EP0_BUFSIZE, _ctrl_xfer.buffer, xact_len));
9898
}
9999
}
100100

@@ -179,7 +179,7 @@ bool usbd_control_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result,
179179
// Data Stage is complete when all request's length are transferred or
180180
// a short packet is sent including zero-length packet.
181181
if ((_ctrl_xfer.request.wLength == _ctrl_xfer.total_xferred) ||
182-
(xferred_bytes < CFG_TUD_ENDPOINT0_SIZE)) {
182+
(xferred_bytes < CFG_TUD_EP0_BUFSIZE)) {
183183
// DATA stage is complete
184184
bool is_ok = true;
185185

src/tusb_option.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,10 @@
482482
#define CFG_TUD_ENDPOINT0_SIZE 64
483483
#endif
484484

485+
#ifndef CFG_TUD_EP0_BUFSIZE
486+
#define CFG_TUD_EP0_BUFSIZE CFG_TUD_ENDPOINT0_SIZE
487+
#endif
488+
485489
#ifndef CFG_TUD_INTERFACE_MAX
486490
#define CFG_TUD_INTERFACE_MAX 16
487491
#endif

0 commit comments

Comments
 (0)