Skip to content

Commit

Permalink
Merge pull request #2404 from fpistm/refactor_code
Browse files Browse the repository at this point in the history
refactor: move several sources as built-in library
  • Loading branch information
fpistm authored Jun 20, 2024
2 parents 6c0c006 + 66b29ba commit a3e468a
Show file tree
Hide file tree
Showing 152 changed files with 337 additions and 89 deletions.
5 changes: 2 additions & 3 deletions CI/update/stm32cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,8 @@ def checkConfig():
stm32_def = (
repo_local_path
/ repo_core_name
/ "cores"
/ "arduino"
/ "stm32"
/ "libraries"
/ "SrcWrapper"
/ stm32_def
)
except IOError:
Expand Down
2 changes: 1 addition & 1 deletion CI/update/stm32wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def checkConfig(arg_core, arg_cmsis):

HALoutSrc_path = SrcWrapper_path / "src" / "HAL"
LLoutSrc_path = SrcWrapper_path / "src" / "LL"
LLoutInc_path = core_path / "cores" / "arduino" / "stm32" / "LL"
LLoutInc_path = SrcWrapper_path / "inc" / "LL"

if arg_cmsis is not None:
CMSIS_path = Path(arg_cmsis).resolve()
Expand Down
26 changes: 22 additions & 4 deletions License.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,23 @@ Note: most license information is available on top of each source file

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

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

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

[Apache License](#apache-license) is used for:
* system/Drivers/CMSIS folder includes the STMicroelectronics CMSIS device
* cores/arduino/stm32/pinmap.*
* system/include/include/pinmap.h
* libraries/SrcWrapper/src/stm32/pinmap.c
* tools/platformio/platformio-build.py

[MIT License](#mit-license)
* libraries/VirtIO/*/virtio*

Note:
* system/STM32*xx/system_stm32*xx.c uses same license than system/Drivers/ subfolders
Expand Down Expand Up @@ -773,3 +781,13 @@ the License. You may obtain a copy of the License at:
limitations under the License.

-------------------------------------------------------------------------------
## MIT License
The MIT License (MIT)

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.

-------------------------------------------------------------------------------
9 changes: 4 additions & 5 deletions cmake/set_base_arduino_config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@ target_include_directories(base_config INTERFACE
"${BUILD_CORE_PATH}"
"${BUILD_CORE_PATH}/avr"
"${BUILD_CORE_PATH}/stm32"
"${BUILD_CORE_PATH}/stm32/LL"
"${BUILD_CORE_PATH}/stm32/usb"
"${BUILD_CORE_PATH}/stm32/OpenAMP"
"${BUILD_CORE_PATH}/stm32/usb/hid"
"${BUILD_CORE_PATH}/stm32/usb/cdc"
"${BUILD_LIB_PATH}/SrcWrapper/inc"
"${BUILD_LIB_PATH}/SrcWrapper/inc/LL"
"${BUILD_LIB_PATH}/USBDevice/inc"
"${BUILD_LIB_PATH}/VirtIO/inc"
"${BUILD_SYSTEM_PATH}/Middlewares/ST/STM32_USB_Device_Library/Core/Inc"
"${BUILD_SYSTEM_PATH}/Middlewares/ST/STM32_USB_Device_Library/Core/Src"
"${CMSIS5_PATH}/CMSIS/DSP/Include"
Expand Down
2 changes: 2 additions & 0 deletions cmake/templates/easy_cmake.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ build_sketch(TARGET "{{tgtname or "@binary_name_here@"}}"
# SD
# Wire
# SPI
# USBDevice
# VirtIO
)

# STEP 4: optional features
Expand Down
37 changes: 0 additions & 37 deletions cores/arduino/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,46 +31,9 @@ add_library(core_bin STATIC EXCLUDE_FROM_ALL
pins_arduino.c
Print.cpp
RingBuffer.cpp
stm32/OpenAMP/libmetal/device.c
stm32/OpenAMP/libmetal/generic/condition.c
stm32/OpenAMP/libmetal/generic/cortexm/sys.c
stm32/OpenAMP/libmetal/generic/generic_device.c
stm32/OpenAMP/libmetal/generic/generic_init.c
stm32/OpenAMP/libmetal/generic/generic_io.c
stm32/OpenAMP/libmetal/generic/generic_shmem.c
stm32/OpenAMP/libmetal/generic/time.c
stm32/OpenAMP/libmetal/init.c
stm32/OpenAMP/libmetal/io.c
stm32/OpenAMP/libmetal/log.c
stm32/OpenAMP/libmetal/shmem.c
stm32/OpenAMP/mbox_ipcc.c
stm32/OpenAMP/open-amp/remoteproc/remoteproc_virtio.c
stm32/OpenAMP/open-amp/rpmsg/rpmsg.c
stm32/OpenAMP/open-amp/rpmsg/rpmsg_virtio.c
stm32/OpenAMP/openamp.c
stm32/OpenAMP/rsc_table.c
stm32/OpenAMP/virt_uart.c
stm32/OpenAMP/virtio/virtio.c
stm32/OpenAMP/virtio/virtqueue.c
stm32/OpenAMP/virtio_buffer.c
stm32/OpenAMP/virtio_log.c
stm32/startup_stm32yyxx.S
stm32/usb/cdc/cdc_queue.c
stm32/usb/cdc/usbd_cdc.c
stm32/usb/cdc/usbd_cdc_if.c
stm32/usb/hid/usbd_hid_composite.c
stm32/usb/hid/usbd_hid_composite_if.c
stm32/usb/usb_device_core.c
stm32/usb/usb_device_ctlreq.c
stm32/usb/usb_device_ioreq.c
stm32/usb/usbd_conf.c
stm32/usb/usbd_desc.c
stm32/usb/usbd_ep_conf.c
stm32/usb/usbd_if.c
Stream.cpp
Tone.cpp
USBSerial.cpp
VirtIOSerial.cpp
WInterrupts.cpp
wiring_analog.c
wiring_digital.c
Expand Down
8 changes: 6 additions & 2 deletions cores/arduino/WSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@

#include "variant.h"
#include "HardwareSerial.h"
#include "USBSerial.h"
#include "VirtIOSerial.h"
#if defined (USBCON) && defined(USBD_USE_CDC)
#include "USBSerial.h"
#endif /* USBCON && USBD_USE_CDC */
#if defined(VIRTIOCON)
#include "VirtIOSerial.h"
#endif /* VIRTIOCON */

#if defined (USBCON) && defined(USBD_USE_CDC)
#ifndef DISABLE_GENERIC_SERIALUSB
Expand Down
2 changes: 2 additions & 0 deletions libraries/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ add_subdirectory(SPI)
add_subdirectory(Servo)
add_subdirectory(SoftwareSerial)
add_subdirectory(SrcWrapper)
add_subdirectory(USBDevice)
add_subdirectory(VirtIO)
add_subdirectory(Wire)
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.
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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/*
*******************************************************************************
* Copyright (c) 2016-2021, STMicroelectronics
* All rights reserved.
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
*******************************************************************************
*/
#ifndef _PINNAMES_H
#define _PINNAMES_H

Expand Down
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.
44 changes: 25 additions & 19 deletions libraries/SrcWrapper/src/new.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
/*
Copyright (c) 2014 Arduino. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

/* Teensyduino Core Library
* http://www.pjrc.com/teensy/
* Copyright (c) 2017 PJRC.COM, LLC.
*
* 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:
*
* 1. 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.
*/
#include <stdlib.h>

void *operator new (size_t size)
Expand Down Expand Up @@ -46,4 +52,4 @@ void operator delete (void *ptr, size_t /*size*/)
void operator delete[](void *ptr, size_t /*size*/)
{
free(ptr);
}
}
4 changes: 3 additions & 1 deletion libraries/SrcWrapper/src/stm32/hw_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
#include "dwt.h"
#include "hw_config.h"
#include "clock.h"
#include "usbd_if.h"
#if defined (USBCON) && defined(USBD_USE_CDC)
#include "usbd_if.h"
#endif

#ifdef __cplusplus
extern "C" {
Expand Down
42 changes: 42 additions & 0 deletions libraries/USBDevice/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# v3.21 implemented semantic changes regarding $<TARGET_OBJECTS:...>
# See https://cmake.org/cmake/help/v3.21/command/target_link_libraries.html#linking-object-libraries-via-target-objects
cmake_minimum_required(VERSION 3.21)

add_library(USBDevice INTERFACE)
add_library(USBDevice_usage INTERFACE)

target_include_directories(USBDevice_usage INTERFACE
src
)


target_link_libraries(USBDevice_usage INTERFACE
base_config
)

target_link_libraries(USBDevice INTERFACE USBDevice_usage)



add_library(USBDevice_bin OBJECT EXCLUDE_FROM_ALL
src/cdc/cdc_queue.c
src/cdc/usbd_cdc.c
src/cdc/usbd_cdc_if.c
src/hid/usbd_hid_composite.c
src/hid/usbd_hid_composite_if.c
src/usb_device_core.c
src/usb_device_ctlreq.c
src/usb_device_ioreq.c
src/usbd_conf.c
src/usbd_desc.c
src/usbd_ep_conf.c
src/usbd_if.c
src/USBSerial.cpp
)
target_link_libraries(USBDevice_bin PUBLIC USBDevice_usage)

target_link_libraries(USBDevice INTERFACE
USBDevice_bin
$<TARGET_OBJECTS:USBDevice_bin>
)

9 changes: 9 additions & 0 deletions libraries/USBDevice/examples/BareMinimum/BareMinimum.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
void setup() {
// put your setup code here, to run once:

}

void loop() {
// put your main code here, to run repeatedly:

}
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.
44 changes: 44 additions & 0 deletions libraries/USBDevice/keywords.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#######################################
# Syntax Coloring Map For USBDevice
#######################################

#######################################
# Datatypes (KEYWORD1)
#######################################
USBSerial KEYWORD1

#######################################
# Methods and Functions (KEYWORD2)
#######################################
SerialUSB KEYWORD2
begin KEYWORD2
available KEYWORD2
availableForWrite KEYWORD2
peek KEYWORD2
read KEYWORD2
readBytes KEYWORD2
readBytesUntil
write KEYWORD2
flush KEYWORD2
baud KEYWORD2
stopbits KEYWORD2
paritytype KEYWORD2
numbits KEYWORD2
dtr KEYWORD2
dtr KEYWORD2
rts KEYWORD2

#######################################
# Constants (LITERAL1)
#######################################
USBD_VID LITERAL1
USBD_PID LITERAL1
USBD_MANUFACTURER_STRING LITERAL1
ONE_STOP_BIT LITERAL1
ONE_AND_HALF_STOP_BIT LITERAL1
TWO_STOP_BITS LITERAL1
NO_PARITY LITERAL1
ODD_PARITY LITERAL1
EVEN_PARITY LITERAL1
MARK_PARITY LITERAL1
SPACE_PARITY LITERAL1
9 changes: 9 additions & 0 deletions libraries/USBDevice/library.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name=USBDevice
version=1.0.0
author=Frederic Pillon
maintainer=stm32duino
sentence=Enables USB device support (CDC or HID).
paragraph=
category=Communication
url=https://github.com/stm32duino/Arduino_Core_STM32
architectures=stm32
4 changes: 4 additions & 0 deletions libraries/USBDevice/src/USBDevice.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#ifndef __USBD_H__
#define __USBD_H__

#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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit a3e468a

Please sign in to comment.