blob: 3c46fc92c660c1e52ed7477fb7574649f31fcbd1 [file] [log] [blame]
Mark Slevinskyc01abaf2021-11-19 11:57:48 -05001# Copyright 2021 The Pigweed Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7# https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14
15import("//build_overrides/pigweed.gni")
16
17import("$dir_pw_build/target_types.gni")
18import("$dir_pw_docgen/docs.gni")
19import("$dir_pw_unit_test/test.gni")
20
21config("public_include_path") {
22 include_dirs = [ "public" ]
23}
24
25group("pw_spi") {
26 deps = [
27 ":chip_selector",
28 ":device",
29 ":initiator",
30 ]
31 if (host_os == "linux") {
32 deps += [ ":linux_spi" ]
33 }
34}
35
36pw_source_set("initiator") {
37 public_configs = [ ":public_include_path" ]
38 public = [ "public/pw_spi/initiator.h" ]
39 public_deps = [
40 "$dir_pw_assert",
41 "$dir_pw_bytes",
42 "$dir_pw_status",
43 ]
44}
45
46pw_source_set("chip_selector") {
47 public_configs = [ ":public_include_path" ]
48 public = [ "public/pw_spi/chip_selector.h" ]
49 public_deps = [ "$dir_pw_status" ]
50}
51
52pw_source_set("device") {
53 public_configs = [ ":public_include_path" ]
54 public = [ "public/pw_spi/device.h" ]
55 public_deps = [
56 ":chip_selector",
57 ":initiator",
58 "$dir_pw_bytes",
59 "$dir_pw_status",
60 "$dir_pw_sync:borrow",
61 ]
62}
63
64# Linux-specific spidev implementation.
65pw_source_set("linux_spi") {
66 public_configs = [ ":public_include_path" ]
67 public = [ "public/pw_spi/linux_spi.h" ]
68 public_deps = [
69 ":device",
70 "$dir_pw_bytes",
71 "$dir_pw_log",
72 "$dir_pw_status",
73 "$dir_pw_sync:borrow",
74 "$dir_pw_sync:mutex",
75 ]
76 sources = [ "linux_spi.cc" ]
77}
78
79pw_test_group("tests") {
80 tests = [ ":spi_test" ]
81}
82
83pw_test("spi_test") {
84 sources = [ "spi_test.cc" ]
85 deps = [
86 ":device",
87 "$dir_pw_sync:mutex",
88 ]
89}
90
91# Linux tests currently only work on a target with spidev support and a SPI endpoint
92# mounted at /dev/spidev0.0
93pw_test("linux_spi_test") {
94 sources = [ "linux_spi_test.cc" ]
95 deps = [
96 ":device",
97 ":linux_spi",
98 ]
99}
100
101pw_doc_group("docs") {
102 sources = [ "docs.rst" ]
103}