Skip to content
This repository was archived by the owner on Feb 17, 2024. It is now read-only.

Commit 081683a

Browse files
ikskuhFelix "xq" Queißner
andauthored
Update to zig-0.11.0 (#24)
Co-authored-by: Felix "xq" Queißner <git@random-projects.net>
1 parent f044113 commit 081683a

File tree

10 files changed

+57
-42
lines changed

10 files changed

+57
-42
lines changed

.buildkite/pipeline.yml

Lines changed: 0 additions & 4 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Build
2+
on:
3+
push:
4+
5+
jobs:
6+
build:
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
matrix:
10+
os: [ubuntu-latest, windows-latest, macos-latest]
11+
optimize: [Debug, ReleaseSmall, ReleaseFast, ReleaseSafe]
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: goto-bus-stop/setup-zig@v2.1.1
15+
with:
16+
version: 0.11.0
17+
18+
- name: Build
19+
run: zig build install "-Doptimize=${{matrix.optimize}}"

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
[submodule "deps/microzig"]
2-
path = deps/microzig
3-
url = https://github.com/ZigEmbeddedGroup/microzig.git

build.zig

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
const std = @import("std");
2-
const microzig = @import("deps/microzig/build.zig");
2+
const microzig = @import("microzig");
33

44
pub const boards = @import("src/boards.zig");
55
pub const chips = @import("src/chips.zig");
66

77
pub fn build(b: *std.build.Builder) void {
88
const optimize = b.standardOptimizeOption(.{});
99
inline for (@typeInfo(boards).Struct.decls) |decl| {
10-
if (!decl.is_pub)
11-
continue;
12-
1310
const exe = microzig.addEmbeddedExecutable(b, .{
1411
.name = @field(boards, decl.name).name ++ ".minimal",
1512
.source_file = .{
@@ -22,9 +19,6 @@ pub fn build(b: *std.build.Builder) void {
2219
}
2320

2421
inline for (@typeInfo(chips).Struct.decls) |decl| {
25-
if (!decl.is_pub)
26-
continue;
27-
2822
const exe = microzig.addEmbeddedExecutable(b, .{
2923
.name = @field(chips, decl.name).name ++ ".minimal",
3024
.source_file = .{

build.zig.zon

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.{
2+
.name = "microzig-espressif-esp",
3+
.version = "0.1.0",
4+
.dependencies = .{
5+
.microzig = .{
6+
.url = "https://github.com/ZigEmbeddedGroup/microzig/archive/0b3be0a4cc7e6d45714cb09961efc771e364723c.tar.gz",
7+
.hash = "1220ada6d01db7b3d0aa8642df89b1af9ee71b681438249e9a7efb2275fc4cf32152",
8+
},
9+
},
10+
}

deps/microzig

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/boards.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const std = @import("std");
2-
const micro = @import("../deps/microzig/build.zig");
2+
const micro = @import("microzig");
33
const chips = @import("chips.zig");
44

55
fn root_dir() []const u8 {

src/chips.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const std = @import("std");
2-
const micro = @import("../deps/microzig/build.zig");
2+
const micro = @import("microzig");
33
const Chip = micro.Chip;
44
const MemoryRegion = micro.MemoryRegion;
55

src/chips/ATmega328P.zig

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,39 +67,39 @@ pub const devices = struct {
6767

6868
pub const peripherals = struct {
6969
/// Fuses
70-
pub const FUSE = @intToPtr(*volatile types.peripherals.FUSE, 0x0);
70+
pub const FUSE = @as(*volatile types.peripherals.FUSE, @ptrFromInt(0x0));
7171
/// Lockbits
72-
pub const LOCKBIT = @intToPtr(*volatile types.peripherals.LOCKBIT, 0x0);
72+
pub const LOCKBIT = @as(*volatile types.peripherals.LOCKBIT, @ptrFromInt(0x0));
7373
/// I/O Port
74-
pub const PORTB = @intToPtr(*volatile types.peripherals.PORT.PORTB, 0x23);
74+
pub const PORTB = @as(*volatile types.peripherals.PORT.PORTB, @ptrFromInt(0x23));
7575
/// I/O Port
76-
pub const PORTC = @intToPtr(*volatile types.peripherals.PORT.PORTC, 0x26);
76+
pub const PORTC = @as(*volatile types.peripherals.PORT.PORTC, @ptrFromInt(0x26));
7777
/// I/O Port
78-
pub const PORTD = @intToPtr(*volatile types.peripherals.PORT.PORTD, 0x29);
78+
pub const PORTD = @as(*volatile types.peripherals.PORT.PORTD, @ptrFromInt(0x29));
7979
/// Timer/Counter, 8-bit
80-
pub const TC0 = @intToPtr(*volatile types.peripherals.TC8.TC0, 0x35);
80+
pub const TC0 = @as(*volatile types.peripherals.TC8.TC0, @ptrFromInt(0x35));
8181
/// Timer/Counter, 16-bit
82-
pub const TC1 = @intToPtr(*volatile types.peripherals.TC16.TC1, 0x36);
82+
pub const TC1 = @as(*volatile types.peripherals.TC16.TC1, @ptrFromInt(0x36));
8383
/// Timer/Counter, 8-bit Async
84-
pub const TC2 = @intToPtr(*volatile types.peripherals.TC8_ASYNC.TC2, 0x37);
84+
pub const TC2 = @as(*volatile types.peripherals.TC8_ASYNC.TC2, @ptrFromInt(0x37));
8585
/// External Interrupts
86-
pub const EXINT = @intToPtr(*volatile types.peripherals.EXINT, 0x3b);
86+
pub const EXINT = @as(*volatile types.peripherals.EXINT, @ptrFromInt(0x3b));
8787
/// CPU Registers
88-
pub const CPU = @intToPtr(*volatile types.peripherals.CPU, 0x3e);
88+
pub const CPU = @as(*volatile types.peripherals.CPU, @ptrFromInt(0x3e));
8989
/// EEPROM
90-
pub const EEPROM = @intToPtr(*volatile types.peripherals.EEPROM, 0x3f);
90+
pub const EEPROM = @as(*volatile types.peripherals.EEPROM, @ptrFromInt(0x3f));
9191
/// Serial Peripheral Interface
92-
pub const SPI = @intToPtr(*volatile types.peripherals.SPI, 0x4c);
92+
pub const SPI = @as(*volatile types.peripherals.SPI, @ptrFromInt(0x4c));
9393
/// Analog Comparator
94-
pub const AC = @intToPtr(*volatile types.peripherals.AC, 0x50);
94+
pub const AC = @as(*volatile types.peripherals.AC, @ptrFromInt(0x50));
9595
/// Watchdog Timer
96-
pub const WDT = @intToPtr(*volatile types.peripherals.WDT, 0x60);
96+
pub const WDT = @as(*volatile types.peripherals.WDT, @ptrFromInt(0x60));
9797
/// Analog-to-Digital Converter
98-
pub const ADC = @intToPtr(*volatile types.peripherals.ADC, 0x78);
98+
pub const ADC = @as(*volatile types.peripherals.ADC, @ptrFromInt(0x78));
9999
/// Two Wire Serial Interface
100-
pub const TWI = @intToPtr(*volatile types.peripherals.TWI, 0xb8);
100+
pub const TWI = @as(*volatile types.peripherals.TWI, @ptrFromInt(0xb8));
101101
/// USART
102-
pub const USART0 = @intToPtr(*volatile types.peripherals.USART.USART0, 0xc0);
102+
pub const USART0 = @as(*volatile types.peripherals.USART.USART0, @ptrFromInt(0xc0));
103103
};
104104
};
105105
};

src/hals/ATmega328P.zig

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ pub const gpio = struct {
3434
fn regs(comptime desc: type) type {
3535
return struct {
3636
// io address
37-
const pin_addr: u5 = 3 * @enumToInt(desc.port) + 0x00;
38-
const dir_addr: u5 = 3 * @enumToInt(desc.port) + 0x01;
39-
const port_addr: u5 = 3 * @enumToInt(desc.port) + 0x02;
37+
const pin_addr: u5 = 3 * @intFromEnum(desc.port) + 0x00;
38+
const dir_addr: u5 = 3 * @intFromEnum(desc.port) + 0x01;
39+
const port_addr: u5 = 3 * @intFromEnum(desc.port) + 0x02;
4040

4141
// ram mapping
42-
const pin = @intToPtr(*volatile u8, 0x20 + @as(usize, pin_addr));
43-
const dir = @intToPtr(*volatile u8, 0x20 + @as(usize, dir_addr));
44-
const port = @intToPtr(*volatile u8, 0x20 + @as(usize, port_addr));
42+
const pin = @as(*volatile u8, @ptrFromInt(0x20 + @as(usize, pin_addr)));
43+
const dir = @as(*volatile u8, @ptrFromInt(0x20 + @as(usize, dir_addr)));
44+
const port = @as(*volatile u8, @ptrFromInt(0x20 + @as(usize, port_addr)));
4545
};
4646
}
4747

@@ -147,7 +147,7 @@ pub fn Uart(comptime index: usize, comptime pins: micro.uart.Pins) type {
147147
USART0.UCSR0B.write(.{
148148
.TXB80 = 0, // we don't care about these btw
149149
.RXB80 = 0, // we don't care about these btw
150-
.UCSZ02 = @truncate(u1, (ucsz & 0x04) >> 2),
150+
.UCSZ02 = @as(u1, @truncate((ucsz & 0x04) >> 2)),
151151
.TXEN0 = 1,
152152
.RXEN0 = 1,
153153
.UDRIE0 = 0, // no interrupts
@@ -156,7 +156,7 @@ pub fn Uart(comptime index: usize, comptime pins: micro.uart.Pins) type {
156156
});
157157
USART0.UCSR0C.write(.{
158158
.UCPOL0 = 0, // async mode
159-
.UCSZ0 = @truncate(u2, (ucsz & 0x03) >> 0),
159+
.UCSZ0 = @as(u2, @truncate((ucsz & 0x03) >> 0)),
160160
.USBS0 = usbs,
161161
.UPM0 = upm,
162162
.UMSEL0 = umsel,

0 commit comments

Comments
 (0)