GithubHelp home page GithubHelp logo

dfrankland / teensy3-rs-demo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jamesmunns/teensy3-rs-demo

0.0 3.0 0.0 23 KB

Demo consumer of the teensy-rs library

License: MIT License

Rust 84.46% Shell 15.54%

teensy3-rs-demo's Introduction

Teensy with Rust

This is an example project that consumes the teensy3-rs crate. It is intended to be forked, or copied into a new project. It provideds the following important components:

  • .cargo/config: Instructs Cargo how which target to build
  • thumb7em-none-eabi.json: Target configuration items specific to the build process
  • Cargo.toml: Specification of profile.(dev|release)
  • mk20dx256.ld: Linker file specific to the Teensy 3.1/3.2 processors
  • src/main.rs: A few necessary compiler flags

Examples

Safe Components

Items used from the teensy3 crate directly can be used as safe rust code. In this function, notice how there is no unsafe marker:

extern crate teensy3;
use teensy3::serial::Serial;

// ...

/// Send a message over the USB Serial port
pub fn hello(ser: &Serial) -> Result<(),()> {
    let msg = "Hello Teensy Rusty World!\n\r";
    ser.write_bytes(msg.as_bytes())
}

Items used from the teensy3::bindings module are NOT marked as safe (because they are direct C++ code mappings). These require an unsafe mark at either the function or block level:

extern crate teensy3;
use teensy3::bindings;

// ...

/// Blink the light twice to know we're alive
pub unsafe fn alive() {
    for _ in 0..2 {
        bindings::digitalWrite(13, bindings::LOW as u8);
        bindings::delay(200);
        bindings::digitalWrite(13, bindings::HIGH as u8);
        bindings::delay(200);
        bindings::digitalWrite(13, bindings::LOW as u8);
        bindings::delay(200);
    }
}

Usage:

  • Fork/Clone this repo
  • Install xargo
  • Install arm-none-eabi-gcc, add to $PATH
  • Run make flash

Dependencies

  • A somewhat current Nightly Build of Rust (currently tested on rustc 1.13.0-nightly (6ffdda1ba 2016-09-14))
  • Japaric's Xargo Tool - used to cross compile libcore
  • A somewhat current arm-none-eabi-gcc toolchain.
    • 4.9.3 seems to work with a slight linker hack
    • 6.x.x seems to work without hacks.

License

Rust contributions are licensed under the MIT License.

Please Note: ASM, C, C++, and Linker Components of the teensy3-sys crate (a dependency of the teensy3 crate) contain components licensed under the MIT License, PJRC's modified MIT License, and the LGPL v2.1. Please refer to individual components for more details.

teensy3-rs-demo's People

Contributors

dfrankland avatar jamesmunns avatar

Watchers

 avatar  avatar  avatar

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.