Skip to content

Commit

Permalink
pw_interrupt_freertos: Add pw_interrupt backend for FreeRTOS
Browse files Browse the repository at this point in the history
This replaces the pw_interrupt_cortex_a module which does not work
correctly.

Change-Id: Ibc7a41e3684c87b30b4d0b6869ca666e070e2189
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/267292
Lint: Lint 🤖 <[email protected]>
Reviewed-by: Dave Roth <[email protected]>
Commit-Queue: Randy Zhang <[email protected]>
Reviewed-by: Eric Ye <[email protected]>
Presubmit-Verified: CQ Bot Account <[email protected]>
  • Loading branch information
Randy Zhang authored and CQ Bot Account committed Feb 14, 2025
1 parent 0481c3f commit 7ab1856
Show file tree
Hide file tree
Showing 16 changed files with 69 additions and 75 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ add_subdirectory(pw_hex_dump EXCLUDE_FROM_ALL)
add_subdirectory(pw_hdlc EXCLUDE_FROM_ALL)
add_subdirectory(pw_i2c EXCLUDE_FROM_ALL)
add_subdirectory(pw_interrupt EXCLUDE_FROM_ALL)
add_subdirectory(pw_interrupt_cortex_a EXCLUDE_FROM_ALL)
add_subdirectory(pw_interrupt_cortex_m EXCLUDE_FROM_ALL)
add_subdirectory(pw_interrupt_freertos EXCLUDE_FROM_ALL)
add_subdirectory(pw_interrupt_zephyr EXCLUDE_FROM_ALL)
add_subdirectory(pw_intrusive_ptr EXCLUDE_FROM_ALL)
add_subdirectory(pw_json EXCLUDE_FROM_ALL)
Expand Down
2 changes: 1 addition & 1 deletion PIGWEED_MODULES
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ pw_i2c_mcuxpresso
pw_i2c_rp2040
pw_ide
pw_interrupt
pw_interrupt_cortex_a
pw_interrupt_cortex_m
pw_interrupt_freertos
pw_interrupt_xtensa
pw_interrupt_zephyr
pw_intrusive_ptr
Expand Down
2 changes: 1 addition & 1 deletion docs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,8 @@ sphinx_docs(
"//pw_i2c_rp2040:docs",
"//pw_ide:docs",
"//pw_interrupt:docs",
"//pw_interrupt_cortex_a:docs",
"//pw_interrupt_cortex_m:docs",
"//pw_interrupt_freertos:docs",
"//pw_interrupt_xtensa:docs",
"//pw_interrupt_zephyr:docs",
"//pw_intrusive_ptr:docs",
Expand Down
4 changes: 2 additions & 2 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ Highlights (Jan 10, 2025 to Jan 24, 2025):
:ref:`layering check <module-pw_toolchain-bazel-layering-check>` in Bazel.
Including headers that aren't in the ``hdrs`` of a ``cc_library``
you directly depend on becomes a compile-time error.
* **Cortex-A support**: :ref:`module-pw_interrupt_cortex_a` is a new
* **Cortex-A support**: pw_interrupt_cortex_a is a new
``pw_interrupt`` backend for Arm Cortex-A processors. ``pw_toolchain``
now supports Arm Cortex-A35.
* **Atomic API**: The new :ref:`module-pw_atomic` module provides software
Expand Down Expand Up @@ -329,7 +329,7 @@ New features:

.. e61919ca93f922bc67fc6bd2f005c00f858cdcbd

* :ref:`module-pw_interrupt_cortex_a` is a new ``pw_interrupt`` backend
* [Deprecated] pw_interrupt_cortex_a is a new ``pw_interrupt`` backend
for Arm Cortex-A processors. Commit: `Add pw_interrupt backend for
A-profile processors <https://pwrev.dev/261396>`__.

Expand Down
8 changes: 4 additions & 4 deletions docs/module_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -488,13 +488,13 @@
"pw_interrupt": {
"status": "unstable"
},
"pw_interrupt_cortex_a": {
"status": "experimental",
"languages": []
},
"pw_interrupt_cortex_m": {
"status": "unstable"
},
"pw_interrupt_freertos": {
"status": "experimental",
"languages": []
},
"pw_interrupt_xtensa": {
"status": "unstable"
},
Expand Down
10 changes: 5 additions & 5 deletions pw_build/generated_pigweed_modules_lists.gni
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ declare_args() {
dir_pw_i2c_rp2040 = get_path_info("../pw_i2c_rp2040", "abspath")
dir_pw_ide = get_path_info("../pw_ide", "abspath")
dir_pw_interrupt = get_path_info("../pw_interrupt", "abspath")
dir_pw_interrupt_cortex_a =
get_path_info("../pw_interrupt_cortex_a", "abspath")
dir_pw_interrupt_cortex_m =
get_path_info("../pw_interrupt_cortex_m", "abspath")
dir_pw_interrupt_freertos =
get_path_info("../pw_interrupt_freertos", "abspath")
dir_pw_interrupt_xtensa = get_path_info("../pw_interrupt_xtensa", "abspath")
dir_pw_interrupt_zephyr = get_path_info("../pw_interrupt_zephyr", "abspath")
dir_pw_intrusive_ptr = get_path_info("../pw_intrusive_ptr", "abspath")
Expand Down Expand Up @@ -317,8 +317,8 @@ declare_args() {
dir_pw_i2c_rp2040,
dir_pw_ide,
dir_pw_interrupt,
dir_pw_interrupt_cortex_a,
dir_pw_interrupt_cortex_m,
dir_pw_interrupt_freertos,
dir_pw_interrupt_xtensa,
dir_pw_interrupt_zephyr,
dir_pw_intrusive_ptr,
Expand Down Expand Up @@ -505,8 +505,8 @@ declare_args() {
"$dir_pw_i2c_rp2040:tests",
"$dir_pw_ide:tests",
"$dir_pw_interrupt:tests",
"$dir_pw_interrupt_cortex_a:tests",
"$dir_pw_interrupt_cortex_m:tests",
"$dir_pw_interrupt_freertos:tests",
"$dir_pw_interrupt_xtensa:tests",
"$dir_pw_interrupt_zephyr:tests",
"$dir_pw_intrusive_ptr:tests",
Expand Down Expand Up @@ -693,8 +693,8 @@ declare_args() {
"$dir_pw_i2c_rp2040:docs",
"$dir_pw_ide:docs",
"$dir_pw_interrupt:docs",
"$dir_pw_interrupt_cortex_a:docs",
"$dir_pw_interrupt_cortex_m:docs",
"$dir_pw_interrupt_freertos:docs",
"$dir_pw_interrupt_xtensa:docs",
"$dir_pw_interrupt_zephyr:docs",
"$dir_pw_intrusive_ptr:docs",
Expand Down
2 changes: 1 addition & 1 deletion pw_interrupt/backends.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Backends
.. toctree::
:maxdepth: 1

Cortex-A <../pw_interrupt_cortex_a/docs>
Cortex-M <../pw_interrupt_cortex_m/docs>
FreeRTOS <../pw_interrupt_freertos/docs>
Xtensa <../pw_interrupt_xtensa/docs>
Zephyr <../pw_interrupt_zephyr/docs>
11 changes: 0 additions & 11 deletions pw_interrupt_cortex_a/docs.rst

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,21 @@ cc_library(
cc_library(
name = "context_implementation",
hdrs = [
"public/pw_interrupt_cortex_a/context_inline.h",
"public/pw_interrupt_freertos/context_inline.h",
],
strip_include_prefix = "public",
tags = ["noclangtidy"],
visibility = ["//visibility:private"],
deps = [
"@freertos",
],
)

sphinx_docs_library(
name = "docs",
srcs = [
"docs.rst",
],
prefix = "pw_interrupt_cortex_a/",
prefix = "pw_interrupt_freertos/",
target_compatible_with = incompatible_with_mcu(),
)
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ config("backend_config") {
}

pw_source_set("context") {
public_deps = [ "$dir_pw_interrupt:context.facade" ]
public_deps = [
"$dir_pw_interrupt:context.facade",
"$dir_pw_third_party/freertos",
]
public_configs = [
":public_include_path",
":backend_config",
]
public = [
"public/pw_interrupt_cortex_a/context_inline.h",
"public/pw_interrupt_freertos/context_inline.h",
"public_overrides/pw_interrupt_backend/context_inline.h",
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@

include($ENV{PW_ROOT}/pw_build/pigweed.cmake)

pw_add_library(pw_interrupt_cortex_a.context INTERFACE
pw_add_library(pw_interrupt_freertos.context INTERFACE
HEADERS
public/pw_interrupt_cortex_a/context_inline.h
public/pw_interrupt_freertos/context_inline.h
public_overrides/pw_interrupt_backend/context_inline.h
PUBLIC_INCLUDES
public
public_overrides
PUBLIC_DEPS
pw_third_party.freertos
)
File renamed without changes.
12 changes: 12 additions & 0 deletions pw_interrupt_freertos/docs.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.. _module-pw_interrupt_freertos:

---------------------
pw_interrupt_freertos
---------------------
.. pigweed-module::
:name: pw_interrupt_freertos

This module implements a backend for ``pw_interrupt``. It requires a port of
FreeRTOS that defines the ``ullPortInterruptNesting``. Usually, ports for ARM
A-profile processors will have this defined. For Cortex-M processors, use the
``pw_interrupt_cortex_m`` backend.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2025 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.
#pragma once

#include <cstdint>

#include "portmacro.h"

namespace pw::interrupt {

// This backend require the FreeRTOS port to define the xPortIsInsideInterrupt,
// which is not available on every officially supported port. It may be
// necessary to extend certain ports for this backend to work.
inline bool InInterruptContext() { return !!xPortIsInsideInterrupt(); }

} // namespace pw::interrupt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
// the PW_LOG macro as the tokenized logging macro.
#pragma once

#include "pw_interrupt_cortex_a/context_inline.h"
#include "pw_interrupt_freertos/context_inline.h"

0 comments on commit 7ab1856

Please sign in to comment.