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

Idea: Convert APIs that takes addresses in HALs to take `anytype`.

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
15/100
Issue 类型
重构
描述清晰度
基本清楚
活跃度
停滞
领域
embedded-iot

调研方向

Start with the trigger_transfer function on the DMA Channel enum shown in the diff, and with the call sites that pass @intFromPtr(...) values. Survey which HAL functions take raw addresses as u32 or usize, and check how callers pass them. The issue is a proposal, not a settled change, so done means agreeing on the API direction with maintainers first. Only then would you add pointer checks and update the callers.

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

描述

We have a bunch of functions that take addresses in our various HALs, but the type is often u32 or usize.

We should evaluate how they are used, and see if people tend to call them with points (e.g. by providing a slice or array) or an actual int.

In the former case, they'd have to do something like @intFromPtr, which is fine, but a bit annoying.

We can improve the ergonomics of these APIs (if we find that usage common) by having the type be anytype, and make type checks to ensure it is a pointer or appropriate type.

@@ -95,14 +95,16 @@ pub const Channel = enum(u4) {
 
     pub fn trigger_transfer(
         chan: Channel,
-        write_addr: u32,
-        read_addr: u32,
+        write_addr: anytype,
+        read_addr: anytype,
         count: u32,
         config: TransferConfig,
     ) void {
+        comptime if (@typeInfo(@TypeOf(write_addr)) != .pointer) @compileError("write_addr must be a pointer");
+        comptime if (@typeInfo(@TypeOf(read_addr)) != .pointer) @compileError("read_addr must be a pointer");
         const regs = chan.get_regs();
-        regs.read_addr = read_addr;
-        regs.write_addr = write_addr;
+        regs.read_addr = @intFromPtr(read_addr);
+        regs.write_addr = @intFromPtr(write_addr);
         regs.trans_count = count;
         regs.ctrl_trig.modify(.{
             .EN = @intFromBool(config.enable),

This allows the client to have a cleaner call:

     channel.?.trigger_transfer(
-        @intFromPtr(dst[0..dst.len].ptr),
-        @intFromPtr(hello[0..src.len].ptr),
+        dst[0..dst.len].ptr,
+        src[0..hello.len].ptr,
         src.len,
         .{

Of course, we can allow ints of the appropriate size as well, and we can write a helper to verify the type.

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