iir: vminnm/vmaxnm
This commit is contained in:
parent
cc64f47004
commit
468929690d
@ -62,7 +62,7 @@ branch = "dma"
|
||||
[features]
|
||||
semihosting = ["panic-semihosting", "cortex-m-log/semihosting"]
|
||||
bkpt = [ ]
|
||||
nightly = ["cortex-m/inline-asm"]
|
||||
nightly = ["cortex-m/inline-asm", "dsp/nightly"]
|
||||
|
||||
[profile.dev]
|
||||
codegen-units = 1
|
||||
|
@ -6,3 +6,6 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0", features = ["derive"], default-features = false }
|
||||
|
||||
[features]
|
||||
nightly = []
|
||||
|
@ -24,6 +24,7 @@ fn copysign(x: f32, y: f32) -> f32 {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "nightly"))]
|
||||
fn max(x: f32, y: f32) -> f32 {
|
||||
if x > y {
|
||||
x
|
||||
@ -32,6 +33,7 @@ fn max(x: f32, y: f32) -> f32 {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "nightly"))]
|
||||
fn min(x: f32, y: f32) -> f32 {
|
||||
if x < y {
|
||||
x
|
||||
@ -40,6 +42,31 @@ fn min(x: f32, y: f32) -> f32 {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "nightly")]
|
||||
fn max(x: f32, y: f32) -> f32 {
|
||||
let o: f32;
|
||||
unsafe {
|
||||
asm!("vmaxnm.f32 {}, {}, {}",
|
||||
lateout(sreg) o, in(sreg) x, in(sreg) y,
|
||||
options(pure, nomem, nostack, preserves_flags)
|
||||
);
|
||||
}
|
||||
o
|
||||
}
|
||||
|
||||
#[cfg(feature = "nightly")]
|
||||
fn min(x: f32, y: f32) -> f32 {
|
||||
let o: f32;
|
||||
unsafe {
|
||||
asm!("vminnm.f32 {}, {}, {}",
|
||||
lateout(sreg) o, in(sreg) x, in(sreg) y,
|
||||
options(pure, nomem, nostack, preserves_flags)
|
||||
);
|
||||
}
|
||||
o
|
||||
}
|
||||
|
||||
|
||||
// Multiply-accumulate vectors `x` and `a`.
|
||||
//
|
||||
// A.k.a. dot product.
|
||||
|
@ -1,3 +1,4 @@
|
||||
#![no_std]
|
||||
#![cfg_attr(feature = "nightly", feature(asm))]
|
||||
|
||||
pub mod iir;
|
||||
|
@ -13,6 +13,9 @@
|
||||
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
||||
let gpiod = unsafe { &*hal::stm32::GPIOD::ptr() };
|
||||
gpiod.odr.modify(|_, w| w.odr6().high().odr12().high()); // FP_LED_1, FP_LED_3
|
||||
#[cfg(feature = "nightly")]
|
||||
core::intrinsics::abort();
|
||||
#[cfg(not(feature = "nightly"))]
|
||||
unsafe {
|
||||
core::intrinsics::abort();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user