Update to zig-0.11.0 (#24)

Co-authored-by: Felix "xq" Queißner <git@random-projects.net>
wch-ch32v003
Felix Queißner 1 year ago committed by GitHub
parent f74311e785
commit 03a53c756c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,10 +1,10 @@
const std = @import("std"); const std = @import("std");
const microzig = @import("deps/microzig/build.zig"); const microzig = @import("microzig");
pub const chips = @import("src/chips.zig"); pub const chips = @import("src/chips.zig");
pub const cpus = @import("src/cpus.zig"); pub const cpus = @import("src/cpus.zig");
pub fn build(b: *std.build.Builder) void { pub fn build(b: *std.Build) void {
const optimize = b.standardOptimizeOption(.{}); const optimize = b.standardOptimizeOption(.{});
var exe = microzig.addEmbeddedExecutable(b, .{ var exe = microzig.addEmbeddedExecutable(b, .{
@ -15,5 +15,16 @@ pub fn build(b: *std.build.Builder) void {
.backing = .{ .chip = chips.esp32_c3 }, .backing = .{ .chip = chips.esp32_c3 },
.optimize = optimize, .optimize = optimize,
}); });
exe.installArtifact(b);
const fw_objcopy = b.addObjCopy(exe.inner.getEmittedBin(), .{
.format = .bin,
});
const fw_bin = fw_objcopy.getOutput();
const install_fw_bin = b.addInstallFile(fw_bin, "firmware/blinky.bin");
b.getInstallStep().dependOn(&install_fw_bin.step);
b.installArtifact(exe.inner);
} }

@ -0,0 +1,10 @@
.{
.name = "microzig-espressif-esp",
.version = "0.1.0",
.dependencies = .{
.microzig = .{
.url = "https://github.com/ZigEmbeddedGroup/microzig/archive/0b3be0a4cc7e6d45714cb09961efc771e364723c.tar.gz",
.hash = "1220ada6d01db7b3d0aa8642df89b1af9ee71b681438249e9a7efb2275fc4cf32152",
},
},
}

1
deps/microzig vendored

@ -1 +0,0 @@
Subproject commit 9392fe0f7bddde26155c181ab80b70097b49c791

@ -1,5 +1,5 @@
const std = @import("std"); const std = @import("std");
const microzig = @import("../deps/microzig/build.zig"); const microzig = @import("microzig");
const cpus = @import("cpus.zig"); const cpus = @import("cpus.zig");
fn root_dir() []const u8 { fn root_dir() []const u8 {

@ -33,77 +33,77 @@ pub const devices = struct {
pub const peripherals = struct { pub const peripherals = struct {
/// UART (Universal Asynchronous Receiver-Transmitter) Controller /// UART (Universal Asynchronous Receiver-Transmitter) Controller
pub const UART0 = @intToPtr(*volatile types.peripherals.UART0, 0x60000000); pub const UART0 = @as(*volatile types.peripherals.UART0, @ptrFromInt(0x60000000));
/// SPI (Serial Peripheral Interface) Controller /// SPI (Serial Peripheral Interface) Controller
pub const SPI1 = @intToPtr(*volatile types.peripherals.SPI1, 0x60002000); pub const SPI1 = @as(*volatile types.peripherals.SPI1, @ptrFromInt(0x60002000));
/// SPI (Serial Peripheral Interface) Controller /// SPI (Serial Peripheral Interface) Controller
pub const SPI0 = @intToPtr(*volatile types.peripherals.SPI0, 0x60003000); pub const SPI0 = @as(*volatile types.peripherals.SPI0, @ptrFromInt(0x60003000));
/// General Purpose Input/Output /// General Purpose Input/Output
pub const GPIO = @intToPtr(*volatile types.peripherals.GPIO, 0x60004000); pub const GPIO = @as(*volatile types.peripherals.GPIO, @ptrFromInt(0x60004000));
/// Sigma-Delta Modulation /// Sigma-Delta Modulation
pub const GPIOSD = @intToPtr(*volatile types.peripherals.GPIOSD, 0x60004f00); pub const GPIOSD = @as(*volatile types.peripherals.GPIOSD, @ptrFromInt(0x60004f00));
/// Real-Time Clock Control /// Real-Time Clock Control
pub const RTC_CNTL = @intToPtr(*volatile types.peripherals.RTC_CNTL, 0x60008000); pub const RTC_CNTL = @as(*volatile types.peripherals.RTC_CNTL, @ptrFromInt(0x60008000));
/// eFuse Controller /// eFuse Controller
pub const EFUSE = @intToPtr(*volatile types.peripherals.EFUSE, 0x60008800); pub const EFUSE = @as(*volatile types.peripherals.EFUSE, @ptrFromInt(0x60008800));
/// Input/Output Multiplexer /// Input/Output Multiplexer
pub const IO_MUX = @intToPtr(*volatile types.peripherals.IO_MUX, 0x60009000); pub const IO_MUX = @as(*volatile types.peripherals.IO_MUX, @ptrFromInt(0x60009000));
/// Universal Host Controller Interface /// Universal Host Controller Interface
pub const UHCI1 = @intToPtr(*volatile types.peripherals.UHCI0, 0x6000c000); pub const UHCI1 = @as(*volatile types.peripherals.UHCI0, @ptrFromInt(0x6000c000));
/// UART (Universal Asynchronous Receiver-Transmitter) Controller /// UART (Universal Asynchronous Receiver-Transmitter) Controller
pub const UART1 = @intToPtr(*volatile types.peripherals.UART0, 0x60010000); pub const UART1 = @as(*volatile types.peripherals.UART0, @ptrFromInt(0x60010000));
/// I2C (Inter-Integrated Circuit) Controller /// I2C (Inter-Integrated Circuit) Controller
pub const I2C0 = @intToPtr(*volatile types.peripherals.I2C0, 0x60013000); pub const I2C0 = @as(*volatile types.peripherals.I2C0, @ptrFromInt(0x60013000));
/// Universal Host Controller Interface /// Universal Host Controller Interface
pub const UHCI0 = @intToPtr(*volatile types.peripherals.UHCI0, 0x60014000); pub const UHCI0 = @as(*volatile types.peripherals.UHCI0, @ptrFromInt(0x60014000));
/// Remote Control Peripheral /// Remote Control Peripheral
pub const RMT = @intToPtr(*volatile types.peripherals.RMT, 0x60016000); pub const RMT = @as(*volatile types.peripherals.RMT, @ptrFromInt(0x60016000));
/// LED Control PWM (Pulse Width Modulation) /// LED Control PWM (Pulse Width Modulation)
pub const LEDC = @intToPtr(*volatile types.peripherals.LEDC, 0x60019000); pub const LEDC = @as(*volatile types.peripherals.LEDC, @ptrFromInt(0x60019000));
/// Timer Group /// Timer Group
pub const TIMG0 = @intToPtr(*volatile types.peripherals.TIMG0, 0x6001f000); pub const TIMG0 = @as(*volatile types.peripherals.TIMG0, @ptrFromInt(0x6001f000));
/// Timer Group /// Timer Group
pub const TIMG1 = @intToPtr(*volatile types.peripherals.TIMG0, 0x60020000); pub const TIMG1 = @as(*volatile types.peripherals.TIMG0, @ptrFromInt(0x60020000));
/// System Timer /// System Timer
pub const SYSTIMER = @intToPtr(*volatile types.peripherals.SYSTIMER, 0x60023000); pub const SYSTIMER = @as(*volatile types.peripherals.SYSTIMER, @ptrFromInt(0x60023000));
/// SPI (Serial Peripheral Interface) Controller /// SPI (Serial Peripheral Interface) Controller
pub const SPI2 = @intToPtr(*volatile types.peripherals.SPI2, 0x60024000); pub const SPI2 = @as(*volatile types.peripherals.SPI2, @ptrFromInt(0x60024000));
/// Advanced Peripheral Bus Controller /// Advanced Peripheral Bus Controller
pub const APB_CTRL = @intToPtr(*volatile types.peripherals.APB_CTRL, 0x60026000); pub const APB_CTRL = @as(*volatile types.peripherals.APB_CTRL, @ptrFromInt(0x60026000));
/// Hardware random number generator /// Hardware random number generator
pub const RNG = @intToPtr(*volatile types.peripherals.RNG, 0x60026000); pub const RNG = @as(*volatile types.peripherals.RNG, @ptrFromInt(0x60026000));
/// Two-Wire Automotive Interface /// Two-Wire Automotive Interface
pub const TWAI = @intToPtr(*volatile types.peripherals.TWAI, 0x6002b000); pub const TWAI = @as(*volatile types.peripherals.TWAI, @ptrFromInt(0x6002b000));
/// I2S (Inter-IC Sound) Controller /// I2S (Inter-IC Sound) Controller
pub const I2S = @intToPtr(*volatile types.peripherals.I2S, 0x6002d000); pub const I2S = @as(*volatile types.peripherals.I2S, @ptrFromInt(0x6002d000));
/// AES (Advanced Encryption Standard) Accelerator /// AES (Advanced Encryption Standard) Accelerator
pub const AES = @intToPtr(*volatile types.peripherals.AES, 0x6003a000); pub const AES = @as(*volatile types.peripherals.AES, @ptrFromInt(0x6003a000));
/// SHA (Secure Hash Algorithm) Accelerator /// SHA (Secure Hash Algorithm) Accelerator
pub const SHA = @intToPtr(*volatile types.peripherals.SHA, 0x6003b000); pub const SHA = @as(*volatile types.peripherals.SHA, @ptrFromInt(0x6003b000));
/// RSA (Rivest Shamir Adleman) Accelerator /// RSA (Rivest Shamir Adleman) Accelerator
pub const RSA = @intToPtr(*volatile types.peripherals.RSA, 0x6003c000); pub const RSA = @as(*volatile types.peripherals.RSA, @ptrFromInt(0x6003c000));
/// Digital Signature /// Digital Signature
pub const DS = @intToPtr(*volatile types.peripherals.DS, 0x6003d000); pub const DS = @as(*volatile types.peripherals.DS, @ptrFromInt(0x6003d000));
/// HMAC (Hash-based Message Authentication Code) Accelerator /// HMAC (Hash-based Message Authentication Code) Accelerator
pub const HMAC = @intToPtr(*volatile types.peripherals.HMAC, 0x6003e000); pub const HMAC = @as(*volatile types.peripherals.HMAC, @ptrFromInt(0x6003e000));
/// DMA (Direct Memory Access) Controller /// DMA (Direct Memory Access) Controller
pub const DMA = @intToPtr(*volatile types.peripherals.DMA, 0x6003f000); pub const DMA = @as(*volatile types.peripherals.DMA, @ptrFromInt(0x6003f000));
/// Successive Approximation Register Analog to Digital Converter /// Successive Approximation Register Analog to Digital Converter
pub const APB_SARADC = @intToPtr(*volatile types.peripherals.APB_SARADC, 0x60040000); pub const APB_SARADC = @as(*volatile types.peripherals.APB_SARADC, @ptrFromInt(0x60040000));
/// Full-speed USB Serial/JTAG Controller /// Full-speed USB Serial/JTAG Controller
pub const USB_DEVICE = @intToPtr(*volatile types.peripherals.USB_DEVICE, 0x60043000); pub const USB_DEVICE = @as(*volatile types.peripherals.USB_DEVICE, @ptrFromInt(0x60043000));
/// System /// System
pub const SYSTEM = @intToPtr(*volatile types.peripherals.SYSTEM, 0x600c0000); pub const SYSTEM = @as(*volatile types.peripherals.SYSTEM, @ptrFromInt(0x600c0000));
/// Sensitive /// Sensitive
pub const SENSITIVE = @intToPtr(*volatile types.peripherals.SENSITIVE, 0x600c1000); pub const SENSITIVE = @as(*volatile types.peripherals.SENSITIVE, @ptrFromInt(0x600c1000));
/// Interrupt Core /// Interrupt Core
pub const INTERRUPT_CORE0 = @intToPtr(*volatile types.peripherals.INTERRUPT_CORE0, 0x600c2000); pub const INTERRUPT_CORE0 = @as(*volatile types.peripherals.INTERRUPT_CORE0, @ptrFromInt(0x600c2000));
/// External Memory /// External Memory
pub const EXTMEM = @intToPtr(*volatile types.peripherals.EXTMEM, 0x600c4000); pub const EXTMEM = @as(*volatile types.peripherals.EXTMEM, @ptrFromInt(0x600c4000));
/// XTS-AES-128 Flash Encryption /// XTS-AES-128 Flash Encryption
pub const XTS_AES = @intToPtr(*volatile types.peripherals.XTS_AES, 0x600cc000); pub const XTS_AES = @as(*volatile types.peripherals.XTS_AES, @ptrFromInt(0x600cc000));
/// Debug Assist /// Debug Assist
pub const ASSIST_DEBUG = @intToPtr(*volatile types.peripherals.ASSIST_DEBUG, 0x600ce000); pub const ASSIST_DEBUG = @as(*volatile types.peripherals.ASSIST_DEBUG, @ptrFromInt(0x600ce000));
}; };
}; };
}; };

@ -1,5 +1,5 @@
const std = @import("std"); const std = @import("std");
const microzig = @import("../deps/microzig/build.zig"); const microzig = @import("microzig");
fn root_dir() []const u8 { fn root_dir() []const u8 {
return std.fs.path.dirname(@src().file) orelse unreachable; return std.fs.path.dirname(@src().file) orelse unreachable;

@ -61,7 +61,7 @@ pub const startup_logic = struct {
extern fn microzig_main() noreturn; extern fn microzig_main() noreturn;
export fn _start() linksection("microzig_flash_start") callconv(.Naked) noreturn { export fn _start() linksection("microzig_flash_start") callconv(.C) noreturn {
microzig.cpu.disable_interrupts(); microzig.cpu.disable_interrupts();
asm volatile ("mv sp, %[eos]" asm volatile ("mv sp, %[eos]"
: :

@ -42,13 +42,13 @@ pub fn main() !void {
while (true) { while (true) {
GPIO.OUT.modify(.{ .DATA_ORIG = (1 << LED_R_PIN) }); GPIO.OUT.modify(.{ .DATA_ORIG = (1 << LED_R_PIN) });
microzig.hal.uart.write(0, "R"); microzig.hal.uart.write(0, "R");
microzig.core.experimental.debug.busy_sleep(1_000_000); microzig.core.experimental.debug.busy_sleep(100_000);
GPIO.OUT.modify(.{ .DATA_ORIG = (1 << LED_G_PIN) }); GPIO.OUT.modify(.{ .DATA_ORIG = (1 << LED_G_PIN) });
microzig.hal.uart.write(0, "G"); microzig.hal.uart.write(0, "G");
microzig.core.experimental.debug.busy_sleep(1_000_000); microzig.core.experimental.debug.busy_sleep(100_000);
GPIO.OUT.modify(.{ .DATA_ORIG = (1 << LED_B_PIN) }); GPIO.OUT.modify(.{ .DATA_ORIG = (1 << LED_B_PIN) });
microzig.hal.uart.write(0, "B"); microzig.hal.uart.write(0, "B");
microzig.core.experimental.debug.busy_sleep(1_000_000); microzig.core.experimental.debug.busy_sleep(100_000);
} }
} }

@ -21,9 +21,9 @@ pub const gpio = struct {
assertRange(pin); assertRange(pin);
GPIO.FUNC_OUT_SEL_CFG[pin].modify(.{ GPIO.FUNC_OUT_SEL_CFG[pin].modify(.{
.OUT_SEL = config.function, .OUT_SEL = config.function,
.INV_SEL = @boolToInt(config.invert_function), .INV_SEL = @intFromBool(config.invert_function),
.OEN_SEL = @boolToInt(config.direct_io), .OEN_SEL = @intFromBool(config.direct_io),
.OEN_INV_SEL = @boolToInt(config.invert_direct_io), .OEN_INV_SEL = @intFromBool(config.invert_direct_io),
}); });
switch (config.direction) { switch (config.direction) {
.input => GPIO.ENABLE.raw &= ~(@as(u32, 1) << pin), .input => GPIO.ENABLE.raw &= ~(@as(u32, 1) << pin),

@ -1,8 +0,0 @@
//! This file is auto-generated by zpm-update and *should*
//! not be changed. This file can be checked into your VCS
//! and is able to work standalone.
const std = @import("std");
pub const sdks = struct {
pub const microzig = @import("vendor/microzig/src/main.zig");
};
Loading…
Cancel
Save