Skip to content

Commit

Permalink
pw_gpio: Add new module and interfaces
Browse files Browse the repository at this point in the history
NOTE: this module will be renamed `pw_digital_io` immediately in a
follow-up change.

The Digital IO interface represents individual GPIO lines that support
some combination of input, output, and/or interrupt functionality.
The choice of supported capability, and most other configuration details
are left up to the backend implementation.

Change-Id: I27437464ff918592e69a0bdbcbe005c68f2e9ef5
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/94100
Reviewed-by: Ewout van Bekkum <[email protected]>
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 d4e68a1 commit f66bf12
Show file tree
Hide file tree
Showing 13 changed files with 1,385 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ add_subdirectory(pw_cpu_exception EXCLUDE_FROM_ALL)
add_subdirectory(pw_cpu_exception_cortex_m 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
1 change: 1 addition & 0 deletions PIGWEED_MODULES
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pw_env_setup
pw_file
pw_function
pw_fuzzer
pw_gpio
pw_hdlc
pw_hex_dump
pw_i2c
Expand Down
4 changes: 4 additions & 0 deletions pw_build/generated_pigweed_modules_lists.gni
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ declare_args() {
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 @@ -203,6 +204,7 @@ declare_args() {
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 @@ -304,6 +306,7 @@ declare_args() {
"$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 @@ -395,6 +398,7 @@ declare_args() {
"$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
48 changes: 48 additions & 0 deletions pw_gpio/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright 2020 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

load(
"//pw_build:pigweed.bzl",
"pw_cc_library",
"pw_cc_test",
)

package(default_visibility = ["//visibility:public"])

licenses(["notice"])

pw_cc_library(
name = "pw_gpio",
srcs = ["gpio.cc"],
hdrs = [
"public/pw_gpio/gpio.h",
"public/pw_gpio/internal/conversions.h",
],
includes = ["public"],
deps = [
"//pw_assert",
"//pw_function",
"//pw_result",
"//pw_status",
],
)

pw_cc_test(
name = "gpio_test",
srcs = ["gpio_test.cc"],
deps = [
":pw_gpio",
"//pw_unit_test",
],
)
53 changes: 53 additions & 0 deletions pw_gpio/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Copyright 2020 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

import("//build_overrides/pigweed.gni")

import("$dir_pw_build/target_types.gni")
import("$dir_pw_docgen/docs.gni")
import("$dir_pw_toolchain/generate_toolchain.gni")
import("$dir_pw_unit_test/test.gni")

config("public_include_path") {
include_dirs = [ "public" ]
visibility = [ ":*" ]
}

pw_source_set("pw_gpio") {
public_configs = [ ":public_include_path" ]
public = [
"public/pw_gpio/gpio.h",
"public/pw_gpio/internal/conversions.h",
]
sources = [ "gpio.cc" ]
public_deps = [
dir_pw_assert,
dir_pw_function,
dir_pw_result,
dir_pw_status,
]
}

pw_doc_group("docs") {
sources = [ "docs.rst" ]
}

pw_test_group("tests") {
tests = [ ":gpio_test" ]
}

pw_test("gpio_test") {
sources = [ "gpio_test.cc" ]
deps = [ ":pw_gpio" ]
}
43 changes: 43 additions & 0 deletions pw_gpio/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2020 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

include($ENV{PW_ROOT}/pw_build/pigweed.cmake)

pw_add_module_library(pw_gpio
HEADERS
public/pw_gpio/gpio.h
public/pw_gpio/internal/conversions.h
PUBLIC_INCLUDES
public
SOURCES
gpio.cc
PUBLIC_DEPS
pw_assert
pw_function
pw_result
pw_status
)
if(Zephyr_FOUND AND CONFIG_PIGWEED_GPIO)
zephyr_link_libraries(pw_gpio)
endif()

pw_add_test(pw_gpio.stream_test
SOURCES
gpio_test.cc
DEPS
pw_gpio
GROUPS
modules
pw_gpio
)
1 change: 1 addition & 0 deletions pw_gpio/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[email protected]
7 changes: 7 additions & 0 deletions pw_gpio/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This directory contains the `pw` Digital IO Hardware Abstraction Layer (HAL).
This HAL defines interfaces for working with Digital IO lines that provide
different combinations of capabilities (input, output, and/or interrupts).
Hardware specific backends provide implementations of these interfaces for
different hardware platforms.

Warning: This module is under construction and may not be ready for use.
Loading

0 comments on commit f66bf12

Please sign in to comment.