diff --git a/demos/device/device_os_none/.cproject b/demos/device/device_os_none/.cproject
index 9175e195e..2214898d9 100644
--- a/demos/device/device_os_none/.cproject
+++ b/demos/device/device_os_none/.cproject
@@ -30,7 +30,7 @@
-
+
-
+
@@ -62,7 +62,7 @@
-
+
@@ -119,7 +119,7 @@
-
+
-
+
@@ -151,7 +151,7 @@
-
+
@@ -208,7 +208,7 @@
-
+
-
+
@@ -243,7 +243,7 @@
-
+
@@ -302,7 +302,7 @@
-
+
-
+
@@ -334,7 +334,7 @@
-
+
@@ -371,45 +371,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<TargetConfig>
-<Properties property_0="" property_3="NXP" property_4="LPC11U37/401" property_count="5" version="1"/>
-<infoList vendor="NXP"><info chip="LPC11U37/401" match_id="0x00017C40" name="LPC11U37/401" stub="crt_emu_lpc11_13_nxp"><chip><name>LPC11U37/401</name>
-<family>LPC11Uxx</family>
+<Properties property_0="" property_2="LPC18x7_43x7_2x512_BootA.cfx" property_3="NXP" property_4="LPC4357" property_count="5" version="1"/>
+<infoList vendor="NXP"><info chip="LPC4357" flash_driver="LPC18x7_43x7_2x512_BootA.cfx" match_id="0x0" name="LPC4357" stub="crt_emu_lpc18_43_nxp"><chip><name>LPC4357</name>
+<family>LPC43xx</family>
<vendor>NXP (formerly Philips)</vendor>
<reset board="None" core="Real" sys="Real"/>
-<clock changeable="TRUE" freq="12MHz" is_accurate="TRUE"/>
+<clock changeable="TRUE" freq="20MHz" is_accurate="TRUE"/>
<memory can_program="true" id="Flash" is_ro="true" type="Flash"/>
<memory id="RAM" type="RAM"/>
<memory id="Periph" is_volatile="true" type="Peripheral"/>
-<memoryInstance derived_from="Flash" id="MFlash128" location="0x0" size="0x20000"/>
-<memoryInstance derived_from="RAM" id="RamLoc8" location="0x10000000" size="0x2000"/>
-<memoryInstance derived_from="RAM" id="RamUsb2" location="0x20004000" size="0x800"/>
-<prog_flash blocksz="0x1000" location="0x0" maxprgbuff="0x400" progwithcode="TRUE" size="0x20000"/>
-<peripheralInstance derived_from="CM0_NVIC" id="NVIC" location="0xe000e000"/>
-<peripheralInstance derived_from="LPC11U_GPIO" id="GPIO" location="0x50000000"/>
-<peripheralInstance derived_from="LPC11U_USBDEV" id="USB" location="0x40080000"/>
-<peripheralInstance derived_from="CM0_DCR" id="DCR" location="0xe000edf0"/>
-<peripheralInstance derived_from="LPC11U_GPIO_GROUP_INT" id="GPIOGROUP0INT" location="0x40060000"/>
-<peripheralInstance derived_from="LPC11U_GPIO_GROUP_INT" id="GPIOGROUP1INT" location="0x4005c000"/>
-<peripheralInstance derived_from="LPC11U_GPIO_INT" id="GPIOINT" location="0x4004c000"/>
-<peripheralInstance derived_from="LPC11_13_SSP" id="SSP1" location="0x40058000"/>
-<peripheralInstance derived_from="LPC11U_FMC" id="FMC" location="0x4003c000"/>
-<peripheralInstance derived_from="LPC11U_SYSCTL" id="SYSCTL" location="0x40048000"/>
-<peripheralInstance derived_from="LPC11U_IOCON" id="IOCON" location="0x40044000"/>
-<peripheralInstance derived_from="LPC11_13_SSP" id="SSP0" location="0x40040000"/>
-<peripheralInstance derived_from="LPC11_13_PMU" id="PMU" location="0x40038000"/>
-<peripheralInstance derived_from="LPC11_13_ADC" id="ADC" location="0x4001c000"/>
-<peripheralInstance derived_from="LPC11_13_TIMER32" id="TIMER1" location="0x40018000"/>
-<peripheralInstance derived_from="LPC11_13_TIMER32" id="TIMER0" location="0x40014000"/>
-<peripheralInstance derived_from="LPC11_13_TIMER16" id="TMR161" location="0x40010000"/>
-<peripheralInstance derived_from="LPC11_13_TIMER16" id="TMR160" location="0x4000c000"/>
-<peripheralInstance derived_from="LPC1xxx_UART_MODEM" id="UART0" location="0x40008000"/>
-<peripheralInstance derived_from="LPC11_13_WDT" id="WDT" location="0x40004000"/>
-<peripheralInstance derived_from="LPC11_13_I2C" id="I2C0" location="0x40000000"/>
+<memoryInstance derived_from="Flash" id="MFlashA512" location="0x1a000000" size="0x80000"/>
+<memoryInstance derived_from="Flash" id="MFlashB512" location="0x1b000000" size="0x80000"/>
+<memoryInstance derived_from="RAM" id="RamLoc32" location="0x10000000" size="0x8000"/>
+<memoryInstance derived_from="RAM" id="RamLoc40" location="0x10080000" size="0xa000"/>
+<memoryInstance derived_from="RAM" id="RamAHB32" location="0x20000000" size="0x8000"/>
+<memoryInstance derived_from="RAM" id="RamAHB16" location="0x20008000" size="0x4000"/>
+<memoryInstance derived_from="RAM" id="RamAHB_ETB16" location="0x2000c000" size="0x4000"/>
+<prog_flash blocksz="0x2000" location="0x1a000000" maxprgbuff="0x400" progwithcode="TRUE" size="0x10000"/>
+<prog_flash blocksz="0x10000" location="0x1a010000" maxprgbuff="0x400" progwithcode="TRUE" size="0x70000"/>
+<prog_flash blocksz="0x2000" location="0x1b000000" maxprgbuff="0x400" progwithcode="TRUE" size="0x10000"/>
+<prog_flash blocksz="0x10000" location="0x1b010000" maxprgbuff="0x400" progwithcode="TRUE" size="0x70000"/>
+<peripheralInstance derived_from="V7M_MPU" id="MPU" location="0xe000ed90"/>
+<peripheralInstance derived_from="V7M_NVIC" id="NVIC" location="0xe000e000"/>
+<peripheralInstance derived_from="V7M_DCR" id="DCR" location="0xe000edf0"/>
+<peripheralInstance derived_from="V7M_ITM" id="ITM" location="0xe0000000"/>
+<peripheralInstance derived_from="SCT" id="SCT" location="0x40000000"/>
+<peripheralInstance derived_from="GPDMA" id="GPDMA" location="0x40002000"/>
+<peripheralInstance derived_from="SDMMC" id="SDMMC" location="0x40004000"/>
+<peripheralInstance derived_from="EMC" id="EMC" location="0x40005000"/>
+<peripheralInstance derived_from="USB0" id="USB0" location="0x40006000"/>
+<peripheralInstance derived_from="USB1" id="USB1" location="0x40007000"/>
+<peripheralInstance derived_from="LCD" id="LCD" location="0x40008000"/>
+<peripheralInstance derived_from="ETHERNET" id="ETHERNET" location="0x40010000"/>
+<peripheralInstance derived_from="ATIMER" id="ATIMER" location="0x40040000"/>
+<peripheralInstance derived_from="REGFILE" id="REGFILE" location="0x40041000"/>
+<peripheralInstance derived_from="PMC" id="PMC" location="0x40042000"/>
+<peripheralInstance derived_from="CREG" id="CREG" location="0x40043000"/>
+<peripheralInstance derived_from="EVENTROUTER" id="EVENTROUTER" location="0x40044000"/>
+<peripheralInstance derived_from="RTC" id="RTC" location="0x40046000"/>
+<peripheralInstance derived_from="CGU" id="CGU" location="0x40050000"/>
+<peripheralInstance derived_from="CCU1" id="CCU1" location="0x40051000"/>
+<peripheralInstance derived_from="CCU2" id="CCU2" location="0x40052000"/>
+<peripheralInstance derived_from="RGU" id="RGU" location="0x40053000"/>
+<peripheralInstance derived_from="WWDT" id="WWDT" location="0x40080000"/>
+<peripheralInstance derived_from="USART0" id="USART0" location="0x40081000"/>
+<peripheralInstance derived_from="USART2" id="USART2" location="0x400c1000"/>
+<peripheralInstance derived_from="USART3" id="USART3" location="0x400c2000"/>
+<peripheralInstance derived_from="UART1" id="UART1" location="0x40082000"/>
+<peripheralInstance derived_from="SSP0" id="SSP0" location="0x40083000"/>
+<peripheralInstance derived_from="SSP1" id="SSP1" location="0x400c5000"/>
+<peripheralInstance derived_from="TIMER0" id="TIMER0" location="0x40084000"/>
+<peripheralInstance derived_from="TIMER1" id="TIMER1" location="0x40085000"/>
+<peripheralInstance derived_from="TIMER2" id="TIMER2" location="0x400c3000"/>
+<peripheralInstance derived_from="TIMER3" id="TIMER3" location="0x400c4000"/>
+<peripheralInstance derived_from="SCU" id="SCU" location="0x40086000"/>
+<peripheralInstance derived_from="GPIO-PIN-INT" id="GPIO-PIN-INT" location="0x40087000"/>
+<peripheralInstance derived_from="GPIO-GROUP-INT0" id="GPIO-GROUP-INT0" location="0x40088000"/>
+<peripheralInstance derived_from="GPIO-GROUP-INT1" id="GPIO-GROUP-INT1" location="0x40089000"/>
+<peripheralInstance derived_from="MCPWM" id="MCPWM" location="0x400a0000"/>
+<peripheralInstance derived_from="I2C0" id="I2C0" location="0x400a1000"/>
+<peripheralInstance derived_from="I2C1" id="I2C1" location="0x400e0000"/>
+<peripheralInstance derived_from="I2S0" id="I2S0" location="0x400a2000"/>
+<peripheralInstance derived_from="I2S1" id="I2S1" location="0x400a3000"/>
+<peripheralInstance derived_from="C-CAN1" id="C-CAN1" location="0x400a4000"/>
+<peripheralInstance derived_from="RITIMER" id="RITIMER" location="0x400c0000"/>
+<peripheralInstance derived_from="QEI" id="QEI" location="0x400c6000"/>
+<peripheralInstance derived_from="GIMA" id="GIMA" location="0x400c7000"/>
+<peripheralInstance derived_from="DAC" id="DAC" location="0x400e1000"/>
+<peripheralInstance derived_from="C-CAN0" id="C-CAN0" location="0x400e2000"/>
+<peripheralInstance derived_from="ADC0" id="ADC0" location="0x400e3000"/>
+<peripheralInstance derived_from="ADC1" id="ADC1" location="0x400e4000"/>
+<peripheralInstance derived_from="GPIO-PORT" id="GPIO-PORT" location="0x400f4000"/>
</chip>
-<processor><name gcc_name="cortex-m0">Cortex-M0</name>
+<processor><name gcc_name="cortex-m4">Cortex-M4</name>
<family>Cortex-M</family>
</processor>
-<link href="nxp_lpc11_13_peripheral.xme" show="embed" type="simple"/>
+<link href="nxp_lpc43xx_peripheral.xme" show="embed" type="simple"/>
</info>
</infoList>
</TargetConfig>
diff --git a/demos/device/device_os_none/tusb_descriptors.c b/demos/device/device_os_none/tusb_descriptors.c
index 78c2ab309..3fe20e674 100644
--- a/demos/device/device_os_none/tusb_descriptors.c
+++ b/demos/device/device_os_none/tusb_descriptors.c
@@ -245,7 +245,7 @@ app_descriptor_configuration_t app_tusb_desc_configuration =
{
.bLength = sizeof(tusb_descriptor_endpoint_t),
.bDescriptorType = TUSB_DESC_TYPE_ENDPOINT,
- .bEndpointAddress = CDC_NOTIFICATION_EP,
+ .bEndpointAddress = CDC_EDPT_NOTIFICATION_ADDR,
.bmAttributes = { .xfer = TUSB_XFER_INTERRUPT },
.wMaxPacketSize = { .size = 0x08 },
.bInterval = 0x0a
@@ -269,9 +269,9 @@ app_descriptor_configuration_t app_tusb_desc_configuration =
{
.bLength = sizeof(tusb_descriptor_endpoint_t),
.bDescriptorType = TUSB_DESC_TYPE_ENDPOINT,
- .bEndpointAddress = CDC_DATA_EP_OUT,
+ .bEndpointAddress = CDC_EDPT_DATA_OUT,
.bmAttributes = { .xfer = TUSB_XFER_BULK },
- .wMaxPacketSize = { .size = CDC_DATA_EP_MAXPACKET_SIZE },
+ .wMaxPacketSize = { .size = CDC_EDPT_DATA_PACKETSIZE },
.bInterval = 0
},
@@ -279,9 +279,9 @@ app_descriptor_configuration_t app_tusb_desc_configuration =
{
.bLength = sizeof(tusb_descriptor_endpoint_t),
.bDescriptorType = TUSB_DESC_TYPE_ENDPOINT,
- .bEndpointAddress = CDC_DATA_EP_IN,
+ .bEndpointAddress = CDC_EDPT_DATA_IN,
.bmAttributes = { .xfer = TUSB_XFER_BULK },
- .wMaxPacketSize = { .size = CDC_DATA_EP_MAXPACKET_SIZE },
+ .wMaxPacketSize = { .size = CDC_EDPT_DATA_PACKETSIZE },
.bInterval = 0
},
#endif
@@ -316,7 +316,7 @@ app_descriptor_configuration_t app_tusb_desc_configuration =
{
.bLength = sizeof(tusb_descriptor_endpoint_t),
.bDescriptorType = TUSB_DESC_TYPE_ENDPOINT,
- .bEndpointAddress = HID_KEYBOARD_EP_IN, //TODO HID_KEYBOARD_EP_IN,
+ .bEndpointAddress = HID_EDPT_KEYBOARD_ADDR,
.bmAttributes = { .xfer = TUSB_XFER_INTERRUPT },
.wMaxPacketSize = { .size = 0x08 },
.bInterval = 0x0A
diff --git a/demos/device/device_os_none/tusb_descriptors.h b/demos/device/device_os_none/tusb_descriptors.h
index 682c9d412..022ea50bc 100644
--- a/demos/device/device_os_none/tusb_descriptors.h
+++ b/demos/device/device_os_none/tusb_descriptors.h
@@ -41,9 +41,44 @@
#include "tusb.h"
+//--------------------------------------------------------------------+
+// Endpoints Address & Max Packet Size
+//--------------------------------------------------------------------+
+//------------- CDC -------------//
+#define CDC_EDPT_NOTIFICATION_ADDR ENDPOINT_IN_LOGICAL_TO_PHYSICAL(2)
+#define CDC_EDPT_NOTIFICATION_PACKETSIZE 64
+
+#define CDC_EDPT_DATA_OUT ENDPOINT_OUT_LOGICAL_TO_PHYSICAL(3)
+#define CDC_EDPT_DATA_IN ENDPOINT_IN_LOGICAL_TO_PHYSICAL(3)
+#define CDC_EDPT_DATA_PACKETSIZE 64
+
+//------------- HID Keyboard -------------//
+#define HID_EDPT_KEYBOARD_ADDR ENDPOINT_IN_LOGICAL_TO_PHYSICAL(1)
+
+//------------- HID Mouse -------------//
+#define HID_MOUSE_EP_IN ENDPOINT_IN_LOGICAL_TO_PHYSICAL(4)
+
+//------------- HID Generic -------------//
+
+//------------- Mass Storage -------------//
+#define MSC_EDPT_IN ENDPOINT_IN_LOGICAL_TO_PHYSICAL(3)
+#define MSC_EDPT_OUT ENDPOINT_OUT_LOGICAL_TO_PHYSICAL(3)
+
+
+//--------------------------------------------------------------------+
+// Descriptors Value (calculated by enabled Classes)
+//--------------------------------------------------------------------+
#define CFG_VENDORID 0x1FC9 // NXP
//#define CFG_PRODUCTID 0x4567 // use auto product id to prevent conflict with pc's driver
+// each combination of interfaces need to have a unique productid, as windows will bind & remember device driver after the first plug.
+#ifndef CFG_PRODUCTID // Auto ProductID layout's Bitmap: MassStorage | Generic | Mouse | Key | CDC
+
+#define PRODUCTID_BITMAP(interface, n) ( (TUSB_CFG_DEVICE_##interface) << (n) )
+#define CFG_PRODUCTID (0x4000 | ( PRODUCTID_BITMAP(CDC, 0) | PRODUCTID_BITMAP(HID_KEYBOARD, 1) | \
+ PRODUCTID_BITMAP(HID_MOUSE, 2) | PRODUCTID_BITMAP(HID_GENERIC, 3) | \
+ PRODUCTID_BITMAP(MSC, 4) ) )
+#endif
#define ENDPOINT_OUT_LOGICAL_TO_PHYSICAL(addr) (addr)
#define ENDPOINT_IN_LOGICAL_TO_PHYSICAL(addr) ((addr) | 0x80)
@@ -57,35 +92,10 @@
#define TOTAL_INTEFACES (2*TUSB_CFG_DEVICE_CDC + TUSB_CFG_DEVICE_HID_KEYBOARD + TUSB_CFG_DEVICE_HID_MOUSE + \
TUSB_CFG_DEVICE_HID_GENERIC + TUSB_CFG_DEVICE_MSC)
-/* HID In/Out Endpoint Address */
-#define HID_KEYBOARD_EP_IN ENDPOINT_IN_LOGICAL_TO_PHYSICAL(1)
-#define HID_MOUSE_EP_IN ENDPOINT_IN_LOGICAL_TO_PHYSICAL(4)
-
-/* CDC Endpoint Address */
-#define CDC_NOTIFICATION_EP ENDPOINT_IN_LOGICAL_TO_PHYSICAL(2)
-#define CDC_DATA_EP_OUT ENDPOINT_OUT_LOGICAL_TO_PHYSICAL(3)
-#define CDC_DATA_EP_IN ENDPOINT_IN_LOGICAL_TO_PHYSICAL(3)
-
-#define CDC_NOTIFICATION_EP_MAXPACKETSIZE 8
-#define CDC_DATA_EP_MAXPACKET_SIZE 16
-
-#define MSC_EDPT_IN ENDPOINT_IN_LOGICAL_TO_PHYSICAL(3)
-#define MSC_EDPT_OUT ENDPOINT_OUT_LOGICAL_TO_PHYSICAL(3)
-
-// Interface Assosication Descriptor if device is CDC + other class
+// Interface Assosication Descriptor is required when enable CDC with any other class
#define IAD_DESC_REQUIRED ( TUSB_CFG_DEVICE_CDC && (TOTAL_INTEFACES > 2) )
-// each combination of interfaces need to have different productid, as windows will bind & remember device driver after the
-// first plug.
-#ifndef CFG_PRODUCTID
-// Bitmap: MassStorage | Generic | Mouse | Key | CDC
-#define PRODUCTID_BITMAP(interface, n) ( (TUSB_CFG_DEVICE_##interface) << (n) )
-#define CFG_PRODUCTID (0x4000 | ( PRODUCTID_BITMAP(CDC, 0) | PRODUCTID_BITMAP(HID_KEYBOARD, 1) | \
- PRODUCTID_BITMAP(HID_MOUSE, 2) | PRODUCTID_BITMAP(HID_GENERIC, 3) | \
- PRODUCTID_BITMAP(MSC, 4) ) )
-#endif
-
//--------------------------------------------------------------------+
// CONFIGURATION DESCRIPTOR
//--------------------------------------------------------------------+
diff --git a/tinyusb/class/cdc.c b/tinyusb/class/cdc.c
deleted file mode 100644
index 18029acf3..000000000
--- a/tinyusb/class/cdc.c
+++ /dev/null
@@ -1,332 +0,0 @@
-/**************************************************************************/
-/*!
- @file cdc.c
- @author hathach (tinyusb.org)
-
- @section LICENSE
-
- Software License Agreement (BSD License)
-
- Copyright (c) 2013, hathach (tinyusb.org)
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holders nor the
- names of its contributors may be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This file is part of the tinyusb stack.
-*/
-/**************************************************************************/
-
-#include "cdc.h"
-#include "common/fifo.h"
-
-#if defined TUSB_CFG_DEVICE_CDC && defined TUSB_CFG_DEVICE
-
-static USBD_HANDLE_T g_hCdc;
-static CDC_LINE_CODING line_coding;
-
-static uint8_t qBuffer[2][CDC_BUFFER_SIZE]; /* TX and RX buffers */
-static fifo_t ffTX, ffRX;
-
-void usb_cdc_recv_isr(void) ATTR_WEAK ATTR_ALIAS(usb_cdc_recv_isr_stub);
-/**************************************************************************/
-/*!
- @brief Stub for the optional CDC receive ISR that can be used
- to perform some action when data arrives via USB CDC
-*/
-/**************************************************************************/
-void usb_cdc_recv_isr_stub (void)
-{
- return;
-}
-
-/**************************************************************************/
-/*!
- @brief Adds a single byte to the transmit buffer for USB CDC
-
- @param[in] c
- The byte to send
-
- @returns TRUE if the byte was successfully added to the TX buffer
-
- @note See example for tusb_cdc_getc
-*/
-/**************************************************************************/
-bool tusb_cdc_putc (uint8_t c)
-{
- return fifo_write(&ffTX, c);
-}
-
-/**************************************************************************/
-/*!
- @brief Reads a single byte from the USB CDC buffer
-
- @param[in] c
- Pointer to the location where the byte should be written
-
- @returns TRUE if a byte was read from the buffer
-
- @section EXAMPLE
-
- @code
-
- // Convert incoming characters to upper case and send back via CDC
- if (usb_isConfigured())
- {
- uint8_t cdc_char;
- if( tusb_cdc_getc(&cdc_char) )
- {
- switch (cdc_char)
- {
- default :
- cdc_char = toupper(cdc_char);
- tusb_cdc_putc(cdc_char);
- break;
- }
- }
- }
-
- @endcode
-*/
-/**************************************************************************/
-bool tusb_cdc_getc(uint8_t *c)
-{
- ASSERT(c, false); // not empty pointer
-
- return fifo_read(&ffRX, c);
-}
-
-/**************************************************************************/
-/*!
- @brief Writes the supplied buffer to the USB CDC device
-
- @param[in] buffer
- Pointer to the buffer that should be written via USB CDC
- @param[in] count
- The number of bytes to write
-
- @returns The actual number of bytes sent out via USB CDC
-
- @section EXAMPLE
-
- @code
-
- // Capture printf output (in Red Suite) and send it to USB CDC
- // (Note: With newlib this function should be renamed to _write)
- int __sys_write(int file, char *ptr, int len)
- {
- #ifdef CFG_PRINTF_USBCDC
- // Handle USB CDC output
- if (usb_isConfigured())
- {
- int length = len;
- while(length > 0)
- {
- uint16_t transferredCount;
-
- transferredCount = tusb_cdc_send( (uint8_t*) ptr, length);
- ptr += transferredCount;
- length -= transferredCount;
- }
- }
- #endif
-
- return len;
- }
-
- @endcode
-*/
-/**************************************************************************/
-uint16_t tusb_cdc_send(uint8_t* buffer, uint16_t count)
-{
- uint16_t i=0;
-
- ASSERT(buffer && count, 0);
-
- while (i < count && fifo_write(&ffTX, buffer[i]) )
- {
- i++;
- }
-
- return i;
-}
-
-/**************************************************************************/
-/*!
- @brief Reads the incoming CDC buffer up to a maximum number of bytes
-
- @param[in] buffer
- Pointer to the buffer where data should be written
- @param[in] max
- The maximum number of bytes to read
-
- @returns The actual number of bytes received
-*/
-/**************************************************************************/
-uint16_t tusb_cdc_recv(uint8_t* buffer, uint16_t max)
-{
- ASSERT(buffer && max, 0);
-
- return fifo_read_n(&ffRX, buffer, max);
-}
-
-#if 0
-// ROM driver bug: cannot hook this to CIC_GetRequest
-// Need this to implement GetLineCode & detect
-ErrorCode_t CDC_Control_GetRequest(USBD_HANDLE_T hUsb, USB_SETUP_PACKET *pSetup, uint8_t **pBuffer, uint16_t *length)
-{
- return LPC_OK;
-}
-#endif
-
-/**************************************************************************/
-/*!
- @brief TODO Add description
-*/
-/**************************************************************************/
-ErrorCode_t CDC_SetLineCoding(USBD_HANDLE_T hUsb, CDC_LINE_CODING *lineCoding)
-{
- ASSERT(lineCoding, ERR_FAILED);
- memcpy(&line_coding, lineCoding, sizeof(CDC_LINE_CODING));
- return LPC_OK;
-}
-
-/**************************************************************************/
-/*!
- @brief TODO Add description
-*/
-/**************************************************************************/
-ErrorCode_t CDC_SendBreak(USBD_HANDLE_T hCDC, uint16_t mstime)
-{
- return LPC_OK;
-}
-
-/**************************************************************************/
-/*!
- @brief Bulk Out handler for the USB ROM drivers (UART TX)
-*/
-/**************************************************************************/
-ErrorCode_t CDC_BulkIn_Hdlr(USBD_HANDLE_T hUsb, void* data, uint32_t event)
-{
- if (USB_EVT_IN == event)
- {
- uint8_t buffer[CDC_DATA_EP_MAXPACKET_SIZE];
- uint16_t count;
-
- count = fifo_read_n(&ffTX, buffer, CDC_DATA_EP_MAXPACKET_SIZE);
- ROM_API->hw->WriteEP(hUsb, CDC_DATA_EP_IN, buffer, count); // write data to EP
- }
-
- return LPC_OK;
-}
-
-/**************************************************************************/
-/*!
- @brief Bulk Out handler for the USB ROM drivers (UART RX)
-*/
-/**************************************************************************/
-ErrorCode_t CDC_BulkOut_Hdlr(USBD_HANDLE_T hUsb, void* data, uint32_t event)
-{
- if (USB_EVT_OUT == event)
- {
- uint16_t count, i;
- uint8_t buffer[CDC_DATA_EP_MAXPACKET_SIZE];
-
- count = ROM_API->hw->ReadEP(hUsb, CDC_DATA_EP_OUT, buffer);
- for (i=0; icore->RegisterEpHandler (hUsb , ((CDC_DATA_EP_IN & 0x0F) << 1) +1 , CDC_BulkIn_Hdlr , NULL), TUSB_ERROR_FAILED );
- ASSERT ( LPC_OK == ROM_API->core->RegisterEpHandler (hUsb , (CDC_DATA_EP_OUT & 0x0F) << 1 , CDC_BulkOut_Hdlr , NULL), TUSB_ERROR_FAILED );
-
- ASSERT ( LPC_OK == ROM_API->cdc->init(hUsb, &cdc_param, &g_hCdc), TUSB_ERROR_FAILED);
-
- /* update memory variables */
- *mem_base = cdc_param.mem_base;
- *mem_size = cdc_param.mem_size;
-
- return TUSB_ERROR_NONE;
-}
-
-/**************************************************************************/
-/*!
- @brief TODO Add description
-*/
-/**************************************************************************/
-tusb_error_t tusb_cdc_configured(USBD_HANDLE_T hUsb)
-{
- uint8_t dummy=0;
- ROM_API->hw->WriteEP(hUsb, CDC_DATA_EP_IN, &dummy, 1); // initial packet for IN endpoint, will not work if omitted
-
- // FIXME abstract to hal
- #if MCU == MCU_LPC11UXX
- fifo_init (&ffTX, qBuffer[0], CDC_BUFFER_SIZE, false, USB_IRQn); // TX is non-overwritable
- fifo_init (&ffRX, qBuffer[1], CDC_BUFFER_SIZE, true, USB_IRQn); // RX is overwritable
- #elif MCU == MCU_LPC13UXX
- fifo_init (&ffTX, qBuffer[0], CDC_BUFFER_SIZE, false, USB_IRQ_IRQn); // TX is non-overwritable
- fifo_init (&ffRX, qBuffer[1], CDC_BUFFER_SIZE, true, USB_IRQ_IRQn); // RX is overwritable
- #elif MCU == MCU_LPC43XX
- fifo_init (&ffTX, qBuffer[0], CDC_BUFFER_SIZE, false, USB0_IRQn); // TODO USB1 TX is non-overwritable
- fifo_init (&ffRX, qBuffer[1], CDC_BUFFER_SIZE, true, USB0_IRQn); // RX is overwritable
- #else
- #error No MCU defined // TODO asbtract MCU
- #endif
-
- return TUSB_ERROR_NONE;
-}
-
-#endif
diff --git a/tinyusb/class/hid.c b/tinyusb/class/hid.c
index 691751ac4..97feed998 100644
--- a/tinyusb/class/hid.c
+++ b/tinyusb/class/hid.c
@@ -224,7 +224,7 @@ tusb_error_t tusb_hid_init(USBD_HANDLE_T hUsb, USB_INTERFACE_DESCRIPTOR const *c
tusb_error_t tusb_hid_configured(USBD_HANDLE_T hUsb)
{
#ifdef TUSB_CFG_DEVICE_HID_KEYBOARD
- ROM_API->hw->WriteEP(hUsb , HID_KEYBOARD_EP_IN , (uint8_t* ) &hid_keyboard_report , sizeof(hid_keyboard_report_t) ); // initial packet for IN endpoint , will not work if omitted
+ ROM_API->hw->WriteEP(hUsb , HID_EDPT_KEYBOARD_ADDR , (uint8_t* ) &hid_keyboard_report , sizeof(hid_keyboard_report_t) ); // initial packet for IN endpoint , will not work if omitted
#endif
#ifdef TUSB_CFG_DEVICE_HID_MOUSE
diff --git a/tinyusb/device/dcd_lpc43xx.c b/tinyusb/device/dcd_lpc43xx.c
index 3d9fa62d8..1d400d2af 100644
--- a/tinyusb/device/dcd_lpc43xx.c
+++ b/tinyusb/device/dcd_lpc43xx.c
@@ -348,28 +348,15 @@ tusb_error_t dcd_pipe_control_xfer(uint8_t coreid, tusb_direction_t dir, void *
LPC_USB0_Type* const lpc_usb = LPC_USB[coreid];
dcd_data_t* p_dcd = dcd_data_ptr[coreid];
- // determine Endpoint where Data & Status phase occurred (IN or OUT)
- uint8_t const endpoint_data = (dir == TUSB_DIR_DEV_TO_HOST) ? 1 : 0;
- uint8_t const endpoint_status = 1 - endpoint_data;
+ uint8_t const ep_id = dir; // IN : 1, OUT = 0
- ASSERT_FALSE(p_dcd->qhd[0].qtd_overlay.active || p_dcd->qhd[1].qtd_overlay.active, TUSB_ERROR_FAILED);
+ ASSERT_FALSE(p_dcd->qhd[ep_id].qtd_overlay.active, TUSB_ERROR_FAILED);
- //------------- Data Phase -------------//
- if (length)
- {
- dcd_qtd_t* p_qtd_data = &p_dcd->qtd[0];
- qtd_init(p_qtd_data, buffer, length);
- p_dcd->qhd[endpoint_data].qtd_overlay.next = (uint32_t) p_qtd_data;
+ dcd_qtd_t* p_qtd = &p_dcd->qtd[ep_id];
+ qtd_init(p_qtd, buffer, length);
+ p_dcd->qhd[ep_id].qtd_overlay.next = (uint32_t) p_qtd;
- lpc_usb->ENDPTPRIME = BIT_( edpt_phy2pos(endpoint_data) );
- }
-
- //------------- Status Phase -------------//
- dcd_qtd_t* p_qtd_status = &p_dcd->qtd[1];
- qtd_init(p_qtd_status, NULL, 0); // zero length xfer
- p_dcd->qhd[endpoint_status].qtd_overlay.next = (uint32_t) p_qtd_status;
-
- LPC_USB0->ENDPTPRIME |= BIT_( edpt_phy2pos(endpoint_status) );
+ lpc_usb->ENDPTPRIME = BIT_( edpt_phy2pos(ep_id) );
return TUSB_ERROR_NONE;
}
diff --git a/tinyusb/device/dcd_lpc_11uxx_13uxx.c b/tinyusb/device/dcd_lpc_11uxx_13uxx.c
index 1ce96b2b0..dac52d406 100644
--- a/tinyusb/device/dcd_lpc_11uxx_13uxx.c
+++ b/tinyusb/device/dcd_lpc_11uxx_13uxx.c
@@ -362,11 +362,11 @@ tusb_error_t dcd_pipe_clear_stall(uint8_t coreid, uint8_t edpt_addr)
endpoint_handle_t dcd_pipe_open(uint8_t coreid, tusb_descriptor_endpoint_t const * p_endpoint_desc, uint8_t class_code)
{
(void) coreid;
-
endpoint_handle_t const null_handle = { 0 };
- if (p_endpoint_desc->bmAttributes.xfer == TUSB_XFER_ISOCHRONOUS)
- return null_handle; // TODO not support ISO yet
+ if (p_endpoint_desc->bmAttributes.xfer == TUSB_XFER_ISOCHRONOUS) return null_handle; // TODO not support ISO yet
+
+ ASSERT (p_endpoint_desc->wMaxPacketSize.size <= 64, null_handle); // TODO ISO can be 1023, but ISO not supported now
//------------- Prepare Queue Head -------------//
uint8_t ep_id = edpt_addr2phy(p_endpoint_desc->bEndpointAddress);