Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Python or C driver for SC16IS762 dual SPI UART?

    Scheduled Pinned Locked Moved MicroPython
    3 Posts 2 Posters 21 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A Offline
      Andrew Starr
      last edited by

      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:

      1. 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).

      2. 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

      E 1 Reply Last reply Reply Quote 0
      • E Offline
        Elizar @Andrew Starr
        last edited by

        @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)
        
        A 1 Reply Last reply Reply Quote 1
        • A Offline
          Andrew Starr @Elizar
          last edited by

          @Elizar I suspected as much. Thanks

          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • 1 / 1
          • First post
            Last post

          Pycom on Twitter

          Pycom