Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
5ef5072
Fixes for console
torfmaster Dec 10, 2017
2d8b22f
Adapt flash location for NRF52
Woyten Dec 28, 2017
ebb2b94
Create rustfmt.toml
Woyten Dec 28, 2017
64306fd
Provide poor man's toolchain
Woyten Dec 28, 2017
24f9bd2
Add 7 segment display example
torfmaster Dec 29, 2017
ad1a857
Use most recent version of elf2tbf and comment out crashing code
Woyten Dec 29, 2017
04661f2
Fix heap problems
Woyten Dec 30, 2017
3597431
Flash LEDs when panicking
Woyten Dec 31, 2017
0e1f73e
Make hello example work partially
Woyten Dec 31, 2017
ee604cf
Make hello example work by using a temporary decimal formatter
Woyten Jan 1, 2018
741bd3a
Format hex numbers and dump memory information on startup
Woyten Jan 1, 2018
5391163
Add ShiftRegister abstraction
Woyten Jan 1, 2018
e5f9cd5
Add Led abstraction
Woyten Jan 2, 2018
ee88289
Simplify method signatures
Woyten Jan 3, 2018
51948b0
Add GPIO support
torfmaster Jan 4, 2018
595f72f
Make GPIO examples work
Woyten Jan 4, 2018
7037cf7
Start work on button support
Woyten Jan 5, 2018
617c080
Make synchronuous button access work
torfmaster Jan 7, 2018
28a380d
Adapt command "command" to current tock-abi
torfmaster Jan 7, 2018
01c529c
Find a toolchain that works for compilation and the RLS
Woyten Jan 7, 2018
914e471
Format on save
Woyten Jan 7, 2018
714b346
Add gpio read support and example
torfmaster Jan 7, 2018
e04578a
Add BLE advertising support
torfmaster Jan 9, 2018
a59a7e2
Buttons with Rust closures
Woyten Jan 11, 2018
bf26fe3
Add skript to build all examples
Woyten Jan 14, 2018
94d21ed
Force specific xargo and elf2tbf version
Woyten Jan 14, 2018
01f23d8
Add first unit test
torfmaster Jan 17, 2018
d7ab026
Add .travis.yml
torfmaster Jan 18, 2018
7958d43
Rename TockResult to TockValue
Woyten Jan 19, 2018
d81a0c6
Add iter_mut() on Buttons
Woyten Jan 19, 2018
eaf500a
Fix comment
Woyten Jan 21, 2018
7e09261
Fix signature of _start
Woyten Jan 24, 2018
5188f4f
Put heap on stack
Woyten Jan 24, 2018
cb665ee
Use linker script from latest tock version
Woyten Jan 20, 2018
af7bc52
Do not emit PIC info
Woyten Jan 23, 2018
cffec31
Link _start function to .start section
Woyten Jan 23, 2018
8b27c99
Make heap great again
torfmaster Feb 2, 2018
e05178d
Speed up build by including tock as a submodule
Woyten Feb 2, 2018
7c907bc
Add service payload
torfmaster Feb 3, 2018
9567d79
Rework timer API
Woyten Feb 3, 2018
41b9135
Ble scanning
torfmaster Feb 5, 2018
a231480
Add temperature support and example
torfmaster Feb 10, 2018
cd7c7fe
Remove all warnings and treat them as build errors
Woyten Feb 10, 2018
80dbde8
Speed up build by including xargo as a submodule
Woyten Feb 10, 2018
c7eec1f
Introduce new generic callback structure
torfmaster Feb 10, 2018
e4c5720
Add IPC support
torfmaster Feb 20, 2018
fa109bf
Remove magical calculations from entry_point.rs
Woyten Feb 24, 2018
55570f2
Move to variable size payload
torfmaster Feb 24, 2018
76c3f1c
Update to current nightly
torfmaster Feb 24, 2018
349417d
Change ble examples to communicate via messagepack
torfmaster Feb 24, 2018
f83c869
Rework callbacks and subscriptions concept
Woyten Feb 24, 2018
097066b
Update tock
Woyten Mar 2, 2018
60df051
Use linked list allocator on crates.io
Woyten Mar 5, 2018
b8f7789
Merge remote-tracking branch 'upstream/master'
Woyten Mar 5, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .cargo/config

This file was deleted.

6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "tock"]
path = tock
url = https://github.com/helena-project/tock
[submodule "xargo"]
path = xargo
url = https://github.com/japaric/xargo
23 changes: 23 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
language: rust
rust:
- nightly-2018-02-23

os:
- linux

cache:
directories:
- $HOME/.cargo
- xargo/target
- tock/userland/tools/elf2tbf/target

install:
- wget -c https://developer.arm.com/-/media/Files/downloads/gnu-rm/6-2016q4/gcc-arm-none-eabi-6_2-2016q4-20161216-linux.tar.bz2
- tar -xjf gcc-arm-none-eabi-6_2-2016q4-20161216-linux.tar.bz2
- rustup component add rust-src

script:
- export PATH="$PATH:gcc-arm-none-eabi-6_2-2016q4/bin"
- export RUSTFLAGS="$RUSTFLAGS -D warnings"
- cargo test --lib
- ./build_examples.sh
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"editor.formatOnSave": true,
"rust-client.channel": "nightly-2018-02-23",
}
7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ authors = ["Tock Project Developers <tock-dev@googlegroups.com>"]
license = "MIT/Apache-2.0"

[dependencies]
linked_list_allocator = "0.4.3"
linked_list_allocator = "0.5.0"

[dev-dependencies]
corepack = { version="~0.3.1", default-features=false, features = ["alloc"] }
serde_derive = { version = "~1.0.10", default-features = false }
serde = { version = "~1.0.10", default-features = false }

[profile.dev]
panic = "abort"
Expand Down
12 changes: 0 additions & 12 deletions Cross.toml

This file was deleted.

19 changes: 5 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
[![Build Status](https://travis-ci.org/torfmaster/libtock-rs.svg?branch=master)](https://travis-ci.org/torfmaster/libtock-rs)
# libtock-rs
Rust userland library for Tock (WIP)

## Getting Started

This project is nascent and still under heavy development, but first steps:

1. First, update rustup to ensure you have the latest toolchain available:
1. Ensure you have a working toolchain available:

`rustup update`

or

`rustup install nightly`
`rustup install nightly-2017-12-16`

2. Get a copy of the latest nightly, in this repo's root:
2. Get a copy of this toolchain, in this repo's root:

`rustup override set nightly`

Your rustc should be at least this new:
```
$ rustc --version
rustc 1.21.0-nightly (7ac979d8c 2017-08-16)
```
`rustup override set nightly-2017-12-16`

3. Need to grab a copy of the rust sources:

Expand Down
7 changes: 7 additions & 0 deletions build_examples.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -eux
export RUST_TARGET_PATH=`pwd`
export CARGO_INCREMENTAL=0

cargo run --manifest-path xargo/Cargo.toml -- build --release --target=thumbv7em-tock-eabi --examples
10 changes: 5 additions & 5 deletions examples/ble_ess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use alloc::fmt::Write;
use tock::console::Console;
use tock::ipc::ble_ess::{self, ReadingType};
use tock::sensors::*;
use tock::timer;
use tock::timer::Duration;

fn main() {
let mut console = Console::new();
Expand All @@ -17,7 +19,7 @@ fn main() {
Ok(ess) => ess,
_ => {
write!(&mut console, "BLE IPC Service not installed\n").unwrap();
return
return;
}
};
write!(&mut console, "Found BLE IPC Service\n").unwrap();
Expand All @@ -26,14 +28,13 @@ fn main() {
let mut temperature = TemperatureSensor;
let mut light = AmbientLightSensor;
loop {

// Temperature
let temp = temperature.read();
write!(&mut console, "Temperature: {}\n", temp).unwrap();
if let Err(_) = ess.set_reading(ReadingType::Temperature, temp) {
write!(&mut console, "Failed to set temperature\n").unwrap_or(());
}

// Light
let lx = light.read();
write!(&mut console, "Light: {}\n", lx).unwrap();
Expand All @@ -48,7 +49,6 @@ fn main() {
write!(&mut console, "Failed to set temperature\n").unwrap_or(());
}

tock::timer::delay_ms(5000);
timer::sleep(Duration::from_ms(5000))
}
}

49 changes: 49 additions & 0 deletions examples/ble_scanning.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#![no_std]
#![feature(alloc)]

extern crate alloc;
extern crate corepack;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate tock;

// Macro usages are not detected
#[allow(unused_imports)]
use alloc::*;
use tock::ble_parser;
use tock::led;
use tock::simple_ble::BleDriver;
use tock::syscalls;

#[derive(Deserialize)]
struct LedCommand {
pub nr: u8,
pub st: bool,
}

fn main() {
let buffer = [0; tock::simple_ble::BUFFER_SIZE_SCAN];
BleDriver::start(&buffer, |_: usize, _: usize| {
match ble_parser::find(&buffer, tock::simple_ble::gap_data::SERVICE_DATA as u8) {
Some(payload) => {
let payload: Vec<u8> = payload.iter().map(|&x| *x).collect::<Vec<u8>>();
let msg: LedCommand = corepack::from_bytes(payload.as_slice()).unwrap();
let msg_led = led::get(msg.nr as isize);
match msg_led {
Some(msg_led) => if msg.st {
msg_led.on();
} else {
msg_led.off();
},
_ => (),
}
}
None => (),
}
}).unwrap();

loop {
syscalls::yieldk();
}
}
13 changes: 7 additions & 6 deletions examples/blink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

extern crate tock;

use tock::{led, timer};
use tock::led;
use tock::timer;
use tock::timer::Duration;

fn main() {
let led_count = led::count();
let led = led::get(0).unwrap();

loop {
for i in 0..led_count {
led::toggle(i as u32);
timer::delay_ms(500);
}
led.toggle();
timer::sleep(Duration::from_ms(500));
}
}
16 changes: 0 additions & 16 deletions examples/blink_async.rs

This file was deleted.

27 changes: 27 additions & 0 deletions examples/button_read.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#![feature(alloc)]
#![no_std]

extern crate alloc;
extern crate tock;

use alloc::string::String;
use tock::buttons;
use tock::buttons::ButtonState;
use tock::console::Console;
use tock::timer;
use tock::timer::Duration;

fn main() {
let mut console = Console::new();
let mut buttons = buttons::with_callback(|_, _| {}).unwrap();
let mut button = buttons.iter_mut().next().unwrap();
let button = button.enable().unwrap();

loop {
match button.read() {
ButtonState::Pressed => console.write(String::from("pressed\n")),
ButtonState::Released => console.write(String::from("released\n")),
}
timer::sleep(Duration::from_ms(500));
}
}
36 changes: 36 additions & 0 deletions examples/button_subscribe.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#![feature(alloc)]
#![no_std]

extern crate alloc;
extern crate tock;

use alloc::string::String;
use tock::buttons;
use tock::buttons::ButtonState;
use tock::console::Console;
use tock::fmt;
use tock::timer;
use tock::timer::Duration;

// FIXME: Hangs up when buttons are pressed rapidly - problem in console?
fn main() {
let mut console = Console::new();

let mut buttons = buttons::with_callback(|button_num: usize, state| {
console.write(String::from("\nButton: "));
console.write(fmt::u32_as_hex(button_num as u32));
console.write(String::from(" - State: "));
console.write(String::from(match state {
ButtonState::Pressed => "pressed",
ButtonState::Released => "released",
}));
}).unwrap();

for mut button in &mut buttons {
button.enable().unwrap();
}

loop {
timer::sleep(Duration::from_ms(500));
}
}
20 changes: 20 additions & 0 deletions examples/gpio.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#![no_std]

extern crate tock;

use tock::gpio::GpioPinUnitialized;
use tock::timer;
use tock::timer::Duration;

// Example works on P0.03
fn main() {
let pin = GpioPinUnitialized::new(0);
let pin = pin.open_for_write().unwrap();

loop {
pin.set_high();
timer::sleep(Duration::from_ms(500));
pin.set_low();;
timer::sleep(Duration::from_ms(500));
}
}
27 changes: 27 additions & 0 deletions examples/gpio_read.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#![feature(alloc)]
#![no_std]

extern crate alloc;
extern crate tock;

use alloc::string::String;
use tock::console::Console;
use tock::gpio::{GpioPinUnitialized, InputMode};
use tock::timer;
use tock::timer::Duration;

// example works on p0.03
fn main() {
let mut console = Console::new();
let pin = GpioPinUnitialized::new(0);
let pin = pin.open_for_read(None, InputMode::PullDown).unwrap();

loop {
if pin.read() {
console.write(String::from("true\n"));
} else {
console.write(String::from("false\n"));
}
timer::sleep(Duration::from_ms(500));
}
}
15 changes: 10 additions & 5 deletions examples/hello.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
#![feature(asm,alloc)]
#![feature(alloc)]
#![no_std]

extern crate alloc;
extern crate tock;

use alloc::fmt::Write;
use alloc::string::String;
use tock::console::Console;
use tock::timer;
use tock::timer::Duration;

// TODO: Make format!/alloc::string::ToString work
fn main() {
let mut console = Console::new();

for i in 0.. {
write!(&mut console, "Hello world! {}\n", i).unwrap();
tock::timer::delay_ms(500);
console.write(String::from("Hello world! "));
console.write(tock::fmt::u32_as_decimal(i));
console.write(String::from("\n"));
timer::sleep(Duration::from_ms(500))
}
}

Loading