Skip to content

Commit

Permalink
pw_digital_io: rename from pw_gpio
Browse files Browse the repository at this point in the history
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 <[email protected]>
Commit-Queue: Anton Markov <[email protected]>
  • Loading branch information
antmar authored and CQ Bot Account committed Jun 16, 2022
1 parent 7287d35 commit 86312ba
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 63 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion PIGWEED_MODULES
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions pw_build/generated_pigweed_modules_lists.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
14 changes: 7 additions & 7 deletions pw_gpio/BUILD.bazel → pw_digital_io/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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",
],
)
16 changes: 8 additions & 8 deletions pw_gpio/BUILD.gn → pw_digital_io/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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" ]
}
20 changes: 10 additions & 10 deletions pw_gpio/CMakeLists.txt → pw_digital_io/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions pw_gpio/gpio.cc → pw_digital_io/digital_io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -57,4 +57,4 @@ Status DigitalInOut::DoEnableInterruptHandler(bool) {
PW_CRASH("DoEnableInterruptHandler not implemented");
}

} // namespace pw::gpio
} // namespace pw::digital_io
6 changes: 3 additions & 3 deletions pw_gpio/gpio_test.cc → pw_digital_io/digital_io_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -293,4 +293,4 @@ TEST(DigitalIo, InOutInterrupt) {
}

} // namespace
} // namespace pw::gpio
} // namespace pw::digital_io
39 changes: 20 additions & 19 deletions pw_gpio/docs.rst → pw_digital_io/docs.rst
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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());
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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.
//
Expand Down Expand Up @@ -444,4 +445,4 @@ class DigitalInOutInterrupt
}
};

} // namespace pw::gpio
} // namespace pw::digital_io
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -138,4 +138,4 @@ struct internal::Requires<class DigitalInOutInterrupt> {
static constexpr bool interrupt = true;
};

} // namespace pw::gpio
} // namespace pw::digital_io

0 comments on commit 86312ba

Please sign in to comment.