Skip to content

F0079 pin-4

Rule: Peripheral pins stay on their function while the peripheral is enabled.

Code F0079 (stable, never reused)
Id pin-4
Category pin
Source spirit_level
Fix by hand

Level per tier

Tier Level Reason
small off
small-workspace off
medium off
big off
ai off
embedded deny bedrock error: Peripheral pins moved to GPIO and back under an enabled peripheral (RP2350: the peripheral reads the OR of all pins with its FUNCSEL; the I2C block saw a start without a stop): keep FUNCSEL, use OEOVER / OUTOVER
ui off
egui off
units-strict off
units-paranoid off

Why

On RP2040/RP2350, a peripheral block reads the logical OR of every pin whose FUNCSEL names that peripheral: moving a pin to GPIO's plain function and back to hand control to software for a moment (a bit-banged recovery sequence, a manual bus reset) is a function-select change the peripheral itself sees as a bus event โ€” an I2C block watching a start/stop pattern on SDA/SCL can see a spurious start with no matching stop, and gets confused about the bus state from then on.

Example

bedrock_can's own notes and i2c_periph's DW_apb_i2c master driver (BE-1) both point at the same RP2040/RP2350 property: "on an RP2350 the pins keep the I2C function and software drives them through GPIOn_CTRL.OEOVER / OUTOVER: the chip gates a peripheral's input by function select, so a function change is a bus event to the block" โ€” the fix is to never reassign FUNCSEL away from the peripheral just to bit-bang a recovery, and instead override the pad's output enable and output value directly while FUNCSEL stays pointed at the peripheral the whole time.

How to fix

Use GPIOn_CTRL.OEOVER/OUTOVER (force output enable / output value regardless of what the peripheral would otherwise drive) for any software-driven excursion on a pin a peripheral owns, and leave FUNCSEL alone.

How it is checked

Check: src mid ยท chip: RP โ€” needs recognizing a FUNCSEL write to a pin that's also configured for a peripheral elsewhere in the firmware model, not just a single-line pattern.

Source

Ported from embedded_bedrock's firmware check catalogue, PIN-4 (book/checks.md, detail in book/checks/pin.md). Found on: usb_io_fw IF-2, i2c_periph BE-1.

Configure

[lints.pin-4]
level = "deny"
reason = "why this project wants it at this level"

Allow one finding in the code with // spirit-level: allow(pin-4) <reason> (waivers); the code works there too, as in [lints.F0079].