aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAustin Foxley <afoxley@google.com>2023-07-14 05:53:52 +0000
committerCQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-07-14 05:53:52 +0000
commite015f8643bce4ad29836587378ef0acdbceafa3e (patch)
treeffb5d71950c04f3c244eb05bc6a8da8f974b6936
parent5eb0c496fdb2881e564c420852cfd8d20d08ffb2 (diff)
downloadpigweed-e015f8643bce4ad29836587378ef0acdbceafa3e.tar.gz
pw_i2c_mcuxpresso: Add test to ensure compilation of module
Change-Id: Ic70cdc3568251978aafbaa62aece62106117cba0 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/155390 Pigweed-Auto-Submit: Austin Foxley <afoxley@google.com> Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ted Pudlik <tpudlik@google.com> Commit-Queue: Auto-Submit <auto-submit@pigweed-service-accounts.iam.gserviceaccount.com>
-rw-r--r--pw_i2c_mcuxpresso/BUILD.bazel10
-rw-r--r--pw_i2c_mcuxpresso/BUILD.gn14
-rw-r--r--pw_i2c_mcuxpresso/initiator_test.cc30
-rw-r--r--targets/mimxrt595_evk_freertos/BUILD.gn1
4 files changed, 52 insertions, 3 deletions
diff --git a/pw_i2c_mcuxpresso/BUILD.bazel b/pw_i2c_mcuxpresso/BUILD.bazel
index 1e9ab2251..b08052053 100644
--- a/pw_i2c_mcuxpresso/BUILD.bazel
+++ b/pw_i2c_mcuxpresso/BUILD.bazel
@@ -14,6 +14,7 @@
load(
"//pw_build:pigweed.bzl",
"pw_cc_library",
+ "pw_cc_test",
)
package(default_visibility = ["//visibility:public"])
@@ -25,9 +26,6 @@ pw_cc_library(
srcs = ["initiator.cc"],
hdrs = ["public/pw_i2c_mcuxpresso/initiator.h"],
includes = ["public"],
- target_compatible_with = [
- "//pw_build/constraints/board:mimxrt595_evk",
- ],
deps = [
"//pw_chrono:system_clock",
"//pw_i2c:address",
@@ -40,3 +38,9 @@ pw_cc_library(
"@pigweed_config//:mcuxpresso_sdk",
],
)
+
+pw_cc_test(
+ name = "initiator_test",
+ srcs = ["initiator_test.cc"],
+ deps = [":pw_i2c_mcuxpresso"],
+)
diff --git a/pw_i2c_mcuxpresso/BUILD.gn b/pw_i2c_mcuxpresso/BUILD.gn
index 3ff44c6bb..59b361759 100644
--- a/pw_i2c_mcuxpresso/BUILD.gn
+++ b/pw_i2c_mcuxpresso/BUILD.gn
@@ -40,9 +40,23 @@ if (pw_third_party_mcuxpresso_SDK != "") {
}
}
+pw_test("initiator_test") {
+ enable_if =
+ pw_third_party_mcuxpresso_SDK == "//targets/mimxrt595_evk_freertos:sdk" &&
+ (pw_toolchain_SCOPE.name == "mimxrt595_evk_freertos_debug" ||
+ pw_toolchain_SCOPE.name == "mimxrt595_evk_freertos_size_optimized" ||
+ pw_toolchain_SCOPE.name == "mimxrt595_evk_freertos_speed_optimized")
+ sources = [ "initiator_test.cc" ]
+ deps = [
+ ":pw_i2c_mcuxpresso",
+ "//targets/mimxrt595_evk_freertos:sdk",
+ ]
+}
+
pw_doc_group("docs") {
sources = [ "docs.rst" ]
}
pw_test_group("tests") {
+ tests = [ ":initiator_test" ]
}
diff --git a/pw_i2c_mcuxpresso/initiator_test.cc b/pw_i2c_mcuxpresso/initiator_test.cc
new file mode 100644
index 000000000..052679612
--- /dev/null
+++ b/pw_i2c_mcuxpresso/initiator_test.cc
@@ -0,0 +1,30 @@
+// Copyright 2023 The Pigweed Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+#include "pw_i2c_mcuxpresso/initiator.h"
+
+#include <gtest/gtest.h>
+
+namespace pw::i2c {
+namespace {
+
+constexpr uint32_t kI2CBaudRate = 100000;
+
+TEST(InitiatorTest, Init) {
+ // Simple test only meant to ensure module is compiled.
+ const auto clock_freq = CLOCK_GetFlexcommClkFreq(11);
+ McuxpressoInitiator initiator(I2C11, kI2CBaudRate, clock_freq);
+}
+
+} // namespace
+} // namespace pw::i2c
diff --git a/targets/mimxrt595_evk_freertos/BUILD.gn b/targets/mimxrt595_evk_freertos/BUILD.gn
index 682246c9c..ee23413ce 100644
--- a/targets/mimxrt595_evk_freertos/BUILD.gn
+++ b/targets/mimxrt595_evk_freertos/BUILD.gn
@@ -112,6 +112,7 @@ if (pw_third_party_mcuxpresso_SDK == "//targets/mimxrt595_evk_freertos:sdk") {
include = [
"project_template.evkmimxrt595.MIMXRT595S",
"component.serial_manager_uart.MIMXRT595S",
+ "platform.drivers.flexcomm_i2c.MIMXRT595S",
"platform.drivers.flexcomm_spi.MIMXRT595S",
"platform.drivers.flexcomm_usart_freertos.MIMXRT595S",
"platform.drivers.flexio_spi.MIMXRT595S",