const cpu = @import("cpu.zig"); const gpio = @import("gpio.zig"); const interrupt = @import("interrupt.zig"); const timer = @import("timer.zig"); const rcc: *[39]u32 = @ptrFromInt(0x40021000); const gpioa = gpio.gpioa; const gpioc = gpio.gpioc; export fn _start() callconv(.C) noreturn { cpu.interrupt_disable(); interrupt.initialize(); interrupt.register(.SVCall, svcall); timer.initialize(1000); cpu.interrupt_enable(); rcc[19] |= 5; // gpio a and c gpioa.set_mode(5, .output); gpioc.set_mode(13, .input); while (true) { //asm volatile("svc 0"); gpioa.toggle(5); const next = timer.ticks() + 1000; while (timer.ticks() < next) { asm volatile("nop"); } } } fn svcall() void { const state = gpioc.read(13); gpioa.write(5, state); }