diff --git a/demos/device/src/tusb_config.h b/demos/device/src/tusb_config.h
index 512d23997..2f32abba7 100644
--- a/demos/device/src/tusb_config.h
+++ b/demos/device/src/tusb_config.h
@@ -123,7 +123,7 @@
#elif __ICCARM__ // compiled with IAR
- #define TUSB_CFG_ATTR_USBRAM @ ".ahb_sram1"
+ #define TUSB_CFG_ATTR_USBRAM _Pragma("location=\".ahb_sram1\"")
#else
diff --git a/demos/device/src/tusb_descriptors.c b/demos/device/src/tusb_descriptors.c
index 51088f324..e31261aeb 100644
--- a/demos/device/src/tusb_descriptors.c
+++ b/demos/device/src/tusb_descriptors.c
@@ -1,438 +1,438 @@
-/**************************************************************************/
-/*!
- @file tusb_descriptors.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 "tusb_descriptors.h"
-
-#if TUSB_CFG_DEVICE_HID_KEYBOARD
-ATTR_USB_MIN_ALIGNMENT TUSB_CFG_ATTR_USBRAM
-uint8_t app_tusb_keyboard_desc_report[] = {
- HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ),
- HID_USAGE ( HID_USAGE_DESKTOP_KEYBOARD ),
- HID_COLLECTION ( HID_COLLECTION_APPLICATION ),
- HID_USAGE_PAGE ( HID_USAGE_PAGE_KEYBOARD ),
- HID_USAGE_MIN ( 224 ),
- HID_USAGE_MAX ( 231 ),
- HID_LOGICAL_MIN ( 0 ),
- HID_LOGICAL_MAX ( 1 ),
-
- HID_REPORT_SIZE ( 1 ),
- HID_REPORT_COUNT ( 8 ), /* 8 bits */
- HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ), /* maskable modifier key */
-
- HID_REPORT_SIZE ( 8 ),
- HID_REPORT_COUNT ( 1 ),
- HID_INPUT ( HID_CONSTANT ), /* reserved */
-
- HID_USAGE_PAGE ( HID_USAGE_PAGE_LED ),
- HID_USAGE_MIN ( 1 ),
- HID_USAGE_MAX ( 5 ),
- HID_REPORT_COUNT ( 5 ),
- HID_REPORT_SIZE ( 1 ),
- HID_OUTPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ), /* 5-bit Led report */
-
- HID_REPORT_SIZE ( 3 ), /* led padding */
- HID_REPORT_COUNT ( 1 ),
- HID_OUTPUT ( HID_CONSTANT ),
-
- HID_USAGE_PAGE (HID_USAGE_PAGE_KEYBOARD),
- HID_USAGE_MIN ( 0 ),
- HID_USAGE_MAX ( 101 ),
- HID_LOGICAL_MIN ( 0 ),
- HID_LOGICAL_MAX ( 101 ),
-
- HID_REPORT_SIZE ( 8 ),
- HID_REPORT_COUNT ( 6 ),
- HID_INPUT ( HID_DATA | HID_ARRAY | HID_ABSOLUTE ), /* keycodes array 6 items */
- HID_COLLECTION_END
-};
-#endif
-
-#if TUSB_CFG_DEVICE_HID_MOUSE
-ATTR_USB_MIN_ALIGNMENT TUSB_CFG_ATTR_USBRAM
-uint8_t app_tusb_mouse_desc_report[] = {
- HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ),
- HID_USAGE ( HID_USAGE_DESKTOP_MOUSE ),
- HID_COLLECTION ( HID_COLLECTION_APPLICATION ),
- HID_USAGE (HID_USAGE_DESKTOP_POINTER),
-
- HID_COLLECTION ( HID_COLLECTION_PHYSICAL ),
- HID_USAGE_PAGE ( HID_USAGE_PAGE_BUTTON ),
- HID_USAGE_MIN ( 1 ),
- HID_USAGE_MAX ( 3 ),
- HID_LOGICAL_MIN ( 0 ),
- HID_LOGICAL_MAX ( 1 ),
-
- HID_REPORT_SIZE ( 1 ),
- HID_REPORT_COUNT ( 3 ), /* Left, Right and Middle mouse*/
- HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ),
-
- HID_REPORT_SIZE ( 5 ),
- HID_REPORT_COUNT ( 1 ),
- HID_INPUT ( HID_CONSTANT ), /* 5 bit padding followed 3 bit buttons */
-
- HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ),
- HID_USAGE ( HID_USAGE_DESKTOP_X ),
- HID_USAGE ( HID_USAGE_DESKTOP_Y ),
- HID_LOGICAL_MIN ( 0x81 ), /* -127 */
- HID_LOGICAL_MAX ( 0x7f ), /* 127 */
-
- HID_REPORT_SIZE ( 8 ),
- HID_REPORT_COUNT ( 2 ), /* X, Y position */
- HID_INPUT ( HID_DATA | HID_VARIABLE | HID_RELATIVE ), /* relative values */
-
- HID_USAGE ( HID_USAGE_DESKTOP_WHEEL ), /* mouse scroll */
- HID_LOGICAL_MIN ( 0x81 ), /* -127 */
- HID_LOGICAL_MAX ( 0x7f ), /* 127 */
- HID_REPORT_COUNT( 1 ),
- HID_REPORT_SIZE ( 8 ), /* 8-bit value */
- HID_INPUT ( HID_DATA | HID_VARIABLE | HID_RELATIVE ), /* relative values */
-
- HID_COLLECTION_END,
-
- HID_COLLECTION_END
-};
-#endif
-
-ATTR_USB_MIN_ALIGNMENT TUSB_CFG_ATTR_USBRAM
-tusb_descriptor_device_t app_tusb_desc_device =
-{
- .bLength = sizeof(tusb_descriptor_device_t),
- .bDescriptorType = TUSB_DESC_TYPE_DEVICE,
- .bcdUSB = 0x0200,
- #if IAD_DESC_REQUIRED
- // Multiple Interfaces Using Interface Association Descriptor (IAD)
- // As required by USB Specs IAD's subclass must be common class (2) and protocol must be IAD (1)
- .bDeviceClass = TUSB_CLASS_MISC,
- .bDeviceSubClass = MISC_SUBCLASS_COMMON,
- .bDeviceProtocol = MISC_PROTOCOL_IAD,
- #else
- .bDeviceClass = 0x00,
- .bDeviceSubClass = 0x00,
- .bDeviceProtocol = 0x00,
- #endif
-
- .bMaxPacketSize0 = TUSB_CFG_DEVICE_CONTROL_ENDOINT_SIZE,
-
- .idVendor = CFG_VENDORID,
- .idProduct = CFG_PRODUCTID,
- .bcdDevice = 0x0100,
-
- .iManufacturer = 0x01,
- .iProduct = 0x02,
- .iSerialNumber = 0x03,
-
- .bNumConfigurations = 0x01 // TODO multiple configurations
-};
-
-ATTR_USB_MIN_ALIGNMENT TUSB_CFG_ATTR_USBRAM
-app_descriptor_configuration_t app_tusb_desc_configuration =
-{
- .configuration =
- {
- .bLength = sizeof(tusb_descriptor_configuration_t),
- .bDescriptorType = TUSB_DESC_TYPE_CONFIGURATION,
-
- .wTotalLength = sizeof(app_descriptor_configuration_t),
- .bNumInterfaces = TOTAL_INTEFACES,
-
- .bConfigurationValue = 1,
- .iConfiguration = 0x00,
- .bmAttributes = TUSB_DESC_CONFIG_ATT_BUS_POWER,
- .bMaxPower = TUSB_DESC_CONFIG_POWER_MA(100)
- },
-
- #if IAD_DESC_REQUIRED
- // IAD points to CDC Interfaces
- .cdc_iad =
- {
- .bLength = sizeof(tusb_descriptor_interface_association_t),
- .bDescriptorType = TUSB_DESC_TYPE_INTERFACE_ASSOCIATION,
-
- .bFirstInterface = INTERFACE_NUM_CDC,
- .bInterfaceCount = 2,
-
- .bFunctionClass = TUSB_CLASS_CDC,
- .bFunctionSubClass = CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL,
- .bFunctionProtocol = CDC_COMM_PROTOCOL_ATCOMMAND,
- .iFunction = 0
- },
- #endif
-
- #if TUSB_CFG_DEVICE_CDC
- //------------- CDC Communication Interface -------------//
- .cdc_comm_interface =
- {
- .bLength = sizeof(tusb_descriptor_interface_t),
- .bDescriptorType = TUSB_DESC_TYPE_INTERFACE,
- .bInterfaceNumber = INTERFACE_NUM_CDC,
- .bAlternateSetting = 0,
- .bNumEndpoints = 1,
- .bInterfaceClass = TUSB_CLASS_CDC,
- .bInterfaceSubClass = CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL,
- .bInterfaceProtocol = CDC_COMM_PROTOCOL_ATCOMMAND,
- .iInterface = 0x00
- },
-
- .cdc_header =
- {
- .bLength = sizeof(cdc_desc_func_header_t),
- .bDescriptorType = TUSB_DESC_TYPE_INTERFACE_CLASS_SPECIFIC,
- .bDescriptorSubType = CDC_FUNC_DESC_HEADER,
- .bcdCDC = 0x0120
- },
-
- .cdc_acm =
- {
- .bLength = sizeof(cdc_desc_func_abstract_control_management_t),
- .bDescriptorType = TUSB_DESC_TYPE_INTERFACE_CLASS_SPECIFIC,
- .bDescriptorSubType = CDC_FUNC_DESC_ABSTRACT_CONTROL_MANAGEMENT,
- .bmCapabilities = { // 0x06
- .support_line_request = 1,
- .support_send_break = 1
- }
- },
-
- .cdc_union =
- {
- .bLength = sizeof(cdc_desc_func_union_t), // plus number of
- .bDescriptorType = TUSB_DESC_TYPE_INTERFACE_CLASS_SPECIFIC,
- .bDescriptorSubType = CDC_FUNC_DESC_UNION,
- .bControlInterface = 0,
- .bSubordinateInterface = 1,
- },
-
- .cdc_endpoint_notification =
- {
- .bLength = sizeof(tusb_descriptor_endpoint_t),
- .bDescriptorType = TUSB_DESC_TYPE_ENDPOINT,
- .bEndpointAddress = CDC_EDPT_NOTIFICATION_ADDR,
- .bmAttributes = { .xfer = TUSB_XFER_INTERRUPT },
- .wMaxPacketSize = { .size = 0x08 },
- .bInterval = 0x0a
- },
-
- //------------- CDC Data Interface -------------//
- .cdc_data_interface =
- {
- .bLength = sizeof(tusb_descriptor_interface_t),
- .bDescriptorType = TUSB_DESC_TYPE_INTERFACE,
- .bInterfaceNumber = INTERFACE_NUM_CDC+1,
- .bAlternateSetting = 0x00,
- .bNumEndpoints = 2,
- .bInterfaceClass = TUSB_CLASS_CDC_DATA,
- .bInterfaceSubClass = 0,
- .bInterfaceProtocol = 0,
- .iInterface = 0x00
- },
-
- .cdc_endpoint_out =
- {
- .bLength = sizeof(tusb_descriptor_endpoint_t),
- .bDescriptorType = TUSB_DESC_TYPE_ENDPOINT,
- .bEndpointAddress = CDC_EDPT_DATA_OUT_ADDR,
- .bmAttributes = { .xfer = TUSB_XFER_BULK },
- .wMaxPacketSize = { .size = CDC_EDPT_DATA_PACKETSIZE },
- .bInterval = 0
- },
-
- .cdc_endpoint_in =
- {
- .bLength = sizeof(tusb_descriptor_endpoint_t),
- .bDescriptorType = TUSB_DESC_TYPE_ENDPOINT,
- .bEndpointAddress = CDC_EDPT_DATA_IN_ADDR,
- .bmAttributes = { .xfer = TUSB_XFER_BULK },
- .wMaxPacketSize = { .size = CDC_EDPT_DATA_PACKETSIZE },
- .bInterval = 0
- },
- #endif
-
- //------------- HID Keyboard -------------//
- #if TUSB_CFG_DEVICE_HID_KEYBOARD
- .keyboard_interface =
- {
- .bLength = sizeof(tusb_descriptor_interface_t),
- .bDescriptorType = TUSB_DESC_TYPE_INTERFACE,
- .bInterfaceNumber = INTERFACE_NUM_HID_KEYBOARD,
- .bAlternateSetting = 0x00,
- .bNumEndpoints = 1,
- .bInterfaceClass = TUSB_CLASS_HID,
- .bInterfaceSubClass = HID_SUBCLASS_BOOT,
- .bInterfaceProtocol = HID_PROTOCOL_KEYBOARD,
- .iInterface = 0x00
- },
-
- .keyboard_hid =
- {
- .bLength = sizeof(tusb_hid_descriptor_hid_t),
- .bDescriptorType = HID_DESC_TYPE_HID,
- .bcdHID = 0x0111,
- .bCountryCode = HID_Local_NotSupported,
- .bNumDescriptors = 1,
- .bReportType = HID_DESC_TYPE_REPORT,
- .wReportLength = sizeof(app_tusb_keyboard_desc_report)
- },
-
- .keyboard_endpoint =
- {
- .bLength = sizeof(tusb_descriptor_endpoint_t),
- .bDescriptorType = TUSB_DESC_TYPE_ENDPOINT,
- .bEndpointAddress = HID_KEYBOARD_EDPT_ADDR,
- .bmAttributes = { .xfer = TUSB_XFER_INTERRUPT },
- .wMaxPacketSize = { .size = HID_KEYBOARD_EDPT_PACKETSIZE },
- .bInterval = 0x0A
- },
- #endif
-
- //------------- HID Mouse -------------//
- #if TUSB_CFG_DEVICE_HID_MOUSE
- .mouse_interface =
- {
- .bLength = sizeof(tusb_descriptor_interface_t),
- .bDescriptorType = TUSB_DESC_TYPE_INTERFACE,
- .bInterfaceNumber = INTERFACE_NUM_HID_MOUSE,
- .bAlternateSetting = 0x00,
- .bNumEndpoints = 1,
- .bInterfaceClass = TUSB_CLASS_HID,
- .bInterfaceSubClass = HID_SUBCLASS_BOOT,
- .bInterfaceProtocol = HID_PROTOCOL_MOUSE,
- .iInterface = 0x00
- },
-
- .mouse_hid =
- {
- .bLength = sizeof(tusb_hid_descriptor_hid_t),
- .bDescriptorType = HID_DESC_TYPE_HID,
- .bcdHID = 0x0111,
- .bCountryCode = HID_Local_NotSupported,
- .bNumDescriptors = 1,
- .bReportType = HID_DESC_TYPE_REPORT,
- .wReportLength = sizeof(app_tusb_mouse_desc_report)
- },
-
- .mouse_endpoint =
- {
- .bLength = sizeof(tusb_descriptor_endpoint_t),
- .bDescriptorType = TUSB_DESC_TYPE_ENDPOINT,
- .bEndpointAddress = HID_MOUSE_EDPT_ADDR, // TODO
- .bmAttributes = { .xfer = TUSB_XFER_INTERRUPT },
- .wMaxPacketSize = { .size = HID_MOUSE_EDPT_PACKETSIZE },
- .bInterval = 0x0A
- },
- #endif
-
- //------------- Mass Storage -------------//
- #if TUSB_CFG_DEVICE_MSC
- .msc_interface =
- {
- .bLength = sizeof(tusb_descriptor_interface_t),
- .bDescriptorType = TUSB_DESC_TYPE_INTERFACE,
- .bInterfaceNumber = INTERFACE_NUM_MSC,
- .bAlternateSetting = 0x00,
- .bNumEndpoints = 2,
- .bInterfaceClass = TUSB_CLASS_MSC,
- .bInterfaceSubClass = MSC_SUBCLASS_SCSI,
- .bInterfaceProtocol = MSC_PROTOCOL_BOT,
- .iInterface = 0x00
- },
-
- .msc_endpoint_in =
- {
- .bLength = sizeof(tusb_descriptor_endpoint_t),
- .bDescriptorType = TUSB_DESC_TYPE_ENDPOINT,
- .bEndpointAddress = MSC_EDPT_IN_ADDR,
- .bmAttributes = { .xfer = TUSB_XFER_BULK },
- .wMaxPacketSize = { .size = MSC_EDPT_PACKETSIZE },
- .bInterval = 1
- },
-
- .msc_endpoint_out =
- {
- .bLength = sizeof(tusb_descriptor_endpoint_t),
- .bDescriptorType = TUSB_DESC_TYPE_ENDPOINT,
- .bEndpointAddress = MSC_EDPT_OUT_ADDR,
- .bmAttributes = { .xfer = TUSB_XFER_BULK },
- .wMaxPacketSize = { .size = MSC_EDPT_PACKETSIZE },
- .bInterval = 1
- },
- #endif
-};
-
-//--------------------------------------------------------------------+
-// STRING DESCRIPTORS
-//--------------------------------------------------------------------+
-#define STRING_LEN_UNICODE(n) (2 + (2*(n))) // also includes 2 byte header
-
-ATTR_USB_MIN_ALIGNMENT TUSB_CFG_ATTR_USBRAM
-tusb_descriptor_string_t desc_str_language =
-{
- .bLength = STRING_LEN_UNICODE(1),
- .bDescriptorType = TUSB_DESC_TYPE_STRING,
- .unicode_string = { 0x0409 }
-};
-
-ATTR_USB_MIN_ALIGNMENT TUSB_CFG_ATTR_USBRAM
-tusb_descriptor_string_t desc_str_manufacturer =
-{
- .bLength = STRING_LEN_UNICODE(11),
- .bDescriptorType = TUSB_DESC_TYPE_STRING,
- .unicode_string = { 't', 'i', 'n', 'y', 'u', 's', 'b', '.', 'o', 'r', 'g' } // len = 11
-};
-
-ATTR_USB_MIN_ALIGNMENT TUSB_CFG_ATTR_USBRAM
-tusb_descriptor_string_t desc_str_product =
-{
- .bLength = STRING_LEN_UNICODE(14),
- .bDescriptorType = TUSB_DESC_TYPE_STRING,
- .unicode_string = { 't', 'i', 'n', 'y', 'u', 's', 'b', ' ', 'D', 'e', 'v', 'i', 'c', 'e' } // len = 14
-};
-
-ATTR_USB_MIN_ALIGNMENT TUSB_CFG_ATTR_USBRAM
-tusb_descriptor_string_t desc_str_serial =
-{
- .bLength = STRING_LEN_UNICODE(4),
- .bDescriptorType = TUSB_DESC_TYPE_STRING,
- .unicode_string = { '1', '2', '3', '4' } // len = 4
-};
-
-tusb_descriptor_string_t * const desc_str_table [TUSB_CFG_DEVICE_STRING_DESCRIPTOR_COUNT] =
-{
- &desc_str_language,
- &desc_str_manufacturer,
- &desc_str_product,
- &desc_str_serial
-};
+/**************************************************************************/
+/*!
+ @file tusb_descriptors.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 "tusb_descriptors.h"
+
+#if TUSB_CFG_DEVICE_HID_KEYBOARD
+ATTR_USB_MIN_ALIGNMENT TUSB_CFG_ATTR_USBRAM
+uint8_t app_tusb_keyboard_desc_report[] = {
+ HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ),
+ HID_USAGE ( HID_USAGE_DESKTOP_KEYBOARD ),
+ HID_COLLECTION ( HID_COLLECTION_APPLICATION ),
+ HID_USAGE_PAGE ( HID_USAGE_PAGE_KEYBOARD ),
+ HID_USAGE_MIN ( 224 ),
+ HID_USAGE_MAX ( 231 ),
+ HID_LOGICAL_MIN ( 0 ),
+ HID_LOGICAL_MAX ( 1 ),
+
+ HID_REPORT_SIZE ( 1 ),
+ HID_REPORT_COUNT ( 8 ), /* 8 bits */
+ HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ), /* maskable modifier key */
+
+ HID_REPORT_SIZE ( 8 ),
+ HID_REPORT_COUNT ( 1 ),
+ HID_INPUT ( HID_CONSTANT ), /* reserved */
+
+ HID_USAGE_PAGE ( HID_USAGE_PAGE_LED ),
+ HID_USAGE_MIN ( 1 ),
+ HID_USAGE_MAX ( 5 ),
+ HID_REPORT_COUNT ( 5 ),
+ HID_REPORT_SIZE ( 1 ),
+ HID_OUTPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ), /* 5-bit Led report */
+
+ HID_REPORT_SIZE ( 3 ), /* led padding */
+ HID_REPORT_COUNT ( 1 ),
+ HID_OUTPUT ( HID_CONSTANT ),
+
+ HID_USAGE_PAGE (HID_USAGE_PAGE_KEYBOARD),
+ HID_USAGE_MIN ( 0 ),
+ HID_USAGE_MAX ( 101 ),
+ HID_LOGICAL_MIN ( 0 ),
+ HID_LOGICAL_MAX ( 101 ),
+
+ HID_REPORT_SIZE ( 8 ),
+ HID_REPORT_COUNT ( 6 ),
+ HID_INPUT ( HID_DATA | HID_ARRAY | HID_ABSOLUTE ), /* keycodes array 6 items */
+ HID_COLLECTION_END
+};
+#endif
+
+#if TUSB_CFG_DEVICE_HID_MOUSE
+ATTR_USB_MIN_ALIGNMENT TUSB_CFG_ATTR_USBRAM
+uint8_t app_tusb_mouse_desc_report[] = {
+ HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ),
+ HID_USAGE ( HID_USAGE_DESKTOP_MOUSE ),
+ HID_COLLECTION ( HID_COLLECTION_APPLICATION ),
+ HID_USAGE (HID_USAGE_DESKTOP_POINTER),
+
+ HID_COLLECTION ( HID_COLLECTION_PHYSICAL ),
+ HID_USAGE_PAGE ( HID_USAGE_PAGE_BUTTON ),
+ HID_USAGE_MIN ( 1 ),
+ HID_USAGE_MAX ( 3 ),
+ HID_LOGICAL_MIN ( 0 ),
+ HID_LOGICAL_MAX ( 1 ),
+
+ HID_REPORT_SIZE ( 1 ),
+ HID_REPORT_COUNT ( 3 ), /* Left, Right and Middle mouse*/
+ HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ),
+
+ HID_REPORT_SIZE ( 5 ),
+ HID_REPORT_COUNT ( 1 ),
+ HID_INPUT ( HID_CONSTANT ), /* 5 bit padding followed 3 bit buttons */
+
+ HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ),
+ HID_USAGE ( HID_USAGE_DESKTOP_X ),
+ HID_USAGE ( HID_USAGE_DESKTOP_Y ),
+ HID_LOGICAL_MIN ( 0x81 ), /* -127 */
+ HID_LOGICAL_MAX ( 0x7f ), /* 127 */
+
+ HID_REPORT_SIZE ( 8 ),
+ HID_REPORT_COUNT ( 2 ), /* X, Y position */
+ HID_INPUT ( HID_DATA | HID_VARIABLE | HID_RELATIVE ), /* relative values */
+
+ HID_USAGE ( HID_USAGE_DESKTOP_WHEEL ), /* mouse scroll */
+ HID_LOGICAL_MIN ( 0x81 ), /* -127 */
+ HID_LOGICAL_MAX ( 0x7f ), /* 127 */
+ HID_REPORT_COUNT( 1 ),
+ HID_REPORT_SIZE ( 8 ), /* 8-bit value */
+ HID_INPUT ( HID_DATA | HID_VARIABLE | HID_RELATIVE ), /* relative values */
+
+ HID_COLLECTION_END,
+
+ HID_COLLECTION_END
+};
+#endif
+
+ATTR_USB_MIN_ALIGNMENT TUSB_CFG_ATTR_USBRAM
+tusb_descriptor_device_t app_tusb_desc_device =
+{
+ .bLength = sizeof(tusb_descriptor_device_t),
+ .bDescriptorType = TUSB_DESC_TYPE_DEVICE,
+ .bcdUSB = 0x0200,
+ #if IAD_DESC_REQUIRED
+ // Multiple Interfaces Using Interface Association Descriptor (IAD)
+ // As required by USB Specs IAD's subclass must be common class (2) and protocol must be IAD (1)
+ .bDeviceClass = TUSB_CLASS_MISC,
+ .bDeviceSubClass = MISC_SUBCLASS_COMMON,
+ .bDeviceProtocol = MISC_PROTOCOL_IAD,
+ #else
+ .bDeviceClass = 0x00,
+ .bDeviceSubClass = 0x00,
+ .bDeviceProtocol = 0x00,
+ #endif
+
+ .bMaxPacketSize0 = TUSB_CFG_DEVICE_CONTROL_ENDOINT_SIZE,
+
+ .idVendor = CFG_VENDORID,
+ .idProduct = CFG_PRODUCTID,
+ .bcdDevice = 0x0100,
+
+ .iManufacturer = 0x01,
+ .iProduct = 0x02,
+ .iSerialNumber = 0x03,
+
+ .bNumConfigurations = 0x01 // TODO multiple configurations
+};
+
+ATTR_USB_MIN_ALIGNMENT TUSB_CFG_ATTR_USBRAM
+app_descriptor_configuration_t app_tusb_desc_configuration =
+{
+ .configuration =
+ {
+ .bLength = sizeof(tusb_descriptor_configuration_t),
+ .bDescriptorType = TUSB_DESC_TYPE_CONFIGURATION,
+
+ .wTotalLength = sizeof(app_descriptor_configuration_t),
+ .bNumInterfaces = TOTAL_INTEFACES,
+
+ .bConfigurationValue = 1,
+ .iConfiguration = 0x00,
+ .bmAttributes = TUSB_DESC_CONFIG_ATT_BUS_POWER,
+ .bMaxPower = TUSB_DESC_CONFIG_POWER_MA(100)
+ },
+
+ #if IAD_DESC_REQUIRED
+ // IAD points to CDC Interfaces
+ .cdc_iad =
+ {
+ .bLength = sizeof(tusb_descriptor_interface_association_t),
+ .bDescriptorType = TUSB_DESC_TYPE_INTERFACE_ASSOCIATION,
+
+ .bFirstInterface = INTERFACE_NUM_CDC,
+ .bInterfaceCount = 2,
+
+ .bFunctionClass = TUSB_CLASS_CDC,
+ .bFunctionSubClass = CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL,
+ .bFunctionProtocol = CDC_COMM_PROTOCOL_ATCOMMAND,
+ .iFunction = 0
+ },
+ #endif
+
+ #if TUSB_CFG_DEVICE_CDC
+ //------------- CDC Communication Interface -------------//
+ .cdc_comm_interface =
+ {
+ .bLength = sizeof(tusb_descriptor_interface_t),
+ .bDescriptorType = TUSB_DESC_TYPE_INTERFACE,
+ .bInterfaceNumber = INTERFACE_NUM_CDC,
+ .bAlternateSetting = 0,
+ .bNumEndpoints = 1,
+ .bInterfaceClass = TUSB_CLASS_CDC,
+ .bInterfaceSubClass = CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL,
+ .bInterfaceProtocol = CDC_COMM_PROTOCOL_ATCOMMAND,
+ .iInterface = 0x00
+ },
+
+ .cdc_header =
+ {
+ .bLength = sizeof(cdc_desc_func_header_t),
+ .bDescriptorType = TUSB_DESC_TYPE_INTERFACE_CLASS_SPECIFIC,
+ .bDescriptorSubType = CDC_FUNC_DESC_HEADER,
+ .bcdCDC = 0x0120
+ },
+
+ .cdc_acm =
+ {
+ .bLength = sizeof(cdc_desc_func_abstract_control_management_t),
+ .bDescriptorType = TUSB_DESC_TYPE_INTERFACE_CLASS_SPECIFIC,
+ .bDescriptorSubType = CDC_FUNC_DESC_ABSTRACT_CONTROL_MANAGEMENT,
+ .bmCapabilities = { // 0x06
+ .support_line_request = 1,
+ .support_send_break = 1
+ }
+ },
+
+ .cdc_union =
+ {
+ .bLength = sizeof(cdc_desc_func_union_t), // plus number of
+ .bDescriptorType = TUSB_DESC_TYPE_INTERFACE_CLASS_SPECIFIC,
+ .bDescriptorSubType = CDC_FUNC_DESC_UNION,
+ .bControlInterface = 0,
+ .bSubordinateInterface = 1,
+ },
+
+ .cdc_endpoint_notification =
+ {
+ .bLength = sizeof(tusb_descriptor_endpoint_t),
+ .bDescriptorType = TUSB_DESC_TYPE_ENDPOINT,
+ .bEndpointAddress = CDC_EDPT_NOTIFICATION_ADDR,
+ .bmAttributes = { .xfer = TUSB_XFER_INTERRUPT },
+ .wMaxPacketSize = { .size = 0x08 },
+ .bInterval = 0x0a
+ },
+
+ //------------- CDC Data Interface -------------//
+ .cdc_data_interface =
+ {
+ .bLength = sizeof(tusb_descriptor_interface_t),
+ .bDescriptorType = TUSB_DESC_TYPE_INTERFACE,
+ .bInterfaceNumber = INTERFACE_NUM_CDC+1,
+ .bAlternateSetting = 0x00,
+ .bNumEndpoints = 2,
+ .bInterfaceClass = TUSB_CLASS_CDC_DATA,
+ .bInterfaceSubClass = 0,
+ .bInterfaceProtocol = 0,
+ .iInterface = 0x00
+ },
+
+ .cdc_endpoint_out =
+ {
+ .bLength = sizeof(tusb_descriptor_endpoint_t),
+ .bDescriptorType = TUSB_DESC_TYPE_ENDPOINT,
+ .bEndpointAddress = CDC_EDPT_DATA_OUT_ADDR,
+ .bmAttributes = { .xfer = TUSB_XFER_BULK },
+ .wMaxPacketSize = { .size = CDC_EDPT_DATA_PACKETSIZE },
+ .bInterval = 0
+ },
+
+ .cdc_endpoint_in =
+ {
+ .bLength = sizeof(tusb_descriptor_endpoint_t),
+ .bDescriptorType = TUSB_DESC_TYPE_ENDPOINT,
+ .bEndpointAddress = CDC_EDPT_DATA_IN_ADDR,
+ .bmAttributes = { .xfer = TUSB_XFER_BULK },
+ .wMaxPacketSize = { .size = CDC_EDPT_DATA_PACKETSIZE },
+ .bInterval = 0
+ },
+ #endif
+
+ //------------- HID Keyboard -------------//
+ #if TUSB_CFG_DEVICE_HID_KEYBOARD
+ .keyboard_interface =
+ {
+ .bLength = sizeof(tusb_descriptor_interface_t),
+ .bDescriptorType = TUSB_DESC_TYPE_INTERFACE,
+ .bInterfaceNumber = INTERFACE_NUM_HID_KEYBOARD,
+ .bAlternateSetting = 0x00,
+ .bNumEndpoints = 1,
+ .bInterfaceClass = TUSB_CLASS_HID,
+ .bInterfaceSubClass = HID_SUBCLASS_BOOT,
+ .bInterfaceProtocol = HID_PROTOCOL_KEYBOARD,
+ .iInterface = 0x00
+ },
+
+ .keyboard_hid =
+ {
+ .bLength = sizeof(tusb_hid_descriptor_hid_t),
+ .bDescriptorType = HID_DESC_TYPE_HID,
+ .bcdHID = 0x0111,
+ .bCountryCode = HID_Local_NotSupported,
+ .bNumDescriptors = 1,
+ .bReportType = HID_DESC_TYPE_REPORT,
+ .wReportLength = sizeof(app_tusb_keyboard_desc_report)
+ },
+
+ .keyboard_endpoint =
+ {
+ .bLength = sizeof(tusb_descriptor_endpoint_t),
+ .bDescriptorType = TUSB_DESC_TYPE_ENDPOINT,
+ .bEndpointAddress = HID_KEYBOARD_EDPT_ADDR,
+ .bmAttributes = { .xfer = TUSB_XFER_INTERRUPT },
+ .wMaxPacketSize = { .size = HID_KEYBOARD_EDPT_PACKETSIZE },
+ .bInterval = 0x0A
+ },
+ #endif
+
+ //------------- HID Mouse -------------//
+ #if TUSB_CFG_DEVICE_HID_MOUSE
+ .mouse_interface =
+ {
+ .bLength = sizeof(tusb_descriptor_interface_t),
+ .bDescriptorType = TUSB_DESC_TYPE_INTERFACE,
+ .bInterfaceNumber = INTERFACE_NUM_HID_MOUSE,
+ .bAlternateSetting = 0x00,
+ .bNumEndpoints = 1,
+ .bInterfaceClass = TUSB_CLASS_HID,
+ .bInterfaceSubClass = HID_SUBCLASS_BOOT,
+ .bInterfaceProtocol = HID_PROTOCOL_MOUSE,
+ .iInterface = 0x00
+ },
+
+ .mouse_hid =
+ {
+ .bLength = sizeof(tusb_hid_descriptor_hid_t),
+ .bDescriptorType = HID_DESC_TYPE_HID,
+ .bcdHID = 0x0111,
+ .bCountryCode = HID_Local_NotSupported,
+ .bNumDescriptors = 1,
+ .bReportType = HID_DESC_TYPE_REPORT,
+ .wReportLength = sizeof(app_tusb_mouse_desc_report)
+ },
+
+ .mouse_endpoint =
+ {
+ .bLength = sizeof(tusb_descriptor_endpoint_t),
+ .bDescriptorType = TUSB_DESC_TYPE_ENDPOINT,
+ .bEndpointAddress = HID_MOUSE_EDPT_ADDR, // TODO
+ .bmAttributes = { .xfer = TUSB_XFER_INTERRUPT },
+ .wMaxPacketSize = { .size = HID_MOUSE_EDPT_PACKETSIZE },
+ .bInterval = 0x0A
+ },
+ #endif
+
+ //------------- Mass Storage -------------//
+ #if TUSB_CFG_DEVICE_MSC
+ .msc_interface =
+ {
+ .bLength = sizeof(tusb_descriptor_interface_t),
+ .bDescriptorType = TUSB_DESC_TYPE_INTERFACE,
+ .bInterfaceNumber = INTERFACE_NUM_MSC,
+ .bAlternateSetting = 0x00,
+ .bNumEndpoints = 2,
+ .bInterfaceClass = TUSB_CLASS_MSC,
+ .bInterfaceSubClass = MSC_SUBCLASS_SCSI,
+ .bInterfaceProtocol = MSC_PROTOCOL_BOT,
+ .iInterface = 0x00
+ },
+
+ .msc_endpoint_in =
+ {
+ .bLength = sizeof(tusb_descriptor_endpoint_t),
+ .bDescriptorType = TUSB_DESC_TYPE_ENDPOINT,
+ .bEndpointAddress = MSC_EDPT_IN_ADDR,
+ .bmAttributes = { .xfer = TUSB_XFER_BULK },
+ .wMaxPacketSize = { .size = MSC_EDPT_PACKETSIZE },
+ .bInterval = 1
+ },
+
+ .msc_endpoint_out =
+ {
+ .bLength = sizeof(tusb_descriptor_endpoint_t),
+ .bDescriptorType = TUSB_DESC_TYPE_ENDPOINT,
+ .bEndpointAddress = MSC_EDPT_OUT_ADDR,
+ .bmAttributes = { .xfer = TUSB_XFER_BULK },
+ .wMaxPacketSize = { .size = MSC_EDPT_PACKETSIZE },
+ .bInterval = 1
+ },
+ #endif
+};
+
+//--------------------------------------------------------------------+
+// STRING DESCRIPTORS
+//--------------------------------------------------------------------+
+#define STRING_LEN_UNICODE(n) (2 + (2*(n))) // also includes 2 byte header
+
+ATTR_USB_MIN_ALIGNMENT TUSB_CFG_ATTR_USBRAM
+tusb_descriptor_string_t desc_str_language =
+{
+ .bLength = STRING_LEN_UNICODE(1),
+ .bDescriptorType = TUSB_DESC_TYPE_STRING,
+ .unicode_string = { 0x0409 }
+};
+
+ATTR_USB_MIN_ALIGNMENT TUSB_CFG_ATTR_USBRAM
+tusb_descriptor_string_t desc_str_manufacturer =
+{
+ .bLength = STRING_LEN_UNICODE(11),
+ .bDescriptorType = TUSB_DESC_TYPE_STRING,
+ .unicode_string = { 't', 'i', 'n', 'y', 'u', 's', 'b', '.', 'o', 'r', 'g' } // len = 11
+};
+
+ATTR_USB_MIN_ALIGNMENT TUSB_CFG_ATTR_USBRAM
+tusb_descriptor_string_t desc_str_product =
+{
+ .bLength = STRING_LEN_UNICODE(14),
+ .bDescriptorType = TUSB_DESC_TYPE_STRING,
+ .unicode_string = { 't', 'i', 'n', 'y', 'u', 's', 'b', ' ', 'D', 'e', 'v', 'i', 'c', 'e' } // len = 14
+};
+
+ATTR_USB_MIN_ALIGNMENT TUSB_CFG_ATTR_USBRAM
+tusb_descriptor_string_t desc_str_serial =
+{
+ .bLength = STRING_LEN_UNICODE(4),
+ .bDescriptorType = TUSB_DESC_TYPE_STRING,
+ .unicode_string = { '1', '2', '3', '4' } // len = 4
+};
+
+tusb_descriptor_string_t * const desc_str_table [TUSB_CFG_DEVICE_STRING_DESCRIPTOR_COUNT] =
+{
+ &desc_str_language,
+ &desc_str_manufacturer,
+ &desc_str_product,
+ &desc_str_serial
+};
diff --git a/demos/host/host_os_none/.cproject b/demos/host/host_os_none/.cproject
index 27d4f6a7e..99960707c 100644
--- a/demos/host/host_os_none/.cproject
+++ b/demos/host/host_os_none/.cproject
@@ -123,7 +123,7 @@
-
+
-
+
@@ -160,7 +160,7 @@
-
+
@@ -566,73 +566,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<TargetConfig>
-<Properties property_0="" property_3="NXP" property_4="LPC1769" property_count="5" version="1"/>
-<infoList vendor="NXP"><info chip="LPC1769" match_id="0x26113F37" name="LPC1769" package="lpc17_lqfp100.xml"><chip><name>LPC1769</name>
-<family>LPC17xx</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" resetscript="LPC18LPC43InternalFLASHBootResetscript.scp" 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="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="MFlash512" location="0x0" size="0x80000"/>
+<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="RamAHB32" location="0x2007c000" size="0x8000"/>
-<prog_flash blocksz="0x1000" location="0" maxprgbuff="0x1000" progwithcode="TRUE" size="0x10000"/>
-<prog_flash blocksz="0x8000" location="0x10000" maxprgbuff="0x1000" progwithcode="TRUE" size="0x70000"/>
-<peripheralInstance derived_from="LPC17_NVIC" id="NVIC" location="0xE000E000"/>
-<peripheralInstance derived_from="TIMER" enable="SYSCTL.PCONP.PCTIM0&0x1" id="TIMER0" location="0x40004000"/>
-<peripheralInstance derived_from="TIMER" enable="SYSCTL.PCONP.PCTIM1&0x1" id="TIMER1" location="0x40008000"/>
-<peripheralInstance derived_from="TIMER" enable="SYSCTL.PCONP.PCTIM2&0x1" id="TIMER2" location="0x40090000"/>
-<peripheralInstance derived_from="TIMER" enable="SYSCTL.PCONP.PCTIM3&0x1" id="TIMER3" location="0x40094000"/>
-<peripheralInstance derived_from="LPC17_RIT" enable="SYSCTL.PCONP.PCRIT&0x1" id="RIT" location="0x400B0000"/>
-<peripheralInstance derived_from="FGPIO" enable="SYSCTL.PCONP.PCGPIO&0x1" id="GPIO0" location="0x2009C000"/>
-<peripheralInstance derived_from="FGPIO" enable="SYSCTL.PCONP.PCGPIO&0x1" id="GPIO1" location="0x2009C020"/>
-<peripheralInstance derived_from="FGPIO" enable="SYSCTL.PCONP.PCGPIO&0x1" id="GPIO2" location="0x2009C040"/>
-<peripheralInstance derived_from="FGPIO" enable="SYSCTL.PCONP.PCGPIO&0x1" id="GPIO3" location="0x2009C060"/>
-<peripheralInstance derived_from="FGPIO" enable="SYSCTL.PCONP.PCGPIO&0x1" id="GPIO4" location="0x2009C080"/>
-<peripheralInstance derived_from="LPC17_I2S" enable="SYSCTL.PCONP&0x08000000" id="I2S" location="0x400A8000"/>
-<peripheralInstance derived_from="LPC17_SYSCTL" id="SYSCTL" location="0x400FC000"/>
-<peripheralInstance derived_from="LPC17_DAC" enable="PCB.PINSEL1.P0_26&0x2=2" id="DAC" location="0x4008C000"/>
-<peripheralInstance derived_from="LPC17xx_UART" enable="SYSCTL.PCONP.PCUART0&0x1" id="UART0" location="0x4000C000"/>
-<peripheralInstance derived_from="LPC17xx_UART_MODEM" enable="SYSCTL.PCONP.PCUART1&0x1" id="UART1" location="0x40010000"/>
-<peripheralInstance derived_from="LPC17xx_UART" enable="SYSCTL.PCONP.PCUART2&0x1" id="UART2" location="0x40098000"/>
-<peripheralInstance derived_from="LPC17xx_UART" enable="SYSCTL.PCONP.PCUART3&0x1" id="UART3" location="0x4009C000"/>
-<peripheralInstance derived_from="SPI" enable="SYSCTL.PCONP.PCSPI&0x1" id="SPI" location="0x40020000"/>
-<peripheralInstance derived_from="LPC17_SSP" enable="SYSCTL.PCONP.PCSSP0&0x1" id="SSP0" location="0x40088000"/>
-<peripheralInstance derived_from="LPC17_SSP" enable="SYSCTL.PCONP.PCSSP1&0x1" id="SSP1" location="0x40030000"/>
-<peripheralInstance derived_from="LPC17_ADC" enable="SYSCTL.PCONP.PCAD&0x1" id="ADC" location="0x40034000"/>
-<peripheralInstance derived_from="LPC17_USBINTST" enable="USBCLKCTL.USBClkCtrl&0x12" id="USBINTSTAT" location="0x400fc1c0"/>
-<peripheralInstance derived_from="LPC17_USB_CLK_CTL" id="USBCLKCTL" location="0x5000cff4"/>
-<peripheralInstance derived_from="LPC17_USBDEV" enable="USBCLKCTL.USBClkSt&0x12=0x12" id="USBDEV" location="0x5000C200"/>
-<peripheralInstance derived_from="LPC17_PWM" enable="SYSCTL.PCONP.PWM1&0x1" id="PWM" location="0x40018000"/>
-<peripheralInstance derived_from="LPC17_I2C" enable="SYSCTL.PCONP.PCI2C0&0x1" id="I2C0" location="0x4001C000"/>
-<peripheralInstance derived_from="LPC17_I2C" enable="SYSCTL.PCONP.PCI2C1&0x1" id="I2C1" location="0x4005C000"/>
-<peripheralInstance derived_from="LPC17_I2C" enable="SYSCTL.PCONP.PCI2C2&0x1" id="I2C2" location="0x400A0000"/>
-<peripheralInstance derived_from="LPC17_DMA" enable="SYSCTL.PCONP.PCGPDMA&0x1" id="DMA" location="0x50004000"/>
-<peripheralInstance derived_from="LPC17_ENET" enable="SYSCTL.PCONP.PCENET&0x1" id="ENET" location="0x50000000"/>
-<peripheralInstance derived_from="CM3_DCR" id="DCR" location="0xE000EDF0"/>
-<peripheralInstance derived_from="LPC17_PCB" id="PCB" location="0x4002c000"/>
-<peripheralInstance derived_from="LPC17_QEI" enable="SYSCTL.PCONP.PCQEI&0x1" id="QEI" location="0x400bc000"/>
-<peripheralInstance derived_from="LPC17_USBHOST" enable="USBCLKCTL.USBClkSt&0x11=0x11" id="USBHOST" location="0x5000C000"/>
-<peripheralInstance derived_from="LPC17_USBOTG" enable="USBCLKCTL.USBClkSt&0x1c=0x1c" id="USBOTG" location="0x5000C000"/>
-<peripheralInstance derived_from="LPC17_RTC" enable="SYSCTL.PCONP.PCRTC&0x1" id="RTC" location="0x40024000"/>
-<peripheralInstance derived_from="MPU" id="MPU" location="0xE000ED90"/>
-<peripheralInstance derived_from="LPC1x_WDT" id="WDT" location="0x40000000"/>
-<peripheralInstance derived_from="LPC17_FLASHCFG" id="FLASHACCEL" location="0x400FC000"/>
-<peripheralInstance derived_from="GPIO_INT" id="GPIOINTMAP" location="0x40028080"/>
-<peripheralInstance derived_from="LPC17_CANAFR" enable="SYSCTL.PCONP.PCCAN1&0x1|SYSCTL.PCONP.PCCAN2&0x1" id="CANAFR" location="0x4003C000"/>
-<peripheralInstance derived_from="LPC17_CANCEN" enable="SYSCTL.PCONP.PCCAN1&0x1|SYSCTL.PCONP.PCCAN2&0x1" id="CANCEN" location="0x40040000"/>
-<peripheralInstance derived_from="LPC17_CANWAKESLEEP" id="CANWAKESLEEP" location="0x400FC110"/>
-<peripheralInstance derived_from="LPC17_CANCON" enable="SYSCTL.PCONP.PCCAN1&0x1" id="CANCON1" location="0x40044000"/>
-<peripheralInstance derived_from="LPC17_CANCON" enable="SYSCTL.PCONP.PCCAN2&0x1" id="CANCON2" location="0x40048000"/>
-<peripheralInstance derived_from="LPC17_MCPWM" enable="SYSCTL.PCONP.PCMCPWM&0x1" id="MCPWM" location="0x400B8000"/>
-<peripheralInstance derived_from="LPC17_FMC" id="FMC" location="0x40084000"/>
+<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="SPIFI" id="SPIFI" location="0x40003000"/>
+<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="EEPROM" id="EEPROM" location="0x4000e000"/>
+<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"/>
+<peripheralInstance derived_from="SPI" id="SPI" location="0x40100000"/>
+<peripheralInstance derived_from="SGPIO" id="SGPIO" location="0x40101000"/>
</chip>
-<processor><name gcc_name="cortex-m3">Cortex-M3</name>
+<processor><name gcc_name="cortex-m4">Cortex-M4</name>
<family>Cortex-M</family>
</processor>
-<link href="nxp_lpcxxxx_peripheral.xme" show="embed" type="simple"/>
+<link href="nxp_lpc43xx_peripheral.xme" show="embed" type="simple"/>
</info>
</infoList>
</TargetConfig>
diff --git a/demos/host/src/cdc_serial_app.c b/demos/host/src/cdc_serial_app.c
index db97bd87c..208cb28a6 100644
--- a/demos/host/src/cdc_serial_app.c
+++ b/demos/host/src/cdc_serial_app.c
@@ -51,8 +51,8 @@ OSAL_SEM_DEF(serial_semaphore);
static osal_semaphore_handle_t sem_hdl;
-static uint8_t serial_in_buffer[32] TUSB_CFG_ATTR_USBRAM;
-static uint8_t serial_out_buffer[32] TUSB_CFG_ATTR_USBRAM;
+TUSB_CFG_ATTR_USBRAM static uint8_t serial_in_buffer[32];
+TUSB_CFG_ATTR_USBRAM static uint8_t serial_out_buffer[32];
static uint8_t received_bytes; // set by transfer complete callback
diff --git a/demos/host/src/cli.c b/demos/host/src/cli.c
index 8816d43ba..d67379b9b 100644
--- a/demos/host/src/cli.c
+++ b/demos/host/src/cli.c
@@ -135,8 +135,8 @@ static cli_cmdfunc_t cli_command_tbl[] =
//--------------------------------------------------------------------+
// INTERNAL OBJECT & FUNCTION DECLARATION
//--------------------------------------------------------------------+
+TUSB_CFG_ATTR_USBRAM uint8_t fileread_buffer[CLI_FILE_READ_BUFFER];
static char cli_buffer[CLI_MAX_BUFFER];
-uint8_t fileread_buffer[CLI_FILE_READ_BUFFER] TUSB_CFG_ATTR_USBRAM;
static char volume_label[20];
static inline void drive_number2letter(char * p_path) ATTR_ALWAYS_INLINE;
diff --git a/demos/host/src/keyboard_app.c b/demos/host/src/keyboard_app.c
index 907ae8c2e..c004059ef 100644
--- a/demos/host/src/keyboard_app.c
+++ b/demos/host/src/keyboard_app.c
@@ -56,7 +56,7 @@ OSAL_TASK_DEF(keyboard_app_task, 128, KEYBOARD_APP_TASK_PRIO);
OSAL_QUEUE_DEF(queue_kbd_def, QUEUE_KEYBOARD_REPORT_DEPTH, hid_keyboard_report_t);
static osal_queue_handle_t queue_kbd_hdl;
-static hid_keyboard_report_t usb_keyboard_report TUSB_CFG_ATTR_USBRAM;
+TUSB_CFG_ATTR_USBRAM static hid_keyboard_report_t usb_keyboard_report;
static inline uint8_t keycode_to_ascii(uint8_t modifier, uint8_t keycode) ATTR_CONST ATTR_ALWAYS_INLINE;
static inline void process_kbd_report(hid_keyboard_report_t const * report);
diff --git a/demos/host/src/mouse_app.c b/demos/host/src/mouse_app.c
index 60b91f4d2..4fabd4f36 100644
--- a/demos/host/src/mouse_app.c
+++ b/demos/host/src/mouse_app.c
@@ -56,7 +56,7 @@ OSAL_TASK_DEF(mouse_app_task, 128, MOUSE_APP_TASK_PRIO);
OSAL_QUEUE_DEF(queue_mouse_def, QUEUE_MOUSE_REPORT_DEPTH, hid_mouse_report_t);
static osal_queue_handle_t queue_mouse_hdl;
-static hid_mouse_report_t usb_mouse_report TUSB_CFG_ATTR_USBRAM;
+TUSB_CFG_ATTR_USBRAM static hid_mouse_report_t usb_mouse_report;
static inline void process_mouse_report(hid_mouse_report_t const * p_report);
diff --git a/demos/host/src/msc_app.c b/demos/host/src/msc_app.c
index b7e909cee..5bd66c9d6 100644
--- a/demos/host/src/msc_app.c
+++ b/demos/host/src/msc_app.c
@@ -57,7 +57,7 @@
//--------------------------------------------------------------------+
OSAL_TASK_DEF(msc_app_task, 512, MSC_APP_TASK_PRIO);
-static FATFS fatfs[TUSB_CFG_HOST_DEVICE_MAX] TUSB_CFG_ATTR_USBRAM;
+TUSB_CFG_ATTR_USBRAM static FATFS fatfs[TUSB_CFG_HOST_DEVICE_MAX];
//--------------------------------------------------------------------+
// tinyusb callback (ISR context)
diff --git a/demos/host/src/tusb_config.h b/demos/host/src/tusb_config.h
index 3315897cf..e12f020a6 100644
--- a/demos/host/src/tusb_config.h
+++ b/demos/host/src/tusb_config.h
@@ -115,7 +115,7 @@
#elif defined __ICCARM__ // compiled with IAR
- #define TUSB_CFG_ATTR_USBRAM @ ".ahb_sram1"
+ #define TUSB_CFG_ATTR_USBRAM _Pragma("location=\".ahb_sram1\"")
#else
diff --git a/tinyusb/class/cdc_device.c b/tinyusb/class/cdc_device.c
index b4e63d1fa..247c72180 100644
--- a/tinyusb/class/cdc_device.c
+++ b/tinyusb/class/cdc_device.c
@@ -50,8 +50,8 @@
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF
//--------------------------------------------------------------------+
-ATTR_USB_MIN_ALIGNMENT
-static cdc_line_coding_t cdcd_line_coding[CONTROLLER_DEVICE_NUMBER] TUSB_CFG_ATTR_USBRAM;
+TUSB_CFG_ATTR_USBRAM ATTR_USB_MIN_ALIGNMENT
+static cdc_line_coding_t cdcd_line_coding[CONTROLLER_DEVICE_NUMBER];
typedef struct {
uint8_t interface_number;
@@ -191,12 +191,12 @@ tusb_error_t cdcd_control_request_subtask(uint8_t coreid, tusb_control_request_t
{
case CDC_REQUEST_GET_LINE_CODING:
dcd_pipe_control_xfer(coreid, p_request->bmRequestType_bit.direction,
- &cdcd_line_coding[coreid], min16_of(sizeof(cdc_line_coding_t), p_request->wLength), false );
+ (uint8_t*) &cdcd_line_coding[coreid], min16_of(sizeof(cdc_line_coding_t), p_request->wLength), false );
break;
case CDC_REQUEST_SET_LINE_CODING:
dcd_pipe_control_xfer(coreid, p_request->bmRequestType_bit.direction,
- &cdcd_line_coding[coreid], min16_of(sizeof(cdc_line_coding_t), p_request->wLength), false );
+ (uint8_t*) &cdcd_line_coding[coreid], min16_of(sizeof(cdc_line_coding_t), p_request->wLength), false );
// TODO notify application on xfer completea
break;
diff --git a/tinyusb/class/cdc_rndis_host.c b/tinyusb/class/cdc_rndis_host.c
index 106f2095c..0e31fcc9a 100644
--- a/tinyusb/class/cdc_rndis_host.c
+++ b/tinyusb/class/cdc_rndis_host.c
@@ -54,8 +54,8 @@
//--------------------------------------------------------------------+
#define RNDIS_MSG_PAYLOAD_MAX (1024*4)
-static uint8_t msg_notification[TUSB_CFG_HOST_DEVICE_MAX][8] TUSB_CFG_ATTR_USBRAM;
-ATTR_ALIGNED(4) static uint8_t msg_payload[RNDIS_MSG_PAYLOAD_MAX] TUSB_CFG_ATTR_USBRAM;
+TUSB_CFG_ATTR_USBRAM static uint8_t msg_notification[TUSB_CFG_HOST_DEVICE_MAX][8];
+TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(4) static uint8_t msg_payload[RNDIS_MSG_PAYLOAD_MAX];
STATIC_VAR rndish_data_t rndish_data[TUSB_CFG_HOST_DEVICE_MAX];
diff --git a/tinyusb/class/hid_device.c b/tinyusb/class/hid_device.c
index 0b413329c..36062e392 100644
--- a/tinyusb/class/hid_device.c
+++ b/tinyusb/class/hid_device.c
@@ -1,466 +1,467 @@
-/**************************************************************************/
-/*!
- @file hid_device.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 "tusb_option.h"
-
-#if (MODE_DEVICE_SUPPORTED && DEVICE_CLASS_HID)
-
-#define _TINY_USB_SOURCE_FILE_
-//--------------------------------------------------------------------+
-// INCLUDE
-//--------------------------------------------------------------------+
-#include "common/common.h"
-#include "hid_device.h"
-#include "tusb_descriptors.h"
-
-//--------------------------------------------------------------------+
-// MACRO CONSTANT TYPEDEF
-//--------------------------------------------------------------------+
-
-enum {
- HIDD_NUMBER_OF_SUBCLASS = 3
-};
-
-typedef struct {
- uint16_t report_length;
-
- endpoint_handle_t ept_handle;
- uint8_t interface_number;
-}hidd_interface_t;
-
-typedef struct {
- uint8_t const * const p_report_desc;
- hidd_interface_t * const p_interface;
- void (* const mounted_cb) (uint8_t coreid);
- void (* const unmounted_cb) (uint8_t coreid);
- void (* const xfer_cb) (uint8_t, tusb_event_t, uint32_t);
- uint16_t (* const get_report_cb) (uint8_t, hid_request_report_type_t, void**, uint16_t );
- void (* const set_report_cb) (uint8_t, hid_request_report_type_t, uint8_t[], uint16_t);
-}hidd_class_driver_t;
-
-extern ATTR_WEAK hidd_interface_t keyboardd_data;
-extern ATTR_WEAK hidd_interface_t moused_data;
-
-static hidd_class_driver_t const hidd_class_driver[HIDD_NUMBER_OF_SUBCLASS] =
-{
-// [HID_PROTOCOL_NONE] = for HID Generic
-
-#if TUSB_CFG_DEVICE_HID_KEYBOARD
- [HID_PROTOCOL_KEYBOARD] =
- {
- .p_report_desc = app_tusb_keyboard_desc_report,
- .p_interface = &keyboardd_data,
- .mounted_cb = tusbd_hid_keyboard_mounted_cb,
- .unmounted_cb = tusbd_hid_keyboard_unmounted_cb,
- .xfer_cb = tusbd_hid_keyboard_cb,
- .get_report_cb = tusbd_hid_keyboard_get_report_cb,
- .set_report_cb = tusbd_hid_keyboard_set_report_cb
- },
-#endif
-
-#if TUSB_CFG_DEVICE_HID_MOUSE
- [HID_PROTOCOL_MOUSE] =
- {
- .p_report_desc = app_tusb_mouse_desc_report,
- .p_interface = &moused_data,
- .mounted_cb = tusbd_hid_mouse_mounted_cb,
- .unmounted_cb = tusbd_hid_mouse_unmounted_cb,
- .xfer_cb = tusbd_hid_mouse_cb,
- .get_report_cb = tusbd_hid_mouse_get_report_cb,
- .set_report_cb = tusbd_hid_mouse_set_report_cb
- }
-#endif
-};
-
-#if TUSB_CFG_DEVICE_HID_KEYBOARD || TUSB_CFG_DEVICE_HID_MOUSE
-ATTR_USB_MIN_ALIGNMENT uint8_t m_control_data[ MAX_OF(sizeof(hid_keyboard_report_t), sizeof(hid_mouse_report_t)) ] TUSB_CFG_ATTR_USBRAM;
-#endif
-
-//--------------------------------------------------------------------+
-// KEYBOARD APPLICATION API
-//--------------------------------------------------------------------+
-#if TUSB_CFG_DEVICE_HID_KEYBOARD
-STATIC_VAR TUSB_CFG_ATTR_USBRAM hidd_interface_t keyboardd_data;
-
-bool tusbd_hid_keyboard_is_busy(uint8_t coreid)
-{
- return dcd_pipe_is_busy(keyboardd_data.ept_handle);
-}
-
-tusb_error_t tusbd_hid_keyboard_send(uint8_t coreid, hid_keyboard_report_t const *p_report)
-{
- ASSERT(tusbd_is_configured(coreid), TUSB_ERROR_USBD_DEVICE_NOT_CONFIGURED);
-
- hidd_interface_t * p_kbd = &keyboardd_data; // TODO &keyboardd_data[coreid];
-
- ASSERT_STATUS( dcd_pipe_xfer(p_kbd->ept_handle, p_report, sizeof(hid_keyboard_report_t), true) ) ;
-
- return TUSB_ERROR_NONE;
-}
-#endif
-
-//--------------------------------------------------------------------+
-// MOUSE APPLICATION API
-//--------------------------------------------------------------------+
-#if TUSB_CFG_DEVICE_HID_MOUSE
-STATIC_VAR TUSB_CFG_ATTR_USBRAM hidd_interface_t moused_data;
-
-bool tusbd_hid_mouse_is_busy(uint8_t coreid)
-{
- return dcd_pipe_is_busy(moused_data.ept_handle);
-}
-
-tusb_error_t tusbd_hid_mouse_send(uint8_t coreid, hid_mouse_report_t const *p_report)
-{
- ASSERT(tusbd_is_configured(coreid), TUSB_ERROR_USBD_DEVICE_NOT_CONFIGURED);
-
- hidd_interface_t * p_mouse = &moused_data; // TODO &keyboardd_data[coreid];
-
- ASSERT_STATUS( dcd_pipe_xfer(p_mouse->ept_handle, p_report, sizeof(hid_mouse_report_t), true) ) ;
-
- return TUSB_ERROR_NONE;
-}
-#endif
-
-//--------------------------------------------------------------------+
-// USBD-CLASS API
-//--------------------------------------------------------------------+
-static void interface_clear(hidd_interface_t * p_interface)
-{
- if ( p_interface != NULL )
- {
- memclr_(p_interface, sizeof(hidd_interface_t));
- p_interface->interface_number = INTERFACE_INVALID_NUMBER;
- }
-}
-
-void hidd_init(void)
-{
- for(uint8_t i=0; iwIndex == p_interface->interface_number) )
- {
- break;
- }
- }
-
- ASSERT(subclass_idx < HIDD_NUMBER_OF_SUBCLASS, TUSB_ERROR_FAILED);
-
- hidd_class_driver_t const * const p_driver = &hidd_class_driver[subclass_idx];
- hidd_interface_t* const p_hid = p_driver->p_interface;
-
- //------------- STD Request -------------//
- if (p_request->bmRequestType_bit.type == TUSB_REQUEST_TYPE_STANDARD)
- {
- uint8_t const desc_type = u16_high_u8(p_request->wValue);
- uint8_t const desc_index = u16_low_u8 (p_request->wValue);
-
- (void) desc_index;
-
- ASSERT ( p_request->bRequest == TUSB_REQUEST_GET_DESCRIPTOR && desc_type == HID_DESC_TYPE_REPORT,
- TUSB_ERROR_DCD_CONTROL_REQUEST_NOT_SUPPORT);
-
- dcd_pipe_control_xfer(coreid, TUSB_DIR_DEV_TO_HOST, p_driver->p_report_desc, p_hid->report_length, false);
- }
- //------------- Class Specific Request -------------//
- else if (p_request->bmRequestType_bit.type == TUSB_REQUEST_TYPE_CLASS)
- {
- OSAL_SUBTASK_BEGIN
-
- if( (HID_REQUEST_CONTROL_GET_REPORT == p_request->bRequest) && (p_driver->get_report_cb != NULL) )
- {
- // wValue = Report Type | Report ID
- void* p_buffer = NULL;
-
- uint16_t actual_length = p_driver->get_report_cb(coreid, (hid_request_report_type_t) u16_high_u8(p_request->wValue),
- &p_buffer, p_request->wLength);
- SUBTASK_ASSERT( p_buffer != NULL && actual_length > 0 );
-
- dcd_pipe_control_xfer(coreid, p_request->bmRequestType_bit.direction, p_buffer, actual_length, false);
- }
- else if ( (HID_REQUEST_CONTROL_SET_REPORT == p_request->bRequest) && (p_driver->set_report_cb != NULL) )
- {
- // return TUSB_ERROR_DCD_CONTROL_REQUEST_NOT_SUPPORT; // TODO test STALL control out endpoint (with mouse+keyboard)
- // wValue = Report Type | Report ID
- tusb_error_t error;
-
- dcd_pipe_control_xfer(coreid, p_request->bmRequestType_bit.direction, &m_control_data, p_request->wLength, true);
-
- osal_semaphore_wait(usbd_control_xfer_sem_hdl, OSAL_TIMEOUT_NORMAL, &error); // wait for control xfer complete
- SUBTASK_ASSERT_STATUS(error);
-
- p_driver->set_report_cb(coreid, (hid_request_report_type_t) u16_high_u8(p_request->wValue),
- &m_control_data, p_request->wLength);
- }
- else if (HID_REQUEST_CONTROL_SET_IDLE == p_request->bRequest)
- {
- // uint8_t idle_rate = u16_high_u8(p_request->wValue);
- }else
- {
-// HID_REQUEST_CONTROL_GET_IDLE:
-// HID_REQUEST_CONTROL_GET_PROTOCOL:
-// HID_REQUEST_CONTROL_SET_PROTOCOL:
- return TUSB_ERROR_DCD_CONTROL_REQUEST_NOT_SUPPORT;
- }
-
- OSAL_SUBTASK_END
- }else
- {
- return TUSB_ERROR_DCD_CONTROL_REQUEST_NOT_SUPPORT;
- }
-
- return TUSB_ERROR_NONE;
-}
-
-tusb_error_t hidd_open(uint8_t coreid, tusb_descriptor_interface_t const * p_interface_desc, uint16_t *p_length)
-{
- uint8_t const *p_desc = (uint8_t const *) p_interface_desc;
-
- //------------- HID descriptor -------------//
- p_desc += p_desc[DESCRIPTOR_OFFSET_LENGTH];
- tusb_hid_descriptor_hid_t const *p_desc_hid = (tusb_hid_descriptor_hid_t const *) p_desc;
- ASSERT_INT(HID_DESC_TYPE_HID, p_desc_hid->bDescriptorType, TUSB_ERROR_HIDD_DESCRIPTOR_INTERFACE);
-
- //------------- Endpoint Descriptor -------------//
- p_desc += p_desc[DESCRIPTOR_OFFSET_LENGTH];
- tusb_descriptor_endpoint_t const *p_desc_endpoint = (tusb_descriptor_endpoint_t const *) p_desc;
- ASSERT_INT(TUSB_DESC_TYPE_ENDPOINT, p_desc_endpoint->bDescriptorType, TUSB_ERROR_HIDD_DESCRIPTOR_INTERFACE);
-
- if (p_interface_desc->bInterfaceSubClass == HID_SUBCLASS_BOOT)
- {
- switch(p_interface_desc->bInterfaceProtocol)
- {
- case HID_PROTOCOL_KEYBOARD:
- case HID_PROTOCOL_MOUSE:
- {
- hidd_class_driver_t const * const p_driver = &hidd_class_driver[p_interface_desc->bInterfaceProtocol];
- hidd_interface_t * const p_hid = p_driver->p_interface;
-
- ASSERT_PTR(p_hid, TUSB_ERROR_FAILED);
-
- p_hid->ept_handle = dcd_pipe_open(coreid, p_desc_endpoint, p_interface_desc->bInterfaceClass);
- ASSERT( endpointhandle_is_valid(p_hid->ept_handle), TUSB_ERROR_DCD_FAILED);
-
- p_hid->interface_number = p_interface_desc->bInterfaceNumber;
- p_hid->report_length = p_desc_hid->wReportLength;
-
- p_driver->mounted_cb(coreid);
- }
- break;
-
- default: // TODO unknown, unsupported protocol --> skip this interface
- return TUSB_ERROR_HIDD_DESCRIPTOR_INTERFACE;
- }
- *p_length = sizeof(tusb_descriptor_interface_t) + sizeof(tusb_hid_descriptor_hid_t) + sizeof(tusb_descriptor_endpoint_t);
- }else
- {
- // open generic
- *p_length = 0;
- return TUSB_ERROR_HIDD_DESCRIPTOR_INTERFACE;
- }
- return TUSB_ERROR_NONE;
-}
-
-tusb_error_t hidd_xfer_cb(endpoint_handle_t edpt_hdl, tusb_event_t event, uint32_t xferred_bytes)
-{
- for(uint8_t i=0; iept_handle) )
- {
- hidd_class_driver[i].xfer_cb(edpt_hdl.coreid, event, xferred_bytes);
- }
- }
-
- return TUSB_ERROR_NONE;
-}
-
-#if defined(CAP_DEVICE_ROMDRIVER)
-
-//--------------------------------------------------------------------+
-// MACRO CONSTANT TYPEDEF
-//--------------------------------------------------------------------+
-#if TUSB_CFG_DEVICE_HID_KEYBOARD
-TUSB_CFG_ATTR_USBRAM uint8_t hidd_keyboard_buffer[1024]; // TODO memory reduce
-TUSB_CFG_ATTR_USBRAM hid_keyboard_report_t hid_keyboard_report;
-static volatile bool bKeyChanged = false;
-#endif
-
-#if TUSB_CFG_DEVICE_HID_MOUSE
-TUSB_CFG_ATTR_USBRAM uint8_t hidd_mouse_buffer[1024]; // TODO memory reduce
-TUSB_CFG_ATTR_USBRAM hid_mouse_report_t hid_mouse_report;
-static volatile bool bMouseChanged = false;
-#endif
-
-//--------------------------------------------------------------------+
-// APPLICATION API
-//--------------------------------------------------------------------+
-
-//--------------------------------------------------------------------+
-// IMPLEMENTATION
-//--------------------------------------------------------------------+
-ErrorCode_t HID_GetReport( USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t* plength)
-{
- USB_HID_CTRL_T* pHidCtrl = (USB_HID_CTRL_T*) hHid;
-
- /* ReportID = SetupPacket.wValue.WB.L; */
- if (pSetup->wValue.WB.H == HID_REQUEST_REPORT_INPUT)
- return (ERR_USBD_STALL); /* Not Supported */
-
- switch (pHidCtrl->protocol)
- {
- #if TUSB_CFG_DEVICE_HID_KEYBOARD
- case HID_PROTOCOL_KEYBOARD:
- *pBuffer = (uint8_t*) &hid_keyboard_report;
- *plength = sizeof(hid_keyboard_report_t);
-
- if (!bKeyChanged)
- {
- memset(pBuffer, 0, *plength);
- }
- bKeyChanged = false;
- break;
- #endif
-
- #if TUSB_CFG_DEVICE_HID_MOUSE
- case HID_PROTOCOL_MOUSE:
- *pBuffer = (uint8_t*) &hid_mouse_report;
- *plength = sizeof(hid_mouse_report_t);
-
- if (!bMouseChanged)
- {
- memset(pBuffer, 0, *plength);
- }
- bMouseChanged = false;
- break;
- #endif
-
- default:
- break;
- }
-
- return (LPC_OK);
-}
-
-ErrorCode_t HID_SetReport( USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t length)
-{
- /* we will reuse standard EP0Buf */
- if (length == 0)
- return LPC_OK;
-
- /* ReportID = SetupPacket.wValue.WB.L; */
- if (pSetup->wValue.WB.H != HID_REQUEST_REPORT_OUTPUT)
- return (ERR_USBD_STALL); /* Not Supported */
-
- return (LPC_OK);
-}
-
-ErrorCode_t HID_EpIn_Hdlr (USBD_HANDLE_T hUsb, void* data, uint32_t event)
-{
- if (USB_EVT_IN == event)
- {
- USB_HID_CTRL_T* pHidCtrl = (USB_HID_CTRL_T*)data;
- switch(pHidCtrl->protocol)
- {
- #if TUSB_CFG_DEVICE_HID_KEYBOARD
- case HID_PROTOCOL_KEYBOARD:
- if (!bKeyChanged)
- {
- memset(&hid_keyboard_report, 0, sizeof(hid_keyboard_report_t));
- }
- ROM_API->hw->WriteEP(hUsb, pHidCtrl->epin_adr, (uint8_t*) &hid_keyboard_report, sizeof(hid_keyboard_report_t));
- bKeyChanged = false;
- break;
- #endif
-
- #if TUSB_CFG_DEVICE_HID_MOUSE
- case HID_PROTOCOL_MOUSE:
- if (!bMouseChanged)
- {
- memset(&hid_mouse_report, 0, sizeof(hid_mouse_report_t));
- }
- ROM_API->hw->WriteEP(hUsb, pHidCtrl->epin_adr, (uint8_t*) &hid_mouse_report, sizeof(hid_mouse_report_t));
- bMouseChanged = false;
- break;
- #endif
-
- default:
- break;
- }
- }
-
- return LPC_OK;
-}
-
-ErrorCode_t HID_EpOut_Hdlr (USBD_HANDLE_T hUsb, void* data, uint32_t event)
-{
- if (USB_EVT_OUT == event)
- {
- // not used yet
- // uint8_t outreport[8];
- // USB_HID_CTRL_T* pHidCtrl = (USB_HID_CTRL_T*)data;
- // ROM_API->hw->ReadEP(hUsb, pHidCtrl->epout_adr, outreport);
- }
- return LPC_OK;
-}
-
-#endif
-
-#endif
+/**************************************************************************/
+/*!
+ @file hid_device.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 "tusb_option.h"
+
+#if (MODE_DEVICE_SUPPORTED && DEVICE_CLASS_HID)
+
+#define _TINY_USB_SOURCE_FILE_
+//--------------------------------------------------------------------+
+// INCLUDE
+//--------------------------------------------------------------------+
+#include "common/common.h"
+#include "hid_device.h"
+#include "tusb_descriptors.h"
+
+//--------------------------------------------------------------------+
+// MACRO CONSTANT TYPEDEF
+//--------------------------------------------------------------------+
+
+enum {
+ HIDD_NUMBER_OF_SUBCLASS = 3
+};
+
+typedef struct {
+ uint16_t report_length;
+
+ endpoint_handle_t ept_handle;
+ uint8_t interface_number;
+}hidd_interface_t;
+
+typedef struct {
+ uint8_t const * const p_report_desc;
+ hidd_interface_t * const p_interface;
+ void (* const mounted_cb) (uint8_t coreid);
+ void (* const unmounted_cb) (uint8_t coreid);
+ void (* const xfer_cb) (uint8_t, tusb_event_t, uint32_t);
+ uint16_t (* const get_report_cb) (uint8_t, hid_request_report_type_t, void**, uint16_t );
+ void (* const set_report_cb) (uint8_t, hid_request_report_type_t, uint8_t[], uint16_t);
+}hidd_class_driver_t;
+
+extern ATTR_WEAK hidd_interface_t keyboardd_data;
+extern ATTR_WEAK hidd_interface_t moused_data;
+
+static hidd_class_driver_t const hidd_class_driver[HIDD_NUMBER_OF_SUBCLASS] =
+{
+// [HID_PROTOCOL_NONE] = for HID Generic
+
+#if TUSB_CFG_DEVICE_HID_KEYBOARD
+ [HID_PROTOCOL_KEYBOARD] =
+ {
+ .p_report_desc = app_tusb_keyboard_desc_report,
+ .p_interface = &keyboardd_data,
+ .mounted_cb = tusbd_hid_keyboard_mounted_cb,
+ .unmounted_cb = tusbd_hid_keyboard_unmounted_cb,
+ .xfer_cb = tusbd_hid_keyboard_cb,
+ .get_report_cb = tusbd_hid_keyboard_get_report_cb,
+ .set_report_cb = tusbd_hid_keyboard_set_report_cb
+ },
+#endif
+
+#if TUSB_CFG_DEVICE_HID_MOUSE
+ [HID_PROTOCOL_MOUSE] =
+ {
+ .p_report_desc = app_tusb_mouse_desc_report,
+ .p_interface = &moused_data,
+ .mounted_cb = tusbd_hid_mouse_mounted_cb,
+ .unmounted_cb = tusbd_hid_mouse_unmounted_cb,
+ .xfer_cb = tusbd_hid_mouse_cb,
+ .get_report_cb = tusbd_hid_mouse_get_report_cb,
+ .set_report_cb = tusbd_hid_mouse_set_report_cb
+ }
+#endif
+};
+
+#if TUSB_CFG_DEVICE_HID_KEYBOARD || TUSB_CFG_DEVICE_HID_MOUSE
+TUSB_CFG_ATTR_USBRAM ATTR_USB_MIN_ALIGNMENT
+uint8_t m_control_data[ MAX_OF(sizeof(hid_keyboard_report_t), sizeof(hid_mouse_report_t)) ];
+#endif
+
+//--------------------------------------------------------------------+
+// KEYBOARD APPLICATION API
+//--------------------------------------------------------------------+
+#if TUSB_CFG_DEVICE_HID_KEYBOARD
+TUSB_CFG_ATTR_USBRAM STATIC_VAR hidd_interface_t keyboardd_data;
+
+bool tusbd_hid_keyboard_is_busy(uint8_t coreid)
+{
+ return dcd_pipe_is_busy(keyboardd_data.ept_handle);
+}
+
+tusb_error_t tusbd_hid_keyboard_send(uint8_t coreid, hid_keyboard_report_t const *p_report)
+{
+ ASSERT(tusbd_is_configured(coreid), TUSB_ERROR_USBD_DEVICE_NOT_CONFIGURED);
+
+ hidd_interface_t * p_kbd = &keyboardd_data; // TODO &keyboardd_data[coreid];
+
+ ASSERT_STATUS( dcd_pipe_xfer(p_kbd->ept_handle, (void*) p_report, sizeof(hid_keyboard_report_t), true) ) ;
+
+ return TUSB_ERROR_NONE;
+}
+#endif
+
+//--------------------------------------------------------------------+
+// MOUSE APPLICATION API
+//--------------------------------------------------------------------+
+#if TUSB_CFG_DEVICE_HID_MOUSE
+TUSB_CFG_ATTR_USBRAM STATIC_VAR hidd_interface_t moused_data;
+
+bool tusbd_hid_mouse_is_busy(uint8_t coreid)
+{
+ return dcd_pipe_is_busy(moused_data.ept_handle);
+}
+
+tusb_error_t tusbd_hid_mouse_send(uint8_t coreid, hid_mouse_report_t const *p_report)
+{
+ ASSERT(tusbd_is_configured(coreid), TUSB_ERROR_USBD_DEVICE_NOT_CONFIGURED);
+
+ hidd_interface_t * p_mouse = &moused_data; // TODO &keyboardd_data[coreid];
+
+ ASSERT_STATUS( dcd_pipe_xfer(p_mouse->ept_handle, (void*) p_report, sizeof(hid_mouse_report_t), true) ) ;
+
+ return TUSB_ERROR_NONE;
+}
+#endif
+
+//--------------------------------------------------------------------+
+// USBD-CLASS API
+//--------------------------------------------------------------------+
+static void interface_clear(hidd_interface_t * p_interface)
+{
+ if ( p_interface != NULL )
+ {
+ memclr_(p_interface, sizeof(hidd_interface_t));
+ p_interface->interface_number = INTERFACE_INVALID_NUMBER;
+ }
+}
+
+void hidd_init(void)
+{
+ for(uint8_t i=0; iwIndex == p_interface->interface_number) )
+ {
+ break;
+ }
+ }
+
+ ASSERT(subclass_idx < HIDD_NUMBER_OF_SUBCLASS, TUSB_ERROR_FAILED);
+
+ hidd_class_driver_t const * const p_driver = &hidd_class_driver[subclass_idx];
+ hidd_interface_t* const p_hid = p_driver->p_interface;
+
+ //------------- STD Request -------------//
+ if (p_request->bmRequestType_bit.type == TUSB_REQUEST_TYPE_STANDARD)
+ {
+ uint8_t const desc_type = u16_high_u8(p_request->wValue);
+ uint8_t const desc_index = u16_low_u8 (p_request->wValue);
+
+ (void) desc_index;
+
+ ASSERT ( p_request->bRequest == TUSB_REQUEST_GET_DESCRIPTOR && desc_type == HID_DESC_TYPE_REPORT,
+ TUSB_ERROR_DCD_CONTROL_REQUEST_NOT_SUPPORT);
+
+ dcd_pipe_control_xfer(coreid, TUSB_DIR_DEV_TO_HOST, (uint8_t*) p_driver->p_report_desc, p_hid->report_length, false);
+ }
+ //------------- Class Specific Request -------------//
+ else if (p_request->bmRequestType_bit.type == TUSB_REQUEST_TYPE_CLASS)
+ {
+ OSAL_SUBTASK_BEGIN
+
+ if( (HID_REQUEST_CONTROL_GET_REPORT == p_request->bRequest) && (p_driver->get_report_cb != NULL) )
+ {
+ // wValue = Report Type | Report ID
+ void* p_buffer = NULL;
+
+ uint16_t actual_length = p_driver->get_report_cb(coreid, (hid_request_report_type_t) u16_high_u8(p_request->wValue),
+ &p_buffer, p_request->wLength);
+ SUBTASK_ASSERT( p_buffer != NULL && actual_length > 0 );
+
+ dcd_pipe_control_xfer(coreid, p_request->bmRequestType_bit.direction, p_buffer, actual_length, false);
+ }
+ else if ( (HID_REQUEST_CONTROL_SET_REPORT == p_request->bRequest) && (p_driver->set_report_cb != NULL) )
+ {
+ // return TUSB_ERROR_DCD_CONTROL_REQUEST_NOT_SUPPORT; // TODO test STALL control out endpoint (with mouse+keyboard)
+ // wValue = Report Type | Report ID
+ tusb_error_t error;
+
+ dcd_pipe_control_xfer(coreid, p_request->bmRequestType_bit.direction, m_control_data, p_request->wLength, true);
+
+ osal_semaphore_wait(usbd_control_xfer_sem_hdl, OSAL_TIMEOUT_NORMAL, &error); // wait for control xfer complete
+ SUBTASK_ASSERT_STATUS(error);
+
+ p_driver->set_report_cb(coreid, (hid_request_report_type_t) u16_high_u8(p_request->wValue),
+ m_control_data, p_request->wLength);
+ }
+ else if (HID_REQUEST_CONTROL_SET_IDLE == p_request->bRequest)
+ {
+ // uint8_t idle_rate = u16_high_u8(p_request->wValue);
+ }else
+ {
+// HID_REQUEST_CONTROL_GET_IDLE:
+// HID_REQUEST_CONTROL_GET_PROTOCOL:
+// HID_REQUEST_CONTROL_SET_PROTOCOL:
+ return TUSB_ERROR_DCD_CONTROL_REQUEST_NOT_SUPPORT;
+ }
+
+ OSAL_SUBTASK_END
+ }else
+ {
+ return TUSB_ERROR_DCD_CONTROL_REQUEST_NOT_SUPPORT;
+ }
+
+ return TUSB_ERROR_NONE;
+}
+
+tusb_error_t hidd_open(uint8_t coreid, tusb_descriptor_interface_t const * p_interface_desc, uint16_t *p_length)
+{
+ uint8_t const *p_desc = (uint8_t const *) p_interface_desc;
+
+ //------------- HID descriptor -------------//
+ p_desc += p_desc[DESCRIPTOR_OFFSET_LENGTH];
+ tusb_hid_descriptor_hid_t const *p_desc_hid = (tusb_hid_descriptor_hid_t const *) p_desc;
+ ASSERT_INT(HID_DESC_TYPE_HID, p_desc_hid->bDescriptorType, TUSB_ERROR_HIDD_DESCRIPTOR_INTERFACE);
+
+ //------------- Endpoint Descriptor -------------//
+ p_desc += p_desc[DESCRIPTOR_OFFSET_LENGTH];
+ tusb_descriptor_endpoint_t const *p_desc_endpoint = (tusb_descriptor_endpoint_t const *) p_desc;
+ ASSERT_INT(TUSB_DESC_TYPE_ENDPOINT, p_desc_endpoint->bDescriptorType, TUSB_ERROR_HIDD_DESCRIPTOR_INTERFACE);
+
+ if (p_interface_desc->bInterfaceSubClass == HID_SUBCLASS_BOOT)
+ {
+ switch(p_interface_desc->bInterfaceProtocol)
+ {
+ case HID_PROTOCOL_KEYBOARD:
+ case HID_PROTOCOL_MOUSE:
+ {
+ hidd_class_driver_t const * const p_driver = &hidd_class_driver[p_interface_desc->bInterfaceProtocol];
+ hidd_interface_t * const p_hid = p_driver->p_interface;
+
+ ASSERT_PTR(p_hid, TUSB_ERROR_FAILED);
+
+ p_hid->ept_handle = dcd_pipe_open(coreid, p_desc_endpoint, p_interface_desc->bInterfaceClass);
+ ASSERT( endpointhandle_is_valid(p_hid->ept_handle), TUSB_ERROR_DCD_FAILED);
+
+ p_hid->interface_number = p_interface_desc->bInterfaceNumber;
+ p_hid->report_length = p_desc_hid->wReportLength;
+
+ p_driver->mounted_cb(coreid);
+ }
+ break;
+
+ default: // TODO unknown, unsupported protocol --> skip this interface
+ return TUSB_ERROR_HIDD_DESCRIPTOR_INTERFACE;
+ }
+ *p_length = sizeof(tusb_descriptor_interface_t) + sizeof(tusb_hid_descriptor_hid_t) + sizeof(tusb_descriptor_endpoint_t);
+ }else
+ {
+ // open generic
+ *p_length = 0;
+ return TUSB_ERROR_HIDD_DESCRIPTOR_INTERFACE;
+ }
+ return TUSB_ERROR_NONE;
+}
+
+tusb_error_t hidd_xfer_cb(endpoint_handle_t edpt_hdl, tusb_event_t event, uint32_t xferred_bytes)
+{
+ for(uint8_t i=0; iept_handle) )
+ {
+ hidd_class_driver[i].xfer_cb(edpt_hdl.coreid, event, xferred_bytes);
+ }
+ }
+
+ return TUSB_ERROR_NONE;
+}
+
+#if defined(CAP_DEVICE_ROMDRIVER)
+
+//--------------------------------------------------------------------+
+// MACRO CONSTANT TYPEDEF
+//--------------------------------------------------------------------+
+#if TUSB_CFG_DEVICE_HID_KEYBOARD
+TUSB_CFG_ATTR_USBRAM uint8_t hidd_keyboard_buffer[1024]; // TODO memory reduce
+TUSB_CFG_ATTR_USBRAM hid_keyboard_report_t hid_keyboard_report;
+static volatile bool bKeyChanged = false;
+#endif
+
+#if TUSB_CFG_DEVICE_HID_MOUSE
+TUSB_CFG_ATTR_USBRAM uint8_t hidd_mouse_buffer[1024]; // TODO memory reduce
+TUSB_CFG_ATTR_USBRAM hid_mouse_report_t hid_mouse_report;
+static volatile bool bMouseChanged = false;
+#endif
+
+//--------------------------------------------------------------------+
+// APPLICATION API
+//--------------------------------------------------------------------+
+
+//--------------------------------------------------------------------+
+// IMPLEMENTATION
+//--------------------------------------------------------------------+
+ErrorCode_t HID_GetReport( USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t* plength)
+{
+ USB_HID_CTRL_T* pHidCtrl = (USB_HID_CTRL_T*) hHid;
+
+ /* ReportID = SetupPacket.wValue.WB.L; */
+ if (pSetup->wValue.WB.H == HID_REQUEST_REPORT_INPUT)
+ return (ERR_USBD_STALL); /* Not Supported */
+
+ switch (pHidCtrl->protocol)
+ {
+ #if TUSB_CFG_DEVICE_HID_KEYBOARD
+ case HID_PROTOCOL_KEYBOARD:
+ *pBuffer = (uint8_t*) &hid_keyboard_report;
+ *plength = sizeof(hid_keyboard_report_t);
+
+ if (!bKeyChanged)
+ {
+ memset(pBuffer, 0, *plength);
+ }
+ bKeyChanged = false;
+ break;
+ #endif
+
+ #if TUSB_CFG_DEVICE_HID_MOUSE
+ case HID_PROTOCOL_MOUSE:
+ *pBuffer = (uint8_t*) &hid_mouse_report;
+ *plength = sizeof(hid_mouse_report_t);
+
+ if (!bMouseChanged)
+ {
+ memset(pBuffer, 0, *plength);
+ }
+ bMouseChanged = false;
+ break;
+ #endif
+
+ default:
+ break;
+ }
+
+ return (LPC_OK);
+}
+
+ErrorCode_t HID_SetReport( USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t length)
+{
+ /* we will reuse standard EP0Buf */
+ if (length == 0)
+ return LPC_OK;
+
+ /* ReportID = SetupPacket.wValue.WB.L; */
+ if (pSetup->wValue.WB.H != HID_REQUEST_REPORT_OUTPUT)
+ return (ERR_USBD_STALL); /* Not Supported */
+
+ return (LPC_OK);
+}
+
+ErrorCode_t HID_EpIn_Hdlr (USBD_HANDLE_T hUsb, void* data, uint32_t event)
+{
+ if (USB_EVT_IN == event)
+ {
+ USB_HID_CTRL_T* pHidCtrl = (USB_HID_CTRL_T*)data;
+ switch(pHidCtrl->protocol)
+ {
+ #if TUSB_CFG_DEVICE_HID_KEYBOARD
+ case HID_PROTOCOL_KEYBOARD:
+ if (!bKeyChanged)
+ {
+ memset(&hid_keyboard_report, 0, sizeof(hid_keyboard_report_t));
+ }
+ ROM_API->hw->WriteEP(hUsb, pHidCtrl->epin_adr, (uint8_t*) &hid_keyboard_report, sizeof(hid_keyboard_report_t));
+ bKeyChanged = false;
+ break;
+ #endif
+
+ #if TUSB_CFG_DEVICE_HID_MOUSE
+ case HID_PROTOCOL_MOUSE:
+ if (!bMouseChanged)
+ {
+ memset(&hid_mouse_report, 0, sizeof(hid_mouse_report_t));
+ }
+ ROM_API->hw->WriteEP(hUsb, pHidCtrl->epin_adr, (uint8_t*) &hid_mouse_report, sizeof(hid_mouse_report_t));
+ bMouseChanged = false;
+ break;
+ #endif
+
+ default:
+ break;
+ }
+ }
+
+ return LPC_OK;
+}
+
+ErrorCode_t HID_EpOut_Hdlr (USBD_HANDLE_T hUsb, void* data, uint32_t event)
+{
+ if (USB_EVT_OUT == event)
+ {
+ // not used yet
+ // uint8_t outreport[8];
+ // USB_HID_CTRL_T* pHidCtrl = (USB_HID_CTRL_T*)data;
+ // ROM_API->hw->ReadEP(hUsb, pHidCtrl->epout_adr, outreport);
+ }
+ return LPC_OK;
+}
+
+#endif
+
+#endif
diff --git a/tinyusb/class/hid_host.c b/tinyusb/class/hid_host.c
index e61590eab..fb50a6e03 100644
--- a/tinyusb/class/hid_host.c
+++ b/tinyusb/class/hid_host.c
@@ -180,7 +180,7 @@ void hidh_init(void)
}
#if 0
-uint8_t report_descriptor[256] TUSB_CFG_ATTR_USBRAM;
+TUSB_CFG_ATTR_USBRAM uint8_t report_descriptor[256];
#endif
tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t const *p_interface_desc, uint16_t *p_length)
diff --git a/tinyusb/class/msc_device.c b/tinyusb/class/msc_device.c
index 6a9251d19..997145499 100644
--- a/tinyusb/class/msc_device.c
+++ b/tinyusb/class/msc_device.c
@@ -62,7 +62,7 @@ typedef struct {
ATTR_USB_MIN_ALIGNMENT msc_cmd_status_wrapper_t csw;
}mscd_interface_t;
-STATIC_VAR mscd_interface_t mscd_data TUSB_CFG_ATTR_USBRAM;
+TUSB_CFG_ATTR_USBRAM STATIC_VAR mscd_interface_t mscd_data;
//--------------------------------------------------------------------+
// INTERNAL OBJECT & FUNCTION DECLARATION
//--------------------------------------------------------------------+
@@ -109,7 +109,7 @@ tusb_error_t mscd_open(uint8_t coreid, tusb_descriptor_interface_t const * p_int
(*p_length) += sizeof(tusb_descriptor_interface_t) + 2*sizeof(tusb_descriptor_endpoint_t);
//------------- Queue Endpoint OUT for Command Block Wrapper -------------//
- ASSERT_STATUS( dcd_pipe_xfer(p_msc->edpt_out, &p_msc->cbw, sizeof(msc_cmd_block_wrapper_t), true) );
+ ASSERT_STATUS( dcd_pipe_xfer(p_msc->edpt_out, (uint8_t*) &p_msc->cbw, sizeof(msc_cmd_block_wrapper_t), true) );
return TUSB_ERROR_NONE;
}
@@ -202,10 +202,10 @@ tusb_error_t mscd_xfer_cb(endpoint_handle_t edpt_hdl, tusb_event_t event, uint32
// Either bulk in & out can be stalled in the data phase, dcd must make sure these queued transfer will be resumed after host clear stall
if (!is_waiting_read10_write10)
{
- ASSERT_STATUS( dcd_pipe_xfer( p_msc->edpt_in , p_csw, sizeof(msc_cmd_status_wrapper_t), false) );
+ ASSERT_STATUS( dcd_pipe_xfer( p_msc->edpt_in , (uint8_t*) p_csw, sizeof(msc_cmd_status_wrapper_t), false) );
//------------- Queue the next CBW -------------//
- ASSERT_STATUS( dcd_pipe_xfer( p_msc->edpt_out, p_cbw, sizeof(msc_cmd_block_wrapper_t), true) );
+ ASSERT_STATUS( dcd_pipe_xfer( p_msc->edpt_out, (uint8_t*) p_cbw, sizeof(msc_cmd_block_wrapper_t), true) );
}
return TUSB_ERROR_NONE;
diff --git a/tinyusb/class/msc_host.c b/tinyusb/class/msc_host.c
index ac62e5d9a..dcb3fff6f 100644
--- a/tinyusb/class/msc_host.c
+++ b/tinyusb/class/msc_host.c
@@ -51,7 +51,7 @@
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF
//--------------------------------------------------------------------+
-STATIC_VAR msch_interface_t msch_data[TUSB_CFG_HOST_DEVICE_MAX] TUSB_CFG_ATTR_USBRAM;
+TUSB_CFG_ATTR_USBRAM STATIC_VAR msch_interface_t msch_data[TUSB_CFG_HOST_DEVICE_MAX];
//------------- Initalization Data -------------//
@@ -59,7 +59,7 @@ OSAL_SEM_DEF(msch_semaphore);
static osal_semaphore_handle_t msch_sem_hdl;
// buffer used to read scsi information when mounted, largest response data currently is inquiry
-ATTR_ALIGNED(4) STATIC_VAR uint8_t msch_buffer[sizeof(scsi_inquiry_data_t)] TUSB_CFG_ATTR_USBRAM;
+TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(4) STATIC_VAR uint8_t msch_buffer[sizeof(scsi_inquiry_data_t)];
//--------------------------------------------------------------------+
// INTERNAL OBJECT & FUNCTION DECLARATION
diff --git a/tinyusb/common/compiler/compiler.h b/tinyusb/common/compiler/compiler.h
index 738711416..4c81047c7 100644
--- a/tinyusb/common/compiler/compiler.h
+++ b/tinyusb/common/compiler/compiler.h
@@ -49,6 +49,7 @@
#ifndef _TEST_
#define STATIC_ static
#define INLINE_ inline
+ #define ATTR_TEST_WEAK
#if TUSB_CFG_DEBUG == 3
#define ATTR_ALWAYS_INLINE // no inline for debug = 3
@@ -56,12 +57,13 @@
#else
#define STATIC_VAR static
#endif
- #define ATTR_TEST_WEAK
+
#else
#define ATTR_ALWAYS_INLINE
#define STATIC_
#define STATIC_VAR
#define INLINE_
+
#endif
#if defined(__GNUC__)
diff --git a/tinyusb/common/compiler/compiler_iar.h b/tinyusb/common/compiler/compiler_iar.h
index cd94f5b2f..7103ee092 100644
--- a/tinyusb/common/compiler/compiler_iar.h
+++ b/tinyusb/common/compiler/compiler_iar.h
@@ -57,17 +57,9 @@
#define ATTR_PACKED_STRUCT(x) __packed x
#define ATTR_PREPACKED __packed
#define ATTR_PACKED
+//#define ATTR_SECTION(section) _Pragma((#section))
-#define ATTR_ALIGNED(Bytes) ATTR_ALIGNED_##Bytes
-#define ATTR_ALIGNED_4096 _Pragma("data_alignment=4096")
-#define ATTR_ALIGNED_2048 _Pragma("data_alignment=2048")
-#define ATTR_ALIGNED_256 _Pragma("data_alignment=256")
-#define ATTR_ALIGNED_128 _Pragma("data_alignment=128")
-#define ATTR_ALIGNED_64 _Pragma("data_alignment=64")
-#define ATTR_ALIGNED_48 _Pragma("data_alignment=48")
-#define ATTR_ALIGNED_32 _Pragma("data_alignment=32")
-#define ATTR_ALIGNED_16 _Pragma("data_alignment=16")
-#define ATTR_ALIGNED_4 _Pragma("data_alignment=4")
+#define ATTR_ALIGNED(bytes) _Pragma(XSTRING_(data_alignment=##bytes))
#ifndef ATTR_ALWAYS_INLINE
/// Generally, functions are not inlined unless optimization is specified. For functions declared inline, this attribute inlines the function even if no optimization level is specified
diff --git a/tinyusb/common/fifo.h b/tinyusb/common/fifo.h
index daef4a84a..4a518ca0c 100644
--- a/tinyusb/common/fifo.h
+++ b/tinyusb/common/fifo.h
@@ -55,23 +55,24 @@
*/
typedef struct
{
+ uint8_t* const buffer ; ///< buffer pointer
uint16_t const depth ; ///< max items
uint16_t const item_size ; ///< size of each item
volatile uint16_t count ; ///< number of items in queue
volatile uint16_t wr_idx ; ///< write pointer
volatile uint16_t rd_idx ; ///< read pointer
bool overwritable ;
- uint8_t buffer[] ; ///< buffer pointer
// IRQn_Type irq;
} fifo_t;
#define FIFO_DEF(name, ff_depth, type, is_overwritable) /*, irq_mutex)*/ \
+ uint8_t name##_buffer[ff_depth*sizeof(type)];\
fifo_t name = {\
+ .buffer = name##_buffer,\
.depth = ff_depth,\
.item_size = sizeof(type),\
.overwritable = is_overwritable,\
/*.irq = irq_mutex*/\
- .buffer = { [ff_depth*sizeof(type) - 1] = 0 },\
}
bool fifo_write(fifo_t* f, void const * p_data);
diff --git a/tinyusb/device/dcd.h b/tinyusb/device/dcd.h
index f84a26d95..95eef8fce 100644
--- a/tinyusb/device/dcd.h
+++ b/tinyusb/device/dcd.h
@@ -75,18 +75,18 @@ tusb_error_t dcd_init(void) ATTR_WARN_UNUSED_RESULT;
void dcd_isr(uint8_t coreid);
//------------- Controller API -------------//
-void dcd_controller_connect(uint8_t coreid);
-void dcd_controller_disconnect(uint8_t coreid);
-void dcd_controller_set_address(uint8_t coreid, uint8_t dev_addr);
-void dcd_controller_set_configuration(uint8_t coreid);
+void dcd_controller_connect (uint8_t coreid);
+void dcd_controller_disconnect (uint8_t coreid);
+void dcd_controller_set_address (uint8_t coreid, uint8_t dev_addr);
+void dcd_controller_set_configuration (uint8_t coreid);
//------------- PIPE API -------------//
-tusb_error_t dcd_pipe_control_xfer(uint8_t coreid, tusb_direction_t dir, void * p_buffer, uint16_t length, bool int_on_complete);
+tusb_error_t dcd_pipe_control_xfer(uint8_t coreid, tusb_direction_t dir, uint8_t * p_buffer, uint16_t length, bool int_on_complete);
void dcd_pipe_control_stall(uint8_t coreid);
endpoint_handle_t dcd_pipe_open(uint8_t coreid, tusb_descriptor_endpoint_t const * p_endpoint_desc, uint8_t class_code) ATTR_WARN_UNUSED_RESULT;
-tusb_error_t dcd_pipe_queue_xfer(endpoint_handle_t edpt_hdl, void * buffer, uint16_t total_bytes) ATTR_WARN_UNUSED_RESULT; // only queue, not transferring yet
-tusb_error_t dcd_pipe_xfer(endpoint_handle_t edpt_hdl, void * buffer, uint16_t total_bytes, bool int_on_complete) ATTR_WARN_UNUSED_RESULT;
+tusb_error_t dcd_pipe_queue_xfer(endpoint_handle_t edpt_hdl, uint8_t * buffer, uint16_t total_bytes) ATTR_WARN_UNUSED_RESULT; // only queue, not transferring yet
+tusb_error_t dcd_pipe_xfer(endpoint_handle_t edpt_hdl, uint8_t * buffer, uint16_t total_bytes, bool int_on_complete) ATTR_WARN_UNUSED_RESULT;
tusb_error_t dcd_pipe_stall(endpoint_handle_t edpt_hdl) ATTR_WARN_UNUSED_RESULT;
bool dcd_pipe_is_busy(endpoint_handle_t edpt_hdl) ATTR_WARN_UNUSED_RESULT ;
diff --git a/tinyusb/device/dcd_lpc175x_6x.c b/tinyusb/device/dcd_lpc175x_6x.c
index 058891e54..df6c49154 100644
--- a/tinyusb/device/dcd_lpc175x_6x.c
+++ b/tinyusb/device/dcd_lpc175x_6x.c
@@ -68,7 +68,7 @@ typedef struct {
}dcd_data_t;
-STATIC_ dcd_data_t dcd_data TUSB_CFG_ATTR_USBRAM;
+TUSB_CFG_ATTR_USBRAM STATIC_ dcd_data_t dcd_data;
//--------------------------------------------------------------------+
// INTERNAL OBJECT & FUNCTION DECLARATION
@@ -372,7 +372,7 @@ void dcd_pipe_control_stall(uint8_t coreid)
sie_write(SIE_CMDCODE_ENDPOINT_SET_STATUS+0, 1, SIE_SET_ENDPOINT_STALLED_MASK | SIE_SET_ENDPOINT_CONDITION_STALLED_MASK);
}
-tusb_error_t dcd_pipe_control_xfer(uint8_t coreid, tusb_direction_t dir, void * p_buffer, uint16_t length, bool int_on_complete)
+tusb_error_t dcd_pipe_control_xfer(uint8_t coreid, tusb_direction_t dir, uint8_t * p_buffer, uint16_t length, bool int_on_complete)
{
(void) coreid;
@@ -473,7 +473,7 @@ void dd_xfer_init(dcd_dma_descriptor_t* p_dd, void* buffer, uint16_t total_bytes
p_dd->present_count = 0;
}
-tusb_error_t dcd_pipe_queue_xfer(endpoint_handle_t edpt_hdl, void * buffer, uint16_t total_bytes)
+tusb_error_t dcd_pipe_queue_xfer(endpoint_handle_t edpt_hdl, uint8_t * buffer, uint16_t total_bytes)
{ // NOTE for sure the qhd has no dds
dcd_dma_descriptor_t* const p_fixed_dd = &dcd_data.dd[edpt_hdl.index][0]; // always queue with the fixed DD
@@ -484,7 +484,7 @@ tusb_error_t dcd_pipe_queue_xfer(endpoint_handle_t edpt_hdl, void * buffer, uint
return TUSB_ERROR_NONE;
}
-tusb_error_t dcd_pipe_xfer(endpoint_handle_t edpt_hdl, void * buffer, uint16_t total_bytes, bool int_on_complete)
+tusb_error_t dcd_pipe_xfer(endpoint_handle_t edpt_hdl, uint8_t* buffer, uint16_t total_bytes, bool int_on_complete)
{
dcd_dma_descriptor_t* const p_first_dd = &dcd_data.dd[edpt_hdl.index][0];
diff --git a/tinyusb/device/dcd_lpc43xx.c b/tinyusb/device/dcd_lpc43xx.c
index c5d6eb666..05e47fd11 100644
--- a/tinyusb/device/dcd_lpc43xx.c
+++ b/tinyusb/device/dcd_lpc43xx.c
@@ -168,11 +168,11 @@ typedef struct {
}dcd_data_t;
#if (TUSB_CFG_CONTROLLER_0_MODE & TUSB_MODE_DEVICE)
-ATTR_ALIGNED(2048) dcd_data_t dcd_data0 TUSB_CFG_ATTR_USBRAM;
+TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(2048) dcd_data_t dcd_data0;
#endif
#if (TUSB_CFG_CONTROLLER_1_MODE & TUSB_MODE_DEVICE)
-ATTR_ALIGNED(2048) dcd_data_t dcd_data1 TUSB_CFG_ATTR_USBRAM;
+TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(2048) dcd_data_t dcd_data1;
#endif
static LPC_USB0_Type * const LPC_USB[2] = { LPC_USB0, ((LPC_USB0_Type*) LPC_USB1_BASE) };
diff --git a/tinyusb/device/dcd_lpc_11uxx_13uxx.c b/tinyusb/device/dcd_lpc_11uxx_13uxx.c
index c68248461..0b2e539fb 100644
--- a/tinyusb/device/dcd_lpc_11uxx_13uxx.c
+++ b/tinyusb/device/dcd_lpc_11uxx_13uxx.c
@@ -133,7 +133,7 @@ typedef struct {
//--------------------------------------------------------------------+
// INTERNAL OBJECT & FUNCTION DECLARATION
//--------------------------------------------------------------------+
-ATTR_ALIGNED(256) static dcd_11u_13u_data_t dcd_data TUSB_CFG_ATTR_USBRAM;
+TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(256) static dcd_11u_13u_data_t dcd_data;
static inline uint16_t addr_offset(void const * p_buffer) ATTR_CONST ATTR_ALWAYS_INLINE;
static inline uint16_t addr_offset(void const * p_buffer)
diff --git a/tinyusb/host/ehci/ehci.c b/tinyusb/host/ehci/ehci.c
index d98773e78..9d606e183 100644
--- a/tinyusb/host/ehci/ehci.c
+++ b/tinyusb/host/ehci/ehci.c
@@ -57,12 +57,12 @@
//--------------------------------------------------------------------+
// INTERNAL OBJECT & FUNCTION DECLARATION
//--------------------------------------------------------------------+
-STATIC_VAR ehci_data_t ehci_data TUSB_CFG_ATTR_USBRAM;
+TUSB_CFG_ATTR_USBRAM STATIC_VAR ehci_data_t ehci_data;
#if EHCI_PERIODIC_LIST
#if (TUSB_CFG_CONTROLLER_0_MODE & TUSB_MODE_HOST)
- ATTR_ALIGNED(4096) STATIC_VAR ehci_link_t period_frame_list0[EHCI_FRAMELIST_SIZE] TUSB_CFG_ATTR_USBRAM;
+ TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(4096) STATIC_VAR ehci_link_t period_frame_list0[EHCI_FRAMELIST_SIZE];
#ifndef __ICCARM__ // IAR cannot able to determine the alignment with datalignment pragma
STATIC_ASSERT( ALIGN_OF(period_frame_list0) == 4096, "Period Framelist must be 4k alginment"); // validation
@@ -70,7 +70,7 @@ STATIC_VAR ehci_data_t ehci_data TUSB_CFG_ATTR_USBRAM;
#endif
#if (TUSB_CFG_CONTROLLER_1_MODE & TUSB_MODE_HOST)
- STATIC_VAR ehci_link_t period_frame_list1[EHCI_FRAMELIST_SIZE] ATTR_ALIGNED(4096) TUSB_CFG_ATTR_USBRAM;
+ TUSB_CFG_ATTR_USBRAM STATIC_VAR ehci_link_t period_frame_list1[EHCI_FRAMELIST_SIZE] ATTR_ALIGNED(4096);
#ifndef __ICCARM__ // IAR cannot able to determine the alignment with datalignment pragma
STATIC_ASSERT( ALIGN_OF(period_frame_list1) == 4096, "Period Framelist must be 4k alginment"); // validation
diff --git a/tinyusb/host/hub.c b/tinyusb/host/hub.c
index 99cebc292..e87ce62f0 100644
--- a/tinyusb/host/hub.c
+++ b/tinyusb/host/hub.c
@@ -58,8 +58,8 @@ typedef struct {
uint8_t status_change; // data from status change interrupt endpoint
}usbh_hub_t;
-usbh_hub_t hub_data[TUSB_CFG_HOST_DEVICE_MAX] TUSB_CFG_ATTR_USBRAM;
-uint8_t hub_enum_buffer[sizeof(descriptor_hub_desc_t)] TUSB_CFG_ATTR_USBRAM;
+TUSB_CFG_ATTR_USBRAM usbh_hub_t hub_data[TUSB_CFG_HOST_DEVICE_MAX];
+TUSB_CFG_ATTR_USBRAM uint8_t hub_enum_buffer[sizeof(descriptor_hub_desc_t)];
//OSAL_SEM_DEF(hub_enum_semaphore);
//static osal_semaphore_handle_t hub_enum_sem_hdl;
diff --git a/tinyusb/host/ohci/ohci.c b/tinyusb/host/ohci/ohci.c
index 8bcde4d21..ab27c6e5a 100644
--- a/tinyusb/host/ohci/ohci.c
+++ b/tinyusb/host/ohci/ohci.c
@@ -135,7 +135,7 @@ enum {
//--------------------------------------------------------------------+
// INTERNAL OBJECT & FUNCTION DECLARATION
//--------------------------------------------------------------------+
-STATIC_VAR ohci_data_t ohci_data TUSB_CFG_ATTR_USBRAM;
+TUSB_CFG_ATTR_USBRAM STATIC_VAR ohci_data_t ohci_data;
static ohci_ed_t * const p_ed_head[] =
{
diff --git a/tinyusb/host/usbh.c b/tinyusb/host/usbh.c
index b149c0f3a..f15cdfebb 100644
--- a/tinyusb/host/usbh.c
+++ b/tinyusb/host/usbh.c
@@ -106,14 +106,14 @@ static host_class_driver_t const usbh_class_drivers[TUSB_CLASS_MAPPED_INDEX_END]
//--------------------------------------------------------------------+
// INTERNAL OBJECT & FUNCTION DECLARATION
//--------------------------------------------------------------------+
-usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1] TUSB_CFG_ATTR_USBRAM; // including zero-address
+TUSB_CFG_ATTR_USBRAM usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1]; // including zero-address
//------------- Enumeration Task Data -------------//
OSAL_TASK_DEF(usbh_enumeration_task, 200, TUSB_CFG_OS_TASK_PRIO);
OSAL_QUEUE_DEF(enum_queue_def, ENUM_QUEUE_DEPTH, uint32_t);
static osal_queue_handle_t enum_queue_hdl;
-ATTR_ALIGNED(4) STATIC_VAR uint8_t enum_data_buffer[TUSB_CFG_HOST_ENUM_BUFFER_SIZE] TUSB_CFG_ATTR_USBRAM;
+TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(4) STATIC_VAR uint8_t enum_data_buffer[TUSB_CFG_HOST_ENUM_BUFFER_SIZE];
//------------- Reporter Task Data -------------//