Dynamic Pin Control/Changing Functionality in runtime

Hello, 

I recently noticed that I may have an issue with our current design of PCB and firmware. We basically have created a datalogger using the nRF9160, and we take readings for a variety of sensors. One such thing that we have yet to add into firmware, is the ability to read Modbus sensors (RS485), which would need a UART port. 

I am not sure I have ever fully understood the devicetree, so bare with me....

We currently have in use - (Enabled in Overlay file)

I2C0

SPI1

I2C2

UART3

So I don't know how we are going to add a further UART Port. 

Is it possible to disable say I2C0, and enable UART0 in runtime? 

Alternatively, is it possible to dynamically change the pins of UART3 to go to another set of UART pins in runtime?

On the latter I have found this remap function but it runs in PRE_KERNEL_1 sdk-zephyr/samples/boards/nordic/dynamic_pinctrl/src/remap.c at main · nrfconnect/sdk-zephyr

Can this be modified to work without rebooting the firmware? 

I am guessing either of these would be possible, maybe without using the Devicetree, but I cant find any specific reference document. 

Thanks, 

Damien

  • Hi Kenneth, 

    I don't have that in the devicetree. I realised why I had the issue though. I had forgotten, that when I print to the com port and I am not expecting any messages back, I use pm_device_runtime_enable() to put it in low power.

    I did have to change the pm_device_action_run(uart, SUSPEND/RESUME) to pm_device_runtime_enable() or pm_device_runtime_disable(). I think that must do some extra configuration compared to action_run(), because it would cause the UART to hang after a couple of swicthes.
    I have had it running 24 hours and not had an issue, so I think it works!

    Thanks, 

    Damien

Related