Skip to content

Commit a3e468a

Browse files
authored
Merge pull request #2404 from fpistm/refactor_code
refactor: move several sources as built-in library
2 parents 6c0c006 + 66b29ba commit a3e468a

File tree

152 files changed

+337
-89
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

152 files changed

+337
-89
lines changed

Diff for: CI/update/stm32cube.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,8 @@ def checkConfig():
123123
stm32_def = (
124124
repo_local_path
125125
/ repo_core_name
126-
/ "cores"
127-
/ "arduino"
128-
/ "stm32"
126+
/ "libraries"
127+
/ "SrcWrapper"
129128
/ stm32_def
130129
)
131130
except IOError:

Diff for: CI/update/stm32wrapper.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def checkConfig(arg_core, arg_cmsis):
9797

9898
HALoutSrc_path = SrcWrapper_path / "src" / "HAL"
9999
LLoutSrc_path = SrcWrapper_path / "src" / "LL"
100-
LLoutInc_path = core_path / "cores" / "arduino" / "stm32" / "LL"
100+
LLoutInc_path = SrcWrapper_path / "inc" / "LL"
101101

102102
if arg_cmsis is not None:
103103
CMSIS_path = Path(arg_cmsis).resolve()

Diff for: License.md

+22-4

Diff for: cmake/set_base_arduino_config.cmake

+4-5
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,10 @@ 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/LL"
59-
"${BUILD_CORE_PATH}/stm32/usb"
60-
"${BUILD_CORE_PATH}/stm32/OpenAMP"
61-
"${BUILD_CORE_PATH}/stm32/usb/hid"
62-
"${BUILD_CORE_PATH}/stm32/usb/cdc"
58+
"${BUILD_LIB_PATH}/SrcWrapper/inc"
59+
"${BUILD_LIB_PATH}/SrcWrapper/inc/LL"
60+
"${BUILD_LIB_PATH}/USBDevice/inc"
61+
"${BUILD_LIB_PATH}/VirtIO/inc"
6362
"${BUILD_SYSTEM_PATH}/Middlewares/ST/STM32_USB_Device_Library/Core/Inc"
6463
"${BUILD_SYSTEM_PATH}/Middlewares/ST/STM32_USB_Device_Library/Core/Src"
6564
"${CMSIS5_PATH}/CMSIS/DSP/Include"

Diff for: cmake/templates/easy_cmake.cmake

+2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ build_sketch(TARGET "{{tgtname or "@binary_name_here@"}}"
9191
# SD
9292
# Wire
9393
# SPI
94+
# USBDevice
95+
# VirtIO
9496
)
9597

9698
# STEP 4: optional features

Diff for: cores/arduino/CMakeLists.txt

-37
Original file line numberDiff line numberDiff line change
@@ -31,46 +31,9 @@ add_library(core_bin STATIC EXCLUDE_FROM_ALL
3131
pins_arduino.c
3232
Print.cpp
3333
RingBuffer.cpp
34-
stm32/OpenAMP/libmetal/device.c
35-
stm32/OpenAMP/libmetal/generic/condition.c
36-
stm32/OpenAMP/libmetal/generic/cortexm/sys.c
37-
stm32/OpenAMP/libmetal/generic/generic_device.c
38-
stm32/OpenAMP/libmetal/generic/generic_init.c
39-
stm32/OpenAMP/libmetal/generic/generic_io.c
40-
stm32/OpenAMP/libmetal/generic/generic_shmem.c
41-
stm32/OpenAMP/libmetal/generic/time.c
42-
stm32/OpenAMP/libmetal/init.c
43-
stm32/OpenAMP/libmetal/io.c
44-
stm32/OpenAMP/libmetal/log.c
45-
stm32/OpenAMP/libmetal/shmem.c
46-
stm32/OpenAMP/mbox_ipcc.c
47-
stm32/OpenAMP/open-amp/remoteproc/remoteproc_virtio.c
48-
stm32/OpenAMP/open-amp/rpmsg/rpmsg.c
49-
stm32/OpenAMP/open-amp/rpmsg/rpmsg_virtio.c
50-
stm32/OpenAMP/openamp.c
51-
stm32/OpenAMP/rsc_table.c
52-
stm32/OpenAMP/virt_uart.c
53-
stm32/OpenAMP/virtio/virtio.c
54-
stm32/OpenAMP/virtio/virtqueue.c
55-
stm32/OpenAMP/virtio_buffer.c
56-
stm32/OpenAMP/virtio_log.c
5734
stm32/startup_stm32yyxx.S
58-
stm32/usb/cdc/cdc_queue.c
59-
stm32/usb/cdc/usbd_cdc.c
60-
stm32/usb/cdc/usbd_cdc_if.c
61-
stm32/usb/hid/usbd_hid_composite.c
62-
stm32/usb/hid/usbd_hid_composite_if.c
63-
stm32/usb/usb_device_core.c
64-
stm32/usb/usb_device_ctlreq.c
65-
stm32/usb/usb_device_ioreq.c
66-
stm32/usb/usbd_conf.c
67-
stm32/usb/usbd_desc.c
68-
stm32/usb/usbd_ep_conf.c
69-
stm32/usb/usbd_if.c
7035
Stream.cpp
7136
Tone.cpp
72-
USBSerial.cpp
73-
VirtIOSerial.cpp
7437
WInterrupts.cpp
7538
wiring_analog.c
7639
wiring_digital.c

Diff for: cores/arduino/WSerial.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33

44
#include "variant.h"
55
#include "HardwareSerial.h"
6-
#include "USBSerial.h"
7-
#include "VirtIOSerial.h"
6+
#if defined (USBCON) && defined(USBD_USE_CDC)
7+
#include "USBSerial.h"
8+
#endif /* USBCON && USBD_USE_CDC */
9+
#if defined(VIRTIOCON)
10+
#include "VirtIOSerial.h"
11+
#endif /* VIRTIOCON */
812

913
#if defined (USBCON) && defined(USBD_USE_CDC)
1014
#ifndef DISABLE_GENERIC_SERIALUSB

Diff for: libraries/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ add_subdirectory(SPI)
1010
add_subdirectory(Servo)
1111
add_subdirectory(SoftwareSerial)
1212
add_subdirectory(SrcWrapper)
13+
add_subdirectory(USBDevice)
14+
add_subdirectory(VirtIO)
1315
add_subdirectory(Wire)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: cores/arduino/stm32/PinNames.h renamed to libraries/SrcWrapper/inc/PinNames.h

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2016-2021, STMicroelectronics
4+
* All rights reserved.
5+
*
6+
* This software component is licensed by ST under BSD 3-Clause license,
7+
* the "License"; You may not use this file except in compliance with the
8+
* License. You may obtain a copy of the License at:
9+
* opensource.org/licenses/BSD-3-Clause
10+
*
11+
*******************************************************************************
12+
*/
113
#ifndef _PINNAMES_H
214
#define _PINNAMES_H
315

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: libraries/SrcWrapper/src/new.cpp

+25-19
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
1-
/*
2-
Copyright (c) 2014 Arduino. All right reserved.
3-
4-
This library is free software; you can redistribute it and/or
5-
modify it under the terms of the GNU Lesser General Public
6-
License as published by the Free Software Foundation; either
7-
version 2.1 of the License, or (at your option) any later version.
8-
9-
This library is distributed in the hope that it will be useful,
10-
but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12-
See the GNU Lesser General Public License for more details.
13-
14-
You should have received a copy of the GNU Lesser General Public
15-
License along with this library; if not, write to the Free Software
16-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17-
*/
18-
1+
/* Teensyduino Core Library
2+
* http://www.pjrc.com/teensy/
3+
* Copyright (c) 2017 PJRC.COM, LLC.
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining
6+
* a copy of this software and associated documentation files (the
7+
* "Software"), to deal in the Software without restriction, including
8+
* without limitation the rights to use, copy, modify, merge, publish,
9+
* distribute, sublicense, and/or sell copies of the Software, and to
10+
* permit persons to whom the Software is furnished to do so, subject to
11+
* the following conditions:
12+
*
13+
* 1. The above copyright notice and this permission notice shall be
14+
* included in all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20+
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21+
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
* SOFTWARE.
24+
*/
1925
#include <stdlib.h>
2026

2127
void *operator new (size_t size)
@@ -46,4 +52,4 @@ void operator delete (void *ptr, size_t /*size*/)
4652
void operator delete[](void *ptr, size_t /*size*/)
4753
{
4854
free(ptr);
49-
}
55+
}

Diff for: libraries/SrcWrapper/src/stm32/hw_config.c

+3-1
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" {

Diff for: libraries/USBDevice/CMakeLists.txt

+42
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+
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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: libraries/USBDevice/keywords.txt

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#######################################
2+
# Syntax Coloring Map For USBDevice
3+
#######################################
4+
5+
#######################################
6+
# Datatypes (KEYWORD1)
7+
#######################################
8+
USBSerial KEYWORD1
9+
10+
#######################################
11+
# Methods and Functions (KEYWORD2)
12+
#######################################
13+
SerialUSB KEYWORD2
14+
begin KEYWORD2
15+
available KEYWORD2
16+
availableForWrite KEYWORD2
17+
peek KEYWORD2
18+
read KEYWORD2
19+
readBytes KEYWORD2
20+
readBytesUntil
21+
write KEYWORD2
22+
flush KEYWORD2
23+
baud KEYWORD2
24+
stopbits KEYWORD2
25+
paritytype KEYWORD2
26+
numbits KEYWORD2
27+
dtr KEYWORD2
28+
dtr KEYWORD2
29+
rts KEYWORD2
30+
31+
#######################################
32+
# Constants (LITERAL1)
33+
#######################################
34+
USBD_VID LITERAL1
35+
USBD_PID LITERAL1
36+
USBD_MANUFACTURER_STRING LITERAL1
37+
ONE_STOP_BIT LITERAL1
38+
ONE_AND_HALF_STOP_BIT LITERAL1
39+
TWO_STOP_BITS LITERAL1
40+
NO_PARITY LITERAL1
41+
ODD_PARITY LITERAL1
42+
EVEN_PARITY LITERAL1
43+
MARK_PARITY LITERAL1
44+
SPACE_PARITY LITERAL1

Diff for: libraries/USBDevice/library.properties

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=USBDevice
2+
version=1.0.0
3+
author=Frederic Pillon
4+
maintainer=stm32duino
5+
sentence=Enables USB device support (CDC or HID).
6+
paragraph=
7+
category=Communication
8+
url=https://github.com/stm32duino/Arduino_Core_STM32
9+
architectures=stm32

Diff for: libraries/USBDevice/src/USBDevice.h

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#ifndef __USBD_H__
2+
#define __USBD_H__
3+
4+
#endif /* __USBD_H__ */
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)