xref: /aosp_15_r20/external/pigweed/pw_spi/BUILD.bazel (revision 61c4878ac05f98d0ceed94b57d316916de578985)
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("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")
16
17package(default_visibility = ["//visibility:public"])
18
19licenses(["notice"])
20
21cc_library(
22    name = "initiator",
23    hdrs = [
24        "public/pw_spi/initiator.h",
25    ],
26    strip_include_prefix = "public",
27    deps = [
28        "//pw_assert",
29        "//pw_bytes",
30        "//pw_status",
31    ],
32)
33
34cc_library(
35    name = "responder",
36    hdrs = [
37        "public/pw_spi/responder.h",
38    ],
39    strip_include_prefix = "public",
40    deps = [
41        "//pw_bytes",
42        "//pw_function",
43        "//pw_status",
44    ],
45)
46
47cc_library(
48    name = "chip_selector",
49    hdrs = [
50        "public/pw_spi/chip_selector.h",
51    ],
52    strip_include_prefix = "public",
53    deps = [
54        "//pw_status",
55    ],
56)
57
58cc_library(
59    name = "chip_selector_digital_out",
60    hdrs = [
61        "public/pw_spi/chip_selector_digital_out.h",
62    ],
63    strip_include_prefix = "public",
64    deps = [
65        ":chip_selector",
66        "//pw_digital_io",
67        "//pw_status",
68    ],
69)
70
71cc_library(
72    name = "initiator_mock",
73    testonly = True,
74    srcs = ["initiator_mock.cc"],
75    hdrs = [
76        "public/pw_spi/chip_selector_mock.h",
77        "public/pw_spi/initiator_mock.h",
78    ],
79    strip_include_prefix = "public",
80    deps = [
81        ":chip_selector",
82        ":initiator",
83        "//pw_assert",
84        "//pw_containers",
85        "//pw_containers:to_array",
86        "//pw_unit_test",
87    ],
88)
89
90pw_cc_test(
91    name = "initiator_mock_test",
92    srcs = [
93        "initiator_mock_test.cc",
94    ],
95    deps = [
96        ":initiator_mock",
97        "//pw_bytes",
98        "//pw_containers",
99        "//pw_unit_test",
100    ],
101)
102
103cc_library(
104    name = "device",
105    hdrs = [
106        "public/pw_spi/device.h",
107    ],
108    strip_include_prefix = "public",
109    deps = [
110        ":chip_selector",
111        ":initiator",
112        "//pw_bytes",
113        "//pw_chrono:system_clock",
114        "//pw_status",
115        "//pw_sync:borrow",
116    ],
117)
118
119pw_cc_test(
120    name = "spi_test",
121    srcs = [
122        "spi_test.cc",
123    ],
124    deps = [
125        ":device",
126        ":responder",
127        "//pw_sync:mutex",
128        "//pw_unit_test",
129    ],
130)
131
132filegroup(
133    name = "doxygen",
134    srcs = [
135        "public/pw_spi/chip_selector.h",
136        "public/pw_spi/chip_selector_digital_out.h",
137    ],
138)
139