From 6bfb38b2a7d0c40c05a74c7b12e258e251189a5c Mon Sep 17 00:00:00 2001 From: Takuya Sasaki Date: Wed, 23 Oct 2024 10:49:11 +0900 Subject: [PATCH] lib: Move power control API from hwtest This commit moves the power control API, which was under `test/hwtest`, to the `lib` directory. This is in preparation for common use with the SC-Sat1 Flight software. Signed-off-by: Takuya Sasaki --- lib/CMakeLists.txt | 1 + lib/Kconfig | 1 + lib/core/CMakeLists.txt | 9 +++++++++ lib/core/Kconfig | 10 ++++++++++ lib/core/Kconfig.adcs | 16 ++++++++++++++++ lib/core/Kconfig.main | 16 ++++++++++++++++ .../src/pwrctrl.c => lib/core/pwrctrl_adcs.c | 0 .../src/pwrctrl.h => lib/core/pwrctrl_adcs.h | 0 .../src/pwrctrl.c => lib/core/pwrctrl_main.c | 2 +- .../src/pwrctrl.h => lib/core/pwrctrl_main.h | 0 tests/hwtest/adcs/CMakeLists.txt | 1 - tests/hwtest/adcs/src/adcs_init.c | 2 +- tests/hwtest/adcs/src/imu.c | 2 +- tests/hwtest/adcs/src/loop_test.c | 2 +- tests/hwtest/adcs/src/rw.h | 2 +- tests/hwtest/adcs/src/syshk_test.c | 2 +- tests/hwtest/main/CMakeLists.txt | 1 - tests/hwtest/main/src/loop_test.c | 2 +- tests/hwtest/main/src/main_init.c | 2 +- tests/hwtest/main/src/syshk_test.c | 2 +- 20 files changed, 62 insertions(+), 11 deletions(-) create mode 100644 lib/core/CMakeLists.txt create mode 100644 lib/core/Kconfig create mode 100644 lib/core/Kconfig.adcs create mode 100644 lib/core/Kconfig.main rename tests/hwtest/adcs/src/pwrctrl.c => lib/core/pwrctrl_adcs.c (100%) rename tests/hwtest/adcs/src/pwrctrl.h => lib/core/pwrctrl_adcs.h (100%) rename tests/hwtest/main/src/pwrctrl.c => lib/core/pwrctrl_main.c (98%) rename tests/hwtest/main/src/pwrctrl.h => lib/core/pwrctrl_main.h (100%) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index fc0eb344..fe3fccaf 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,4 +1,5 @@ # Copyright (c) 2024 Space Cubics, LLC. # SPDX-License-Identifier: Apache-2.0 +add_subdirectory(core) add_subdirectory_ifdef(CONFIG_SC_LIB_FLASH flash) diff --git a/lib/Kconfig b/lib/Kconfig index a3bfd57c..c0aacaf6 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -3,6 +3,7 @@ menu "Space Cubics Libraries" +rsource "core/Kconfig" rsource "flash/Kconfig" endmenu diff --git a/lib/core/CMakeLists.txt b/lib/core/CMakeLists.txt new file mode 100644 index 00000000..471fad91 --- /dev/null +++ b/lib/core/CMakeLists.txt @@ -0,0 +1,9 @@ +# Copyright (c) 2024 Space Cubics, LLC. +# SPDX-License-Identifier: Apache-2.0 + +if (CONFIG_BOARD_SCSAT1_MAIN OR CONFIG_BOARD_SCSAT1_ADCS) + zephyr_library() + zephyr_library_sources_ifdef(CONFIG_SC_LIB_CORE_MAIN pwrctrl_main.c) + zephyr_library_sources_ifdef(CONFIG_SC_LIB_CORE_ADCS pwrctrl_adcs.c) + zephyr_include_directories(.) +endif() diff --git a/lib/core/Kconfig b/lib/core/Kconfig new file mode 100644 index 00000000..48b92087 --- /dev/null +++ b/lib/core/Kconfig @@ -0,0 +1,10 @@ +# Copyright (c) 2024 Space Cubics, LLC. +# SPDX-License-Identifier: Apache-2.0 + +if BOARD_SCSAT1_MAIN +rsource "Kconfig.main" +endif + +if BOARD_SCSAT1_ADCS +rsource "Kconfig.adcs" +endif diff --git a/lib/core/Kconfig.adcs b/lib/core/Kconfig.adcs new file mode 100644 index 00000000..a7cee83b --- /dev/null +++ b/lib/core/Kconfig.adcs @@ -0,0 +1,16 @@ +# Copyright (c) 2024 Space Cubics, LLC. +# SPDX-License-Identifier: Apache-2.0 + +menuconfig SC_LIB_CORE_ADCS + bool "Space Cubics Core libraries for ADCS Board" + default y + help + Enable Space Cubics Core libraries for ADCS Board. + +if SC_LIB_CORE_ADCS + +module = SC_LIB_CORE_ADCS +module-str = Space Cubics Core libraries for ADCS Board +source "subsys/logging/Kconfig.template.log_config" + +endif diff --git a/lib/core/Kconfig.main b/lib/core/Kconfig.main new file mode 100644 index 00000000..fced834a --- /dev/null +++ b/lib/core/Kconfig.main @@ -0,0 +1,16 @@ +# Copyright (c) 2024 Space Cubics, LLC. +# SPDX-License-Identifier: Apache-2.0 + +menuconfig SC_LIB_CORE_MAIN + bool "Space Cubics Core libraries for MAIN Board" + default y + help + Enable Space Cubics Core libraries for MAIN Board. + +if SC_LIB_CORE_MAIN + +module = SC_LIB_CORE_MAIN +module-str = Space Cubics Core libraries for MAIN Board +source "subsys/logging/Kconfig.template.log_config" + +endif diff --git a/tests/hwtest/adcs/src/pwrctrl.c b/lib/core/pwrctrl_adcs.c similarity index 100% rename from tests/hwtest/adcs/src/pwrctrl.c rename to lib/core/pwrctrl_adcs.c diff --git a/tests/hwtest/adcs/src/pwrctrl.h b/lib/core/pwrctrl_adcs.h similarity index 100% rename from tests/hwtest/adcs/src/pwrctrl.h rename to lib/core/pwrctrl_adcs.h diff --git a/tests/hwtest/main/src/pwrctrl.c b/lib/core/pwrctrl_main.c similarity index 98% rename from tests/hwtest/main/src/pwrctrl.c rename to lib/core/pwrctrl_main.c index 06871525..0201210c 100644 --- a/tests/hwtest/main/src/pwrctrl.c +++ b/lib/core/pwrctrl_main.c @@ -6,7 +6,7 @@ #include #include "sc_dstrx3.h" -#include "pwrctrl.h" +#include "pwrctrl_main.h" /* Registers */ #define SC_MAIN_SYSREG_BASE_ADDR (0x4F000000) diff --git a/tests/hwtest/main/src/pwrctrl.h b/lib/core/pwrctrl_main.h similarity index 100% rename from tests/hwtest/main/src/pwrctrl.h rename to lib/core/pwrctrl_main.h diff --git a/tests/hwtest/adcs/CMakeLists.txt b/tests/hwtest/adcs/CMakeLists.txt index 037c83ca..46480a4f 100644 --- a/tests/hwtest/adcs/CMakeLists.txt +++ b/tests/hwtest/adcs/CMakeLists.txt @@ -10,7 +10,6 @@ project(scsat1-adcs) target_sources(app PRIVATE src/main.c) target_sources(app PRIVATE src/wdog.c) -target_sources(app PRIVATE src/pwrctrl.c) target_sources(app PRIVATE src/sysmon.c) target_sources(app PRIVATE src/temp.c) target_sources(app PRIVATE src/temp_test.c) diff --git a/tests/hwtest/adcs/src/adcs_init.c b/tests/hwtest/adcs/src/adcs_init.c index 39528767..b6299a5e 100644 --- a/tests/hwtest/adcs/src/adcs_init.c +++ b/tests/hwtest/adcs/src/adcs_init.c @@ -5,7 +5,7 @@ */ #include -#include "pwrctrl.h" +#include "pwrctrl_adcs.h" #include "sysmon.h" #include "gnss.h" #include "imu.h" diff --git a/tests/hwtest/adcs/src/imu.c b/tests/hwtest/adcs/src/imu.c index 2a16ce0f..901d361a 100644 --- a/tests/hwtest/adcs/src/imu.c +++ b/tests/hwtest/adcs/src/imu.c @@ -6,7 +6,7 @@ #include #include -#include "pwrctrl.h" +#include "pwrctrl_adcs.h" #include "imu.h" #include diff --git a/tests/hwtest/adcs/src/loop_test.c b/tests/hwtest/adcs/src/loop_test.c index 32fa10e9..eef989ba 100644 --- a/tests/hwtest/adcs/src/loop_test.c +++ b/tests/hwtest/adcs/src/loop_test.c @@ -8,7 +8,7 @@ #include #include "common.h" #include "loop_test.h" -#include "pwrctrl.h" +#include "pwrctrl_adcs.h" #include "temp_test.h" #include "cv_test.h" #include "imu_test.h" diff --git a/tests/hwtest/adcs/src/rw.h b/tests/hwtest/adcs/src/rw.h index c638c24c..f93d701e 100644 --- a/tests/hwtest/adcs/src/rw.h +++ b/tests/hwtest/adcs/src/rw.h @@ -7,7 +7,7 @@ #pragma once #include -#include "pwrctrl.h" +#include "pwrctrl_adcs.h" #define RW_MAX_POTENTION (0x7F) #define RW_HALF_POTENTION (0x40) diff --git a/tests/hwtest/adcs/src/syshk_test.c b/tests/hwtest/adcs/src/syshk_test.c index 72e5f02b..5f038796 100644 --- a/tests/hwtest/adcs/src/syshk_test.c +++ b/tests/hwtest/adcs/src/syshk_test.c @@ -7,7 +7,7 @@ #include #include #include "common.h" -#include "pwrctrl.h" +#include "pwrctrl_adcs.h" #include "temp_test.h" #include "cv_test.h" #include "imu_test.h" diff --git a/tests/hwtest/main/CMakeLists.txt b/tests/hwtest/main/CMakeLists.txt index 4ac9c493..2cb4a4ec 100644 --- a/tests/hwtest/main/CMakeLists.txt +++ b/tests/hwtest/main/CMakeLists.txt @@ -10,7 +10,6 @@ project(scsat1-main) target_sources(app PRIVATE src/main.c) target_sources(app PRIVATE src/wdog.c) -target_sources(app PRIVATE src/pwrctrl.c) target_sources(app PRIVATE src/mgnm.c ) target_sources(app PRIVATE src/mgnm_test.c ) target_sources(app PRIVATE src/temp.c) diff --git a/tests/hwtest/main/src/loop_test.c b/tests/hwtest/main/src/loop_test.c index e286d20c..75b27b5c 100644 --- a/tests/hwtest/main/src/loop_test.c +++ b/tests/hwtest/main/src/loop_test.c @@ -7,7 +7,7 @@ #include #include "common.h" #include "loop_test.h" -#include "pwrctrl.h" +#include "pwrctrl_main.h" #include "temp_test.h" #include "cv_test.h" #include "csp_test.h" diff --git a/tests/hwtest/main/src/main_init.c b/tests/hwtest/main/src/main_init.c index 0f096b81..1bc8591f 100644 --- a/tests/hwtest/main/src/main_init.c +++ b/tests/hwtest/main/src/main_init.c @@ -6,7 +6,7 @@ #include #include "common.h" -#include "pwrctrl.h" +#include "pwrctrl_main.h" #include "sysmon.h" #include diff --git a/tests/hwtest/main/src/syshk_test.c b/tests/hwtest/main/src/syshk_test.c index 66bdf307..84ef21a1 100644 --- a/tests/hwtest/main/src/syshk_test.c +++ b/tests/hwtest/main/src/syshk_test.c @@ -7,7 +7,7 @@ #include #include #include "common.h" -#include "pwrctrl.h" +#include "pwrctrl_main.h" #include "temp_test.h" #include "cv_test.h" #include "csp_test.h"