Closed kzyapkov closed 2 years ago
@kzyapkov I think we can start thinking about integrating this functionality. If this does not interfere with the existing CDC code and does not degrade its performance, there is no harm in having the GPIO stuff available. Please address the cppcheck issues so that the PR passes all checks.
This PR is inactive for quite a long time. Closing for now. If you are still willing to work on this, pease feel free to reopen.
This is a proposal for enhancing the capabilities of the serial monster by adding arbitrary GPIO control.
Having serial ports with all the bells and whistles is awesome. However, sometimes not all 3 ports are required, or not all signals for a given port are required. It then makes sense to enable those pins to be controlled with console commands. This enables many use cases where slow GPIO access is enough to sense the state of the attached system or operate attached peripherals.
This PR implements a proof-of-concept of the above proposal. It tries to follow the original coding style, but does take many shortcuts and does add
stdio
to the linked libraries, bloating the size of the firmware by a few KB. The envisioned use case is for the first port to always be a control/config console, and the second and third UARTs to be available for use as either serial ports or their pins to be used as generic inputs or outputs. The control console can be scripted (with expect or expect-like tool) or operated manually by typing in commands.By default, the monster behaves just like before -- all pins are associated to serial ports an controlled by the CDC-ACM machinery. If the
use
parameter of a signal is set togpio
it is detached from said machinery and is available as IO.A sample command session, annotated:
While quite crude, the implementation is functional enough. If deemed upstreamable I'll try to polish it, probably add a few more features to facilitate programatic usage.