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