aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authori509VCB <[email protected]>2025-11-24 22:59:13 +0000
committerGitHub <[email protected]>2025-11-24 22:59:13 +0000
commit5ffb3698541674d57fddb22044ac0f06397c6113 (patch)
treee78c68d7702928ce5e7acc19a72b7e4f7bfb858f /examples
parenta66d9f6bea6b6e55ba3dfe0f3b86152402e47d3f (diff)
parent672165572e36d04a59eb672e19ebf4c1726fc8aa (diff)
Merge pull request #4897 from bespsm/MSPM0-MATHACL
MSPSM0: module MATHACL
Diffstat (limited to 'examples')
-rw-r--r--examples/mspm0g3507/src/bin/mathacl_ops.rs39
1 files changed, 39 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..25d74b29b
--- /dev/null
+++ b/examples/mspm0g3507/src/bin/mathacl_ops.rs
@@ -0,0 +1,39 @@
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 core::f32::consts::PI;
9
10use defmt::*;
11use embassy_executor::Spawner;
12use embassy_mspm0::mathacl::{Mathacl, Precision};
13use embassy_time::Timer;
14use {defmt_rtt as _, panic_halt as _};
15
16#[embassy_executor::main]
17async fn main(_spawner: Spawner) -> ! {
18 info!("Hello world!");
19
20 let d = embassy_mspm0::init(Default::default());
21
22 let mut macl = Mathacl::new(d.MATHACL);
23
24 // value radians [-PI; PI]
25 let rads = PI * 0.5;
26 match macl.sin(rads, Precision::High) {
27 Ok(res) => info!("sin({}) = {}", rads, res),
28 Err(e) => error!("sin Error: {:?}", e),
29 }
30
31 match macl.cos(rads, Precision::Medium) {
32 Ok(res) => info!("cos({}) = {}", rads, res),
33 Err(e) => error!("cos Error: {:?}", e),
34 }
35
36 loop {
37 Timer::after_millis(500).await;
38 }
39}