During testing of a program with constrained memory there would be intermittent HardFaults during IAP calls with very few traces of what went wrong (note: the I²C peripheral/pins were not used). After a bit of tracing it became obvious that the pin abstraction actually creates a 12K large stack post to hold the abstraction, which would leave this program in particular with only 4K of memory and crash as the stack pointer would dip below mapped RAM.
To fix this, the abstraction has been rewritten to abstain from "actual" ownership of the SFSI2C0
member of pac::SCU
and instead owns phantom data that represents the ownership. Furthermore the sfsi2c0
member should not be under an immutable borrow when sent to the I²C abstraction, as it most definitely is modified in the constructor.