Is there a way to modify only a single bit in the pin change interrupt control register (pcicr) for the atmega328p?
To enable the external interrupt for Port C, for example, it would be something like:
let dp = atmega_hal::Peripherals::take().unwrap();
dp.EXINT.pcicr.modify(|_, w| w.pcie().bits(0b010));
but it seems rather silly to need to modify all 3 bits when only 1 bit is desired to be changed. I would think something like:
dp.EXINT.pcicr.modify(|_, w| w.pcie1().set_bit());
but pcie1() doesn't appear to exist.
I think https://github.com/Rahix/avr-device/issues/130 is related?
Note that the same also applies for pcmsk with pcint[0-8]
Yeah the issue you linked to is exactly it. We have to do similar patches for ATmega328P then. Also see the PR linked to that issue: https://github.com/Rahix/avr-device/pull/131
If you need help, let me know :)
but it seems rather silly to need to modify all 3 bits when only 1 bit is desired to be changed
Well, I wouldn't necessarily say so. During peripheral initialization, I would argue that it is usually a good idea to overwrite the registers in whole, to ensure all bits are in a deterministic and known state. I know this cannot always be done, but during early initialization in an application firmware project, it usually works. If you just write single bits, you risk hard-to-debug errors when registers aren't in the state you expect, e.g. after a soft reset or different boot path.