diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml deleted file mode 100644 index 24d9646..0000000 --- a/.buildkite/pipeline.yml +++ /dev/null @@ -1,4 +0,0 @@ -steps: - - group: Build - steps: - - command: zig build -Doptimize=ReleaseSmall diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..63ea533 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,19 @@ +name: Build +on: + push: + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + optimize: [Debug, ReleaseSmall, ReleaseFast, ReleaseSafe] + steps: + - uses: actions/checkout@v2 + - uses: goto-bus-stop/setup-zig@v2.1.1 + with: + version: 0.11.0 + + - name: Build + run: zig build install "-Doptimize=${{matrix.optimize}}" diff --git a/.gitmodules b/.gitmodules index 32e895c..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "deps/microzig"] - path = deps/microzig - url = https://github.com/ZigEmbeddedGroup/microzig.git diff --git a/build.zig b/build.zig index 56ed4e5..dd84d30 100644 --- a/build.zig +++ b/build.zig @@ -1,5 +1,5 @@ const std = @import("std"); -const microzig = @import("deps/microzig/build.zig"); +const microzig = @import("microzig"); pub const boards = @import("src/boards.zig"); pub const chips = @import("src/chips.zig"); @@ -7,9 +7,6 @@ pub const chips = @import("src/chips.zig"); pub fn build(b: *std.build.Builder) void { const optimize = b.standardOptimizeOption(.{}); inline for (@typeInfo(boards).Struct.decls) |decl| { - if (!decl.is_pub) - continue; - const exe = microzig.addEmbeddedExecutable(b, .{ .name = @field(boards, decl.name).name ++ ".minimal", .source_file = .{ @@ -22,9 +19,6 @@ pub fn build(b: *std.build.Builder) void { } inline for (@typeInfo(chips).Struct.decls) |decl| { - if (!decl.is_pub) - continue; - const exe = microzig.addEmbeddedExecutable(b, .{ .name = @field(chips, decl.name).name ++ ".minimal", .source_file = .{ diff --git a/build.zig.zon b/build.zig.zon new file mode 100644 index 0000000..e8787ef --- /dev/null +++ b/build.zig.zon @@ -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", + }, + }, +} diff --git a/deps/microzig b/deps/microzig deleted file mode 160000 index 9392fe0..0000000 --- a/deps/microzig +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 9392fe0f7bddde26155c181ab80b70097b49c791 diff --git a/src/boards.zig b/src/boards.zig index 55fc220..0691ab5 100644 --- a/src/boards.zig +++ b/src/boards.zig @@ -1,5 +1,5 @@ const std = @import("std"); -const micro = @import("../deps/microzig/build.zig"); +const micro = @import("microzig"); const chips = @import("chips.zig"); fn root_dir() []const u8 { diff --git a/src/chips.zig b/src/chips.zig index cc7816b..a1c7d58 100644 --- a/src/chips.zig +++ b/src/chips.zig @@ -1,5 +1,5 @@ const std = @import("std"); -const micro = @import("../deps/microzig/build.zig"); +const micro = @import("microzig"); const Chip = micro.Chip; const MemoryRegion = micro.MemoryRegion; diff --git a/src/chips/ATmega328P.zig b/src/chips/ATmega328P.zig index 604b37f..6ea0410 100644 --- a/src/chips/ATmega328P.zig +++ b/src/chips/ATmega328P.zig @@ -67,39 +67,39 @@ pub const devices = struct { pub const peripherals = struct { /// Fuses - pub const FUSE = @intToPtr(*volatile types.peripherals.FUSE, 0x0); + pub const FUSE = @as(*volatile types.peripherals.FUSE, @ptrFromInt(0x0)); /// Lockbits - pub const LOCKBIT = @intToPtr(*volatile types.peripherals.LOCKBIT, 0x0); + pub const LOCKBIT = @as(*volatile types.peripherals.LOCKBIT, @ptrFromInt(0x0)); /// I/O Port - pub const PORTB = @intToPtr(*volatile types.peripherals.PORT.PORTB, 0x23); + pub const PORTB = @as(*volatile types.peripherals.PORT.PORTB, @ptrFromInt(0x23)); /// I/O Port - pub const PORTC = @intToPtr(*volatile types.peripherals.PORT.PORTC, 0x26); + pub const PORTC = @as(*volatile types.peripherals.PORT.PORTC, @ptrFromInt(0x26)); /// I/O Port - pub const PORTD = @intToPtr(*volatile types.peripherals.PORT.PORTD, 0x29); + pub const PORTD = @as(*volatile types.peripherals.PORT.PORTD, @ptrFromInt(0x29)); /// Timer/Counter, 8-bit - pub const TC0 = @intToPtr(*volatile types.peripherals.TC8.TC0, 0x35); + pub const TC0 = @as(*volatile types.peripherals.TC8.TC0, @ptrFromInt(0x35)); /// Timer/Counter, 16-bit - pub const TC1 = @intToPtr(*volatile types.peripherals.TC16.TC1, 0x36); + pub const TC1 = @as(*volatile types.peripherals.TC16.TC1, @ptrFromInt(0x36)); /// Timer/Counter, 8-bit Async - pub const TC2 = @intToPtr(*volatile types.peripherals.TC8_ASYNC.TC2, 0x37); + pub const TC2 = @as(*volatile types.peripherals.TC8_ASYNC.TC2, @ptrFromInt(0x37)); /// External Interrupts - pub const EXINT = @intToPtr(*volatile types.peripherals.EXINT, 0x3b); + pub const EXINT = @as(*volatile types.peripherals.EXINT, @ptrFromInt(0x3b)); /// CPU Registers - pub const CPU = @intToPtr(*volatile types.peripherals.CPU, 0x3e); + pub const CPU = @as(*volatile types.peripherals.CPU, @ptrFromInt(0x3e)); /// EEPROM - pub const EEPROM = @intToPtr(*volatile types.peripherals.EEPROM, 0x3f); + pub const EEPROM = @as(*volatile types.peripherals.EEPROM, @ptrFromInt(0x3f)); /// Serial Peripheral Interface - pub const SPI = @intToPtr(*volatile types.peripherals.SPI, 0x4c); + pub const SPI = @as(*volatile types.peripherals.SPI, @ptrFromInt(0x4c)); /// Analog Comparator - pub const AC = @intToPtr(*volatile types.peripherals.AC, 0x50); + pub const AC = @as(*volatile types.peripherals.AC, @ptrFromInt(0x50)); /// Watchdog Timer - pub const WDT = @intToPtr(*volatile types.peripherals.WDT, 0x60); + pub const WDT = @as(*volatile types.peripherals.WDT, @ptrFromInt(0x60)); /// Analog-to-Digital Converter - pub const ADC = @intToPtr(*volatile types.peripherals.ADC, 0x78); + pub const ADC = @as(*volatile types.peripherals.ADC, @ptrFromInt(0x78)); /// Two Wire Serial Interface - pub const TWI = @intToPtr(*volatile types.peripherals.TWI, 0xb8); + pub const TWI = @as(*volatile types.peripherals.TWI, @ptrFromInt(0xb8)); /// USART - pub const USART0 = @intToPtr(*volatile types.peripherals.USART.USART0, 0xc0); + pub const USART0 = @as(*volatile types.peripherals.USART.USART0, @ptrFromInt(0xc0)); }; }; }; diff --git a/src/hals/ATmega328P.zig b/src/hals/ATmega328P.zig index 6e4ef94..b74e6a9 100644 --- a/src/hals/ATmega328P.zig +++ b/src/hals/ATmega328P.zig @@ -34,14 +34,14 @@ pub const gpio = struct { fn regs(comptime desc: type) type { return struct { // io address - const pin_addr: u5 = 3 * @enumToInt(desc.port) + 0x00; - const dir_addr: u5 = 3 * @enumToInt(desc.port) + 0x01; - const port_addr: u5 = 3 * @enumToInt(desc.port) + 0x02; + const pin_addr: u5 = 3 * @intFromEnum(desc.port) + 0x00; + const dir_addr: u5 = 3 * @intFromEnum(desc.port) + 0x01; + const port_addr: u5 = 3 * @intFromEnum(desc.port) + 0x02; // ram mapping - const pin = @intToPtr(*volatile u8, 0x20 + @as(usize, pin_addr)); - const dir = @intToPtr(*volatile u8, 0x20 + @as(usize, dir_addr)); - const port = @intToPtr(*volatile u8, 0x20 + @as(usize, port_addr)); + const pin = @as(*volatile u8, @ptrFromInt(0x20 + @as(usize, pin_addr))); + const dir = @as(*volatile u8, @ptrFromInt(0x20 + @as(usize, dir_addr))); + const port = @as(*volatile u8, @ptrFromInt(0x20 + @as(usize, port_addr))); }; } @@ -147,7 +147,7 @@ pub fn Uart(comptime index: usize, comptime pins: micro.uart.Pins) type { USART0.UCSR0B.write(.{ .TXB80 = 0, // we don't care about these btw .RXB80 = 0, // we don't care about these btw - .UCSZ02 = @truncate(u1, (ucsz & 0x04) >> 2), + .UCSZ02 = @as(u1, @truncate((ucsz & 0x04) >> 2)), .TXEN0 = 1, .RXEN0 = 1, .UDRIE0 = 0, // no interrupts @@ -156,7 +156,7 @@ pub fn Uart(comptime index: usize, comptime pins: micro.uart.Pins) type { }); USART0.UCSR0C.write(.{ .UCPOL0 = 0, // async mode - .UCSZ0 = @truncate(u2, (ucsz & 0x03) >> 0), + .UCSZ0 = @as(u2, @truncate((ucsz & 0x03) >> 0)), .USBS0 = usbs, .UPM0 = upm, .UMSEL0 = umsel,