aboutsummaryrefslogtreecommitdiff
path: root/examples/mspm0g3507/src
diff options
context:
space:
mode:
authorSiarhei B <[email protected]>2025-11-16 11:59:57 +0100
committerSiarhei B <[email protected]>2025-11-16 11:59:57 +0100
commitd34dd3006dbcaff198c4e72469b5598dc3a8faa0 (patch)
tree5580552557330744283eacf8802927eb1ad5d36f /examples/mspm0g3507/src
parentf236bb49301e3e726d60e0af8f6b998083b6215e (diff)
mspm0-mathacl: switch to radians as input param for sincos operations
Diffstat (limited to 'examples/mspm0g3507/src')
-rw-r--r--examples/mspm0g3507/src/bin/mathacl_ops.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/examples/mspm0g3507/src/bin/mathacl_ops.rs b/examples/mspm0g3507/src/bin/mathacl_ops.rs
index 06265ae18..aeca96d2b 100644
--- a/examples/mspm0g3507/src/bin/mathacl_ops.rs
+++ b/examples/mspm0g3507/src/bin/mathacl_ops.rs
@@ -5,6 +5,7 @@
5#![no_std] 5#![no_std]
6#![no_main] 6#![no_main]
7 7
8use core::f32::consts::PI;
8use defmt::*; 9use defmt::*;
9use embassy_executor::Spawner; 10use embassy_executor::Spawner;
10use embassy_mspm0::mathacl::{Mathacl, Precision}; 11use embassy_mspm0::mathacl::{Mathacl, Precision};
@@ -19,15 +20,15 @@ async fn main(_spawner: Spawner) -> ! {
19 20
20 let mut macl = Mathacl::new(d.MATHACL); 21 let mut macl = Mathacl::new(d.MATHACL);
21 22
22 // in range [-1,1) 23 // value radians [-PI; PI]
23 let angle = 0.5; 24 let rads = PI * 0.5;
24 match macl.sin(angle, Precision::High) { 25 match macl.sin(rads, Precision::High) {
25 Ok(res) => info!("sin({}) = {}", angle * 180.0, res), 26 Ok(res) => info!("sin({}) = {}", rads, res),
26 Err(e) => error!("sin Error: {:?}", e), 27 Err(e) => error!("sin Error: {:?}", e),
27 } 28 }
28 29
29 match macl.cos(angle, Precision::Medium) { 30 match macl.cos(rads, Precision::Medium) {
30 Ok(res) => info!("cos({}) = {}", angle * 180.0, res), 31 Ok(res) => info!("cos({}) = {}", rads, res),
31 Err(e) => error!("cos Error: {:?}", e), 32 Err(e) => error!("cos Error: {:?}", e),
32 } 33 }
33 34