|
|
@ -3,8 +3,44 @@
|
|
|
|
//! is to delete this file and start with root.zig instead.
|
|
|
|
//! is to delete this file and start with root.zig instead.
|
|
|
|
//const std = @import("std");
|
|
|
|
//const std = @import("std");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const gpio = packed struct {
|
|
|
|
|
|
|
|
moder: u32,
|
|
|
|
|
|
|
|
otyper: u32,
|
|
|
|
|
|
|
|
ospeedr: u32,
|
|
|
|
|
|
|
|
pupdr: u32,
|
|
|
|
|
|
|
|
idr: u32,
|
|
|
|
|
|
|
|
odr: u32,
|
|
|
|
|
|
|
|
bsrr: u32,
|
|
|
|
|
|
|
|
lckr: u32,
|
|
|
|
|
|
|
|
afrl: u32,
|
|
|
|
|
|
|
|
afrh: u32,
|
|
|
|
|
|
|
|
brr: u32,
|
|
|
|
|
|
|
|
ascr: u32,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const cpu = struct {
|
|
|
|
|
|
|
|
pub fn interrupt_disable() void {
|
|
|
|
|
|
|
|
asm volatile("cpsid i");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn interrupt_enable() void {
|
|
|
|
|
|
|
|
asm volatile("cpsie i");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const gpioa: *gpio = @ptrFromInt(0x48000000);
|
|
|
|
|
|
|
|
const rcc: *[39]u32 = @ptrFromInt(0x40021000);
|
|
|
|
|
|
|
|
|
|
|
|
export fn _start() callconv(.C) noreturn {
|
|
|
|
export fn _start() callconv(.C) noreturn {
|
|
|
|
while (true) {}
|
|
|
|
cpu.interrupt_disable();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rcc[19] |= 1; // gpioaen
|
|
|
|
|
|
|
|
gpioa.moder &= ~@as(u32, 0x3 << (5 * 2));
|
|
|
|
|
|
|
|
gpioa.moder |= (1 << (5 * 2));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
|
|
|
|
gpioa.odr ^= (1 << 5);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export fn fault_handler() callconv(.C) void {
|
|
|
|
export fn fault_handler() callconv(.C) void {
|
|
|
|