Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Getting Started documentation doesn't work with MicroZig 0.15.0

未关闭
#860 3 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
35/100
Issue 类型
文档
描述清晰度
基本清楚
活跃度
停滞
技术栈
raspberry-pi

调研方向

Start with the Getting Started page in the docs and the RP2xxx pin configuration apply() in the MicroZig HAL, which the issue says returns void in 0.15.0. Check the docs example against that signature, and use the workaround in the issue as a reference for the gpio.num() form. Done means either the docs example compiles against 0.15.0 or the maintainers have chosen between the two fixes. The thread is stale and the fix direction is not settled, so confirm with a maintainer before writing the change.

由索引模型根据 Issue 内容生成。

描述

Problem

The Getting Started guide shows example code that doesn't compile with the recommended MicroZig version (0.15.0).

Steps to Reproduce

  1. Follow the getting started guide exactly as written
  2. Install MicroZig 0.15.0 as instructed:
    zig fetch --save https://github.com/ZigEmbeddedGroup/microzig/releases/download/0.15.0/microzig.tar.gz
    
  3. Use the example code from the docs:
    const pin_config = rp2xxx.pins.GlobalConfiguration{
        .GPIO25 = .{
            .name = "led",
            .direction = .out,
        },
    };
    
    pub fn main() !void {
        const pins = pin_config.apply();
    
        while (true) {
            pins.led.toggle();
            time.sleep_ms(250);
        }
    }
    
  4. Run zig build

Expected Behavior

The code should compile and work as documented.

Actual Behavior

Compilation fails with:

src/main.zig:17:13: error: type 'void' does not support field access
        pins.led.toggle();
        ~~~~^~~~

Root Cause

In MicroZig 0.15.0, the GlobalConfiguration.apply() function returns void, not a struct with named pin fields. The function signature is:

pub fn apply(comptime config: GlobalConfiguration) void {

So const pins = pin_config.apply() results in pins having type void, which doesn't support field access.

Environment

  • Zig version: 0.15.2
  • MicroZig version: 0.15.0 (as recommended in docs)
  • Target: Raspberry Pi Pico (RP2040)

Suggested Fix

Either:

  1. Update the documentation to show code that works with 0.15.0 (using gpio.num() directly), or
  2. Release a new version of MicroZig where apply() returns a struct with named pins, and update the docs to recommend that version

Workaround

For anyone hitting this issue, here's working code for MicroZig 0.15.0:

const std = @import("std");
const microzig = @import("microzig");
const rp2xxx = microzig.hal;
const time = rp2xxx.time;
const gpio = rp2xxx.gpio;

pub fn main() !void {
    const led = gpio.num(25);
    led.set_function(.sio);
    led.set_direction(.out);

    while (true) {
        led.toggle();
        time.sleep_ms(250);
    }
}
主要语言
Zig
星标
2.3k
派生
198
平均合并
1 天 8 小时
30 天内合并 PR
37

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ZigEmbeddedGroup/microzig 的其他 Issue

查看 ZigEmbeddedGroup/microzig 的全部 Issue

相似的 Issue

更多 Documentation Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。