Change pin configuration

Hello,

I'm working with the nRF Connect SDK version 1.8, using Zephyr and a CC1101 radio module. The radio communicates via SPI, but at the beginning of the process, I need to perform a hardware reset. This reset requires changing the SPI pins configuration to GPIO mode with some pins as output and some as input, performing some operations, and then reconfiguring them back to SPI mode.

I noticed that in newer versions of Zephyr, you can use pinctrl to dynamically change pin configurations at runtime. However, is it possible to achieve this in the older version of Zephyr used with nRF Connect SDK 1.8?

Parents
  • Hi Bartosz, 
    As far as I know dynamically change pin configuration is done in build time on older Zephyr version (including v1.8). Even with pinctrl in newer Zephyr version it still requires a reset to change the pin configuration. 

    In your case, you mentioned it's a hardware reset that you want to do ? If it's the case I think it's possible to overwrite what Zephyr is configuring and control the pin directly via the chip's registers. What you need to do is to stop any SPI activity. Then use NRF_GPIO->PIN_CNF to change the configuration and use NRF_GPIO->OUTSET to set the GPIO pins. (You can also use nrfx_gpio library, see zephyr\samples\boards\nrf\system_off sample. )
    But I don't think the system would work properly after that. So it's better to trigger a chip reset after you are done with the GPIO operations. 

  • Based on what you've written, it's not possible to:

    1. Initialize some GPIOs as input and output pins (these are used for SPI: MOSI, MISO, SCK).
    2. Perform operations on these pins (write and read).
    3. Reconfigure them for SPI usage.
    4. Carry out standard SPI communication.

    In summary, I can't perform the steps described above without resetting the MCU in zephyr, correct?

  • Correct. As you already known, Zephyr doesn't allow that. What I suggested was kind of a hack. So it's not guarantee that if you reconfigure the SPI back it would work normally. So it's better to trigger a reset instead. 

  • It doesn't sound ideal that I can't change the pin configuration at runtime. Is this still the case with the latest version of Zephyr?

Reply Children
Related