This repository was archived by the owner on Jul 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 99
This repository was archived by the owner on Jul 6, 2019. It is now read-only.
Using uart from outside of "run". #239
Copy link
Copy link
Closed
Description
First, apologies for not using a mailing list - I've searched (in-page) for "mail" in https://github.com/hackndev/zinc and http://zinc.rs/ but found nothing.
I'm trying to use the uart
(and other run_args
) from outside the run
function.
Adding just a small quantity of code:
+ fn func(args: &pt::run_args) {
+ args.uart.puts("Hello, world, from func.\n"); // this isn't allowed
+ }
fn run(args: &pt::run_args) {
...
args.uart.puts("Hello, world\n"); // no error here, this is allowed
+ func(args);
to the app_uart.rs causes it to fail to compile with:
/home/chris/ecryptfs/rust/zinc/apps/app_uart.rs:61:13: 61:47 error: type `&zinc::hal::lpc17xx::uart::UART` does not implement any method in scope named `puts`
/home/chris/ecryptfs/rust/zinc/apps/app_uart.rs:61 args.uart.puts("Hello, world, from func.\n");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
- Is there something magic about
run_args
, or (more likely) something stupid in what I'm trying to do? - How should the
uart
(and otherrun_args
) be accessed form outside of the mainrun
function?
P.S. It all compiles and runs perfectly until I try to use the uart from a function other than run
.
P.P.S. Full source:
#![feature(phase)]
#![crate_type="staticlib"]
#![no_std]
extern crate core;
extern crate zinc;
#[phase(plugin)] extern crate macro_platformtree;
platformtree!(
lpc17xx@mcu {
clock {
source = "main-oscillator";
source_frequency = 12_000_000;
pll {
m = 50;
n = 3;
divisor = 4;
}
}
timer {
timer@1 {
counter = 25;
divisor = 4;
}
}
uart {
uart@0 {
baud_rate = 115200;
mode = "8N1";
tx = &uart_tx;
rx = &uart_rx;
}
}
gpio {
0 {
uart_tx@2;
uart_rx@3;
}
1 {
led4@23 { direction = "out"; }
}
}
}
os {
single_task {
loop = "run";
args {
timer = &timer;
txled = &led4;
uart = &uart;
}
}
}
)
fn func(args: &pt::run_args) {
args.uart.puts("Hello, world, from func.\n");
}
fn run(args: &pt::run_args) {
use zinc::drivers::chario::CharIO;
use zinc::hal::timer::Timer;
use zinc::hal::pin::Gpio;
args.uart.puts("Hello, world\n");
func(args);
let mut i = 0;
loop {
args.txled.set_high();
args.uart.puts("Waiting for ");
args.uart.puti(i);
args.uart.puts(" seconds...\n");
i += 1;
args.txled.set_low();
args.timer.wait(1);
}
}
Metadata
Metadata
Assignees
Labels
No labels