[stm32] Add pw_spin_delay_stm32cubef4

Change-Id: I2b2b16047508f4c0bacfe77b31856dd6c9b0362a
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/experimental/+/39768
Commit-Queue: Varun Sharma <vars@google.com>
Reviewed-by: Ali Zhang <alizhang@google.com>
diff --git a/build_overrides/pigweed.gni b/build_overrides/pigweed.gni
index d40f911..96486b1 100644
--- a/build_overrides/pigweed.gni
+++ b/build_overrides/pigweed.gni
@@ -36,4 +36,6 @@
   dir_pw_spin_delay_host = get_path_info("//pw_spin_delay_host", "abspath")
   dir_pw_spin_delay_stm32f429i_disc1 =
       get_path_info("//pw_spin_delay_stm32f429i_disc1", "abspath")
+  dir_pw_spin_delay_stm32cubef4 =
+      get_path_info("//pw_spin_delay_stm32cubef4", "abspath")
 }
diff --git a/pw_spin_delay_stm32cubef4/BUILD.gn b/pw_spin_delay_stm32cubef4/BUILD.gn
new file mode 100644
index 0000000..cd22d24
--- /dev/null
+++ b/pw_spin_delay_stm32cubef4/BUILD.gn
@@ -0,0 +1,25 @@
+# Copyright 2021 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.
+
+import("//build_overrides/pigweed.gni")
+
+import("$dir_pw_build/target_types.gni")
+
+pw_source_set("pw_spin_delay_stm32cubef4") {
+  deps = [
+    "$dir_pw_spin_delay:pw_spin_delay.facade",
+    "//third_party/stm32cubef4:stm32f4xx_hal",
+  ]
+  sources = [ "delay.cc" ]
+}
diff --git a/pw_spin_delay_stm32cubef4/delay.cc b/pw_spin_delay_stm32cubef4/delay.cc
new file mode 100644
index 0000000..72e4f87
--- /dev/null
+++ b/pw_spin_delay_stm32cubef4/delay.cc
@@ -0,0 +1,25 @@
+// Copyright 2021 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_spin_delay/delay.h"
+
+#include "stm32f4xx.h"
+
+namespace pw::spin_delay {
+
+void WaitMillis(size_t delay_ms) { HAL_Delay(delay_ms); }
+
+uint32_t Millis() { return HAL_GetTick(); }
+
+}  // namespace pw::spin_delay