1#![cfg_attr(not(feature = "std"), no_std)]
2#![feature(core_intrinsics)]
3#![feature(alloc_error_handler)]
4#![feature(once_cell)]
5#![feature(waker_getters)]
6
7extern crate core;
8
9mod futures;
10mod common;
11#[cfg(feature = "peripherals")]
12mod peripherals;
13#[cfg(feature = "std")]
14mod std;
15#[cfg(not(feature = "std"))]
16mod no_std;
17
18pub use common::task::{Task, TaskResult};
19pub use common::executor::Executor;
20pub use common::lazy::Lazy;
21pub use common::timer::timer_init;
22
23pub use futures::channel::Channel;
24pub use futures::time::delay;
25pub use futures::mutex::Mutex;
26pub use futures::trigger::Trigger;
27pub use futures::semaphore::{Semaphore, SemaphoreUnbounded};
28
29#[macro_export]
30macro_rules! trigger {
31 ($name:ident, $task_num:expr) => {
32 #[allow(non_upper_case_globals)]
33 static $name: Lazy<Trigger<$task_num>> = Lazy::new_with_init(|| {
34 Trigger::new()
35 });
36 };
37}
38
39#[macro_export]
40macro_rules! trigger_pub {
41 ($name:ident, $task_num:expr) => {
42 #[allow(non_upper_case_globals)]
43 pub static $name: Lazy<Trigger<$task_num>> = Lazy::new_with_init(|| {
44 Trigger::new()
45 });
46 };
47}
48
49#[macro_export]
50macro_rules! mutex {
51 ($name:ident, $val_type:ty, $init_val:expr, $task_num:expr) => {
52 #[allow(non_upper_case_globals)]
53 static $name: Lazy<Mutex<$val_type, $task_num>> = Lazy::new_with_init(|| {
54 Mutex::new($init_val)
55 });
56 };
57}
58
59#[macro_export]
60macro_rules! mutex_pub {
61 ($name:ident, $val_type:ty, $init_val:expr, $task_num:expr) => {
62 #[allow(non_upper_case_globals)]
63 pub static $name: Lazy<Mutex<$val_type, $task_num>> = Lazy::new_with_init(|| {
64 Mutex::new($init_val)
65 });
66 };
67}
68
69#[macro_export]
70macro_rules! semaphore {
71 ($name:ident, $init_count:expr, $total_count:expr, $task_num:expr) => {
72 #[allow(non_upper_case_globals)]
73 static $name: Lazy<Semaphore<$total_count, $task_num>> = Lazy::new_with_init(|| {
74 Semaphore::new($init_count)
75 });
76 };
77}
78
79#[macro_export]
80macro_rules! semaphore_pub {
81 ($name:ident, $init_count:expr, $total_count:expr, $task_num:expr) => {
82 #[allow(non_upper_case_globals)]
83 pub static $name: Lazy<Semaphore<$total_count, $task_num>> = Lazy::new_with_init(|| {
84 Semaphore::new($init_count)
85 });
86 };
87}
88
89#[macro_export]
90macro_rules! channel {
91 ($name:ident, $val_type:ty, $num_of_itens:expr, $task_num:expr) => {
92 #[allow(non_upper_case_globals)]
93 static $name: Lazy<Channel<$val_type, $num_of_itens, $task_num>> = Lazy::new_with_init(|| {
94 Channel::new()
95 });
96 };
97}
98
99#[macro_export]
100macro_rules! channel_pub {
101 ($name:ident, $val_type:ty, $num_of_itens:expr, $task_num:expr) => {
102 #[allow(non_upper_case_globals)]
103 pub static $name: Lazy<Channel<$val_type, $num_of_itens, $task_num>> = Lazy::new_with_init(|| {
104 Channel::new()
105 });
106 };
107}
108
109#[cfg(feature = "zbus")]
110pub use futures::zbus::ZbusChannel;
111#[cfg(all(not(feature = "std"), feature = "zbus"))]
112pub use no_std::zbus_backend::zbus_observer;
113
114pub use common::result::{Expect, RARTError};
115#[cfg(not(feature = "std"))]
116pub use no_std::{log_fn, timestamp};
117#[cfg(not(feature = "std"))]
118pub use const_format::formatcp;
119
120#[cfg(all(feature = "std", feature = "peripherals"))]
121pub use peripherals::{Peripheral, gpio::Gpio};
122#[cfg(all(feature = "std", feature = "peripherals"))]
123pub use crate::std::peripheral::read_gpio;