Skip to content

Commit e7f7f9a

Browse files
Re-add support for Arduino Nicla Sense ME
1 parent 21b214c commit e7f7f9a

File tree

28 files changed

+58384
-43
lines changed

28 files changed

+58384
-43
lines changed

CMakeLists.txt

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,35 @@ set(MBED_APP_JSON_PATH mbed_app.json5)
1010
include(mbed-os/tools/cmake/app.cmake)
1111
add_subdirectory(mbed-os)
1212

13-
project(ArduinoCore-mbed-ce VERSION 1.0.0) # This is the version of the Mbed CE Arduino core, not of Mbed CE
13+
project(ArduinoCore-mbed-ce VERSION 1.1.0) # This is the version of the Mbed CE Arduino core, not of Mbed CE
1414

1515
# Figure out variant name. This is generally the same as the mbed target, but we need
1616
# to handle a few variations (e.g. the _SWD variants of the mbed targets)
1717
if("ARDUINO_NANO33BLE" IN_LIST MBED_TARGET_LABELS)
1818
set(ARDUINO_VARIANT_NAME "ARDUINO_NANO33BLE")
1919
elseif("RASPBERRY_PI_PICO" IN_LIST MBED_TARGET_LABELS)
2020
set(ARDUINO_VARIANT_NAME "RASPBERRY_PI_PICO")
21+
elseif("ARDUINO_NICLA_SENSE_ME" IN_LIST MBED_TARGET_LABELS)
22+
set(ARDUINO_VARIANT_NAME "ARDUINO_NICLA_SENSE_ME")
2123
else()
2224
message(FATAL_ERROR "This MBED_TARGET is currently not supported by the arduino core!")
2325
endif()
2426

2527
message(STATUS "Will install Arduino core for ${ARDUINO_VARIANT_NAME} at ${CMAKE_INSTALL_PREFIX}")
2628

27-
2829
# Compile and install libraries needed by Arduino
2930
# ---------------------------------------------------------
3031

3132
# Pass in version defines for the core
32-
target_compile_definitions(mbed-core-flags INTERFACE
33-
CORE_MAJOR=${ArduinoCore-mbed-ceVERSION_MAJOR}
34-
CORE_MINOR=${ArduinoCore-mbed-ceVERSION_MINOR}
35-
CORE_PATCH=${ArduinoCore-mbed-ceVERSION_PATCH})
33+
target_compile_definitions(mbed-os PUBLIC
34+
CORE_MAJOR=${ArduinoCore-mbed-ce_VERSION_MAJOR}
35+
CORE_MINOR=${ArduinoCore-mbed-ce_VERSION_MINOR}
36+
CORE_PATCH=${ArduinoCore-mbed-ce_VERSION_PATCH})
37+
38+
# Flag to some Mbed and Arduino code that Arduino and Mbed are being used together.
39+
# It can't be added as a "regular" Mbed define in mbed-target.config.h because there's
40+
# some code in ArduinoBLE that looks for this define without including Arduino.h.
41+
target_compile_definitions(mbed-os PUBLIC ARDUINO_ARCH_MBED=1)
3642

3743
# Create static library out of mbed-os
3844
# Note that this library MUST be linked with -Wl,--whole-archive to work.
@@ -62,13 +68,30 @@ set(MBED_LIBS_TO_INSTALL
6268
mbed-storage-littlefs-v2
6369
mbed-storage-securestore
6470
mbed-storage-tdbstore
65-
66-
# USB
67-
mbed-usb
68-
mbed-usb-cdc-ecm
69-
mbed-usb-msd
7071
)
7172

73+
if("TARGET_USBDEVICE" IN_LIST MBED_TARGET_LABELS)
74+
list(APPEND MBED_LIBS_TO_INSTALL
75+
mbed-usb
76+
mbed-usb-cdc-ecm
77+
mbed-usb-msd)
78+
endif()
79+
80+
if("FEATURE_BLE=1" IN_LIST MBED_TARGET_DEFINITIONS)
81+
82+
# Note: There are circular dependencies between the BLE libraries, so we have to list some of them twice.
83+
list(APPEND MBED_LIBS_TO_INSTALL
84+
mbed-ble
85+
mbed-ble-cordio_ll
86+
mbed-ble-cordio
87+
mbed-ble
88+
mbed-ble-cordio_ll
89+
mbed-ble-cordio
90+
mbed-ble
91+
mbed-ble-cordio_ll
92+
mbed-ble-cordio)
93+
endif()
94+
7295
# We also need to know about any precompiled .a files
7396
# under variants/xxx/libs
7497
if("ARDUINO_NANO33BLE" IN_LIST MBED_TARGET_LABELS)
@@ -80,17 +103,20 @@ else()
80103
set(ARDUINO_PRECOMPILED_A_FILES "")
81104
endif()
82105

106+
set(MBED_UNIQUE_LIBS_TO_INSTALL ${MBED_LIBS_TO_INSTALL})
107+
list(REMOVE_DUPLICATES MBED_UNIQUE_LIBS_TO_INSTALL)
108+
83109
# Minor hack: all of the Mbed optional libraries are marked as EXCLUDE_FROM_ALL, so they won't get built during the build
84110
# phase, so it will error when trying to install them. To fix this, mark them as dependencies of a target that is in ALL.
85-
add_dependencies(mbed-os-static ${MBED_LIBS_TO_INSTALL})
111+
add_dependencies(mbed-os-static ${MBED_UNIQUE_LIBS_TO_INSTALL})
86112

87-
install(TARGETS ${MBED_LIBS_TO_INSTALL} DESTINATION "variants/${ARDUINO_VARIANT_NAME}/libs")
113+
install(TARGETS ${MBED_UNIQUE_LIBS_TO_INSTALL} DESTINATION "variants/${ARDUINO_VARIANT_NAME}/libs")
88114

89115
# Generate compile option files for Arduino IDE
90116
# ---------------------------------------------------------
91117

92118
# Iterate though the Mbed main build target and the optional targets and collect include dirs / defines / etc.
93-
set(TARGETS_TO_SCAN mbed-os ${MBED_LIBS_TO_INSTALL})
119+
set(TARGETS_TO_SCAN mbed-os ${MBED_UNIQUE_LIBS_TO_INSTALL})
94120
set(SCANNED_INCLUDE_DIRS "")
95121
set(SCANNED_DEFINES "")
96122
foreach(TARGET ${TARGETS_TO_SCAN})
@@ -253,6 +279,7 @@ add_subdirectory(variants)
253279
add_subdirectory(cores)
254280
add_subdirectory(svd)
255281
add_subdirectory(libraries)
282+
add_subdirectory(debugger)
256283

257284
# Set up packaging. We want CMake to build a zip file containing the core.
258285
set(CPACK_PACKAGE_NAME "ArduinoCore-mbed-ce-${ARDUINO_VARIANT_NAME}-${CMAKE_BUILD_TYPE}")

bootloaders/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
if("ARDUINO_NANO33BLE" IN_LIST MBED_TARGET_LABELS)
22
install(DIRECTORY nano33ble DESTINATION bootloaders/)
33
endif()
4+
5+
if("ARDUINO_NICLA_SENSE_ME" IN_LIST MBED_TARGET_LABELS)
6+
install(DIRECTORY NICLA_SENSE_ME DESTINATION bootloaders/)
7+
endif()
1.92 MB
Binary file not shown.

0 commit comments

Comments
 (0)