1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
//! Example of using mathematical calculations performed by the MSPM0G3507 chip.
//!
//! It prints the result of basics trigonometric calculation.
#![no_std]
#![no_main]
use core::f32::consts::PI;
use defmt::*;
use embassy_executor::Spawner;
use embassy_mspm0::mathacl::{Mathacl, Precision};
use embassy_time::Timer;
use {defmt_rtt as _, panic_halt as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner) -> ! {
info!("Hello world!");
let d = embassy_mspm0::init(Default::default());
let mut macl = Mathacl::new(d.MATHACL);
// value radians [-PI; PI]
let rads = PI * 0.5;
match macl.sin(rads, Precision::High) {
Ok(res) => info!("sin({}) = {}", rads, res),
Err(e) => error!("sin Error: {:?}", e),
}
match macl.cos(rads, Precision::Medium) {
Ok(res) => info!("cos({}) = {}", rads, res),
Err(e) => error!("cos Error: {:?}", e),
}
loop {
Timer::after_millis(500).await;
}
}
|