embedded_c_sdk_bind_hal/
lib.rs1#![no_std]
2
3#[macro_use]
4mod common;
5mod ll_api;
6mod tick_freq_hz;
7
8pub mod adc;
9pub mod dma;
10pub mod gpio;
11pub mod i2c;
12pub mod print;
13pub mod pwm;
14pub mod spi;
15pub mod tick;
16pub mod usart;
17
18pub use common::format;
19pub use ll_api::ll_cmd::*;
20
21#[cfg(feature = "print-log-csdk")]
22pub use embedded_c_sdk_bind_print_macros::{print, println};
23
24#[macro_export]
25macro_rules! ll_invoke {
26 ( $( $x:expr ),* ) => {
27 {
28 unsafe { $crate::ll_invoke( $( $x as $crate::InvokeParam, )* ) }
29 }
30 };
31}
32
33#[macro_export]
34macro_rules! sys_tick_handler {
35 () => {
36 <$crate::tick::Tick as $crate::tick::HalTickHandler>::on_sys_tick_interrupt();
37 };
38}
39
40#[macro_export]
64macro_rules! setInterval {
65 ($f:expr, $period_ms:expr) => {
66 {
67 static mut TICK: Tick = Tick::with_value(0);
68
69 if unsafe { TICK.elapsed_time().to_millis() } >= $period_ms {
70 unsafe { TICK = Tick::now(); }
71 $f();
72 }
73 }
74 };
75
76 ($f:expr, $period_ms:expr, $( $param:expr ),*) => {
77 {
78 static mut TICK: Tick = Tick::with_value(0);
79
80 if unsafe { TICK.elapsed_time().to_millis() } >= $period_ms {
81 unsafe { TICK = Tick::now(); }
82 $f($( $param, )*);
83 }
84 }
85 };
86}