Skip to content

Commit f30df88

Browse files
committed
refactor(USBDevice): move USB device support as a built-in library
It could propbaly be splitted in 3 libraries: - USBDevice: base support - USBDCDC - USBDHID Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent 9bd70d7 commit f30df88

37 files changed

+128
-23
lines changed

License.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ Note: most license information is available on top of each source file
99

1010
[BSD 3-Clause License](#bsd-3-clause-license) is used for:
1111

12-
* cores/arduino/stm32/ mainly contains source from STMicroelectronics.
1312
* system/Drivers/STM32*xx_HAL_Driver folders include the STMicroelectronics HAL Drivers.
1413
* system/Middlewares/OpenAMP folders.
1514
* libraries/VirtIO/ OpenAMP part except virtio* implementation see [MIT License](#mit-license)
1615
* libraries/SrcWrapper/inc/PinName*.h
1716

1817
[Ultimate Liberty License](#Ultimate-Liberty-License) is used for:
1918
* system/Middlewares/STM32_USB_*_Library/ folders
19+
* libraries/USBDevice/ (see header)
2020

2121
[Apache License](#apache-license) is used for:
2222
* system/Drivers/CMSIS folder includes the STMicroelectronics CMSIS device

cmake/set_base_arduino_config.cmake

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,9 @@ target_include_directories(base_config INTERFACE
5555
"${BUILD_CORE_PATH}"
5656
"${BUILD_CORE_PATH}/avr"
5757
"${BUILD_CORE_PATH}/stm32"
58-
"${BUILD_CORE_PATH}/stm32/usb"
59-
"${BUILD_CORE_PATH}/stm32/usb/hid"
60-
"${BUILD_CORE_PATH}/stm32/usb/cdc"
6158
"${BUILD_LIB_PATH}/SrcWrapper/inc"
6259
"${BUILD_LIB_PATH}/SrcWrapper/inc/LL"
60+
"${BUILD_LIB_PATH}/USBDevice/inc"
6361
"${BUILD_LIB_PATH}/VirtIO/inc"
6462
"${BUILD_SYSTEM_PATH}/Middlewares/ST/STM32_USB_Device_Library/Core/Inc"
6563
"${BUILD_SYSTEM_PATH}/Middlewares/ST/STM32_USB_Device_Library/Core/Src"

cmake/templates/easy_cmake.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ build_sketch(TARGET "{{tgtname or "@binary_name_here@"}}"
9191
# SD
9292
# Wire
9393
# SPI
94+
# USBDevice
9495
# VirtIO
9596
)
9697

cores/arduino/CMakeLists.txt

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,8 @@ add_library(core_bin STATIC EXCLUDE_FROM_ALL
3232
Print.cpp
3333
RingBuffer.cpp
3434
stm32/startup_stm32yyxx.S
35-
stm32/usb/cdc/cdc_queue.c
36-
stm32/usb/cdc/usbd_cdc.c
37-
stm32/usb/cdc/usbd_cdc_if.c
38-
stm32/usb/hid/usbd_hid_composite.c
39-
stm32/usb/hid/usbd_hid_composite_if.c
40-
stm32/usb/usb_device_core.c
41-
stm32/usb/usb_device_ctlreq.c
42-
stm32/usb/usb_device_ioreq.c
43-
stm32/usb/usbd_conf.c
44-
stm32/usb/usbd_desc.c
45-
stm32/usb/usbd_ep_conf.c
46-
stm32/usb/usbd_if.c
4735
Stream.cpp
4836
Tone.cpp
49-
USBSerial.cpp
5037
WInterrupts.cpp
5138
wiring_analog.c
5239
wiring_digital.c

cores/arduino/WSerial.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
#include "variant.h"
55
#include "HardwareSerial.h"
6-
#include "USBSerial.h"
6+
#if defined (USBCON) && defined(USBD_USE_CDC)
7+
#include "USBSerial.h"
8+
#endif /* USBCON && USBD_USE_CDC */
79
#if defined(VIRTIOCON)
810
#include "VirtIOSerial.h"
911
#endif /* VIRTIOCON */

libraries/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ add_subdirectory(SPI)
1010
add_subdirectory(Servo)
1111
add_subdirectory(SoftwareSerial)
1212
add_subdirectory(SrcWrapper)
13+
add_subdirectory(USBDevice)
1314
add_subdirectory(VirtIO)
1415
add_subdirectory(Wire)

libraries/SrcWrapper/src/stm32/hw_config.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
#include "dwt.h"
1414
#include "hw_config.h"
1515
#include "clock.h"
16-
#include "usbd_if.h"
16+
#if defined (USBCON) && defined(USBD_USE_CDC)
17+
#include "usbd_if.h"
18+
#endif
1719

1820
#ifdef __cplusplus
1921
extern "C" {

libraries/USBDevice/CMakeLists.txt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# v3.21 implemented semantic changes regarding $<TARGET_OBJECTS:...>
2+
# See https://cmake.org/cmake/help/v3.21/command/target_link_libraries.html#linking-object-libraries-via-target-objects
3+
cmake_minimum_required(VERSION 3.21)
4+
5+
add_library(USBDevice INTERFACE)
6+
add_library(USBDevice_usage INTERFACE)
7+
8+
target_include_directories(USBDevice_usage INTERFACE
9+
src
10+
)
11+
12+
13+
target_link_libraries(USBDevice_usage INTERFACE
14+
base_config
15+
)
16+
17+
target_link_libraries(USBDevice INTERFACE USBDevice_usage)
18+
19+
20+
21+
add_library(USBDevice_bin OBJECT EXCLUDE_FROM_ALL
22+
src/cdc/cdc_queue.c
23+
src/cdc/usbd_cdc.c
24+
src/cdc/usbd_cdc_if.c
25+
src/hid/usbd_hid_composite.c
26+
src/hid/usbd_hid_composite_if.c
27+
src/usb_device_core.c
28+
src/usb_device_ctlreq.c
29+
src/usb_device_ioreq.c
30+
src/usbd_conf.c
31+
src/usbd_desc.c
32+
src/usbd_ep_conf.c
33+
src/usbd_if.c
34+
src/USBSerial.cpp
35+
)
36+
target_link_libraries(USBDevice_bin PUBLIC USBDevice_usage)
37+
38+
target_link_libraries(USBDevice INTERFACE
39+
USBDevice_bin
40+
$<TARGET_OBJECTS:USBDevice_bin>
41+
)
42+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
void setup() {
2+
// put your setup code here, to run once:
3+
4+
}
5+
6+
void loop() {
7+
// put your main code here, to run repeatedly:
8+
9+
}
File renamed without changes.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy