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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//! # FreeRTOS for Rust
//!
//! Rust interface for the FreeRTOS embedded operating system. Requires beta Rust.
//! It is assumed that dynamic memory allocation is provided on the target system.
//!
//! This library interfaces with FreeRTOS using a C shim library which provides function
//! wrappers for FreeRTOS macros. The compiled Rust application should be linked to the
//! base C/C++ firmware binary. Check the subdirectory ``shim``. Copy the source file to
//! your firmware's sources directory and modify it to include the appropriate headers for
//! target your system.
//!
//! For a complete example, check the enclosed GCC ARM/Rust/QEMU based unit tests. The project
//! ``qemu_runner`` cross-compiles this library, compiles the main firmware using GCC ARM and links
//! in the appropriate entry points for unit tests. [GNU ARM Eclipse QEMU](http://gnuarmeclipse.github.io/qemu/)
//! is used to run the test binaries.
//!
//! Be sure to check the [FreeRTOS documentation](http://www.freertos.org/RTOS.html).
//!
//! # Samples
//!
//! Spawning a new task
//!
//! ```rust
//! # use freertos_rs::*;
//! Task::new().name("hello").stack_size(128).start(|| {
//! 	loop {
//! 		println!("Hello world!");
//! 		CurrentTask::delay(Duration::infinite());
//! 	}
//! }).unwrap();
//! ```
//!
//! Queue
//!
//! ```rust
//! # use freertos_rs::*;
//! let q = Queue::new(10).unwrap();
//! q.send(10, Duration::ms(5)).unwrap();
//! q.receive(Duration::infinite()).unwrap();
//! ```
//!
//! Mutex
//!
//! ```rust
//! # use freertos_rs::*;
//! let m = Mutex::new(0).unwrap();
//! {
//! 	let mut v = m.lock(Duration::infinite()).unwrap();
//! 	*v += 1;
//! }
//! ```

#![no_std]

#[macro_use]
extern crate alloc;

mod prelude;
mod shim;

mod base;
mod task;
mod timers;
mod queue;
mod semaphore;
mod mutex;
mod units;
mod utils;
mod isr;
mod delays;
mod critical;

pub mod patterns;

pub use crate::base::FreeRtosError;
pub use crate::task::*;
pub use crate::queue::*;
pub use crate::units::*;
pub use crate::mutex::*;
pub use crate::semaphore::*;
pub use crate::isr::*;
pub use crate::delays::*;
pub use crate::timers::*;
pub use crate::critical::*;

pub use crate::utils::shim_sanity_check;