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

Parents Reply
  • I think I understand...

    For the majority of the time in my code, the UART is in sleep mode (using pm_device_runtime_enable()), and the RX pin is attached to a GPIO interrupt, so if that fires it wakes up the UART (using pm_device_runtime_disable()). The UART is only really used for configuration and testing. There are already wrappers around code to stop trying to do a UART transaction if in sleep mode, so I guess I can do a similar thing, but use pm_suspend/pm_resume if I need to update the uart pins, do something, then switch back when needed. 

    I dont think there are any other Zephyr modules that use my UART3, all the logging modules I have used are on RTT. 

    I may just have to try it and see if it falls over...

    Thanks, 

    Damien

Children
Related