Something went wrong. Try again.
Baremetal Zig running on RP2350
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657pub const registers = @import("registers.zig");pub const resets = @import("resets.zig");pub const clocks = @import("clocks.zig");
// NOTE: Not entirely sure about thispub const Uart = @import("peripherals/uart.zig").Uart;pub const gpio = @import("peripherals/gpio.zig");
// NOTE: Not really happy with thispub const mmio = struct { pub inline fn write(address: u32, value: u32) void { MMIO(address).* = value; }
pub inline fn write_xor(address: u32, value: u32) void { MMIO(address + 0x1000).* = value; }
pub inline fn write_set(address: u32, value: u32) void { MMIO(address + 0x2000).* = value; }
pub inline fn write_clr(address: u32, value: u32) void { MMIO(address + 0x3000).* = value; }
pub inline fn read(address: u32) u32 { return MMIO(address).*; }};
inline fn MMIO(address: u32) *volatile u32 { return @ptrFromInt(address);}
// TODO: Do proper waitingpub fn dummy_wait(max_cycles: u32) void { var current_cycle: u32 = 0; while (current_cycle < max_cycles) : (current_cycle += 1) { asm volatile ("add zero, zero, zero"); }}
// TODO: mmio_wait* must be replaced with a better alternative!pub fn mmio_wait(address: u32, mask: u32, non_equal: bool, value: u32) void { while (switch (non_equal) { true => mmio.read(address) & mask != value, false => mmio.read(address) & mask == value, }) { asm volatile ("add zero, zero, zero"); }}
pub fn mmio_wait_status(address: u32, mask: u32, non_eq: bool) void { mmio_wait(address, mask, non_eq, 0);}