Conversation
| const gpio = microzig.hal.gpio; | ||
|
|
||
| // ATtiny84: use PA0 as the LED pin | ||
| const led_pin = gpio.pin(.a, 0); |
There was a problem hiding this comment.
can't we put this in the board config so that we can use the same blinky.zig for multiple boards?
d24d37b to
9ab36bb
Compare
mattnite
left a comment
There was a problem hiding this comment.
Feels like there's a lot of duplication in the cpu files, will have to comb through and trim it down.
| }; | ||
|
|
||
| /// AVR interrupt handler function type. | ||
| pub const HandlerFn = *const fn () callconv(.avr_signal) void; |
There was a problem hiding this comment.
not sure if this should actually be avr_signal
| }); | ||
| } | ||
|
|
||
| fn make_isr_handler(comptime name: []const u8, comptime func: anytype) type { |
There was a problem hiding this comment.
is this a duplicate?
| .name = "avr5", | ||
| .root_source_file = mb.core_dep.namedLazyPath("cpu_avr5"), | ||
| }; | ||
| } else if (std.mem.eql(u8, target.cpu.model.name, "avr25")) { |
There was a problem hiding this comment.
let's start looking at making a table instead of if elses.
Add a new port for Microchip ATtiny (ATtiny85, ATtiny84) with HAL, board definitions (Digispark, Adafruit Trinket, Adafruit Gemma), and blinky examples including an interrupt handler example. Also fix the AVR startup logic for both avr25 and avr5: - Place vector table in microzig_flash_start section so it lands at address 0x0 where the hardware expects it - Emit full vector table with entries for all interrupt vectors, not just the reset vector - Add InterruptOptions so users can specify interrupt handlers via microzig_options, which get wired into the vector table - Update calling convention names for zig 0.15.2 compatibility (.avr_signal/.avr_interrupt/.auto, .@"fn") Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
mattnite
left a comment
There was a problem hiding this comment.
More comments and verifications that need to be made before merging
|
|
||
| pub const microzig_options: microzig.Options = .{ | ||
| .interrupts = .{ | ||
| .INT0 = &my_int0_handler, |
There was a problem hiding this comment.
I don't see any configuration in the main function for this, consider removing the example it if it's unverified.
| @@ -0,0 +1,16 @@ | |||
| const microzig = @import("microzig"); | |||
There was a problem hiding this comment.
TODO: Double check
| @@ -0,0 +1,18 @@ | |||
| const microzig = @import("microzig"); | |||
There was a problem hiding this comment.
TODO: double check
| @@ -0,0 +1,20 @@ | |||
| const microzig = @import("microzig"); | |||
There was a problem hiding this comment.
TODO: double check
| const microzig = @import("microzig"); | ||
| const cpu = microzig.cpu; | ||
|
|
||
| pub const gpio = struct { |
There was a problem hiding this comment.
TODO: review ATtiny84 datasheet/family reference.
|
|
||
| const atpack = b.dependency("atpack", .{}); | ||
|
|
||
| const avr25_target: std.Target.Query = .{ |
There was a problem hiding this comment.
Shouldn't we be getting this from the cpu?
| .atdf = atpack.path("atdf/ATtiny85.atdf"), | ||
| }, | ||
| .memory_regions = &.{ | ||
| .{ .tag = .flash, .offset = 0x000000, .length = 8 * 1024, .access = .rx }, |
There was a problem hiding this comment.
TODO: Double check memory
| .atdf = atpack.path("atdf/ATtiny84.atdf"), | ||
| }, | ||
| .memory_regions = &.{ | ||
| .{ .tag = .flash, .offset = 0x000000, .length = 8 * 1024, .access = .rx }, |
There was a problem hiding this comment.
TODO: double check memory
|
|
||
| return .{ | ||
| .chips = .{ | ||
| .attiny85 = chip_attiny85.derive(.{}), |
There was a problem hiding this comment.
Why aren't we just assigning these? it should be safe to do that.
| .attiny85 = chip_attiny85.derive(.{}), | ||
| .attiny84 = chip_attiny84.derive(.{}), | ||
| }, | ||
| .boards = .{ |
There was a problem hiding this comment.
None of these boards use chip_attiny84.
Add a new port for Microchip ATtiny (ATtiny85, ATtiny84) with HAL, board definitions (Digispark, Adafruit Trinket, Adafruit Gemma), and blinky examples including an interrupt handler example.
Also fix the AVR startup logic for both avr25 and avr5: