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 <hepler@google.com>
Commit-Queue: Anton Markov <amarkov@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6dcc56f..e26949d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,9 +38,9 @@
 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 7e8d572..4f20530 100644
--- a/PIGWEED_MODULES
+++ b/PIGWEED_MODULES
@@ -32,13 +32,13 @@
 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 1ec4b65..750ab71 100644
--- a/pw_build/generated_pigweed_modules_lists.gni
+++ b/pw_build/generated_pigweed_modules_lists.gni
@@ -62,13 +62,13 @@
   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 @@
     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 @@
     "$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 @@
     "$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 c84638c..a4632a5 100644
--- a/pw_gpio/BUILD.bazel
+++ b/pw_digital_io/BUILD.bazel
@@ -23,11 +23,11 @@
 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_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 3d8d7ff..2cf8949 100644
--- a/pw_gpio/BUILD.gn
+++ b/pw_digital_io/BUILD.gn
@@ -24,13 +24,13 @@
   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_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 66b93dc..c3470b3 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 94%
rename from pw_gpio/gpio.cc
rename to pw_digital_io/digital_io.cc
index a5ce209..b845d3f 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 @@
   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 9a8c115..e263c4d 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 @@
 }
 
 }  // namespace
-}  // namespace pw::gpio
+}  // namespace pw::digital_io
diff --git a/pw_gpio/docs.rst b/pw_digital_io/docs.rst
similarity index 90%
rename from pw_gpio/docs.rst
rename to pw_digital_io/docs.rst
index 7e1ad1e..e503879 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 @@
 
 .. 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 @@
      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 @@
 
 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 @@
 
 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 @@
 
 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 97%
rename from pw_gpio/public/pw_gpio/gpio.h
rename to pw_digital_io/public/pw_digital_io/digital_io.h
index 786c496..bbb565b 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 @@
   // 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 @@
   }
 };
 
-}  // 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 99595de..e0acde9 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 <type_traits>
 
-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 @@
   static constexpr bool interrupt = true;
 };
 
-}  // namespace pw::gpio
+}  // namespace pw::digital_io