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