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
|
//! The floor: the smallest thing that can boot on this chip and prove it is alive.
//! No printing, no descriptor text - just a pin that toggles. Build it with
//! zig build -Dapp=examples/minimal.zig size
const std = @import("std");
const config = @import("config");
const soc = @import("soc");
/// Even the floor needs a panic handler: the default one formats and would pull in half of std.
pub const panic = std.debug.FullPanic(struct {
fn call(_: []const u8, _: ?usize) noreturn {
while (true) {}
}
}.call);
const led: u6 = @intCast(config.led_pin);
export fn zig_main() noreturn {
soc.gpio.configureOutput(led, .{});
while (true) {
soc.gpio.setHigh(led);
soc.rom.ets_delay_us(100_000);
soc.gpio.setLow(led);
soc.rom.ets_delay_us(100_000);
}
}
export fn _start() linksection(".text.entry") callconv(.naked) noreturn {
asm volatile (
\\ li t0, 1 << 13
\\ csrs mstatus, t0
\\ la sp, __stack_top
\\ la t0, __bss_start
\\ la t1, __bss_end
\\ bgeu t0, t1, 2f
\\1:
\\ sw zero, 0(t0)
\\ addi t0, t0, 4
\\ bltu t0, t1, 1b
\\2:
\\ j zig_main
);
}
|