Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

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

Offen
#446 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
15/100
Issue-Typ
Refactoring
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Bereich
embedded-iot

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
Zig
Sterne
2.3k
Forks
198
Ø Merge
1 T. 8 Std.
Gemergte PRs (30 T.)
37

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus ZigEmbeddedGroup/microzig

Alle Issues in ZigEmbeddedGroup/microzig

Ähnliche Issues

Weitere Issues zu Embedded & IoT

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.