Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Zinc at Rust London '14
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Vladimir Pouzanov
August 14, 2014
Technology
130
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Zinc at Rust London '14
Vladimir Pouzanov
August 14, 2014
More Decks by Vladimir Pouzanov
See All by Vladimir Pouzanov
Pixels Everywhere!
farcaller
0
170
Prepare to Dock
farcaller
1
280
REPL Done Right
farcaller
1
330
iOS in Motion
farcaller
1
150
Reversing WTF
farcaller
2
130
iOS TDD
farcaller
1
190
Clang 3.0 Memory Management
farcaller
1
130
Effective Multithreading in iOS
farcaller
1
140
GameKit and Social APIs
farcaller
1
95
Other Decks in Technology
See All in Technology
FPC(フレキシブル)基板にZephyr実装してみた。
iotengineer22
0
170
AI-DLCを “そのまま導入しなかった”話 ~組織に合わせてアジャストした 私たちの実践共有~
hiroramos4
PRO
1
430
[AWS Summit Japan 2026]迷っているあなたへ_小さな一歩が、やがて自分を助けてくれる
sh_fk2
2
420
IaC コードを資産へ:AWS CDK 社内ライブラリと横断展開 / aws-summit-japan-2026
gotok365
10
1.6k
“詰む”前に仕組みを作れ 〜技術の波に溺れないためのキャッチアップ術〜
takasyou
7
3.9k
【FinOps】データドリブンな意思決定を目指して
z63d
0
380
AIAU_UMEMOGU_ninomiya_slide
ninomiya_ii
0
260
現場のトークンマネジメント
dak2
1
190
AI時代のコスト管理を考えよう〜明日から使える実践AWSノウハウ~
yoshimi0227
0
890
AIチャット検索改善の3週間
kworkdev
PRO
2
180
元・セキュリティ学習経験0大学生による業務紹介 / An Introduction to the Job by a Former College Student with Zero Security Training Experience
nttcom
0
250
FPGAの開発コンペでZephyrを使ってみた
iotengineer22
0
200
Featured
See All Featured
30 Presentation Tips
portentint
PRO
1
330
Optimising Largest Contentful Paint
csswizardry
37
3.7k
Rails Girls Zürich Keynote
gr2m
96
14k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
870
Navigating Weather and Climate Data
rabernat
0
240
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
210
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
170
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
380
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
190
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
480
Java REST API Framework Comparison - PWX 2021
mraible
34
9.4k
Transcript
Zn 30 65.38 Vladimir Pouzanov <
[email protected]
>
rust
embedded
None
None
zinc
why rust?
fun
embedded
it's C and C++ all the way down
useful features
safe
expressive
still not 1.0
metaprogramming
a typical embedded program
think arduino "hello world" in rust
pub unsafe fn main() { init_stack();
init_data(); system_clock::init_clock(&Clock { source: system_clock::Main(12000000), pll: Some(PLL0 { m: 50, n: 3, divisor: 4 }) }); let timer = Timer::new(Timer1, 25, 4); let led1 = Pin::new(Port1, 18, GPIO, Some(Out)); let led2 = Pin::new(Port1, 20, GPIO, Some(Out)); loop { run(&pt::run_args { led1: &led1, led2: &led2, timer: &timer }); } }
pub unsafe fn main() { init_stack();
init_data(); system_clock::init_clock(&Clock { source: system_clock::Main(12000000), pll: Some(PLL0 { m: 50, n: 3, divisor: 4 }) }); let timer = Timer::new(Timer1, 25, 4); let led1 = Pin::new(Port1, 18, GPIO, Some(Out)); let led2 = Pin::new(Port1, 20, GPIO, Some(Out)); loop { run(&pt::run_args { led1: &led1, led2: &led2, timer: &timer }); } }
pub unsafe fn main() { init_stack();
init_data(); system_clock::init_clock(&Clock { source: system_clock::Main(12000000), pll: Some(PLL0 { m: 50, n: 3, divisor: 4 }) }); let timer = Timer::new(Timer1, 25, 4); let led1 = Pin::new(Port1, 18, GPIO, Some(Out)); let led2 = Pin::new(Port1, 20, GPIO, Some(Out)); loop { run(&pt::run_args { led1: &led1, led2: &led2, timer: &timer }); } }
pub unsafe fn main() { init_stack();
init_data(); system_clock::init_clock(&Clock { source: system_clock::Main(12000000), pll: Some(PLL0 { m: 50, n: 3, divisor: 4 }) }); let timer = Timer::new(Timer1, 25, 4); let led1 = Pin::new(Port1, 18, GPIO, Some(Out)); let led2 = Pin::new(Port1, 20, GPIO, Some(Out)); loop { run(&pt::run_args { led1: &led1, led2: &led2, timer: &timer }); } }
pub unsafe fn main() { init_stack();
init_data(); system_clock::init_clock(&Clock { source: system_clock::Main(12000000), pll: Some(PLL0 { m: 50, n: 3, divisor: 4 }) }); let timer = Timer::new(Timer1, 25, 4); let led1 = Pin::new(Port1, 18, GPIO, Some(Out)); let led2 = Pin::new(Port1, 20, GPIO, Some(Out)); loop { run(&pt::run_args { led1: &led1, led2: &led2, timer: &timer }); } }
pub unsafe fn main() { init_stack();
init_data(); system_clock::init_clock(&Clock { source: system_clock::Main(12000000), pll: Some(PLL0 { m: 50, n: 3, divisor: 4 }) }); let timer = Timer::new(Timer1, 25, 4); let led1 = Pin::new(Port1, 18, GPIO, Some(Out)); let led2 = Pin::new(Port1, 20, GPIO, Some(Out)); loop { run(&pt::run_args { led1: &led1, led2: &led2, timer: &timer }); } }
pub unsafe fn main() { init_stack();
init_data(); system_clock::init_clock(&Clock { source: system_clock::Main(12000000), pll: Some(PLL0 { m: 50, n: 3, divisor: 4 }) }); let timer = Timer::new(Timer1, 25, 4); let led1 = Pin::new(Port1, 18, GPIO, Some(Out)); let led2 = Pin::new(Port1, 20, GPIO, Some(Out)); loop { run(&pt::run_args { led1: &led1, led2: &led2, timer: &timer }); } }
pub unsafe fn main() { init_stack();
init_data(); system_clock::init_clock(&Clock { source: system_clock::Main(12000000), pll: Some(PLL0 { m: 50, n: 3, divisor: 4 }) }); let timer = Timer::new(Timer1, 25, 4); let led1 = Pin::new(Port1, 18, GPIO, Some(Out)); let led2 = Pin::new(Port1, 20, GPIO, Some(Out)); loop { run(&pt::run_args { led1: &led1, led2: &led2, timer: &timer }); } }
fn run(args: &pt::run_args) { args.led1.set_high(); args.led2.set_low();
args.timer.wait(1); ! args.led1.set_low(); args.led2.set_high(); args.timer.wait(1); }
fn run(args: &pt::run_args) { args.led1.set_high(); args.led2.set_low();
args.timer.wait(1); ! args.led1.set_low(); args.led2.set_high(); args.timer.wait(1); } WHAT IF I SAY THIS IS THE ONLY CODE YOU NEED?
platform definition and verification in code
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; } } ! gpio { 1 { led1@18 { direction = "out"; } led2@20 { direction = "out"; } } } } ! os { single_task { loop = "run"; args { timer = &timer; led1 = &led1; led2 = &led2; } } }
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; } } ! gpio { 1 { led1@18 { direction = "out"; } led2@20 { direction = "out"; } } } } ! os { single_task { loop = "run"; args { timer = &timer; led1 = &led1; led2 = &led2; } } }
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; } } ! gpio { 1 { led1@18 { direction = "out"; } led2@20 { direction = "out"; } } } } ! os { single_task { loop = "run"; args { timer = &timer; led1 = &led1; led2 = &led2; } } }
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; } } ! gpio { 1 { led1@18 { direction = "out"; } led2@20 { direction = "out"; } } } } ! os { single_task { loop = "run"; args { timer = &timer; led1 = &led1; led2 = &led2; } } }
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; } } ! gpio { 1 { led1@18 { direction = "out"; } led2@20 { direction = "out"; } } } } ! os { single_task { loop = "run"; args { timer = &timer; led1 = &led1; led2 = &led2; } } }
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; } } ! gpio { 1 { led1@18 { direction = "out"; } led2@20 { direction = "out"; } } } } ! os { single_task { loop = "run"; args { timer = &timer; led1 = &led1; led2 = &led2; } } }
compile-time validation
example: configure SPI pin
None
Pin::new(Port1, 11, Function3, Some(Out)); X
spi_ck@11 { function = "sck"; }
spi_ck@11 { function = "sck"; }
hiding complexity from user
single_task { loop = "run";
args { timer = &timer; uart = &uart; dht = &dht; } } } ! pub struct run_args<'a, P, Q> { pub dht: &'a zinc::drivers::dht22::DHT22<'a, P, Q>, pub timer: &'a zinc::hal::lpc17xx::timer::Timer, pub uart: &'a zinc::hal::lpc17xx::uart::UART, }
#[zinc_task] fn run(args: &pt::run_args) {
... }
#[zinc_task] fn run(args: &pt::run_args) {
... }
fn run<P: zinc::hal::timer::Timer,
Q: zinc::hal::pin::GPIO>(args: &pt::run_args<P, Q>) { ... }
thanks! questions? http://vfp.in/zinc-london