GithubHelp home page GithubHelp logo

itron-rs's Introduction

itron

docs.rs

A Rust interface to interact with operating systems based on μITRON or its derivative.

This is not an officially supported project.

Examples

Cargo.toml:

[dependencies]
itron = { version = "0.1.0", features = ["asp3", "dcre"] }

Using the low-level binding:

use core::{mem, ptr};
use itron::abi::{acre_tsk, TA_ACT, T_CTSK, EXINF, ID};

fn create_task(param: isize) -> ID {
    extern "C" fn task_body(exinf: EXINF) {
        let _param = unsafe { exinf.assume_init() };
    }

    let er = unsafe {
        acre_tsk(&T_CTSK {
            tskatr: TA_ACT,
            exinf: mem::MaybeUninit::new(param),
            task: Some(task_body),
            itskpri: 4,
            stksz: 2048,
            stk: ptr::null_mut(),
        })
    };

    assert!(er >= 0, "could not create a task (error {})", er);
    er
}

Using the safe, high-level binding (experimental, requires unstable feature):

use itron::task;

fn create_task(param: isize) -> task::Task {
    let task_body = move || {
        let _param = param;
    };

    let new_task = task::Task::build()
        .start(create_task)
        .stack_size(2048)
        .initial_priority(4)
        .finish()
        .expect("could not create a task");

    new_task.as_ref().activate().unwrap();

    new_task
}

itron-rs's People

Contributors

kawadakk avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

itron-rs's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.