6 Replies Latest reply on Jul 27, 2015 11:26 PM by Madhura!

    Edison Interrupt Service Routine

    ForumMigrationAdmin

      Hi,

      are there any example for implement a interrupt service Routine??

      Brian Dahl

        • 2. Re: Edison Interrupt Service Routine
          ForumMigrationAdmin

          Hi,

          the example is nice, but it does not tell you how to safely manage resources, that you feed into the interrupt function via the void* args parameter. If you only use static resources, everything will be fine. But if you use dynamically allocated resources in your interrupt function, there is no safe way to deallocate the resource, since you don't know if the interrupt function is still using the resource.

          By calling mraa_gpio_close will not cancel the interrupt handling thread. By doing this, the gpio file will be closed and the interrupt handler thread will terminate the next time it tries to poll the interrupts. When this will happen, depends on your interrupt function. If you deallocate your resources immediately after calling mraa_gpio_close, the interrupt function may still use the deallocated memory.

          But there is another option. You can call mraa_gpio_isr_exit, which tries to cancel the thread immediately. The problem is that this function also does not guarantee that the thread is canceled after the call. If your interrupt function is being executed, the thread will continue to run until your function exits, because thread cancellation is disabled as long as the interrupt function is being executed. So you can not safely deallocate your resources after calling mraa_gpio_isr_exit.

          Currently you will have to wait some time after mraa_gpio_close or mraa_gpio_isr_exit and hope that your interrupt function will be finished after the given time span.

          Best regards,

          Bernd

          • 3. Re: Edison Interrupt Service Routine
            ForumMigrationAdmin

            Hi,

            I'm new to Intel Edison development and just a bit of prior Arduino knowledge behind so please bare with me
            I am trying to port some Arduino code and an implementation of the DMX protocol, but I think I need to
            find equivalent Quark calls for the existing AVR code.

            Here are the functions/constants I will need to replicate on Intel Edison:

            1. _SFR_IO_ADDR()
            2. _SFR_IO8()
            3. cli() / noInterrupts()
            4. sei() / interrupts()
            5. digitalPinToBitMask()
            6. NOT_A_PORT / PORTB / PORTC / PORTD

            From what I understand in this post, interrupts()/noInterrupts() can be achieved with libmraa.
            Would I use that in plain c on the linux side or from the Arduino IDE ?

            I found digitalPinToBitMask() in hardware/arduino/edison/cores/arduino/wiring_digital.h but I get an error when I try to use it:

            1C:\Users\HM\Downloads\Windows\arduino-windows-patched-1.0.4\arduino-windows-1.0.4\arduino-1.5.3-Intel.1.0.4\hardware\arduino\edison\cores\arduino/wiring_digital.h:106:56: error: 'PinDescription' has no member named 'ulPin'

             

             

            2 #define digitalPinToBitMask(P)  ( g_APinDescription[P].ulPin )

             

            I've also found this GPIO reference I'm going through at the moment:
            http://www.emutexlabs.com/project/215-intel-edison-gpio-pin-multiplexing...

            Is it feasible to port the DMX code to the IntelEdison ? Where could I find the AVR equivalent calls/constants for Edison ?

            Thank you,
            George

            • 4. Re: Edison Interrupt Service Routine
              ForumMigrationAdmin

              @George

              would you mind copy&pasting this feature request to https://communities.intel.com/community/makers/? The forum  you posted here is mostly around Intel IoT developer kit  but not about Arduino IDE which isn't part of the devkit.

              On questions on how to bring it to C/C++/Python or Node.JS using the devkit feel free to continue on this forum.

              • 5. Re: Edison Interrupt Service Routine
                ForumMigrationAdmin

                Hi Mattias,

                Thank you for the advice. I will ask on the Makers community as well.
                If I can get the code running in Arduino that would be great,
                but I'm not excluding porting the code to c or python using libmraa
                in which case the questions on finding equivalents for the AVR
                constants and functions within libmraa remain.

                Would you consider it's possible to do this sort of port manipulation with libmraa ?
                If so, how can I continue ?

                Thanks,
                George

                • 6. Re: Edison Interrupt Service Routine
                  Madhura!

                  Are there any examples of interrupt in javascript (I am working on XDK) using mraa for Edison?