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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
// -*- coding: utf-8 -*-
//
// Copyright 2023 Michael Büsch <m@bues.ch>
//
// Licensed under the Apache License version 2.0
// or the MIT license, at your option.
// SPDX-License-Identifier: Apache-2.0 OR MIT
//
#![forbid(unsafe_code)]
#![allow(clippy::needless_doctest_main)]
//! # Simple time slice scheduler
//!
//! ## Example code
//!
//! ```
//! // Define the scheduler, its tasks and behavior.
//! timeslice::define_timeslice_sched! {
//! name: sched_main,
//! num_objs: 2,
//! tasks: {
//! { name: task_10ms, period: 10 ms, cpu: 0, stack: 16 kiB },
//! { name: task_50ms, period: 50 ms, cpu: 0, stack: 3 kiB },
//! { name: task_100ms, period: 100 ms, cpu: 1, stack: 16 kiB },
//! { name: task_1000ms, period: 1000 ms, cpu: 1, stack: 3 kiB }
//! }
//! }
//!
//! struct MyThing1 {
//! // ...
//! }
//!
//! impl MyThing1 {
//! fn new() -> Self {
//! Self {
//! // ...
//! }
//! }
//! }
//!
//! impl sched_main::Ops for Box<MyThing1> {
//! fn task_10ms(&self) {
//! // Called every 10 ms.
//! // ... Put your code here ...
//! }
//!
//! fn task_50ms(&self) {
//! // Called every 50 ms.
//! // ... Put your code here ...
//! }
//!
//! fn task_100ms(&self) {
//! // Called every 100 ms.
//! // ... Put your code here ...
//! }
//!
//! fn task_1000ms(&self) {
//! // Called every 1000 ms.
//! // ... Put your code here ...
//! }
//! }
//!
//! struct MyThing2 {
//! // ...
//! }
//!
//! impl MyThing2 {
//! fn new() -> Self {
//! Self {
//! // ...
//! }
//! }
//! }
//!
//! impl sched_main::Ops for Box<MyThing2> {
//! fn task_10ms(&self) {
//! // Called every 10 ms.
//! // ... Put your code here ...
//! }
//!
//! fn task_100ms(&self) {
//! // Called every 100 ms.
//! // ... Put your code here ...
//! }
//! }
//!
//! fn main() {
//! use std::sync::Arc;
//! let thing1 = Arc::new(Box::new(MyThing1::new()));
//! let thing2 = Arc::new(Box::new(MyThing2::new()));
//!
//! let obj1 = Arc::clone(&thing1);
//! let obj2 = Arc::clone(&thing2);
//! sched_main::init([obj1, obj2]);
//!
//! // ...
//! }
//! ```
/// Do not access this module directly from other crates.
#[doc(hidden)]
pub mod hal;
/// Do not access this module directly from other crates.
#[doc(hidden)]
pub mod meas;
/// This module contains the main API macros.
mod define_macro;
// vim: ts=4 sw=4 expandtab