From 3b8457b56dbe0c1097d8ee7f279db6f9a40b80b7 Mon Sep 17 00:00:00 2001
From: Serge Bazanski <q3k@q3k.org>
Date: Sat, 13 May 2023 16:29:22 +0200
Subject: [PATCH] usermodule: init

This moves the badge23-specific hardware/synth modules into usermodule/.
---
 main/CMakeLists.txt                                  |  4 ++--
 usermodule/micropython.cmake                         | 12 ++++++++++++
 .../mp_hardware.c                                    |  0
 .../badge23_mp_synth.c => usermodule/mp_synth.c      |  0
 4 files changed, 14 insertions(+), 2 deletions(-)
 create mode 100644 usermodule/micropython.cmake
 rename micropython/ports/esp32/badge23_mp_hardware.c => usermodule/mp_hardware.c (100%)
 rename micropython/ports/esp32/badge23_mp_synth.c => usermodule/mp_synth.c (100%)

diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt
index ea39b53659..fd1ee89789 100644
--- a/main/CMakeLists.txt
+++ b/main/CMakeLists.txt
@@ -16,6 +16,8 @@ set(MICROPY_QSTRDEFS_PORT "${MICROPY_PORT_DIR}/qstrdefsport.h")
 
 include("${MICROPY_DIR}/py/py.cmake")
 
+set(USER_C_MODULES "${PROJECT_DIR}/usermodule/micropython.cmake")
+
 if(NOT CMAKE_BUILD_EARLY_EXPANSION)
     # Enable extmod components that will be configured by extmod.cmake.
     # A board may also have enabled additional components.
@@ -51,8 +53,6 @@ set(MICROPY_SOURCE_DRIVERS
 )
 
 set(MICROPY_SOURCE_PORT
-    ${MICROPY_PORT_DIR}/badge23_mp_hardware.c
-    ${MICROPY_PORT_DIR}/badge23_mp_synth.c
     ${MICROPY_PORT_DIR}/main.c
     ${MICROPY_PORT_DIR}/uart.c
     ${MICROPY_PORT_DIR}/usb.c
diff --git a/usermodule/micropython.cmake b/usermodule/micropython.cmake
new file mode 100644
index 0000000000..fbc5ed9b56
--- /dev/null
+++ b/usermodule/micropython.cmake
@@ -0,0 +1,12 @@
+add_library(usermod_badge23 INTERFACE)
+
+target_sources(usermod_badge23 INTERFACE
+    ${CMAKE_CURRENT_LIST_DIR}/mp_hardware.c
+    ${CMAKE_CURRENT_LIST_DIR}/mp_synth.c
+)
+
+target_include_directories(usermod_badge23 INTERFACE
+    ${CMAKE_CURRENT_LIST_DIR}
+)
+
+target_link_libraries(usermod INTERFACE usermod_badge23)
diff --git a/micropython/ports/esp32/badge23_mp_hardware.c b/usermodule/mp_hardware.c
similarity index 100%
rename from micropython/ports/esp32/badge23_mp_hardware.c
rename to usermodule/mp_hardware.c
diff --git a/micropython/ports/esp32/badge23_mp_synth.c b/usermodule/mp_synth.c
similarity index 100%
rename from micropython/ports/esp32/badge23_mp_synth.c
rename to usermodule/mp_synth.c
-- 
GitLab