summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/device/board_test/src/tusb_config.h2
-rw-r--r--examples/device/cdc_msc/src/tusb_config.h4
-rw-r--r--examples/device/cdc_msc/src/usb_descriptors.c2
-rw-r--r--examples/device/cdc_msc_hid_freertos/src/tusb_config.h4
-rw-r--r--examples/device/cdc_msc_hid_freertos/src/usb_descriptors.c2
-rw-r--r--examples/device/hid_composite/src/tusb_config.h4
-rw-r--r--examples/device/hid_composite/src/usb_descriptors.c2
-rw-r--r--examples/device/hid_generic_inout/src/tusb_config.h4
-rw-r--r--examples/device/hid_generic_inout/src/usb_descriptors.c2
-rw-r--r--examples/device/midi_test/src/tusb_config.h4
-rw-r--r--examples/device/midi_test/src/usb_descriptors.c2
-rw-r--r--examples/device/msc_dual_lun/src/tusb_config.h4
-rw-r--r--examples/device/msc_dual_lun/src/usb_descriptors.c2
-rw-r--r--examples/device/usbtmc/src/tusb_config.h2
-rw-r--r--examples/device/usbtmc/src/usb_descriptors.c2
-rw-r--r--examples/device/webusb_serial/src/tusb_config.h4
-rw-r--r--examples/device/webusb_serial/src/usb_descriptors.c2
-rw-r--r--src/device/usbd_control.c333
-rw-r--r--src/portable/nxp/lpc17_40/dcd_lpc17_40.c4
-rw-r--r--src/portable/nxp/lpc18_43/dcd_lpc18_43.c2
20 files changed, 194 insertions, 193 deletions
diff --git a/examples/device/board_test/src/tusb_config.h b/examples/device/board_test/src/tusb_config.h
index 5c3cac83a..2f2a4deeb 100644
--- a/examples/device/board_test/src/tusb_config.h
+++ b/examples/device/board_test/src/tusb_config.h
@@ -64,7 +64,7 @@
// DEVICE CONFIGURATION
//--------------------------------------------------------------------
-#define CFG_TUD_ENDOINT0_SIZE 64
+#define CFG_TUD_ENDPOINT0_SIZE 64
//------------- CLASS -------------//
#define CFG_TUD_CDC 0
diff --git a/examples/device/cdc_msc/src/tusb_config.h b/examples/device/cdc_msc/src/tusb_config.h
index e307870ed..4455f665e 100644
--- a/examples/device/cdc_msc/src/tusb_config.h
+++ b/examples/device/cdc_msc/src/tusb_config.h
@@ -68,8 +68,8 @@
//--------------------------------------------------------------------
// DEVICE CONFIGURATION
//--------------------------------------------------------------------
-#ifndef CFG_TUD_ENDOINT0_SIZE
-#define CFG_TUD_ENDOINT0_SIZE 64
+#ifndef CFG_TUD_ENDPOINT0_SIZE
+#define CFG_TUD_ENDPOINT0_SIZE 64
#endif
//------------- CLASS -------------//
diff --git a/examples/device/cdc_msc/src/usb_descriptors.c b/examples/device/cdc_msc/src/usb_descriptors.c
index ac8214e37..11d07e9ba 100644
--- a/examples/device/cdc_msc/src/usb_descriptors.c
+++ b/examples/device/cdc_msc/src/usb_descriptors.c
@@ -50,7 +50,7 @@ tusb_desc_device_t const desc_device =
.bDeviceSubClass = MISC_SUBCLASS_COMMON,
.bDeviceProtocol = MISC_PROTOCOL_IAD,
- .bMaxPacketSize0 = CFG_TUD_ENDOINT0_SIZE,
+ .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
.idVendor = 0xCafe,
.idProduct = USB_PID,
diff --git a/examples/device/cdc_msc_hid_freertos/src/tusb_config.h b/examples/device/cdc_msc_hid_freertos/src/tusb_config.h
index 7869e24cc..f84874ab1 100644
--- a/examples/device/cdc_msc_hid_freertos/src/tusb_config.h
+++ b/examples/device/cdc_msc_hid_freertos/src/tusb_config.h
@@ -69,8 +69,8 @@
// DEVICE CONFIGURATION
//--------------------------------------------------------------------
-#ifndef CFG_TUD_ENDOINT0_SIZE
-#define CFG_TUD_ENDOINT0_SIZE 64
+#ifndef CFG_TUD_ENDPOINT0_SIZE
+#define CFG_TUD_ENDPOINT0_SIZE 64
#endif
//------------- CLASS -------------//
diff --git a/examples/device/cdc_msc_hid_freertos/src/usb_descriptors.c b/examples/device/cdc_msc_hid_freertos/src/usb_descriptors.c
index 5d93cc2f6..d60c9a585 100644
--- a/examples/device/cdc_msc_hid_freertos/src/usb_descriptors.c
+++ b/examples/device/cdc_msc_hid_freertos/src/usb_descriptors.c
@@ -57,7 +57,7 @@ tusb_desc_device_t const desc_device =
.bDeviceProtocol = 0x00,
#endif
- .bMaxPacketSize0 = CFG_TUD_ENDOINT0_SIZE,
+ .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
.idVendor = 0xCafe,
.idProduct = USB_PID,
diff --git a/examples/device/hid_composite/src/tusb_config.h b/examples/device/hid_composite/src/tusb_config.h
index 13ecfa415..8d29f10be 100644
--- a/examples/device/hid_composite/src/tusb_config.h
+++ b/examples/device/hid_composite/src/tusb_config.h
@@ -69,8 +69,8 @@
// DEVICE CONFIGURATION
//--------------------------------------------------------------------
-#ifndef CFG_TUD_ENDOINT0_SIZE
-#define CFG_TUD_ENDOINT0_SIZE 64
+#ifndef CFG_TUD_ENDPOINT0_SIZE
+#define CFG_TUD_ENDPOINT0_SIZE 64
#endif
//------------- CLASS -------------//
diff --git a/examples/device/hid_composite/src/usb_descriptors.c b/examples/device/hid_composite/src/usb_descriptors.c
index 678b7528b..01f2cb59b 100644
--- a/examples/device/hid_composite/src/usb_descriptors.c
+++ b/examples/device/hid_composite/src/usb_descriptors.c
@@ -47,7 +47,7 @@ tusb_desc_device_t const desc_device =
.bDeviceClass = 0x00,
.bDeviceSubClass = 0x00,
.bDeviceProtocol = 0x00,
- .bMaxPacketSize0 = CFG_TUD_ENDOINT0_SIZE,
+ .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
.idVendor = 0xCafe,
.idProduct = USB_PID,
diff --git a/examples/device/hid_generic_inout/src/tusb_config.h b/examples/device/hid_generic_inout/src/tusb_config.h
index c82588c2f..a7ce7acf8 100644
--- a/examples/device/hid_generic_inout/src/tusb_config.h
+++ b/examples/device/hid_generic_inout/src/tusb_config.h
@@ -69,8 +69,8 @@
// DEVICE CONFIGURATION
//--------------------------------------------------------------------
-#ifndef CFG_TUD_ENDOINT0_SIZE
-#define CFG_TUD_ENDOINT0_SIZE 64
+#ifndef CFG_TUD_ENDPOINT0_SIZE
+#define CFG_TUD_ENDPOINT0_SIZE 64
#endif
//------------- CLASS -------------//
diff --git a/examples/device/hid_generic_inout/src/usb_descriptors.c b/examples/device/hid_generic_inout/src/usb_descriptors.c
index d0fc6b1bc..07989c5fd 100644
--- a/examples/device/hid_generic_inout/src/usb_descriptors.c
+++ b/examples/device/hid_generic_inout/src/usb_descriptors.c
@@ -46,7 +46,7 @@ tusb_desc_device_t const desc_device =
.bDeviceClass = 0x00,
.bDeviceSubClass = 0x00,
.bDeviceProtocol = 0x00,
- .bMaxPacketSize0 = CFG_TUD_ENDOINT0_SIZE,
+ .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
.idVendor = 0xCafe,
.idProduct = USB_PID,
diff --git a/examples/device/midi_test/src/tusb_config.h b/examples/device/midi_test/src/tusb_config.h
index 4a84812c5..fcd6b97c2 100644
--- a/examples/device/midi_test/src/tusb_config.h
+++ b/examples/device/midi_test/src/tusb_config.h
@@ -69,8 +69,8 @@
// DEVICE CONFIGURATION
//--------------------------------------------------------------------
-#ifndef CFG_TUD_ENDOINT0_SIZE
-#define CFG_TUD_ENDOINT0_SIZE 64
+#ifndef CFG_TUD_ENDPOINT0_SIZE
+#define CFG_TUD_ENDPOINT0_SIZE 64
#endif
//------------- CLASS -------------//
diff --git a/examples/device/midi_test/src/usb_descriptors.c b/examples/device/midi_test/src/usb_descriptors.c
index 7cebc6a15..2305c9f68 100644
--- a/examples/device/midi_test/src/usb_descriptors.c
+++ b/examples/device/midi_test/src/usb_descriptors.c
@@ -46,7 +46,7 @@ tusb_desc_device_t const desc_device =
.bDeviceClass = 0x00,
.bDeviceSubClass = 0x00,
.bDeviceProtocol = 0x00,
- .bMaxPacketSize0 = CFG_TUD_ENDOINT0_SIZE,
+ .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
.idVendor = 0xCafe,
.idProduct = USB_PID,
diff --git a/examples/device/msc_dual_lun/src/tusb_config.h b/examples/device/msc_dual_lun/src/tusb_config.h
index 073e2379f..b45e9c4dc 100644
--- a/examples/device/msc_dual_lun/src/tusb_config.h
+++ b/examples/device/msc_dual_lun/src/tusb_config.h
@@ -69,8 +69,8 @@
// DEVICE CONFIGURATION
//--------------------------------------------------------------------
-#ifndef CFG_TUD_ENDOINT0_SIZE
-#define CFG_TUD_ENDOINT0_SIZE 64
+#ifndef CFG_TUD_ENDPOINT0_SIZE
+#define CFG_TUD_ENDPOINT0_SIZE 64
#endif
//------------- CLASS -------------//
diff --git a/examples/device/msc_dual_lun/src/usb_descriptors.c b/examples/device/msc_dual_lun/src/usb_descriptors.c
index cab37cf1f..e0a5904a4 100644
--- a/examples/device/msc_dual_lun/src/usb_descriptors.c
+++ b/examples/device/msc_dual_lun/src/usb_descriptors.c
@@ -46,7 +46,7 @@ tusb_desc_device_t const desc_device =
.bDeviceClass = 0x00,
.bDeviceSubClass = 0x00,
.bDeviceProtocol = 0x00,
- .bMaxPacketSize0 = CFG_TUD_ENDOINT0_SIZE,
+ .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
.idVendor = 0xCafe,
.idProduct = USB_PID,
diff --git a/examples/device/usbtmc/src/tusb_config.h b/examples/device/usbtmc/src/tusb_config.h
index c20b05fbb..9141e6a5a 100644
--- a/examples/device/usbtmc/src/tusb_config.h
+++ b/examples/device/usbtmc/src/tusb_config.h
@@ -51,7 +51,7 @@
// DEVICE CONFIGURATION
//--------------------------------------------------------------------
-#define CFG_TUD_ENDOINT0_SIZE 64
+#define CFG_TUD_ENDPOINT0_SIZE 64
//------------- CLASS -------------//
diff --git a/examples/device/usbtmc/src/usb_descriptors.c b/examples/device/usbtmc/src/usb_descriptors.c
index 1175ebb99..27e1bdaa9 100644
--- a/examples/device/usbtmc/src/usb_descriptors.c
+++ b/examples/device/usbtmc/src/usb_descriptors.c
@@ -58,7 +58,7 @@ tusb_desc_device_t const desc_device =
.bDeviceProtocol = 0x00,
#endif
- .bMaxPacketSize0 = CFG_TUD_ENDOINT0_SIZE,
+ .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
.idVendor = 0xCafe,
.idProduct = USB_PID,
diff --git a/examples/device/webusb_serial/src/tusb_config.h b/examples/device/webusb_serial/src/tusb_config.h
index b2f09cac0..8a73e8353 100644
--- a/examples/device/webusb_serial/src/tusb_config.h
+++ b/examples/device/webusb_serial/src/tusb_config.h
@@ -69,8 +69,8 @@
// DEVICE CONFIGURATION
//--------------------------------------------------------------------
-#ifndef CFG_TUD_ENDOINT0_SIZE
-#define CFG_TUD_ENDOINT0_SIZE 64
+#ifndef CFG_TUD_ENDPOINT0_SIZE
+#define CFG_TUD_ENDPOINT0_SIZE 64
#endif
//------------- CLASS -------------//
diff --git a/examples/device/webusb_serial/src/usb_descriptors.c b/examples/device/webusb_serial/src/usb_descriptors.c
index a1d5cd9b9..740defe4e 100644
--- a/examples/device/webusb_serial/src/usb_descriptors.c
+++ b/examples/device/webusb_serial/src/usb_descriptors.c
@@ -50,7 +50,7 @@ tusb_desc_device_t const desc_device =
.bDeviceClass = TUSB_CLASS_MISC,
.bDeviceSubClass = MISC_SUBCLASS_COMMON,
.bDeviceProtocol = MISC_PROTOCOL_IAD,
- .bMaxPacketSize0 = CFG_TUD_ENDOINT0_SIZE,
+ .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
.idVendor = 0xCafe,
.idProduct = USB_PID,
diff --git a/src/device/usbd_control.c b/src/device/usbd_control.c
index 5f8751b57..de1075033 100644
--- a/src/device/usbd_control.c
+++ b/src/device/usbd_control.c
@@ -1,166 +1,167 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2019 Ha Thach (tinyusb.org)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * This file is part of the TinyUSB stack.
- */
-
-#include "tusb_option.h"
-
-#if TUSB_OPT_DEVICE_ENABLED
-
-#include "tusb.h"
-#include "device/usbd_pvt.h"
-#include "dcd.h"
-
-enum
-{
- EDPT_CTRL_OUT = 0x00,
- EDPT_CTRL_IN = 0x80
-};
-
-typedef struct
-{
- tusb_control_request_t request;
-
- void* buffer;
- uint16_t len;
- uint16_t total_transferred;
- uint16_t requested_len;
-
- bool (*complete_cb) (uint8_t, tusb_control_request_t const *);
-} usbd_control_xfer_t;
-
-static usbd_control_xfer_t _control_state;
-
-CFG_TUSB_MEM_SECTION CFG_TUSB_MEM_ALIGN uint8_t _usbd_ctrl_buf[CFG_TUD_ENDPOINT0_SIZE];
-
-void usbd_control_reset (uint8_t rhport)
-{
- (void) rhport;
- tu_varclr(&_control_state);
-}
-
-bool tud_control_status(uint8_t rhport, tusb_control_request_t const * request)
-{
- // status direction is reversed to one in the setup packet
- return dcd_edpt_xfer(rhport, request->bmRequestType_bit.direction ? EDPT_CTRL_OUT : EDPT_CTRL_IN, NULL, 0);
-}
-
-// Each transaction is up to endpoint0's max packet size
-static bool start_control_data_xact(uint8_t rhport)
-{
- uint16_t const xact_len = tu_min16(_control_state.len - _control_state.total_transferred, CFG_TUD_ENDPOINT0_SIZE);
-
- uint8_t ep_addr = EDPT_CTRL_OUT;
-
- if ( _control_state.request.bmRequestType_bit.direction == TUSB_DIR_IN )
- {
- ep_addr = EDPT_CTRL_IN;
- memcpy(_usbd_ctrl_buf, _control_state.buffer, xact_len);
- }
-
- return dcd_edpt_xfer(rhport, ep_addr, _usbd_ctrl_buf, xact_len);
-}
-
-// TODO may find a better way
-void usbd_control_set_complete_callback( bool (*fp) (uint8_t, tusb_control_request_t const * ) )
-{
- _control_state.complete_cb = fp;
-}
-
-bool tud_control_xfer(uint8_t rhport, tusb_control_request_t const * request, void* buffer, uint16_t len)
-{
- // transmitted length must be <= requested length (USB 2.0 spec: 8.5.3.1 )
- // FIXME: Should logic be here or in place that calls this function?
- if(len > request->wLength)
- len = request->wLength;
-
- _control_state.request = (*request);
- _control_state.buffer = buffer;
- _control_state.total_transferred = 0;
- _control_state.requested_len = request->wLength;
- _control_state.len = len;
-
- if ( len )
- {
- TU_ASSERT(buffer);
-
- // Data stage
- TU_ASSERT( start_control_data_xact(rhport) );
- }else
- {
- // Status stage
- TU_ASSERT( tud_control_status(rhport, request) );
- }
-
- return true;
-}
-
-// callback when a transaction complete on DATA stage of control endpoint
-bool usbd_control_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes)
-{
- (void) result;
- (void) ep_addr;
-
- if ( _control_state.request.bmRequestType_bit.direction == TUSB_DIR_OUT )
- {
- TU_VERIFY(_control_state.buffer);
- memcpy(_control_state.buffer, _usbd_ctrl_buf, xferred_bytes);
- }
-
- _control_state.total_transferred += xferred_bytes;
- _control_state.buffer = ((uint8_t*)_control_state.buffer) + xferred_bytes;
-
- if ( (_control_state.requested_len == _control_state.total_transferred) || xferred_bytes < CFG_TUD_ENDOINT0_SIZE )
- {
- // DATA stage is complete
- bool is_ok = true;
-
- // invoke complete callback if set
- // callback can still stall control in status phase e.g out data does not make sense
- if ( _control_state.complete_cb )
- {
- is_ok = _control_state.complete_cb(rhport, &_control_state.request);
- }
-
- if ( is_ok )
- {
- // Send status
- TU_ASSERT( tud_control_status(rhport, &_control_state.request) );
- }else
- {
- // Stall both IN and OUT control endpoint
- dcd_edpt_stall(rhport, EDPT_CTRL_OUT);
- dcd_edpt_stall(rhport, EDPT_CTRL_IN);
- }
- }
- else
- {
- // More data to transfer
- TU_ASSERT( start_control_data_xact(rhport) );
- }
-
- return true;
-}
-
-#endif
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "tusb_option.h"
+
+#if TUSB_OPT_DEVICE_ENABLED
+
+#include "tusb.h"
+#include "device/usbd_pvt.h"
+#include "dcd.h"
+
+enum
+{
+ EDPT_CTRL_OUT = 0x00,
+ EDPT_CTRL_IN = 0x80
+};
+
+typedef struct
+{
+ tusb_control_request_t request;
+
+ void* buffer;
+ uint16_t len;
+ uint16_t total_transferred;
+ uint16_t requested_len;
+
+ bool (*complete_cb) (uint8_t, tusb_control_request_t const *);
+} usbd_control_xfer_t;
+
+static usbd_control_xfer_t _control_state;
+
+CFG_TUSB_MEM_SECTION CFG_TUSB_MEM_ALIGN uint8_t _usbd_ctrl_buf[CFG_TUD_ENDPOINT0_SIZE];
+
+void usbd_control_reset (uint8_t rhport)
+{
+ (void) rhport;
+ tu_varclr(&_control_state);
+}
+
+bool tud_control_status(uint8_t rhport, tusb_control_request_t const * request)
+{
+ // status direction is reversed to one in the setup packet
+ return dcd_edpt_xfer(rhport, request->bmRequestType_bit.direction ? EDPT_CTRL_OUT : EDPT_CTRL_IN, NULL, 0);
+}
+
+// Each transaction is up to endpoint0's max packet size
+static bool start_control_data_xact(uint8_t rhport)
+{
+ uint16_t const xact_len = tu_min16(_control_state.len - _control_state.total_transferred, CFG_TUD_ENDPOINT0_SIZE);
+
+ uint8_t ep_addr = EDPT_CTRL_OUT;
+
+ if ( _control_state.request.bmRequestType_bit.direction == TUSB_DIR_IN )
+ {
+ ep_addr = EDPT_CTRL_IN;
+ memcpy(_usbd_ctrl_buf, _control_state.buffer, xact_len);
+ }
+
+ return dcd_edpt_xfer(rhport, ep_addr, _usbd_ctrl_buf, xact_len);
+}
+
+// TODO may find a better way
+void usbd_control_set_complete_callback( bool (*fp) (uint8_t, tusb_control_request_t const * ) )
+{
+ _control_state.complete_cb = fp;
+}
+
+bool tud_control_xfer(uint8_t rhport, tusb_control_request_t const * request, void* buffer, uint16_t len)
+{
+ // transmitted length must be <= requested length (USB 2.0 spec: 8.5.3.1 )
+ // FIXME: Should logic be here or in place that calls this function?
+ if(len > request->wLength)
+ len = request->wLength;
+
+ _control_state.request = (*request);
+ _control_state.buffer = buffer;
+ _control_state.total_transferred = 0;
+ _control_state.requested_len = request->wLength;
+ _control_state.len = len;
+
+ if ( len )
+ {
+ TU_ASSERT(buffer);
+
+ // Data stage
+ TU_ASSERT( start_control_data_xact(rhport) );
+ }else
+ {
+ // Status stage
+ TU_ASSERT( tud_control_status(rhport, request) );
+ }
+
+ return true;
+}
+
+// callback when a transaction complete on DATA stage of control endpoint
+bool usbd_control_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes)
+{
+ (void) result;
+ (void) ep_addr;
+
+ if ( _control_state.request.bmRequestType_bit.direction == TUSB_DIR_OUT )
+ {
+ TU_VERIFY(_control_state.buffer);
+ memcpy(_control_state.buffer, _usbd_ctrl_buf, xferred_bytes);
+ }
+
+ _control_state.total_transferred += xferred_bytes;
+ _control_state.buffer = ((uint8_t*)_control_state.buffer) + xferred_bytes;
+
+ if ( (_control_state.requested_len == _control_state.total_transferred) || xferred_bytes < CFG_TUD_ENDPOINT0_SIZE )
+
+ {
+ // DATA stage is complete
+ bool is_ok = true;
+
+ // invoke complete callback if set
+ // callback can still stall control in status phase e.g out data does not make sense
+ if ( _control_state.complete_cb )
+ {
+ is_ok = _control_state.complete_cb(rhport, &_control_state.request);
+ }
+
+ if ( is_ok )
+ {
+ // Send status
+ TU_ASSERT( tud_control_status(rhport, &_control_state.request) );
+ }else
+ {
+ // Stall both IN and OUT control endpoint
+ dcd_edpt_stall(rhport, EDPT_CTRL_OUT);
+ dcd_edpt_stall(rhport, EDPT_CTRL_IN);
+ }
+ }
+ else
+ {
+ // More data to transfer
+ TU_ASSERT( start_control_data_xact(rhport) );
+ }
+
+ return true;
+}
+
+#endif
diff --git a/src/portable/nxp/lpc17_40/dcd_lpc17_40.c b/src/portable/nxp/lpc17_40/dcd_lpc17_40.c
index d5f90d2a7..8c439616a 100644
--- a/src/portable/nxp/lpc17_40/dcd_lpc17_40.c
+++ b/src/portable/nxp/lpc17_40/dcd_lpc17_40.c
@@ -172,8 +172,8 @@ void dcd_init(uint8_t rhport)
//------------- user manual 11.13 usb device controller initialization -------------//
// step 6 : set up control endpoint
- set_ep_size(0, CFG_TUD_ENDOINT0_SIZE);
- set_ep_size(1, CFG_TUD_ENDOINT0_SIZE);
+ set_ep_size(0, CFG_TUD_ENDPOINT0_SIZE);
+ set_ep_size(1, CFG_TUD_ENDPOINT0_SIZE);
bus_reset();
diff --git a/src/portable/nxp/lpc18_43/dcd_lpc18_43.c b/src/portable/nxp/lpc18_43/dcd_lpc18_43.c
index 519e0dcc6..3619a7c2b 100644
--- a/src/portable/nxp/lpc18_43/dcd_lpc18_43.c
+++ b/src/portable/nxp/lpc18_43/dcd_lpc18_43.c
@@ -115,7 +115,7 @@ static void bus_reset(uint8_t rhport)
//------------- Set up Control Endpoints (0 OUT, 1 IN) -------------//
p_dcd->qhd[0].zero_length_termination = p_dcd->qhd[1].zero_length_termination = 1;
- p_dcd->qhd[0].max_package_size = p_dcd->qhd[1].max_package_size = CFG_TUD_ENDOINT0_SIZE;
+ p_dcd->qhd[0].max_package_size = p_dcd->qhd[1].max_package_size = CFG_TUD_ENDPOINT0_SIZE;
p_dcd->qhd[0].qtd_overlay.next = p_dcd->qhd[1].qtd_overlay.next = QTD_NEXT_INVALID;
p_dcd->qhd[0].int_on_setup = 1; // OUT only