• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2020 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
15load("@rules_cc//cc:cc_library.bzl", "cc_library")
16load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
17load("//pw_build:compatibility.bzl", "incompatible_with_mcu")
18load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")
19
20package(
21    default_visibility = ["//visibility:public"],
22)
23
24licenses(["notice"])
25
26cc_library(
27    name = "initiator",
28    hdrs = [
29        "public/pw_spi/initiator.h",
30    ],
31    strip_include_prefix = "public",
32    deps = [
33        "//pw_assert:assert",
34        "//pw_bytes",
35        "//pw_status",
36    ],
37)
38
39cc_library(
40    name = "responder",
41    hdrs = [
42        "public/pw_spi/responder.h",
43    ],
44    strip_include_prefix = "public",
45    deps = [
46        "//pw_bytes",
47        "//pw_function",
48        "//pw_status",
49    ],
50)
51
52cc_library(
53    name = "chip_selector",
54    hdrs = [
55        "public/pw_spi/chip_selector.h",
56    ],
57    strip_include_prefix = "public",
58    deps = [
59        "//pw_status",
60    ],
61)
62
63cc_library(
64    name = "chip_selector_digital_out",
65    hdrs = [
66        "public/pw_spi/chip_selector_digital_out.h",
67    ],
68    strip_include_prefix = "public",
69    deps = [
70        ":chip_selector",
71        "//pw_digital_io",
72        "//pw_status",
73    ],
74)
75
76cc_library(
77    name = "initiator_mock",
78    testonly = True,
79    srcs = ["initiator_mock.cc"],
80    hdrs = [
81        "public/pw_spi/chip_selector_mock.h",
82        "public/pw_spi/initiator_mock.h",
83    ],
84    implementation_deps = [
85        "//pw_assert:check",
86        "//pw_containers:algorithm",
87    ],
88    strip_include_prefix = "public",
89    deps = [
90        ":chip_selector",
91        ":initiator",
92        "//pw_bytes",
93        "//pw_containers:to_array",
94        "//pw_unit_test",
95    ],
96)
97
98pw_cc_test(
99    name = "initiator_mock_test",
100    srcs = [
101        "initiator_mock_test.cc",
102    ],
103    deps = [
104        ":initiator_mock",
105        "//pw_bytes",
106        "//pw_containers:algorithm",
107        "//pw_span",
108    ],
109)
110
111cc_library(
112    name = "device",
113    hdrs = [
114        "public/pw_spi/device.h",
115    ],
116    strip_include_prefix = "public",
117    deps = [
118        ":chip_selector",
119        ":initiator",
120        "//pw_bytes",
121        "//pw_chrono:system_clock",
122        "//pw_status",
123        "//pw_sync:borrow",
124    ],
125)
126
127pw_cc_test(
128    name = "spi_test",
129    srcs = [
130        "spi_test.cc",
131    ],
132    deps = [
133        ":chip_selector",
134        ":device",
135        ":initiator",
136        ":responder",
137        "//pw_status",
138        "//pw_sync:borrow",
139        "//pw_sync:mutex",
140    ],
141)
142
143filegroup(
144    name = "doxygen",
145    srcs = [
146        "public/pw_spi/chip_selector.h",
147        "public/pw_spi/chip_selector_digital_out.h",
148    ],
149)
150
151sphinx_docs_library(
152    name = "docs",
153    srcs = [
154        "backends.rst",
155        "docs.rst",
156    ],
157    prefix = "pw_spi/",
158    target_compatible_with = incompatible_with_mcu(),
159)
160