diff options
| author | i509VCB <[email protected]> | 2025-11-24 22:59:13 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-11-24 22:59:13 +0000 |
| commit | 5ffb3698541674d57fddb22044ac0f06397c6113 (patch) | |
| tree | e78c68d7702928ce5e7acc19a72b7e4f7bfb858f /examples | |
| parent | a66d9f6bea6b6e55ba3dfe0f3b86152402e47d3f (diff) | |
| parent | 672165572e36d04a59eb672e19ebf4c1726fc8aa (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.rs | 39 |
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 | |||
| 8 | use core::f32::consts::PI; | ||
| 9 | |||
| 10 | use defmt::*; | ||
| 11 | use embassy_executor::Spawner; | ||
| 12 | use embassy_mspm0::mathacl::{Mathacl, Precision}; | ||
| 13 | use embassy_time::Timer; | ||
| 14 | use {defmt_rtt as _, panic_halt as _}; | ||
| 15 | |||
| 16 | #[embassy_executor::main] | ||
| 17 | async 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 | } | ||
