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

Custom `Frequency` enum shared across hals

未关闭
#837 0 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
18/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
zig
领域
embedded-iot

调研方向

The issue names no files or tests; the only code is a proof-of-concept Frequency enum and a call to i2c.apply(.{ .baud_rate = .khz(100) }). Start by finding where the HAL I2C config and its baud_rate field are defined in the repository. The open question is whether a shared frequency type should exist and where other measures could use decl literals, so a maintainer must decide the scope before any code. Done would need that decision recorded.

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

描述

i2c.apply(.{
    .baud_rate = .khz(100),
});

// POC implementation
const Frequency = enum(u32) {
    _,

    pub fn hz(value: u32) Frequency {
        return @enumFromInt(value);
    }

    pub fn khz(value: u32) Frequency {
        return @enumFromInt(value * 1_000);
    }

    pub fn mhz(value: u32) Frequency {
        // what to do about overflows? Though I think it's fine to assert that the result must fit into u32.
        return @enumFromInt(value * 1_000_000);
    }
};

This would be used for baud rates, etc.

Something like this can be applied for other measures as well (apart from Frequency). In what other places can we use decl literals for more verbose initializations?

主要语言
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

更多 Embedded & IoT Issue

把新 issue 发到你的邮箱

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