Idea: Convert APIs that takes addresses in HALs to take `anytype`.
维护者通常 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,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ZigEmbeddedGroup/microzig 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 88/100
ZigEmbeddedGroup/microzig#1086 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 69/100
ZigEmbeddedGroup/microzig#1085 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
ZigEmbeddedGroup/microzig#1061 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
ZigEmbeddedGroup/microzig#1059 · 1 条评论 ·
维护者通常 1 天内回复
-
regz: AVR peripherals generated at address 0 when the register-group name matches the module (ATDF)可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 4/5 3-5 天 新手友好度 48/100
ZigEmbeddedGroup/microzig#1072 ·
维护者通常 1 天内回复
查看 ZigEmbeddedGroup/microzig 的全部 Issue
相似的 Issue
-
c++ good first issue no hardware needed tests
难度 2/5 1 小时以内 新手友好度 95/100
GageLawton/noise-cancellation#217 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
facebookincubator/muse-gadget-sdk#226 ·
维护者通常 1 天内回复
-
btnr (and keyr)未关闭
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
InfiniTimeOrg/InfiniTime#2492 ·
-
system: coco
难度 1/5 1 小时以内 新手友好度 90/100
FujiNetWIFI/fujinet-config#274 ·
维护者通常 1 天内回复