Skip to content

Commit

Permalink
Add RISC-V support
Browse files Browse the repository at this point in the history
  • Loading branch information
Disasm committed Nov 22, 2020
1 parent a220012 commit f61d420
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion rtt-target/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ufmt-write = "0.1.0"

# Platform specific stuff
cortex-m = { version = "0.6.2", optional = true }
riscv = { version = "0.6.0", optional = true }

# Dependencies used only for examples
ufmt = { version = "0.1.0", optional = true }
Expand Down Expand Up @@ -43,4 +44,4 @@ opt-level = "s"
panic = "abort"

[package.metadata.docs.rs]
features = ["cortex-m"]
features = ["cortex-m"]
12 changes: 8 additions & 4 deletions rtt-target/src/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,16 @@ pub unsafe fn set_print_channel_cs(channel: UpChannel, cs: &'static CriticalSect
///
/// This function is available only if you have enabled a platform support feature. Otherwise,
/// [`set_print_channel_cs`] must be used.
#[cfg(feature = "cortex-m")]
#[cfg(any(feature = "cortex-m", feature = "riscv"))]
pub fn set_print_channel(channel: UpChannel) {
#[cfg(feature = "cortex-m")]
use cortex_m as arch;
#[cfg(feature = "riscv")]
use riscv as arch;
unsafe {
set_print_channel_cs(
channel,
&((|arg, f| cortex_m::interrupt::free(|_| f(arg))) as CriticalSectionFunc),
&((|arg, f| arch::interrupt::free(|_| f(arg))) as CriticalSectionFunc),
);
}
}
Expand Down Expand Up @@ -176,7 +180,7 @@ macro_rules! rprintln {
///
/// This macro is defined only if the [`set_print_channel`] function is available, i.e. if you have
/// enabled a platform support feature.
#[cfg(any(feature = "cortex-m"))]
#[cfg(any(feature = "cortex-m", feature = "riscv"))]
#[macro_export]
macro_rules! rtt_init_print {
($mode:ident, $size:literal) => {
Expand Down Expand Up @@ -204,7 +208,7 @@ macro_rules! rtt_init_print {

/// This version of the macro only is defined if no platform support feature is enabled and outputs
/// a more friendly error message.
#[cfg(not(any(feature = "cortex-m")))]
#[cfg(not(any(feature = "cortex-m", feature = "riscv")))]
#[macro_export]
macro_rules! rtt_init_print {
($($_:tt)*) => {
Expand Down

0 comments on commit f61d420

Please sign in to comment.