Python or C driver for SC16IS762 dual SPI UART?
-
Hi all,
I have designed a data logger incorporating a G01 and a SC16IS762 to provide 2 external UART interfaces via SPI. I have a couple of questions regarding the approach I should take for writing the driver:
-
Would there be any significant performance gain if the driver for the SC16IS762 was written in C as a python-loadable module, instead of pure python? The baud rates are low - 9600 and 1200, and data volume is not expected to be high (so interrupt workload is not expected to be huge).
-
Assuming that it is worth writing a C driver: I've done some preliminary playing around writing simple loadable modules using the documentation on this forum and the Micropython docs, and it's reasonably straightforward. The tricky part is that I would like to make use of the interrupt pin on the SC16IS762 via a GPIO to call some C code in my driver module. Looking at firmware source, it seems that all the GPIO interrupts are handled by machpin_intr_process(). machpin_intr_process() in turn calls call_interrupt_handler() for each pin. call_interrupt_handler() expects a micropython pin object, so what would be the correct approach for supplying my own handler routine?
Thanks in advance,
Andrew
-
-
@Elizar I suspected as much. Thanks
-
@Andrew-Starr From the view of a G01 your low baud rate device is a very slow device. There is no much point in using a faster programming language with this.
Just enjoy the convenient python environment:def PinIRQ(src): print("IRQ from pin #"+str(src)) ... # IRQ initialization: pin.callback(Pin.IRQ_FALLING, handler=PinIRQ, arg=999)