-
Notifications
You must be signed in to change notification settings - Fork 108
PinMux
Due to size and spec restrictions, is common to have a physical I/O pin shared by the different I/O protocols provided by IoT boards. When that is the case, in order to make use of a given pin, it is necessary to execute some additional steps to configure the pin to work on the desired mode. It would cumbersome for a programmer to do it for all pins in all boards in all projects, so that's the job of a Pin Multiplexer. For example, when a Soletta application uses the pin number 3 as PWM, behind the scenes a pin multiplexer for that specific board first checks if it is possible to use such pin as PWM and, it it is, execute the needed setup, so the application don't have to worry about that.
Since the multiplexer implementation differs a lot between boards, it would be practically impossible to add support for all. Instead, entry points were added in Soletta's I/O APIs that allows the execution of board specific code to do the necessary setup. This code is provided through a special kind of module in Soletta called 'pinmux module'. This way, the multiplexer code needed for new boards can be fully developed and maintained in external repositories. All it is needed is to implement the 'pinmux' module API, install the module in the corrected path and provide Soletta with means to detected the board.
In Linux, this folder is usually <DESTDIR>/lib/modules/pin-mux
.
The interface that needs to be implemented by a pinmux module can be found in 'sol-pin-mux-modules.h' file. A convenience macro is provided to make easier to declare the correct symbol that is needed so the module can be successfully loaded by Soletta library.
Soletta maintaing pin-mux implementation for some boards that can serve as example for thoses trying to implement a custom pin-mux. You can find them here.
See Board Detection for detailed info about the detection process.
Board's name is then used to search for it's module. First, in the built-in modules list and then for <DESTDIR>/lib/soletta/modules/pin-mux/<board_name>.so
.