aboutsummaryrefslogtreecommitdiff
path: root/examples/mspm0g3507
diff options
context:
space:
mode:
authorSiarhei B <[email protected]>2025-11-16 01:16:30 +0100
committerSiarhei B <[email protected]>2025-11-16 01:26:28 +0100
commit5729b653ae5a95fe1af131dcbceb9dbb0397f4c6 (patch)
treebd0fdbefcb5054021f86ae85b5f75877eafb7284 /examples/mspm0g3507
parent535c6d378fb68083623338f8534b5da8efd6a139 (diff)
mspm0: add example of MATHACL based & tested on mspm0g3507
Diffstat (limited to 'examples/mspm0g3507')
-rw-r--r--examples/mspm0g3507/src/bin/mathacl_ops.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/examples/mspm0g3507/src/bin/mathacl_ops.rs b/examples/mspm0g3507/src/bin/mathacl_ops.rs
new file mode 100644
index 000000000..429cc5ad6
--- /dev/null
+++ b/examples/mspm0g3507/src/bin/mathacl_ops.rs
@@ -0,0 +1,37 @@
1//! Example of using mathematical calculations performed by the MSPM0G3507 chip.
2//!
3//! It prints the result of basics trigonometric calculation.
4
5#![no_std]
6#![no_main]
7
8use defmt::*;
9use embassy_executor::Spawner;
10use embassy_mspm0::mathacl::{Mathacl, Precision};
11use embassy_time::Timer;
12use {defmt_rtt as _, panic_halt as _};
13
14#[embassy_executor::main]
15async fn main(_spawner: Spawner) -> ! {
16 info!("Hello world!");
17
18 let d = embassy_mspm0::init(Default::default());
19
20 let mut macl = Mathacl::new(d.MATHACL);
21
22 // in range [-1,1)
23 let angle = 0.5;
24 match macl.sin(angle, Precision::High) {
25 Ok(res) => info!("sin({}) = {}", angle*180.0, res),
26 Err(e) => error!("sin Error: {:?}", e),
27 }
28
29 match macl.cos(angle, Precision::Medium) {
30 Ok(res) => info!("cos({}) = {}", angle*180.0, res),
31 Err(e) => error!("cos Error: {:?}", e),
32 }
33
34 loop {
35 Timer::after_millis(500).await;
36 }
37}