Description
ArduinoCore-megaavr/cores/arduino/wiring_digital.c
Lines 33 to 47 in 5e639ee
On an Uno, you can use these lines to switch directly from INPUT_PULLUP to HIGH:
digitalWrite(pin,HIGH); // enable pullup
pinMode(pin,OUTPUT); // switch to OUTPUT HIGH
On a Nano Every, those commands switch instead to an OUTPUT LOW
See the discussion at:
https://forum.arduino.cc/t/how-to-set-output-high-without-pulse/1364909
The documentation at https://docs.arduino.cc/learn/microcontrollers/digital-pins/ says it should switch directly to HIGH:
Consequently, a pin that is configured to have pullup resistors turned on when the pin is an INPUT, will have the pin configured as HIGH if the pin is then switched to an OUTPUT with pinMode().
Per this chunk of code, it looks like half of the issue was considered:
ArduinoCore-megaavr/cores/arduino/wiring_digital.c
Lines 162 to 192 in 5e639ee
But the pinMode code is where the problem happens. Instead of always assuming LOW, it should use the state on the pullup to set the level before enabling the OUTPUT direction in order to match the documentation and the behavior on the '328 and '2560.
See also #86