Zephyr + NRF5340: change GPIO function in runtime

The project uses nRF5340. A signal is connected to P0.27/AIN6, and during "normal" mode the pin is used as an ADC.

Before going into sleep mode we would need this pin to become a GPIO Input with enabled interrupt, so as to waking up the MCU (and then back again to ADC during "normal mode").

Some previous posts state that Zephyr did not allow for runtime configuration of pins. Is that still the case? If this is not available and we use direct configuration of the MCU's registers, what are the "special concerns" in the device tree that we have to take in order not to mess up Zephyr usage of the pin?

Parents
  • Hi Simon,
    Thank you for the attention! We will implement this on our side to see how it goes.
    Before I deeply analyze your code, reading from your description, it seems that the solution involves configuring both options in Zephyr's Device Tree and then "disable" the one not being used directly by register control in run time...
    I hope that this post becomes useful for more people up ahead.
    Cheers
    Bruno

Reply
  • Hi Simon,
    Thank you for the attention! We will implement this on our side to see how it goes.
    Before I deeply analyze your code, reading from your description, it seems that the solution involves configuring both options in Zephyr's Device Tree and then "disable" the one not being used directly by register control in run time...
    I hope that this post becomes useful for more people up ahead.
    Cheers
    Bruno

Children
Related