Article: NuttX RTOS for PinePhone: Feature Phone UI in LVGL, Zig and WebAssembly
#44
Code:
pub const I2S_PCM0 = IRQ(45);
pub const I2S_PCM1 = IRQ(46);
pub const I2S_PCM2 = IRQ(47);
pub const PG_EINT = IRQ(49);
pub const TIMER0 = IRQ(50);
pub const TIMER1 = IRQ(51);

fn IRQ(comptime irq: u8) type {
    const cache = struct {
        var lookup: [IRQ_LIMIT]*const fn () void = undefined;

        pub export fn zigInterruptHandler(id: c_int) void {
            const handler = lookup[@intCast(u8, id)];
            handler();
            debug.green(true);
        }
    };
    return struct {
        const irqNo: u8 = irq;
        var enabled: bool = false;

        pub fn enable(handler: *const fn () void) void {
            if (!enabled) {
                c.enableIRQ(irqNo);
                cache.lookup[irqNo] = handler;
                enabled = true;
            }
        }
    };
}

Oh and the code if you are interested.  It works if I move the exported fn and lookup table up to the file level, but since that is also just a 'struct' in Zig, I thought this might work.
  Reply


Messages In This Thread
RE: Article: NuttX RTOS for PinePhone: Feature Phone UI in LVGL, Zig and WebAssembly - by WhiteHexagon - 07-31-2023, 04:26 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  asterisk or FreePBX on pinephone? vanja 0 453 06-16-2026, 09:24 AM
Last Post: vanja
  Jami on Pinephone [ IM and VOIP ] p1trson 15 23,202 06-16-2026, 05:02 AM
Last Post: marlboro1950
  Movuan distribution for PinePhone merom 6 6,979 06-04-2026, 02:10 AM
Last Post: merom
  Latest firmware for PinePhone modem! Subsentient 106 233,241 04-03-2026, 08:37 AM
Last Post: baptx
  Fedora + Phosh for PinePhone njha 77 220,839 01-14-2026, 12:22 AM
Last Post: tllim
  Difficulty with openSUSE Tumbleweed Install PinePhone Beta danm1988 0 988 11-17-2025, 07:49 AM
Last Post: danm1988
  How-To: Remote Control Your Phone from Desktop via VNC biketool 16 14,238 10-16-2025, 06:55 AM
Last Post: biketool
  baremetal via Zig on PinePhone - JumpDrive help please WhiteHexagon 1 4,193 07-07-2025, 10:33 AM
Last Post: WhiteHexagon
  Jami on the Pine phone ? bcnaz 8 15,510 06-09-2025, 04:17 PM
Last Post: j_s
  Slarm64 on PinePhone [Unofficial Slackware ARM - 64 bit] acid andy 40 66,277 12-28-2024, 12:19 AM
Last Post: mara

Forum Jump:


Users browsing this thread: 2 Guest(s)