forked from japaric/ufmt
-
Notifications
You must be signed in to change notification settings - Fork 2
/
struct.rs
70 lines (53 loc) · 1.43 KB
/
struct.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#![no_main]
#![no_std]
use core::sync::atomic::{AtomicI32, Ordering};
use common::W;
use cortex_m_rt::{entry, exception};
use ufmt::{derive::uDebug, uwrite};
#[derive(uDebug)]
struct Braces {}
#[derive(uDebug)]
struct Parens();
#[derive(uDebug)]
struct I32(i32);
#[derive(uDebug)]
struct Tuple(i32, i32);
#[derive(uDebug)]
struct Nested {
first: Pair,
second: Pair,
}
#[entry]
fn main() -> ! {
loop {
X.fetch_add(1, Ordering::Relaxed);
Y.fetch_add(1, Ordering::Relaxed);
}
}
#[derive(Clone, Copy, uDebug)]
struct Pair {
x: i32,
y: i32,
}
static X: AtomicI32 = AtomicI32::new(0);
static Y: AtomicI32 = AtomicI32::new(0);
#[exception]
fn PendSV() {
let x = X.load(Ordering::Relaxed);
let y = Y.load(Ordering::Relaxed);
uwrite!(&mut W, "{:?}", Braces {}).unwrap();
uwrite!(&mut W, "{:#?}", Braces {}).unwrap();
uwrite!(&mut W, "{:?}", Parens()).unwrap();
uwrite!(&mut W, "{:#?}", Parens()).unwrap();
uwrite!(&mut W, "{:?}", I32(x)).unwrap();
uwrite!(&mut W, "{:#?}", I32(x)).unwrap();
uwrite!(&mut W, "{:?}", Tuple(x, y)).unwrap();
uwrite!(&mut W, "{:#?}", Tuple(x, y)).unwrap();
let pair = Pair { x, y };
uwrite!(&mut W, "{:?}", pair).unwrap();
uwrite!(&mut W, "{:#?}", pair).unwrap();
let first = pair;
let second = pair;
uwrite!(&mut W, "{:?}", Nested { first, second }).unwrap();
uwrite!(&mut W, "{:#?}", Nested { first, second }).unwrap();
}