From 86312ba21e9d173296a5c20ad474362291f9c080 Mon Sep 17 00:00:00 2001 From: Anton Markov Date: Tue, 14 Jun 2022 16:48:23 +0000 Subject: [PATCH] pw_digital_io: rename from pw_gpio As per discussion in the change that adds pw_gpio, we would like to name the module pw_digital_io. Doing the rename in a follow-up change makes the original discussion easier to follow. Change-Id: I27a40e3f4899b2a3498323457866b785ca0ddc06 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/98040 Reviewed-by: Wyatt Hepler Commit-Queue: Anton Markov --- CMakeLists.txt | 2 +- PIGWEED_MODULES | 2 +- pw_build/generated_pigweed_modules_lists.gni | 8 ++-- {pw_gpio => pw_digital_io}/BUILD.bazel | 14 +++---- {pw_gpio => pw_digital_io}/BUILD.gn | 16 ++++---- {pw_gpio => pw_digital_io}/CMakeLists.txt | 20 +++++----- {pw_gpio => pw_digital_io}/OWNERS | 0 {pw_gpio => pw_digital_io}/README.md | 0 .../gpio.cc => pw_digital_io/digital_io.cc | 6 +-- .../digital_io_test.cc | 6 +-- {pw_gpio => pw_digital_io}/docs.rst | 39 ++++++++++--------- .../public/pw_digital_io/digital_io.h | 11 +++--- .../pw_digital_io}/internal/conversions.h | 4 +- 13 files changed, 65 insertions(+), 63 deletions(-) rename {pw_gpio => pw_digital_io}/BUILD.bazel (79%) rename {pw_gpio => pw_digital_io}/BUILD.gn (79%) rename {pw_gpio => pw_digital_io}/CMakeLists.txt (71%) rename {pw_gpio => pw_digital_io}/OWNERS (100%) rename {pw_gpio => pw_digital_io}/README.md (100%) rename pw_gpio/gpio.cc => pw_digital_io/digital_io.cc (95%) rename pw_gpio/gpio_test.cc => pw_digital_io/digital_io_test.cc (98%) rename {pw_gpio => pw_digital_io}/docs.rst (91%) rename pw_gpio/public/pw_gpio/gpio.h => pw_digital_io/public/pw_digital_io/digital_io.h (98%) rename {pw_gpio/public/pw_gpio => pw_digital_io/public/pw_digital_io}/internal/conversions.h (98%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6dcc56fc66..e26949d37d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,9 +38,9 @@ add_subdirectory(pw_chrono_zephyr EXCLUDE_FROM_ALL) add_subdirectory(pw_containers EXCLUDE_FROM_ALL) add_subdirectory(pw_cpu_exception EXCLUDE_FROM_ALL) add_subdirectory(pw_cpu_exception_cortex_m EXCLUDE_FROM_ALL) +add_subdirectory(pw_digital_io EXCLUDE_FROM_ALL) add_subdirectory(pw_file EXCLUDE_FROM_ALL) add_subdirectory(pw_function EXCLUDE_FROM_ALL) -add_subdirectory(pw_gpio EXCLUDE_FROM_ALL) add_subdirectory(pw_hdlc EXCLUDE_FROM_ALL) add_subdirectory(pw_interrupt EXCLUDE_FROM_ALL) add_subdirectory(pw_interrupt_cortex_m EXCLUDE_FROM_ALL) diff --git a/PIGWEED_MODULES b/PIGWEED_MODULES index 7e8d572999..4f20530946 100644 --- a/PIGWEED_MODULES +++ b/PIGWEED_MODULES @@ -32,13 +32,13 @@ pw_containers pw_cpu_exception pw_cpu_exception_cortex_m pw_crypto +pw_digital_io pw_docgen pw_doctor pw_env_setup pw_file pw_function pw_fuzzer -pw_gpio pw_hdlc pw_hex_dump pw_i2c diff --git a/pw_build/generated_pigweed_modules_lists.gni b/pw_build/generated_pigweed_modules_lists.gni index 1ec4b65061..750ab713b4 100644 --- a/pw_build/generated_pigweed_modules_lists.gni +++ b/pw_build/generated_pigweed_modules_lists.gni @@ -62,13 +62,13 @@ declare_args() { dir_pw_cpu_exception_cortex_m = get_path_info("../pw_cpu_exception_cortex_m", "abspath") dir_pw_crypto = get_path_info("../pw_crypto", "abspath") + dir_pw_digital_io = get_path_info("../pw_digital_io", "abspath") dir_pw_docgen = get_path_info("../pw_docgen", "abspath") dir_pw_doctor = get_path_info("../pw_doctor", "abspath") dir_pw_env_setup = get_path_info("../pw_env_setup", "abspath") dir_pw_file = get_path_info("../pw_file", "abspath") dir_pw_function = get_path_info("../pw_function", "abspath") dir_pw_fuzzer = get_path_info("../pw_fuzzer", "abspath") - dir_pw_gpio = get_path_info("../pw_gpio", "abspath") dir_pw_hdlc = get_path_info("../pw_hdlc", "abspath") dir_pw_hex_dump = get_path_info("../pw_hex_dump", "abspath") dir_pw_i2c = get_path_info("../pw_i2c", "abspath") @@ -198,13 +198,13 @@ declare_args() { dir_pw_cpu_exception, dir_pw_cpu_exception_cortex_m, dir_pw_crypto, + dir_pw_digital_io, dir_pw_docgen, dir_pw_doctor, dir_pw_env_setup, dir_pw_file, dir_pw_function, dir_pw_fuzzer, - dir_pw_gpio, dir_pw_hdlc, dir_pw_hex_dump, dir_pw_i2c, @@ -303,10 +303,10 @@ declare_args() { "$dir_pw_containers:tests", "$dir_pw_cpu_exception_cortex_m:tests", "$dir_pw_crypto:tests", + "$dir_pw_digital_io:tests", "$dir_pw_file:tests", "$dir_pw_function:tests", "$dir_pw_fuzzer:tests", - "$dir_pw_gpio:tests", "$dir_pw_hdlc:tests", "$dir_pw_hex_dump:tests", "$dir_pw_i2c:tests", @@ -392,13 +392,13 @@ declare_args() { "$dir_pw_cpu_exception:docs", "$dir_pw_cpu_exception_cortex_m:docs", "$dir_pw_crypto:docs", + "$dir_pw_digital_io:docs", "$dir_pw_docgen:docs", "$dir_pw_doctor:docs", "$dir_pw_env_setup:docs", "$dir_pw_file:docs", "$dir_pw_function:docs", "$dir_pw_fuzzer:docs", - "$dir_pw_gpio:docs", "$dir_pw_hdlc:docs", "$dir_pw_hex_dump:docs", "$dir_pw_i2c:docs", diff --git a/pw_gpio/BUILD.bazel b/pw_digital_io/BUILD.bazel similarity index 79% rename from pw_gpio/BUILD.bazel rename to pw_digital_io/BUILD.bazel index c84638cccd..a4632a5e9c 100644 --- a/pw_gpio/BUILD.bazel +++ b/pw_digital_io/BUILD.bazel @@ -23,11 +23,11 @@ package(default_visibility = ["//visibility:public"]) licenses(["notice"]) pw_cc_library( - name = "pw_gpio", - srcs = ["gpio.cc"], + name = "pw_digital_io", + srcs = ["digital_io.cc"], hdrs = [ - "public/pw_gpio/gpio.h", - "public/pw_gpio/internal/conversions.h", + "public/pw_digital_io/digital_io.h", + "public/pw_digital_io/internal/conversions.h", ], includes = ["public"], deps = [ @@ -39,10 +39,10 @@ pw_cc_library( ) pw_cc_test( - name = "gpio_test", - srcs = ["gpio_test.cc"], + name = "digital_io_test", + srcs = ["digital_io_test.cc"], deps = [ - ":pw_gpio", + ":pw_digital_io", "//pw_unit_test", ], ) diff --git a/pw_gpio/BUILD.gn b/pw_digital_io/BUILD.gn similarity index 79% rename from pw_gpio/BUILD.gn rename to pw_digital_io/BUILD.gn index 3d8d7ff63b..2cf894932a 100644 --- a/pw_gpio/BUILD.gn +++ b/pw_digital_io/BUILD.gn @@ -24,13 +24,13 @@ config("public_include_path") { visibility = [ ":*" ] } -pw_source_set("pw_gpio") { +pw_source_set("pw_digital_io") { public_configs = [ ":public_include_path" ] public = [ - "public/pw_gpio/gpio.h", - "public/pw_gpio/internal/conversions.h", + "public/pw_digital_io/digital_io.h", + "public/pw_digital_io/internal/conversions.h", ] - sources = [ "gpio.cc" ] + sources = [ "digital_io.cc" ] public_deps = [ dir_pw_assert, dir_pw_function, @@ -44,10 +44,10 @@ pw_doc_group("docs") { } pw_test_group("tests") { - tests = [ ":gpio_test" ] + tests = [ ":digital_io_test" ] } -pw_test("gpio_test") { - sources = [ "gpio_test.cc" ] - deps = [ ":pw_gpio" ] +pw_test("digital_io_test") { + sources = [ "digital_io_test.cc" ] + deps = [ ":pw_digital_io" ] } diff --git a/pw_gpio/CMakeLists.txt b/pw_digital_io/CMakeLists.txt similarity index 71% rename from pw_gpio/CMakeLists.txt rename to pw_digital_io/CMakeLists.txt index 66b93dccd6..c3470b3fe5 100644 --- a/pw_gpio/CMakeLists.txt +++ b/pw_digital_io/CMakeLists.txt @@ -14,30 +14,30 @@ include($ENV{PW_ROOT}/pw_build/pigweed.cmake) -pw_add_module_library(pw_gpio +pw_add_module_library(pw_digital_io HEADERS - public/pw_gpio/gpio.h - public/pw_gpio/internal/conversions.h + public/pw_digital_io/digital_io.h + public/pw_digital_io/internal/conversions.h PUBLIC_INCLUDES public SOURCES - gpio.cc + digital_io.cc PUBLIC_DEPS pw_assert pw_function pw_result pw_status ) -if(Zephyr_FOUND AND CONFIG_PIGWEED_GPIO) - zephyr_link_libraries(pw_gpio) +if(Zephyr_FOUND AND CONFIG_PIGWEED_DIGITAL_IO) + zephyr_link_libraries(pw_digital_io) endif() -pw_add_test(pw_gpio.stream_test +pw_add_test(pw_digital_io.stream_test SOURCES - gpio_test.cc + digital_io_test.cc DEPS - pw_gpio + pw_digital_io GROUPS modules - pw_gpio + pw_digital_io ) diff --git a/pw_gpio/OWNERS b/pw_digital_io/OWNERS similarity index 100% rename from pw_gpio/OWNERS rename to pw_digital_io/OWNERS diff --git a/pw_gpio/README.md b/pw_digital_io/README.md similarity index 100% rename from pw_gpio/README.md rename to pw_digital_io/README.md diff --git a/pw_gpio/gpio.cc b/pw_digital_io/digital_io.cc similarity index 95% rename from pw_gpio/gpio.cc rename to pw_digital_io/digital_io.cc index a5ce2093a4..b845d3f338 100644 --- a/pw_gpio/gpio.cc +++ b/pw_digital_io/digital_io.cc @@ -12,9 +12,9 @@ // License for the specific language governing permissions and limitations under // the License. -#include "pw_gpio/gpio.h" +#include "pw_digital_io/digital_io.h" -namespace pw::gpio { +namespace pw::digital_io { Status DigitalInterrupt::DoSetState(State) { PW_CRASH("DoSetState not implemented"); @@ -57,4 +57,4 @@ Status DigitalInOut::DoEnableInterruptHandler(bool) { PW_CRASH("DoEnableInterruptHandler not implemented"); } -} // namespace pw::gpio +} // namespace pw::digital_io diff --git a/pw_gpio/gpio_test.cc b/pw_digital_io/digital_io_test.cc similarity index 98% rename from pw_gpio/gpio_test.cc rename to pw_digital_io/digital_io_test.cc index 9a8c115308..e263c4d3a0 100644 --- a/pw_gpio/gpio_test.cc +++ b/pw_digital_io/digital_io_test.cc @@ -12,12 +12,12 @@ // License for the specific language governing permissions and limitations under // the License. -#include "pw_gpio/gpio.h" +#include "pw_digital_io/digital_io.h" #include "gtest/gtest.h" #include "pw_status/status.h" -namespace pw::gpio { +namespace pw::digital_io { namespace { // The base class should be compact. @@ -293,4 +293,4 @@ TEST(DigitalIo, InOutInterrupt) { } } // namespace -} // namespace pw::gpio +} // namespace pw::digital_io diff --git a/pw_gpio/docs.rst b/pw_digital_io/docs.rst similarity index 91% rename from pw_gpio/docs.rst rename to pw_digital_io/docs.rst index 7e1ad1e2fb..e503879107 100644 --- a/pw_gpio/docs.rst +++ b/pw_digital_io/docs.rst @@ -1,16 +1,17 @@ -.. _module-pw_gpio: +.. _module-pw_digital_io: -.. cpp:namespace-push:: pw::gpio +.. cpp:namespace-push:: pw::digital_io -======= -pw_gpio -======= +============= +pw_digital_io +============= .. warning:: This module is under construction and may not be ready for use. -``pw_gpio`` provides a set of interfaces for using General Purpose Input and -Output (GPIO) lines for Digital IO. This module can either be used directly by -the application code or wrapped in a device driver for more complex peripherals. +``pw_digital_io`` provides a set of interfaces for using General Purpose Input +and Output (GPIO) lines for simple Digital I/O. This module can either be used +directly by the application code or wrapped in a device driver for more complex +peripherals. -------- Overview @@ -25,7 +26,7 @@ Example API usage: .. code-block:: cpp - using namespace pw::gpio; + using namespace pw::digital_io; Status UpdateLedFromSwitch(const DigitalIn& switch, DigitalOut& led) { PW_TRY_ASSIGN(const DigitalIo::State state, switch.GetState()); @@ -41,9 +42,9 @@ Example API usage: return button.EnableInterruptHandler(); } -------------------- -pw::gpio Interfaces -------------------- +------------------------- +pw::digital_io Interfaces +------------------------- There are 3 basic capabilities of a Digital IO line: * Input - Get the state of the line. @@ -189,7 +190,7 @@ handlers running in an interrupt context cannot query the state of the line. Class Hierarchy =============== -``pw_gpio`` contains a 2-level hierarchy of classes. +``pw_digital_io`` contains a 2-level hierarchy of classes. * ``DigitalIoOptional`` acts as the base class and represents a line that does not guarantee any particular functionality is available. @@ -232,10 +233,10 @@ example: Asynchronous APIs ================= -At present, ``pw_gpio`` is synchronous. All the API calls are expected to block -until the operation is complete. This is desirable for simple GPIO chips that -are controlled through direct register access. However, this may be undesirable -for GPIO extenders controlled through I2C or another shared bus. +At present, ``pw_digital_io`` is synchronous. All the API calls are expected to +block until the operation is complete. This is desirable for simple GPIO chips +that are controlled through direct register access. However, this may be +undesirable for GPIO extenders controlled through I2C or another shared bus. The API may be extended in the future to add asynchronous capabilities, or a separate asynchronous API may be created. @@ -279,5 +280,5 @@ Dependencies Zephyr ====== -To enable ``pw_gpio`` for Zephyr add ``CONFIG_PIGWEED_GPIO=y`` to the -project's configuration. +To enable ``pw_digital_io`` for Zephyr add ``CONFIG_PIGWEED_DIGITAL_IO=y`` to +the project's configuration. diff --git a/pw_gpio/public/pw_gpio/gpio.h b/pw_digital_io/public/pw_digital_io/digital_io.h similarity index 98% rename from pw_gpio/public/pw_gpio/gpio.h rename to pw_digital_io/public/pw_digital_io/digital_io.h index 786c496d44..bbb565b3f0 100644 --- a/pw_gpio/public/pw_gpio/gpio.h +++ b/pw_digital_io/public/pw_digital_io/digital_io.h @@ -14,13 +14,13 @@ #pragma once #include "pw_assert/check.h" +#include "pw_digital_io/internal/conversions.h" #include "pw_function/function.h" -#include "pw_gpio/internal/conversions.h" #include "pw_result/result.h" #include "pw_status/status.h" #include "pw_status/try.h" -namespace pw::gpio { +namespace pw::digital_io { // The logical state of a digital line. enum class State : bool { @@ -111,8 +111,9 @@ class DigitalIoOptional { // blocking or expensive work in the handler. The only universally safe // operations are the IRQ-safe functions on pw_sync primitives. // - // In particular, it is NOT safe to get the state of a GPIO line - either from - // this line or any other DigitalIoOptional instance - inside the handler. + // In particular, it is NOT safe to get the state of a DigitalIo line - either + // from this line or any other DigitalIoOptional instance - inside the + // handler. // // This method is not thread-safe and cannot be used in interrupt handlers. // @@ -444,4 +445,4 @@ class DigitalInOutInterrupt } }; -} // namespace pw::gpio +} // namespace pw::digital_io diff --git a/pw_gpio/public/pw_gpio/internal/conversions.h b/pw_digital_io/public/pw_digital_io/internal/conversions.h similarity index 98% rename from pw_gpio/public/pw_gpio/internal/conversions.h rename to pw_digital_io/public/pw_digital_io/internal/conversions.h index 99595de0b7..e0acde951c 100644 --- a/pw_gpio/public/pw_gpio/internal/conversions.h +++ b/pw_digital_io/public/pw_digital_io/internal/conversions.h @@ -15,7 +15,7 @@ #include -namespace pw::gpio { +namespace pw::digital_io { namespace internal { // A type trait that describes the functionality required by a particular type @@ -138,4 +138,4 @@ struct internal::Requires { static constexpr bool interrupt = true; }; -} // namespace pw::gpio +} // namespace pw::digital_io