-
Notifications
You must be signed in to change notification settings - Fork 28
Mmio: expected type '*volatile , found '*align(1) volatile' #51
Comments
Looking at the datasheet and the generated file, it looks like some padding is needed after |
I tried adding the comptime {
if (@alignOf(@TypeOf(micro.chip.regs.OSCCTRL.DPLL[0].DPLLCTRLB.raw)) != 4) {
@compileError("incorrect alignment of DPLLCTRLB");
}
} I also tried to add padding to
but then, accessing |
you'd actually want to do something like comptime {
std.debug.assert(@bitOffsetOf(@TypeOf(micro.chip.regs.OSCCTRL.DPLL[0]), "DPLLCTRLB") % 4 == 0);
} because that is asserting the alignment of the type, and we're interested in the alignment wrt the beginning of the struct that encapsulates it. Also since the u24 doesn't work, try doing 24 u1's, that's a sure fire way to get around the packed struct bug in the stage 1 compiler. If that doesn't work then I need to rethink this API. |
comptime {
std.debug.assert(@bitOffsetOf(@TypeOf(regs.OSCCTRL.DPLL[0]), "DPLLRATIO") % 4 == 0);
std.debug.assert(@bitOffsetOf(@TypeOf(regs.OSCCTRL.DPLL[0]), "DPLLCTRLB") % 4 == 0);
}
regs.OSCCTRL.DPLL[0].DPLLCTRLB.modify(.{.FILTER = 0}); With u24pub const DPLL = @intToPtr(*volatile [2]packed struct {
/// DPLL Control A
DPLLCTRLA: Mmio(8, packed struct {
reserved0: u1,
/// DPLL Enable
ENABLE: u1,
reserved1: u1,
reserved2: u1,
reserved3: u1,
reserved4: u1,
/// Run in Standby
RUNSTDBY: u1,
/// On Demand Control
ONDEMAND: u1,
}),
padding0: u24,
...
} Error:
with 24 x u1'spub const DPLL = @intToPtr(*volatile [2]packed struct {
/// DPLL Control A
DPLLCTRLA: Mmio(8, packed struct {
reserved0: u1,
/// DPLL Enable
ENABLE: u1,
reserved1: u1,
reserved2: u1,
reserved3: u1,
reserved4: u1,
/// Run in Standby
RUNSTDBY: u1,
/// On Demand Control
ONDEMAND: u1,
}),
padding0: u1,
padding1: u1,
padding2: u1,
padding3: u1,
padding4: u1,
padding5: u1,
padding6: u1,
padding7: u1,
padding8: u1,
padding9: u1,
padding10: u1,
padding11: u1,
padding12: u1,
padding13: u1,
padding14: u1,
padding15: u1,
padding16: u1,
padding17: u1,
padding18: u1,
padding19: u1,
padding20: u1,
padding21: u1,
padding22: u1,
padding23: u1,
....
} Error:
|
Hi,
first of all, thank you for your efforts. I encountered the following error when trying to access
regs.DPLL[0].DPLLCTRLB
usingmodify()
(regs.DPLL[0].DPLLCTRLA
works fine).The register file can be found here.
zig:
0.10.0-dev.3445+18440cb23
regz:
main
(last commit is4b04e50cf14a3df87662dc79863e9b7e3dfc6591
)The text was updated successfully, but these errors were encountered: