Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#446 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
15/100
Tipo de issue
Refactorización
Claridad
Bastante claro
Estado de actividad
Estancado
Área
embedded-iot

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Zig
Estrellas
2.3k
Forks
198
Merge medio
1 d 8 h
PR fusionados (30 d)
37

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de ZigEmbeddedGroup/microzig

Todos los issues de ZigEmbeddedGroup/microzig

Issues similares

Más issues de Embedded & IoT

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.