diff --git a/STM32G431CBTx_FLASH.ld b/STM32G431CBTx_FLASH.ld
deleted file mode 100644
index 9eae2bf..0000000
--- a/STM32G431CBTx_FLASH.ld
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
-******************************************************************************
-**
-
-** File : LinkerScript.ld
-**
-** Author : STM32CubeMX
-**
-** Abstract : Linker script for STM32G431CBTx series
-** 112Kbytes FLASH and 32Kbytes RAM
-**
-** Set heap size, stack size and stack location according
-** to application requirements.
-**
-** Set memory bank area and size if external memory is used.
-**
-** Target : STMicroelectronics STM32
-**
-** Distribution: The file is distributed “as is,” without any warranty
-** of any kind.
-**
-*****************************************************************************
-** @attention
-**
-**
© COPYRIGHT(c) 2019 STMicroelectronics
-**
-** Redistribution and use in source and binary forms, with or without modification,
-** are permitted provided that the following conditions are met:
-** 1. Redistributions of source code must retain the above copyright notice,
-** this list of conditions and the following disclaimer.
-** 2. Redistributions in binary form must reproduce the above copyright notice,
-** this list of conditions and the following disclaimer in the documentation
-** and/or other materials provided with the distribution.
-** 3. Neither the name of STMicroelectronics nor the names of its contributors
-** may be used to endorse or promote products derived from this software
-** without specific prior written permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-**
-*****************************************************************************
-*/
-
-/* Entry Point */
-ENTRY(Reset_Handler)
-
-/* Generate a link error if heap and stack don't fit into RAM */
-_Min_Heap_Size = 0x200; /* required amount of heap */
-_Min_Stack_Size = 0x400; /* required amount of stack */
-
-/* Specify the memory areas */
-MEMORY
-{
-RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
-FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 112K
-}
-
-/* _estack = ORIGIN(RAM) + LENGTH(RAM); */
-_estack = 0x20008000;
-
-
-
-/* Highest address of the user mode stack */
-
-
-/* Define output sections */
-SECTIONS
-{
- /* The startup code goes first into FLASH */
- .isr_vector :
- {
- . = ALIGN(4);
- KEEP(*(.isr_vector)) /* Startup code */
- . = ALIGN(4);
- } >FLASH
-
- /* The program code and other data goes into FLASH */
- .text :
- {
- . = ALIGN(4);
- *(.text) /* .text sections (code) */
- *(.text*) /* .text* sections (code) */
- *(.glue_7) /* glue arm to thumb code */
- *(.glue_7t) /* glue thumb to arm code */
- *(.eh_frame)
-
- KEEP (*(.init))
- KEEP (*(.fini))
-
- . = ALIGN(4);
- _etext = .; /* define a global symbols at end of code */
- } >FLASH
-
- /* Constant data goes into FLASH */
- .rodata :
- {
- . = ALIGN(4);
- *(.rodata) /* .rodata sections (constants, strings, etc.) */
- *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
- . = ALIGN(4);
- } >FLASH
-
- /* used by the startup to initialize data */
- _sidata = LOADADDR(.data);
-
- /* Initialized data sections goes into RAM, load LMA copy after code */
- .data :
- {
- . = ALIGN(4);
- _sdata = .; /* create a global symbol at data start */
- *(.data) /* .data sections */
- *(.data*) /* .data* sections */
-
- . = ALIGN(4);
- _edata = .; /* define a global symbol at data end */
- } >RAM AT> FLASH
-
-
- /* Uninitialized data section */
- . = ALIGN(4);
- .bss :
- {
- /* This is used by the startup in order to initialize the .bss secion */
- _sbss = .; /* define a global symbol at bss start */
- __bss_start__ = _sbss;
- *(.bss)
- *(.bss*)
- *(COMMON)
-
- . = ALIGN(4);
- _ebss = .; /* define a global symbol at bss end */
- __bss_end__ = _ebss;
- } >RAM
-
- /* User_heap_stack section, used to check that there is enough RAM left */
- ._user_heap_stack :
- {
- . = ALIGN(8);
- PROVIDE ( end = . );
- PROVIDE ( _end = . );
- . = . + _Min_Heap_Size;
- . = . + _Min_Stack_Size;
- . = ALIGN(8);
- } >RAM
-
-
-
- /* Remove information from the standard libraries */
- /DISCARD/ :
- {
- libc.a ( * )
- libm.a ( * )
- libgcc.a ( * )
- }
-
- .ARM.attributes 0 : { *(.ARM.attributes) }
-}
diff --git a/build.zig b/build.zig
index f18b4c6..e03f51c 100644
--- a/build.zig
+++ b/build.zig
@@ -4,6 +4,7 @@ pub fn build(b: *std.Build) void {
const optimize = b.standardOptimizeOption(.{
.preferred_optimize_mode = .ReleaseSmall,
});
+
const target = b.resolveTargetQuery(.{
.cpu_arch = .thumb,
.cpu_model = .{
@@ -13,26 +14,54 @@ pub fn build(b: *std.Build) void {
.abi = .eabihf,
});
- // const mod = b.addModule("zig_stm32g4_test", .{
- // .root_source_file = b.path("src/root.zig"),
- // .target = target,
- // });
+ const main_mod = b.addModule("Main", .{
+ .root_source_file = b.path("src/main.zig"),
+ .target = target,
+ .optimize = optimize,
+ .link_libc = false,
+ .strip = false,
+ .single_threaded = true,
+ });
+
+ const mcu_mod = b.addModule("Mcu", .{
+ .root_source_file = b.path("src/microcontroller/mcu.zig"),
+ .target = target,
+ .optimize = optimize,
+ .link_libc = false,
+ .strip = false,
+ .single_threaded = true,
+ });
+
+ const stm32G4_mod = b.addModule("main", .{
+ .root_source_file = b.path("src/microcontroller/stm32g4/startup.zig"),
+ .target = target,
+ .optimize = optimize,
+ .link_libc = false,
+ .strip = false,
+ .single_threaded = true,
+ });
+
+ stm32G4_mod.addImport("Mcu", mcu_mod);
+ mcu_mod.addImport("Stm32g4", stm32G4_mod);
+ main_mod.addImport("Mcu", mcu_mod);
const exe = b.addExecutable(.{
.name = "zig_stm32g4_test",
- .root_module = b.createModule(.{
- .root_source_file = b.path("src/main.zig"),
- .target = target,
- .optimize = optimize,
- }),
+ .linkage = .static,
+ .use_lld = true,
+ .use_llvm = true,
+ .root_module = stm32G4_mod,
});
+
exe.dead_strip_dylibs = true;
exe.link_gc_sections = true;
exe.link_function_sections = true;
exe.link_data_sections = true;
- exe.lto = .full;
+ exe.lto = .none;
exe.discard_local_symbols = true;
+ exe.root_module.addImport("Main", main_mod);
+
const bin = exe.addObjCopy(.{ .format = .bin });
const install_exe = b.addInstallArtifact(exe, .{});
const install_bin = b.addInstallBinFile(bin.getOutput(), bin.basename);
@@ -42,9 +71,24 @@ pub fn build(b: *std.Build) void {
install_bin.step.dependOn(&install_exe.step);
b.installArtifact(exe);
- // const run_step = b.step("run", "Run the app");
+ const flash_run = b.addSystemCommand(&.{
+ "openocd",
+ "-f",
+ "/usr/share/openocd/scripts/board/st_nucleo_g4.cfg",
+ "-c",
+ "init",
+ "-c",
+ "reset halt; flash write_image erase zig-out/bin/zig_stm32g4_test.bin 0x08000000 bin",
+ "-c",
+ "flash verify_image zig-out/bin/zig_stm32g4_test.bin 0x08000000 bin",
+ "-c",
+ "reset run; shutdown",
+ });
+ const flash_step = b.step("flash", "Flash the code to the target");
+
+ flash_run.step.dependOn(&install_bin.step);
+ flash_step.dependOn(&flash_run.step);
- // const run_cmd = b.addRunArtifact(exe);
// run_step.dependOn(&run_cmd.step);
// run_cmd.step.dependOn(b.getInstallStep());
diff --git a/src/main.zig b/src/main.zig
index b942150..01b1214 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -1,59 +1,21 @@
-const std = @import("std");
-const Io = std.Io;
+const Mcu = @import("Mcu").Mcu;
-export fn resetHandler() callconv(.c) void {
- _start();
-}
+pub fn main(mcu: Mcu) !void {
+ _ = mcu;
-export fn _start() void {
-
-
- // const io = std.Io{
- // .vtable
- // };
-
-
- try main(undefined);
-
-
+ Mcu.peripherals.RCC.RCC_AHB2ENR.write(.{ .GPIOAEN = .B_0x1 });
+ Mcu.peripherals.GPIOA.MODER.write(.{ .MODER5 = 0b01 });
+ Mcu.peripherals.GPIOA.ODR.write(.{ .ODR5 = 1 });
+ var toggle: u1 = 1;
while (true) {
- asm volatile ("nop");
+ for (0..1000000) |_| {
+ asm volatile ("nop");
+ }
+
+ Mcu.peripherals.GPIOA.ODR.write(.{ .ODR5 = toggle });
+ if (toggle == 1) toggle = 0 else toggle = 1;
}
}
-
-pub fn main(init: std.process.Init) !void {
- _ = init;
- asm volatile ("nop");
-}
-
-export fn nmiHandler() callconv(.c) void {}
-export fn hardFaultHandler() callconv(.c) void {}
-export fn memManageHandler() callconv(.c) void {}
-export fn busFaultHandler() callconv(.c) void {}
-export fn usageFaultHandler() callconv(.c) void {}
-export fn svCallHandler() callconv(.c) void {}
-export fn debugMonitorHandler() callconv(.c) void {}
-export fn pendSvHandler() callconv(.c) void {}
-export fn sysTickHandler() callconv(.c) void {}
-
-export const vectors linksection(".vectors") = [_]?*const fn () callconv(.c) void{
- resetHandler,
- nmiHandler,
- hardFaultHandler,
- memManageHandler,
- busFaultHandler,
- usageFaultHandler,
- null, // reserved
- null, // reserved
- null, // reserved
- null, // reserved
- svCallHandler,
- debugMonitorHandler,
- null, // reserved
- pendSvHandler,
- sysTickHandler,
- // -- snip: continued for MCU-specific interrupts; consult datasheet
-};
diff --git a/src/microcontroller/mcu.zig b/src/microcontroller/mcu.zig
new file mode 100644
index 0000000..1d9576e
--- /dev/null
+++ b/src/microcontroller/mcu.zig
@@ -0,0 +1,6 @@
+const stm32g4 = @import("Stm32g4");
+
+pub const Mcu = struct {
+ pub const peripherals = stm32g4.stm32g4.peripherals;
+ isr_vectors: *stm32g4.VectorTable,
+};
diff --git a/src/stm32g4/STM32G431.zig b/src/microcontroller/stm32g4/STM32G431.zig
similarity index 98%
rename from src/stm32g4/STM32G431.zig
rename to src/microcontroller/stm32g4/STM32G431.zig
index 1b4a89f..31f1827 100644
--- a/src/stm32g4/STM32G431.zig
+++ b/src/microcontroller/stm32g4/STM32G431.zig
@@ -1,6 +1,6 @@
//! Description for STM32G431
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("mmio.zig").mmio;
+const InterruptHandle = @import("interrupt.zig").InterruptHandle;
pub const types = @import("types.zig");
@@ -124,10 +124,9 @@ pub const interrupts: []const Interrupt = &.{
};
pub const VectorTable = extern struct {
- const Handler = microzig.interrupt.Handler;
- const unhandled = microzig.interrupt.unhandled;
+ const Handler = InterruptHandle;
+ const unhandled = InterruptHandle.unhandled;
- initial_stack_pointer: *const anyopaque,
Reset: Handler,
NMI: Handler = unhandled,
HardFault: Handler = unhandled,
diff --git a/src/microcontroller/stm32g4/interrupt.zig b/src/microcontroller/stm32g4/interrupt.zig
new file mode 100644
index 0000000..83b3b02
--- /dev/null
+++ b/src/microcontroller/stm32g4/interrupt.zig
@@ -0,0 +1,9 @@
+fn unhandledInterrupt() callconv(.c) void {}
+
+pub const InterruptHandle = extern struct {
+ func: *const fn () callconv(.c) void,
+
+ pub const unhandled = InterruptHandle{
+ .func = &unhandledInterrupt,
+ };
+};
diff --git a/src/microcontroller/stm32g4/mmio.zig b/src/microcontroller/stm32g4/mmio.zig
new file mode 100644
index 0000000..88a2a49
--- /dev/null
+++ b/src/microcontroller/stm32g4/mmio.zig
@@ -0,0 +1,100 @@
+//! yoniked https://github.com/ZigEmbeddedGroup/microzig/blob/main/core/src/mmio.zig
+//!
+
+const std = @import("std");
+const assert = std.debug.assert;
+
+pub fn Mmio(comptime Packed: type) type {
+ @setEvalBranchQuota(2_000);
+
+ const size = @bitSizeOf(Packed);
+ if ((size % 8) != 0)
+ @compileError("size must be divisible by 8!");
+
+ if (!std.math.isPowerOfTwo(size / 8))
+ @compileError("size must encode a power of two number of bytes!");
+
+ const Int = @Int(.unsigned, size);
+
+ if (@sizeOf(Packed) != (size / 8))
+ @compileError(std.fmt.comptimePrint("Int and Packed must have the same size!, they are {} and {} bytes respectively", .{ size / 8, @sizeOf(Packed) }));
+
+ return packed struct(Int) {
+ const Self = @This();
+
+ raw: Int,
+
+ pub const underlying_type = Packed;
+
+ pub inline fn read(addr: *volatile Self) Packed {
+ return @bitCast(addr.raw);
+ }
+
+ pub inline fn write(addr: *volatile Self, val: Packed) void {
+ comptime {
+ assert(@bitSizeOf(Packed) == @bitSizeOf(Int));
+ }
+ addr.writeRaw(@bitCast(val));
+ }
+
+ pub inline fn writeRaw(addr: *volatile Self, val: Int) void {
+ addr.raw = val;
+ }
+
+ /// Set field `field_name` of this register to `value`.
+ /// A one-field version of modify(), more helpful if `field_name` is comptime calculated.
+ pub inline fn modifyOne(addr: *volatile Self, comptime field_name: []const u8, value: @FieldType(underlying_type, field_name)) void {
+ var val = read(addr);
+ @field(val, field_name) = value;
+ write(addr, val);
+ }
+
+ /// For each `.Field = value` entry of `fields`:
+ /// Set field `Field` of this register to `value`.
+ pub inline fn modify(addr: *volatile Self, fields: anytype) void {
+ var val = read(addr);
+ inline for (@typeInfo(@TypeOf(fields)).@"struct".field_names) |field_name| {
+ @field(val, field_name) = @field(fields, field_name);
+ }
+ write(addr, val);
+ }
+
+ /// In field `field_name` of struct `val`, toggle (only) all bits that are set in `value`.
+ inline fn toggleField(val: anytype, comptime field_name: []const u8, value: anytype) void {
+ const FieldType = @TypeOf(@field(val, field_name));
+ switch (@typeInfo(FieldType)) {
+ .int => {
+ @field(val, field_name) = @field(val, field_name) ^ value;
+ },
+ .@"enum" => |enum_info| {
+ // same as for the .Int case, but casting to and from the u... tag type U of the enum FieldType
+ const U = enum_info.tag_type;
+ @field(val, field_name) =
+ @as(FieldType, @enumFromInt(@as(U, @intFromEnum(@field(val, field_name))) ^
+ @as(U, @intFromEnum(@as(FieldType, value)))));
+ },
+ else => |T| {
+ @compileError("unsupported register field type '" ++ @typeName(T) ++ "'");
+ },
+ }
+ }
+
+ /// In field `field_name` of this register, toggle (only) all bits that are set in `value`.
+ /// A one-field version of toggle(), more helpful if `field_name` is comptime calculated.
+ pub inline fn toggleOne(addr: *volatile Self, comptime field_name: []const u8, value: anytype) void {
+ var val = read(addr);
+ toggleField(&val, field_name, value);
+ write(addr, val);
+ }
+
+ /// For each `.Field = value` entry of `fields`:
+ /// In field `F` of this register, toggle (only) all bits that are set in `value`.
+ pub inline fn toggle(addr: *volatile Self, fields: anytype) void {
+ var val = read(addr);
+ inline for (@typeInfo(@TypeOf(fields)).@"struct".field_names) |field_name| {
+ toggleField(&val, field_name, @field(fields, field_name));
+ }
+ write(addr, val);
+ }
+ };
+}
diff --git a/src/microcontroller/stm32g4/startup.zig b/src/microcontroller/stm32g4/startup.zig
new file mode 100644
index 0000000..7d1564c
--- /dev/null
+++ b/src/microcontroller/stm32g4/startup.zig
@@ -0,0 +1,47 @@
+pub const VectorTable = @import("STM32G431.zig").VectorTable;
+pub const InterruptHandle = @import("interrupt.zig").InterruptHandle;
+pub const stm32g4 = @import("STM32G431.zig");
+
+const Mcu = @import("Mcu").Mcu;
+
+const main = @import("Main").main;
+
+export fn resetHandler() callconv(.c) void {
+ _start();
+}
+
+pub export var vectors linksection(".vectors") = VectorTable{
+ .Reset = InterruptHandle{ .func = &resetHandler },
+};
+
+extern var _szero: u32;
+extern var _ezero: u32;
+extern var _sdata: u32;
+extern var _edata: u32;
+extern var _ldata: u32;
+export fn _start() callconv(.c) void {
+ const szero: [*]u8 = @ptrCast(&_szero);
+ const sdata: [*]u8 = @ptrCast(&_sdata);
+ const ldata: [*]u8 = @ptrCast(&_ldata);
+
+ const bss_len = @intFromPtr(&_ezero) - @intFromPtr(&_szero);
+ if (bss_len > 0) {
+ @memset(szero[0..bss_len], 0);
+ }
+
+ const data_len = @intFromPtr(&_edata) - @intFromPtr(&_sdata);
+ if (data_len > 0) {
+ @memcpy(sdata[0..data_len], ldata[0..data_len]);
+ }
+
+ // @compileLog(@typeInfo(Mcu));
+ const mcu = Mcu{
+ .isr_vectors = &vectors,
+ };
+ main(mcu) catch {};
+
+ // put error code in here
+ while (true) {
+ asm volatile ("nop");
+ }
+}
diff --git a/src/stm32g4/types.zig b/src/microcontroller/stm32g4/types.zig
similarity index 100%
rename from src/stm32g4/types.zig
rename to src/microcontroller/stm32g4/types.zig
diff --git a/src/stm32g4/types/peripherals.zig b/src/microcontroller/stm32g4/types/peripherals.zig
similarity index 100%
rename from src/stm32g4/types/peripherals.zig
rename to src/microcontroller/stm32g4/types/peripherals.zig
diff --git a/src/stm32g4/types/peripherals/ADC1.zig b/src/microcontroller/stm32g4/types/peripherals/ADC1.zig
similarity index 99%
rename from src/stm32g4/types/peripherals/ADC1.zig
rename to src/microcontroller/stm32g4/types/peripherals/ADC1.zig
index 35dc473..86ed63b 100644
--- a/src/stm32g4/types/peripherals/ADC1.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/ADC1.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/ADC12_Common.zig b/src/microcontroller/stm32g4/types/peripherals/ADC12_Common.zig
similarity index 97%
rename from src/stm32g4/types/peripherals/ADC12_Common.zig
rename to src/microcontroller/stm32g4/types/peripherals/ADC12_Common.zig
index 79cfb40..bee4804 100644
--- a/src/stm32g4/types/peripherals/ADC12_Common.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/ADC12_Common.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/AES.zig b/src/microcontroller/stm32g4/types/peripherals/AES.zig
similarity index 98%
rename from src/stm32g4/types/peripherals/AES.zig
rename to src/microcontroller/stm32g4/types/peripherals/AES.zig
index 424383f..d51bd85 100644
--- a/src/stm32g4/types/peripherals/AES.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/AES.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/COMP.zig b/src/microcontroller/stm32g4/types/peripherals/COMP.zig
similarity index 97%
rename from src/stm32g4/types/peripherals/COMP.zig
rename to src/microcontroller/stm32g4/types/peripherals/COMP.zig
index 72f8e13..e4b5979 100644
--- a/src/stm32g4/types/peripherals/COMP.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/COMP.zig
@@ -1,6 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
-
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
/// Comparator control and status register
diff --git a/src/stm32g4/types/peripherals/CORDIC.zig b/src/microcontroller/stm32g4/types/peripherals/CORDIC.zig
similarity index 94%
rename from src/stm32g4/types/peripherals/CORDIC.zig
rename to src/microcontroller/stm32g4/types/peripherals/CORDIC.zig
index 3c6bbc4..cadcefb 100644
--- a/src/stm32g4/types/peripherals/CORDIC.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/CORDIC.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/CRC.zig b/src/microcontroller/stm32g4/types/peripherals/CRC.zig
similarity index 94%
rename from src/stm32g4/types/peripherals/CRC.zig
rename to src/microcontroller/stm32g4/types/peripherals/CRC.zig
index 214be8b..ab80030 100644
--- a/src/stm32g4/types/peripherals/CRC.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/CRC.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/CRS.zig b/src/microcontroller/stm32g4/types/peripherals/CRS.zig
similarity index 99%
rename from src/stm32g4/types/peripherals/CRS.zig
rename to src/microcontroller/stm32g4/types/peripherals/CRS.zig
index ae21564..5349bb1 100644
--- a/src/stm32g4/types/peripherals/CRS.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/CRS.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/DAC1.zig b/src/microcontroller/stm32g4/types/peripherals/DAC1.zig
similarity index 99%
rename from src/stm32g4/types/peripherals/DAC1.zig
rename to src/microcontroller/stm32g4/types/peripherals/DAC1.zig
index c672e59..cb19584 100644
--- a/src/stm32g4/types/peripherals/DAC1.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/DAC1.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/DBGMCU.zig b/src/microcontroller/stm32g4/types/peripherals/DBGMCU.zig
similarity index 98%
rename from src/stm32g4/types/peripherals/DBGMCU.zig
rename to src/microcontroller/stm32g4/types/peripherals/DBGMCU.zig
index 0d2568a..fa55e72 100644
--- a/src/stm32g4/types/peripherals/DBGMCU.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/DBGMCU.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/DMA1.zig b/src/microcontroller/stm32g4/types/peripherals/DMA1.zig
similarity index 99%
rename from src/stm32g4/types/peripherals/DMA1.zig
rename to src/microcontroller/stm32g4/types/peripherals/DMA1.zig
index 6c23cd0..a4b5d96 100644
--- a/src/stm32g4/types/peripherals/DMA1.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/DMA1.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/DMAMUX.zig b/src/microcontroller/stm32g4/types/peripherals/DMAMUX.zig
similarity index 99%
rename from src/stm32g4/types/peripherals/DMAMUX.zig
rename to src/microcontroller/stm32g4/types/peripherals/DMAMUX.zig
index e9e5eb8..5f5c368 100644
--- a/src/stm32g4/types/peripherals/DMAMUX.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/DMAMUX.zig
@@ -1,6 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
-
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
/// DMAMUX
diff --git a/src/stm32g4/types/peripherals/EXTI.zig b/src/microcontroller/stm32g4/types/peripherals/EXTI.zig
similarity index 99%
rename from src/stm32g4/types/peripherals/EXTI.zig
rename to src/microcontroller/stm32g4/types/peripherals/EXTI.zig
index 433280a..649ee44 100644
--- a/src/stm32g4/types/peripherals/EXTI.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/EXTI.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/FDCAN.zig b/src/microcontroller/stm32g4/types/peripherals/FDCAN.zig
similarity index 99%
rename from src/stm32g4/types/peripherals/FDCAN.zig
rename to src/microcontroller/stm32g4/types/peripherals/FDCAN.zig
index 54f34db..4a03a01 100644
--- a/src/stm32g4/types/peripherals/FDCAN.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/FDCAN.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/FLASH.zig b/src/microcontroller/stm32g4/types/peripherals/FLASH.zig
similarity index 99%
rename from src/stm32g4/types/peripherals/FLASH.zig
rename to src/microcontroller/stm32g4/types/peripherals/FLASH.zig
index 7b95a41..746d76e 100644
--- a/src/stm32g4/types/peripherals/FLASH.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/FLASH.zig
@@ -1,6 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
-
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
/// Flash
diff --git a/src/stm32g4/types/peripherals/FMAC.zig b/src/microcontroller/stm32g4/types/peripherals/FMAC.zig
similarity index 97%
rename from src/stm32g4/types/peripherals/FMAC.zig
rename to src/microcontroller/stm32g4/types/peripherals/FMAC.zig
index 91718b9..3509803 100644
--- a/src/stm32g4/types/peripherals/FMAC.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/FMAC.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/GPIOA.zig b/src/microcontroller/stm32g4/types/peripherals/GPIOA.zig
similarity index 99%
rename from src/stm32g4/types/peripherals/GPIOA.zig
rename to src/microcontroller/stm32g4/types/peripherals/GPIOA.zig
index 68cdf73..cff4086 100644
--- a/src/stm32g4/types/peripherals/GPIOA.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/GPIOA.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/GPIOB.zig b/src/microcontroller/stm32g4/types/peripherals/GPIOB.zig
similarity index 99%
rename from src/stm32g4/types/peripherals/GPIOB.zig
rename to src/microcontroller/stm32g4/types/peripherals/GPIOB.zig
index 98c57b8..d09e2b4 100644
--- a/src/stm32g4/types/peripherals/GPIOB.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/GPIOB.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/GPIOC.zig b/src/microcontroller/stm32g4/types/peripherals/GPIOC.zig
similarity index 99%
rename from src/stm32g4/types/peripherals/GPIOC.zig
rename to src/microcontroller/stm32g4/types/peripherals/GPIOC.zig
index a00e7d4..01d4ec3 100644
--- a/src/stm32g4/types/peripherals/GPIOC.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/GPIOC.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/I2C1.zig b/src/microcontroller/stm32g4/types/peripherals/I2C1.zig
similarity index 98%
rename from src/stm32g4/types/peripherals/I2C1.zig
rename to src/microcontroller/stm32g4/types/peripherals/I2C1.zig
index e97f090..0f148de 100644
--- a/src/stm32g4/types/peripherals/I2C1.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/I2C1.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/IWDG.zig b/src/microcontroller/stm32g4/types/peripherals/IWDG.zig
similarity index 94%
rename from src/stm32g4/types/peripherals/IWDG.zig
rename to src/microcontroller/stm32g4/types/peripherals/IWDG.zig
index ba585ed..8b8cba5 100644
--- a/src/stm32g4/types/peripherals/IWDG.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/IWDG.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/LPTIM1.zig b/src/microcontroller/stm32g4/types/peripherals/LPTIM1.zig
similarity index 98%
rename from src/stm32g4/types/peripherals/LPTIM1.zig
rename to src/microcontroller/stm32g4/types/peripherals/LPTIM1.zig
index a6e63fe..f904bd9 100644
--- a/src/stm32g4/types/peripherals/LPTIM1.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/LPTIM1.zig
@@ -1,6 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
-
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
/// Low power timer
diff --git a/src/stm32g4/types/peripherals/LPUART1.zig b/src/microcontroller/stm32g4/types/peripherals/LPUART1.zig
similarity index 99%
rename from src/stm32g4/types/peripherals/LPUART1.zig
rename to src/microcontroller/stm32g4/types/peripherals/LPUART1.zig
index 59443e2..95af460 100644
--- a/src/stm32g4/types/peripherals/LPUART1.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/LPUART1.zig
@@ -1,6 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
-
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
/// Universal synchronous asynchronous receiver transmitter
diff --git a/src/stm32g4/types/peripherals/OPAMP.zig b/src/microcontroller/stm32g4/types/peripherals/OPAMP.zig
similarity index 99%
rename from src/stm32g4/types/peripherals/OPAMP.zig
rename to src/microcontroller/stm32g4/types/peripherals/OPAMP.zig
index 60b6705..937765d 100644
--- a/src/stm32g4/types/peripherals/OPAMP.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/OPAMP.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/PWR.zig b/src/microcontroller/stm32g4/types/peripherals/PWR.zig
similarity index 99%
rename from src/stm32g4/types/peripherals/PWR.zig
rename to src/microcontroller/stm32g4/types/peripherals/PWR.zig
index a787162..8b9fa99 100644
--- a/src/stm32g4/types/peripherals/PWR.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/PWR.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/RCC.zig b/src/microcontroller/stm32g4/types/peripherals/RCC.zig
similarity index 99%
rename from src/stm32g4/types/peripherals/RCC.zig
rename to src/microcontroller/stm32g4/types/peripherals/RCC.zig
index 1e41212..567fa87 100644
--- a/src/stm32g4/types/peripherals/RCC.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/RCC.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/RNG.zig b/src/microcontroller/stm32g4/types/peripherals/RNG.zig
similarity index 94%
rename from src/stm32g4/types/peripherals/RNG.zig
rename to src/microcontroller/stm32g4/types/peripherals/RNG.zig
index 2e7510b..e2f4533 100644
--- a/src/stm32g4/types/peripherals/RNG.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/RNG.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/RTC.zig b/src/microcontroller/stm32g4/types/peripherals/RTC.zig
similarity index 99%
rename from src/stm32g4/types/peripherals/RTC.zig
rename to src/microcontroller/stm32g4/types/peripherals/RTC.zig
index 8bb3e1f..d73c3d1 100644
--- a/src/stm32g4/types/peripherals/RTC.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/RTC.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/SAI.zig b/src/microcontroller/stm32g4/types/peripherals/SAI.zig
similarity index 99%
rename from src/stm32g4/types/peripherals/SAI.zig
rename to src/microcontroller/stm32g4/types/peripherals/SAI.zig
index 7e87293..f170f61 100644
--- a/src/stm32g4/types/peripherals/SAI.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/SAI.zig
@@ -1,6 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
-
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
/// Serial audio interface
diff --git a/src/stm32g4/types/peripherals/SPI1.zig b/src/microcontroller/stm32g4/types/peripherals/SPI1.zig
similarity index 98%
rename from src/stm32g4/types/peripherals/SPI1.zig
rename to src/microcontroller/stm32g4/types/peripherals/SPI1.zig
index 913c759..f0cc24e 100644
--- a/src/stm32g4/types/peripherals/SPI1.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/SPI1.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/SYSCFG.zig b/src/microcontroller/stm32g4/types/peripherals/SYSCFG.zig
similarity index 98%
rename from src/stm32g4/types/peripherals/SYSCFG.zig
rename to src/microcontroller/stm32g4/types/peripherals/SYSCFG.zig
index df1f86a..0f12426 100644
--- a/src/stm32g4/types/peripherals/SYSCFG.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/SYSCFG.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/TAMP.zig b/src/microcontroller/stm32g4/types/peripherals/TAMP.zig
similarity index 99%
rename from src/stm32g4/types/peripherals/TAMP.zig
rename to src/microcontroller/stm32g4/types/peripherals/TAMP.zig
index a1787af..9903e9d 100644
--- a/src/stm32g4/types/peripherals/TAMP.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/TAMP.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/TIM1.zig b/src/microcontroller/stm32g4/types/peripherals/TIM1.zig
similarity index 99%
rename from src/stm32g4/types/peripherals/TIM1.zig
rename to src/microcontroller/stm32g4/types/peripherals/TIM1.zig
index 36553c4..c15e187 100644
--- a/src/stm32g4/types/peripherals/TIM1.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/TIM1.zig
@@ -1,6 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
-
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
/// Advanced-timers
diff --git a/src/stm32g4/types/peripherals/TIM15.zig b/src/microcontroller/stm32g4/types/peripherals/TIM15.zig
similarity index 99%
rename from src/stm32g4/types/peripherals/TIM15.zig
rename to src/microcontroller/stm32g4/types/peripherals/TIM15.zig
index 57bd784..aed19fd 100644
--- a/src/stm32g4/types/peripherals/TIM15.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/TIM15.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/TIM16.zig b/src/microcontroller/stm32g4/types/peripherals/TIM16.zig
similarity index 99%
rename from src/stm32g4/types/peripherals/TIM16.zig
rename to src/microcontroller/stm32g4/types/peripherals/TIM16.zig
index 91c83f8..82727fe 100644
--- a/src/stm32g4/types/peripherals/TIM16.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/TIM16.zig
@@ -1,6 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
-
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
/// General purpose timers
diff --git a/src/stm32g4/types/peripherals/TIM2.zig b/src/microcontroller/stm32g4/types/peripherals/TIM2.zig
similarity index 99%
rename from src/stm32g4/types/peripherals/TIM2.zig
rename to src/microcontroller/stm32g4/types/peripherals/TIM2.zig
index 528d616..c650dc0 100644
--- a/src/stm32g4/types/peripherals/TIM2.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/TIM2.zig
@@ -1,6 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
-
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
/// Advanced-timers
diff --git a/src/stm32g4/types/peripherals/TIM3.zig b/src/microcontroller/stm32g4/types/peripherals/TIM3.zig
similarity index 99%
rename from src/stm32g4/types/peripherals/TIM3.zig
rename to src/microcontroller/stm32g4/types/peripherals/TIM3.zig
index 25fb87f..6c4b728 100644
--- a/src/stm32g4/types/peripherals/TIM3.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/TIM3.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/TIM6.zig b/src/microcontroller/stm32g4/types/peripherals/TIM6.zig
similarity index 98%
rename from src/stm32g4/types/peripherals/TIM6.zig
rename to src/microcontroller/stm32g4/types/peripherals/TIM6.zig
index e6d8bff..07a6135 100644
--- a/src/stm32g4/types/peripherals/TIM6.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/TIM6.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/UART4.zig b/src/microcontroller/stm32g4/types/peripherals/UART4.zig
similarity index 99%
rename from src/stm32g4/types/peripherals/UART4.zig
rename to src/microcontroller/stm32g4/types/peripherals/UART4.zig
index 55e0c31..bdc0816 100644
--- a/src/stm32g4/types/peripherals/UART4.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/UART4.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/UCPD1.zig b/src/microcontroller/stm32g4/types/peripherals/UCPD1.zig
similarity index 98%
rename from src/stm32g4/types/peripherals/UCPD1.zig
rename to src/microcontroller/stm32g4/types/peripherals/UCPD1.zig
index 15ccc34..3302640 100644
--- a/src/stm32g4/types/peripherals/UCPD1.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/UCPD1.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/USART1.zig b/src/microcontroller/stm32g4/types/peripherals/USART1.zig
similarity index 99%
rename from src/stm32g4/types/peripherals/USART1.zig
rename to src/microcontroller/stm32g4/types/peripherals/USART1.zig
index fc35108..4f3bd26 100644
--- a/src/stm32g4/types/peripherals/USART1.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/USART1.zig
@@ -1,6 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
-
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
/// Universal synchronous asynchronous receiver transmitter
diff --git a/src/stm32g4/types/peripherals/USB_FS_device.zig b/src/microcontroller/stm32g4/types/peripherals/USB_FS_device.zig
similarity index 99%
rename from src/stm32g4/types/peripherals/USB_FS_device.zig
rename to src/microcontroller/stm32g4/types/peripherals/USB_FS_device.zig
index ddbfa24..23fabe3 100644
--- a/src/stm32g4/types/peripherals/USB_FS_device.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/USB_FS_device.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/stm32g4/types/peripherals/VREFBUF.zig b/src/microcontroller/stm32g4/types/peripherals/VREFBUF.zig
similarity index 91%
rename from src/stm32g4/types/peripherals/VREFBUF.zig
rename to src/microcontroller/stm32g4/types/peripherals/VREFBUF.zig
index 341311e..5429bb9 100644
--- a/src/stm32g4/types/peripherals/VREFBUF.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/VREFBUF.zig
@@ -1,6 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
-
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
/// Voltage reference buffer
diff --git a/src/stm32g4/types/peripherals/WWDG.zig b/src/microcontroller/stm32g4/types/peripherals/WWDG.zig
similarity index 92%
rename from src/stm32g4/types/peripherals/WWDG.zig
rename to src/microcontroller/stm32g4/types/peripherals/WWDG.zig
index 7309d3e..afaefc4 100644
--- a/src/stm32g4/types/peripherals/WWDG.zig
+++ b/src/microcontroller/stm32g4/types/peripherals/WWDG.zig
@@ -1,5 +1,4 @@
-const microzig = @import("microzig");
-const mmio = microzig.mmio;
+const mmio = @import("../../mmio.zig");
const types = @import("../../types.zig");
diff --git a/src/root.zig b/src/root.zig
deleted file mode 100644
index 5be6f45..0000000
--- a/src/root.zig
+++ /dev/null
@@ -1,18 +0,0 @@
-// //! By convention, root.zig is the root source file when making a package.
-// const std = @import("std");
-// const Io = std.Io;
-
-// /// This is a documentation comment to explain the `printAnotherMessage` function below.
-// ///
-// /// Accepting an `Io.Writer` instance is a handy way to write reusable code.
-// pub fn printAnotherMessage(writer: *Io.Writer) Io.Writer.Error!void {
-// try writer.print("Run `zig build test` to run the tests.\n", .{});
-// }
-
-// pub fn add(a: i32, b: i32) i32 {
-// return a + b;
-// }
-
-// test "basic add functionality" {
-// try std.testing.expect(add(3, 7) == 10);
-// }
diff --git a/stm32g431cbtx.ld b/stm32g431cbtx.ld
index eff4bac..7bab74f 100644
--- a/stm32g431cbtx.ld
+++ b/stm32g431cbtx.ld
@@ -2,7 +2,6 @@ FLASH_SIZE = 0x1b580; /* 112k flash */
SRAM_SIZE = 0x8000; /* 32k sram */
STACK_SIZE = 0x400; /* 1k stack */
-
ENTRY(resetHandler)
MEMORY
@@ -33,7 +32,6 @@ SECTIONS
__initial_stack_pointer = .;
} > sram
-
.data :
{
_sdata = .;
@@ -41,7 +39,7 @@ SECTIONS
*(.data*)
. = ALIGN(4);
_edata = .;
- } > sram AT> flash
+ } > sram
_ldata = LOADADDR(.data);
diff --git a/using-microzig-regez-for-standalone-projects.md b/using-microzig-regez-for-standalone-projects.md
new file mode 100644
index 0000000..e69de29