Replies: 2 comments 2 replies
-
Some thought for today: i was thinking it could be possible to provide a pinctrl type structure containing multiple pinctrl defines as a second element in the init of a device, and said pinctrl structure data could be generated per platform using preprocessor foreach and stringify over the pinctrl defines of the device, this could be multiplatform for all the platforms that provide a serie of defines as pinctrl argument. Such arguments typically take the form of GPIO14_SPI_MOSI for examples so could be identified by a incvlude and pattern defined in mpconfigport.h. eg. |
Beta Was this translation helpful? Give feedback.
-
it does half the work now, need to be implemented to device side now. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
It should be now possible to implement dynamic pin allocation on the zephyr RTOS port, here are my thoughts/plans about it:
First off, any platform will require 2 things: the peripherals having the deinit capability in their drivers, and secondly, awareness on the micropython side of the pin capabilities at the platform level, so beyond just the zephyr API.
in the case of bflb for example, this could mean reading the yaml files that contain the pin capabilities and generate all the bindings. Alternatively, there can be dedicated code for each platform (platform group?) that is aware of the platform specific pinctrl_soc_pin_t struct and generates the binding dynamically from the pin capability data. Both solutions require some amount platform-specific awareness on the side of micropython.
On actual implementation, i think it could take the pin list like regular ports, I2C(sda=2, scl=3) for example, then have the code deinit/check deinited the peripheral, parse through the possible assignement, and if valid apply the pinctrl setting via https://docs.zephyrproject.org/apidoc/latest/group__pinctrl__interface__dynamic.html, and then re-initialize the peripheral.
Beta Was this translation helpful? Give feedback.
All reactions