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 f0441139a6
commit 081683a451
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,4 +0,0 @@
steps:
- group: Build
steps:
- command: zig build -Doptimize=ReleaseSmall

@ -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}}"

3
.gitmodules vendored

@ -1,3 +0,0 @@
[submodule "deps/microzig"]
path = deps/microzig
url = https://github.com/ZigEmbeddedGroup/microzig.git

@ -1,5 +1,5 @@
const std = @import("std"); const std = @import("std");
const microzig = @import("deps/microzig/build.zig"); const microzig = @import("microzig");
pub const boards = @import("src/boards.zig"); pub const boards = @import("src/boards.zig");
pub const chips = @import("src/chips.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 { pub fn build(b: *std.build.Builder) void {
const optimize = b.standardOptimizeOption(.{}); const optimize = b.standardOptimizeOption(.{});
inline for (@typeInfo(boards).Struct.decls) |decl| { inline for (@typeInfo(boards).Struct.decls) |decl| {
if (!decl.is_pub)
continue;
const exe = microzig.addEmbeddedExecutable(b, .{ const exe = microzig.addEmbeddedExecutable(b, .{
.name = @field(boards, decl.name).name ++ ".minimal", .name = @field(boards, decl.name).name ++ ".minimal",
.source_file = .{ .source_file = .{
@ -22,9 +19,6 @@ pub fn build(b: *std.build.Builder) void {
} }
inline for (@typeInfo(chips).Struct.decls) |decl| { inline for (@typeInfo(chips).Struct.decls) |decl| {
if (!decl.is_pub)
continue;
const exe = microzig.addEmbeddedExecutable(b, .{ const exe = microzig.addEmbeddedExecutable(b, .{
.name = @field(chips, decl.name).name ++ ".minimal", .name = @field(chips, decl.name).name ++ ".minimal",
.source_file = .{ .source_file = .{

@ -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 micro = @import("../deps/microzig/build.zig"); const micro = @import("microzig");
const chips = @import("chips.zig"); const chips = @import("chips.zig");
fn root_dir() []const u8 { fn root_dir() []const u8 {

@ -1,5 +1,5 @@
const std = @import("std"); const std = @import("std");
const micro = @import("../deps/microzig/build.zig"); const micro = @import("microzig");
const Chip = micro.Chip; const Chip = micro.Chip;
const MemoryRegion = micro.MemoryRegion; const MemoryRegion = micro.MemoryRegion;

@ -67,39 +67,39 @@ pub const devices = struct {
pub const peripherals = struct { pub const peripherals = struct {
/// Fuses /// Fuses
pub const FUSE = @intToPtr(*volatile types.peripherals.FUSE, 0x0); pub const FUSE = @as(*volatile types.peripherals.FUSE, @ptrFromInt(0x0));
/// Lockbits /// Lockbits
pub const LOCKBIT = @intToPtr(*volatile types.peripherals.LOCKBIT, 0x0); pub const LOCKBIT = @as(*volatile types.peripherals.LOCKBIT, @ptrFromInt(0x0));
/// I/O Port /// 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 /// 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 /// 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 /// 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 /// 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 /// 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 /// External Interrupts
pub const EXINT = @intToPtr(*volatile types.peripherals.EXINT, 0x3b); pub const EXINT = @as(*volatile types.peripherals.EXINT, @ptrFromInt(0x3b));
/// CPU Registers /// CPU Registers
pub const CPU = @intToPtr(*volatile types.peripherals.CPU, 0x3e); pub const CPU = @as(*volatile types.peripherals.CPU, @ptrFromInt(0x3e));
/// EEPROM /// EEPROM
pub const EEPROM = @intToPtr(*volatile types.peripherals.EEPROM, 0x3f); pub const EEPROM = @as(*volatile types.peripherals.EEPROM, @ptrFromInt(0x3f));
/// Serial Peripheral Interface /// Serial Peripheral Interface
pub const SPI = @intToPtr(*volatile types.peripherals.SPI, 0x4c); pub const SPI = @as(*volatile types.peripherals.SPI, @ptrFromInt(0x4c));
/// Analog Comparator /// Analog Comparator
pub const AC = @intToPtr(*volatile types.peripherals.AC, 0x50); pub const AC = @as(*volatile types.peripherals.AC, @ptrFromInt(0x50));
/// Watchdog Timer /// 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 /// 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 /// Two Wire Serial Interface
pub const TWI = @intToPtr(*volatile types.peripherals.TWI, 0xb8); pub const TWI = @as(*volatile types.peripherals.TWI, @ptrFromInt(0xb8));
/// USART /// USART
pub const USART0 = @intToPtr(*volatile types.peripherals.USART.USART0, 0xc0); pub const USART0 = @as(*volatile types.peripherals.USART.USART0, @ptrFromInt(0xc0));
}; };
}; };
}; };

@ -34,14 +34,14 @@ pub const gpio = struct {
fn regs(comptime desc: type) type { fn regs(comptime desc: type) type {
return struct { return struct {
// io address // io address
const pin_addr: u5 = 3 * @enumToInt(desc.port) + 0x00; const pin_addr: u5 = 3 * @intFromEnum(desc.port) + 0x00;
const dir_addr: u5 = 3 * @enumToInt(desc.port) + 0x01; const dir_addr: u5 = 3 * @intFromEnum(desc.port) + 0x01;
const port_addr: u5 = 3 * @enumToInt(desc.port) + 0x02; const port_addr: u5 = 3 * @intFromEnum(desc.port) + 0x02;
// ram mapping // ram mapping
const pin = @intToPtr(*volatile u8, 0x20 + @as(usize, pin_addr)); const pin = @as(*volatile u8, @ptrFromInt(0x20 + @as(usize, pin_addr)));
const dir = @intToPtr(*volatile u8, 0x20 + @as(usize, dir_addr)); const dir = @as(*volatile u8, @ptrFromInt(0x20 + @as(usize, dir_addr)));
const port = @intToPtr(*volatile u8, 0x20 + @as(usize, port_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(.{ USART0.UCSR0B.write(.{
.TXB80 = 0, // we don't care about these btw .TXB80 = 0, // we don't care about these btw
.RXB80 = 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, .TXEN0 = 1,
.RXEN0 = 1, .RXEN0 = 1,
.UDRIE0 = 0, // no interrupts .UDRIE0 = 0, // no interrupts
@ -156,7 +156,7 @@ pub fn Uart(comptime index: usize, comptime pins: micro.uart.Pins) type {
}); });
USART0.UCSR0C.write(.{ USART0.UCSR0C.write(.{
.UCPOL0 = 0, // async mode .UCPOL0 = 0, // async mode
.UCSZ0 = @truncate(u2, (ucsz & 0x03) >> 0), .UCSZ0 = @as(u2, @truncate((ucsz & 0x03) >> 0)),
.USBS0 = usbs, .USBS0 = usbs,
.UPM0 = upm, .UPM0 = upm,
.UMSEL0 = umsel, .UMSEL0 = umsel,

Loading…
Cancel
Save