Thank you @Araq, but I don't know where to apply it. Both arguments to
`write()` are constants. I applied `{.noinit.}` to `main()` to no effect. The
first argument to `_ZL10nimZeroMemPvl()` is an address four bytes after the
`SP` (a ptr to a local variable?), but I don't believe I've declared a local.
Here's an explicit re-write that gives me the same problem:
const GPIOA* = GPIOA_Type(
MODER: GPIOA_MODER_Type(loc: 0x40020000'u),
BSRR: GPIOA_BSRR_Type(loc: 0x40020018'u),
)
proc main() {.noinit.} =
modifyIt(RCC.AHB1ENR): it.GPIOAEN = true # PortA clk enable
modifyIt(GPIOA.MODER): it.MODER5 = 1 # PA5 pin is GP Output
const pa5_set = (1 shl 5).GPIOA_BSRR_Fields
const pa5_clr = (1 shl 21).GPIOA_BSRR_Fields
while true: # GPIOA.BSRR =
0x40020018
write(GPIOA.BSRR, pa5_set) # Bit-Set PA5
write(GPIOA.BSRR, pa5_clr) # Bit-Reset PA5
when isMainModule:
main()
Run