summaryrefslogtreecommitdiff
path: root/libusb
diff options
context:
space:
mode:
Diffstat (limited to 'libusb')
-rw-r--r--libusb/CMakeLists.txt23
-rw-r--r--libusb/include/libusb/tusb_helpers.h (renamed from libusb/tusb_helpers.h)0
-rwxr-xr-xlibusb/include/libusb/tusb_helpers.h.gen (renamed from libusb/tusb_helpers.h.gen)20
-rw-r--r--libusb/include/libusb/usb_common.h (renamed from libusb/usb_common.h)0
-rw-r--r--libusb/tusb_config.h107
5 files changed, 33 insertions, 117 deletions
diff --git a/libusb/CMakeLists.txt b/libusb/CMakeLists.txt
new file mode 100644
index 0000000..8f015a1
--- /dev/null
+++ b/libusb/CMakeLists.txt
@@ -0,0 +1,23 @@
+# libusb/CMakeLists.txt - Build script for libusb support library
+#
+# Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
+# SPDX-Licence-Identifier: AGPL-3.0-or-later
+
+add_library(libusb INTERFACE)
+target_sources(libusb INTERFACE
+ usb_common.c
+)
+target_include_directories(libusb SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
+
+add_custom_command(
+ OUTPUT ${CMAKE_SOURCE_DIR}/3rd-party/MS-LCID.pdf
+ ${CMAKE_SOURCE_DIR}/3rd-party/MS-LCID.txt
+ ${CMAKE_CURRENT_SOURCE_DIR}/include/libusb/tusb_helpers.h
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/include/libusb/tusb_helpers.gen
+ COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/include/libusb/tusb_helpers.gen
+)
+add_dependencies(generate
+ ${CMAKE_SOURCE_DIR}/3rd-party/MS-LCID.pdf
+ ${CMAKE_SOURCE_DIR}/3rd-party/MS-LCID.txt
+ ${CMAKE_CURRENT_SOURCE_DIR}/include/libusb/tusb_helpers.h
+)
diff --git a/libusb/tusb_helpers.h b/libusb/include/libusb/tusb_helpers.h
index cd96357..cd96357 100644
--- a/libusb/tusb_helpers.h
+++ b/libusb/include/libusb/tusb_helpers.h
diff --git a/libusb/tusb_helpers.h.gen b/libusb/include/libusb/tusb_helpers.h.gen
index a348b16..213eda0 100755
--- a/libusb/tusb_helpers.h.gen
+++ b/libusb/include/libusb/tusb_helpers.h.gen
@@ -3,7 +3,7 @@
set -e
exec >"${0%.gen}"
cat <<'EOT'
-/* tusb_helpers.h - Preprocessor macros that I think should be included in TinyUSB
+/* libusb/tusb_helpers.h - Preprocessor macros that I think should be included in TinyUSB
*
* Copyright (c) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
*
@@ -29,10 +29,11 @@ cat <<'EOT'
*
*/
-#ifndef _USB_HELPERS_H_
-#define _USB_HELPERS_H_
+#ifndef _LIBUSB_TUSB_HELPERS_H_
+#define _LIBUSB_TUSB_HELPERS_H_
-/* USB 2.0 §9.6.7 "String" says "The list of currently defined USB LANGIDs can be found at
+/**
+ * USB 2.0 §9.6.7 "String" says "The list of currently defined USB LANGIDs can be found at
* http://www.usb.org/developers/docs.html.", but that page 404s.
*
* Once upon a time the USB-IF (usb.org) published a "Language Identifiers (LANGIDs)" version 1.0,
@@ -61,10 +62,9 @@ cat <<'EOT'
* to sort their list of by most-significant-byte was a poor editorial choice.
*/
EOT
-[ -d 3rd-party ] || mkdir 3rd-party
-[ -f 3rd-party/MS-LCID.pdf ] || wget -O 3rd-party/MS-LCID.pdf 'https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-LCID/%5bMS-LCID%5d.pdf'
-[ -f 3rd-party/MS-LCID.txt ] || pdftotext -layout 3rd-party/MS-LCID.pdf
-<3rd-party/MS-LCID.txt \
+[ -f ${CMAKE_SOURCE_DIR?}/3rd-party/MS-LCID.pdf ] || wget -O ${CMAKE_SOURCE_DIR?}/3rd-party/MS-LCID.pdf 'https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-LCID/%5bMS-LCID%5d.pdf'
+[ -f ${CMAKE_SOURCE_DIR?}/3rd-party/MS-LCID.txt ] || pdftotext -layout ${CMAKE_SOURCE_DIR?}/3rd-party/MS-LCID.pdf
+<${CMAKE_SOURCE_DIR?}/3rd-party/MS-LCID.txt \
grep -E '^\s*0x[0-9A-F]{4}\s+[a-z]' | sed 's/,.*//' | grep -v reserved | # find the lines we're interested in
sed -E 's/^\s*0x(..)(..)\s+(\S.*)/\2 \1 \3/p' | tr '[:lower:]-' '[:upper:]_' | # format them as 'PRIhex SUBhex UPPER_STR'
sort |
@@ -72,11 +72,11 @@ EOT
column --table --output-separator=' '
cat <<'EOT'
-/* USB 2.0 §9.6.6 "Endpoint", field bEndpointAddress, bit 7 */
+/** USB 2.0 §9.6.6 "Endpoint", field bEndpointAddress, bit 7 */
#define TUD_ENDPOINT_OUT 0x00
#define TUD_ENDPOINT_IN 0x80
#define TU_UTF16(str) u ## str
-#endif /* _USB_HELPERS_H_ */
+#endif /* _LIBUSB_TUSB_HELPERS_H_ */
EOT
diff --git a/libusb/usb_common.h b/libusb/include/libusb/usb_common.h
index 3b45246..3b45246 100644
--- a/libusb/usb_common.h
+++ b/libusb/include/libusb/usb_common.h
diff --git a/libusb/tusb_config.h b/libusb/tusb_config.h
deleted file mode 100644
index cb1ca3b..0000000
--- a/libusb/tusb_config.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/* tusb_config.h - Compile-time configuration for the TinyUSB library
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2019 Ha Thach (tinyusb.org)
- * Copyright (c) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-#ifndef _TUSB_CONFIG_H_
-#define _TUSB_CONFIG_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-//--------------------------------------------------------------------
-// TinyUSB Device (TUD) initialization for rp2040-based boards
-//--------------------------------------------------------------------
-
-// Which USB port to use for the RootHub.
-// The rp2040 only has 1 port, so it's gotta be port #0.
-#define BOARD_TUD_RHPORT 0
-
-// RHPort max operational speed.
-// Use OPT_MODE_DEFAULT_SPEED for max speed supported by MCU.
-#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
-
-//--------------------------------------------------------------------
-// Configuration: common
-//--------------------------------------------------------------------
-
-// defined by compiler flags
-#ifndef CFG_TUSB_MCU
-#error CFG_TUSB_MCU must be defined
-#endif
-
-// Conditional because it might be defined with `-D` on the command
-// line if `cmake -DCMAKE_BUILD_TYPE=Debug`.
-#ifndef CFG_TUSB_DEBUG
-#define CFG_TUSB_DEBUG 0
-#endif
-
-// USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
-// Tinyusb use follows macros to declare transferring memory so that they can be put
-// into those specific section.
-// e.g
-// - CFG_TUSB_MEM SECTION : __attribute__ (( section(".usb_ram") ))
-// - CFG_TUSB_MEM_ALIGN : __attribute__ ((aligned(4)))
-#define CFG_TUSB_MEM_SECTION /* blank */
-#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
-
-#define CFG_TUD_ENABLED 1
-#define CFG_TUD_MAX_SPEED BOARD_TUD_MAX_SPEED
-
-//--------------------------------------------------------------------
-// Configuration: TinyUSB Device (TUD)
-//--------------------------------------------------------------------
-
-// control endpoint max packet size (only 8, 16, 32, or 64 are valid)
-#define CFG_TUD_ENDPOINT0_SIZE 64
-
-// Which of TinyUSB's built-in class drivers to enable.
-//
-// If a class takes an int, that's the maximum number of interfaces of
-// that type that may be listed in the same configuration descriptor.
-#define CFG_TUD_CDC 0 // int : Communications Device Class (e.g. ttyUSB) https://www.usb.org/sites/default/files/CDC1.2_WMC1.1_012011.zip
-#define CFG_TUD_MSC 0 // bool: Mass Storage Class https://www.usb.org/sites/default/files/Mass_Storage_Specification_Overview_v1.4_2-19-2010.pdf
-#define CFG_TUD_HID 1 // int : Human Interface Device https://www.usb.org/sites/default/files/hid1_11.pdf
-#define CFG_TUD_AUDIO 0 // int : Audio https://www.usb.org/sites/default/files/audio10.pdf
-#define CFG_TUD_VIDEO 0 // int : Video https://www.usb.org/sites/default/files/USB_Video_Class_1_5.zip
-#define CFG_TUD_MIDI 0 // int : Musical Instrument Digital Interface https://www.usb.org/sites/default/files/USB%20MIDI%20v2_0.pdf
-#define CFG_TUD_VENDOR 0 // int : ???
-#define CFG_TUD_USBTMC 0 // bool: Test & Measurement Class https://www.usb.org/sites/default/files/USBTMC_1_006a.zip
-#define CFG_TUD_DFU_RUNTIME 0 // bool: Device Firmware Upgrade https://www.usb.org/sites/default/files/DFU_1.1.pdf
-#define CFG_TUD_DFU 0 // bool: Device Firmware Upgrade https://www.usb.org/sites/default/files/DFU_1.1.pdf
-#define CFG_TUD_ECM_RNDIS 0 // bool: net
-#define CFG_TUD_NCM 0 // bool: net
-#define CFG_TUD_BTH 0 // bool: Bluetooth
-
-// HID buffer size Should be sufficient to hold ID (if any) + Data
-#define CFG_TUD_HID_EP_BUFSIZE 8
-
-//--------------------------------------------------------------------
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _TUSB_CONFIG_H_ */