osal_rs/
lib.rs

1#![cfg_attr(not(feature = "std"), no_std)]
2
3// Suppress warnings from FreeRTOS FFI bindings being included in multiple modules
4#![allow(clashing_extern_declarations)]
5#![allow(dead_code)]
6#![allow(unused_imports)]
7extern crate alloc;
8
9#[cfg(feature = "freertos")]
10mod freertos;
11
12#[cfg(feature = "posix")]
13mod posix;
14
15pub mod log;
16
17mod traits;
18
19pub mod utils;
20
21#[cfg(feature = "freertos")]
22use crate::freertos as osal;
23
24#[cfg(feature = "posix")]
25use crate::posix as osal;
26
27pub mod os {
28
29    #[cfg(not(feature = "disable_panic"))]
30    use crate::osal::allocator::Allocator;
31
32
33    #[cfg(not(feature = "disable_panic"))]
34    #[global_allocator]
35    pub static ALLOCATOR: Allocator = Allocator;
36
37    
38    pub use crate::osal::duration::*;
39    pub use crate::osal::event_group::*;
40    pub use crate::osal::mutex::*;
41    pub use crate::osal::queue::*;
42    pub use crate::osal::semaphore::*;
43    pub use crate::osal::system::*;
44    pub use crate::osal::thread::*;
45    pub use crate::osal::timer::*;
46    pub use crate::traits::*;
47    pub use crate::osal::config as config;
48    pub use crate::osal::types as types;
49    
50}
51
52
53// Panic handler for no_std library - only when building as final binary
54// Examples with std will provide their own
55#[cfg(not(feature = "disable_panic"))]
56#[panic_handler]
57
58fn panic(info: &core::panic::PanicInfo) -> ! {
59    println!("Panic occurred: {}", info);
60    #[allow(clippy::empty_loop)]
61    loop {}
62}
63